babylon.module.d.ts 6.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877
  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. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * 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.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * 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).
  163. * 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.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @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.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Check if the document object exists
  290. * @returns true if the document object exists
  291. */
  292. static IsDocumentAvailable(): boolean;
  293. /**
  294. * Extracts text content from a DOM element hierarchy
  295. * @param element defines the root element
  296. * @returns a string
  297. */
  298. static GetDOMTextContent(element: HTMLElement): string;
  299. }
  300. }
  301. declare module "babylonjs/Misc/logger" {
  302. /**
  303. * Logger used througouht the application to allow configuration of
  304. * the log level required for the messages.
  305. */
  306. export class Logger {
  307. /**
  308. * No log
  309. */
  310. static readonly NoneLogLevel: number;
  311. /**
  312. * Only message logs
  313. */
  314. static readonly MessageLogLevel: number;
  315. /**
  316. * Only warning logs
  317. */
  318. static readonly WarningLogLevel: number;
  319. /**
  320. * Only error logs
  321. */
  322. static readonly ErrorLogLevel: number;
  323. /**
  324. * All logs
  325. */
  326. static readonly AllLogLevel: number;
  327. private static _LogCache;
  328. /**
  329. * Gets a value indicating the number of loading errors
  330. * @ignorenaming
  331. */
  332. static errorsCount: number;
  333. /**
  334. * Callback called when a new log is added
  335. */
  336. static OnNewCacheEntry: (entry: string) => void;
  337. private static _AddLogEntry;
  338. private static _FormatMessage;
  339. private static _LogDisabled;
  340. private static _LogEnabled;
  341. private static _WarnDisabled;
  342. private static _WarnEnabled;
  343. private static _ErrorDisabled;
  344. private static _ErrorEnabled;
  345. /**
  346. * Log a message to the console
  347. */
  348. static Log: (message: string) => void;
  349. /**
  350. * Write a warning message to the console
  351. */
  352. static Warn: (message: string) => void;
  353. /**
  354. * Write an error message to the console
  355. */
  356. static Error: (message: string) => void;
  357. /**
  358. * Gets current log cache (list of logs)
  359. */
  360. static get LogCache(): string;
  361. /**
  362. * Clears the log cache
  363. */
  364. static ClearLogCache(): void;
  365. /**
  366. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  367. */
  368. static set LogLevels(level: number);
  369. }
  370. }
  371. declare module "babylonjs/Misc/typeStore" {
  372. /** @hidden */
  373. export class _TypeStore {
  374. /** @hidden */
  375. static RegisteredTypes: {
  376. [key: string]: Object;
  377. };
  378. /** @hidden */
  379. static GetClass(fqdn: string): any;
  380. }
  381. }
  382. declare module "babylonjs/Misc/stringTools" {
  383. /**
  384. * Helper to manipulate strings
  385. */
  386. export class StringTools {
  387. /**
  388. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  389. * @param str Source string
  390. * @param suffix Suffix to search for in the source string
  391. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  392. */
  393. static EndsWith(str: string, suffix: string): boolean;
  394. /**
  395. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  396. * @param str Source string
  397. * @param suffix Suffix to search for in the source string
  398. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  399. */
  400. static StartsWith(str: string, suffix: string): boolean;
  401. /**
  402. * Decodes a buffer into a string
  403. * @param buffer The buffer to decode
  404. * @returns The decoded string
  405. */
  406. static Decode(buffer: Uint8Array | Uint16Array): string;
  407. /**
  408. * Encode a buffer to a base64 string
  409. * @param buffer defines the buffer to encode
  410. * @returns the encoded string
  411. */
  412. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  413. /**
  414. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  415. * @param num the number to convert and pad
  416. * @param length the expected length of the string
  417. * @returns the padded string
  418. */
  419. static PadNumber(num: number, length: number): string;
  420. }
  421. }
  422. declare module "babylonjs/Misc/deepCopier" {
  423. /**
  424. * Class containing a set of static utilities functions for deep copy.
  425. */
  426. export class DeepCopier {
  427. /**
  428. * Tries to copy an object by duplicating every property
  429. * @param source defines the source object
  430. * @param destination defines the target object
  431. * @param doNotCopyList defines a list of properties to avoid
  432. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  433. */
  434. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  435. }
  436. }
  437. declare module "babylonjs/Misc/precisionDate" {
  438. /**
  439. * Class containing a set of static utilities functions for precision date
  440. */
  441. export class PrecisionDate {
  442. /**
  443. * Gets either window.performance.now() if supported or Date.now() else
  444. */
  445. static get Now(): number;
  446. }
  447. }
  448. declare module "babylonjs/Misc/devTools" {
  449. /** @hidden */
  450. export class _DevTools {
  451. static WarnImport(name: string): string;
  452. }
  453. }
  454. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  455. /**
  456. * Interface used to define the mechanism to get data from the network
  457. */
  458. export interface IWebRequest {
  459. /**
  460. * Returns client's response url
  461. */
  462. responseURL: string;
  463. /**
  464. * Returns client's status
  465. */
  466. status: number;
  467. /**
  468. * Returns client's status as a text
  469. */
  470. statusText: string;
  471. }
  472. }
  473. declare module "babylonjs/Misc/webRequest" {
  474. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  475. import { Nullable } from "babylonjs/types";
  476. /**
  477. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  478. */
  479. export class WebRequest implements IWebRequest {
  480. private _xhr;
  481. /**
  482. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  483. * i.e. when loading files, where the server/service expects an Authorization header
  484. */
  485. static CustomRequestHeaders: {
  486. [key: string]: string;
  487. };
  488. /**
  489. * Add callback functions in this array to update all the requests before they get sent to the network
  490. */
  491. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  492. private _injectCustomRequestHeaders;
  493. /**
  494. * Gets or sets a function to be called when loading progress changes
  495. */
  496. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  497. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  498. /**
  499. * Returns client's state
  500. */
  501. get readyState(): number;
  502. /**
  503. * Returns client's status
  504. */
  505. get status(): number;
  506. /**
  507. * Returns client's status as a text
  508. */
  509. get statusText(): string;
  510. /**
  511. * Returns client's response
  512. */
  513. get response(): any;
  514. /**
  515. * Returns client's response url
  516. */
  517. get responseURL(): string;
  518. /**
  519. * Returns client's response as text
  520. */
  521. get responseText(): string;
  522. /**
  523. * Gets or sets the expected response type
  524. */
  525. get responseType(): XMLHttpRequestResponseType;
  526. set responseType(value: XMLHttpRequestResponseType);
  527. /** @hidden */
  528. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  529. /** @hidden */
  530. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  531. /**
  532. * Cancels any network activity
  533. */
  534. abort(): void;
  535. /**
  536. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  537. * @param body defines an optional request body
  538. */
  539. send(body?: Document | BodyInit | null): void;
  540. /**
  541. * Sets the request method, request URL
  542. * @param method defines the method to use (GET, POST, etc..)
  543. * @param url defines the url to connect with
  544. */
  545. open(method: string, url: string): void;
  546. /**
  547. * Sets the value of a request header.
  548. * @param name The name of the header whose value is to be set
  549. * @param value The value to set as the body of the header
  550. */
  551. setRequestHeader(name: string, value: string): void;
  552. /**
  553. * Get the string containing the text of a particular header's value.
  554. * @param name The name of the header
  555. * @returns The string containing the text of the given header name
  556. */
  557. getResponseHeader(name: string): Nullable<string>;
  558. }
  559. }
  560. declare module "babylonjs/Misc/fileRequest" {
  561. import { Observable } from "babylonjs/Misc/observable";
  562. /**
  563. * File request interface
  564. */
  565. export interface IFileRequest {
  566. /**
  567. * Raised when the request is complete (success or error).
  568. */
  569. onCompleteObservable: Observable<IFileRequest>;
  570. /**
  571. * Aborts the request for a file.
  572. */
  573. abort: () => void;
  574. }
  575. }
  576. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  577. /**
  578. * Define options used to create a render target texture
  579. */
  580. export class RenderTargetCreationOptions {
  581. /**
  582. * Specifies is mipmaps must be generated
  583. */
  584. generateMipMaps?: boolean;
  585. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  586. generateDepthBuffer?: boolean;
  587. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  588. generateStencilBuffer?: boolean;
  589. /** Defines texture type (int by default) */
  590. type?: number;
  591. /** Defines sampling mode (trilinear by default) */
  592. samplingMode?: number;
  593. /** Defines format (RGBA by default) */
  594. format?: number;
  595. }
  596. }
  597. declare module "babylonjs/Engines/constants" {
  598. /** Defines the cross module used constants to avoid circular dependncies */
  599. export class Constants {
  600. /** Defines that alpha blending is disabled */
  601. static readonly ALPHA_DISABLE: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  603. static readonly ALPHA_ADD: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  605. static readonly ALPHA_COMBINE: number;
  606. /** Defines that alpha blending is DEST - SRC * DEST */
  607. static readonly ALPHA_SUBTRACT: number;
  608. /** Defines that alpha blending is SRC * DEST */
  609. static readonly ALPHA_MULTIPLY: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  611. static readonly ALPHA_MAXIMIZED: number;
  612. /** Defines that alpha blending is SRC + DEST */
  613. static readonly ALPHA_ONEONE: number;
  614. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  615. static readonly ALPHA_PREMULTIPLIED: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  618. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  621. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  622. static readonly ALPHA_INTERPOLATE: number;
  623. /**
  624. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  625. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  626. */
  627. static readonly ALPHA_SCREENMODE: number;
  628. /**
  629. * Defines that alpha blending is SRC + DST
  630. * Alpha will be set to SRC ALPHA + DST ALPHA
  631. */
  632. static readonly ALPHA_ONEONE_ONEONE: number;
  633. /**
  634. * Defines that alpha blending is SRC * DST ALPHA + DST
  635. * Alpha will be set to 0
  636. */
  637. static readonly ALPHA_ALPHATOCOLOR: number;
  638. /**
  639. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  640. */
  641. static readonly ALPHA_REVERSEONEMINUS: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  644. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  645. */
  646. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEZERO: number;
  652. /**
  653. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  654. * Alpha will be set to DST ALPHA
  655. */
  656. static readonly ALPHA_EXCLUSION: number;
  657. /** Defines that alpha blending equation a SUM */
  658. static readonly ALPHA_EQUATION_ADD: number;
  659. /** Defines that alpha blending equation a SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  661. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  663. /** Defines that alpha blending equation a MAX operation */
  664. static readonly ALPHA_EQUATION_MAX: number;
  665. /** Defines that alpha blending equation a MIN operation */
  666. static readonly ALPHA_EQUATION_MIN: number;
  667. /**
  668. * Defines that alpha blending equation a DARKEN operation:
  669. * It takes the min of the src and sums the alpha channels.
  670. */
  671. static readonly ALPHA_EQUATION_DARKEN: number;
  672. /** Defines that the ressource is not delayed*/
  673. static readonly DELAYLOADSTATE_NONE: number;
  674. /** Defines that the ressource was successfully delay loaded */
  675. static readonly DELAYLOADSTATE_LOADED: number;
  676. /** Defines that the ressource is currently delay loading */
  677. static readonly DELAYLOADSTATE_LOADING: number;
  678. /** Defines that the ressource is delayed and has not started loading */
  679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  681. static readonly NEVER: number;
  682. /** 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 */
  683. static readonly ALWAYS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  685. static readonly LESS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  687. static readonly EQUAL: number;
  688. /** 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 */
  689. static readonly LEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  691. static readonly GREATER: number;
  692. /** 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 */
  693. static readonly GEQUAL: number;
  694. /** 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 */
  695. static readonly NOTEQUAL: number;
  696. /** Passed to stencilOperation to specify that stencil value must be kept */
  697. static readonly KEEP: number;
  698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  699. static readonly REPLACE: number;
  700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  701. static readonly INCR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  703. static readonly DECR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  705. static readonly INVERT: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  707. static readonly INCR_WRAP: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  709. static readonly DECR_WRAP: number;
  710. /** Texture is not repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  712. /** Texture is repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  714. /** Texture is repeating and mirrored */
  715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  716. /** ALPHA */
  717. static readonly TEXTUREFORMAT_ALPHA: number;
  718. /** LUMINANCE */
  719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  720. /** LUMINANCE_ALPHA */
  721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  722. /** RGB */
  723. static readonly TEXTUREFORMAT_RGB: number;
  724. /** RGBA */
  725. static readonly TEXTUREFORMAT_RGBA: number;
  726. /** RED */
  727. static readonly TEXTUREFORMAT_RED: number;
  728. /** RED (2nd reference) */
  729. static readonly TEXTUREFORMAT_R: number;
  730. /** RG */
  731. static readonly TEXTUREFORMAT_RG: number;
  732. /** RED_INTEGER */
  733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  734. /** RED_INTEGER (2nd reference) */
  735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  736. /** RG_INTEGER */
  737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  738. /** RGB_INTEGER */
  739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  740. /** RGBA_INTEGER */
  741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  742. /** UNSIGNED_BYTE */
  743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  744. /** UNSIGNED_BYTE (2nd reference) */
  745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  746. /** FLOAT */
  747. static readonly TEXTURETYPE_FLOAT: number;
  748. /** HALF_FLOAT */
  749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  750. /** BYTE */
  751. static readonly TEXTURETYPE_BYTE: number;
  752. /** SHORT */
  753. static readonly TEXTURETYPE_SHORT: number;
  754. /** UNSIGNED_SHORT */
  755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  756. /** INT */
  757. static readonly TEXTURETYPE_INT: number;
  758. /** UNSIGNED_INT */
  759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  760. /** UNSIGNED_SHORT_4_4_4_4 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  762. /** UNSIGNED_SHORT_5_5_5_1 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  764. /** UNSIGNED_SHORT_5_6_5 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  766. /** UNSIGNED_INT_2_10_10_10_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  768. /** UNSIGNED_INT_24_8 */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  770. /** UNSIGNED_INT_10F_11F_11F_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  772. /** UNSIGNED_INT_5_9_9_9_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  776. /** nearest is mag = nearest and min = nearest and no mip */
  777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  778. /** mag = nearest and min = nearest and mip = none */
  779. static readonly TEXTURE_NEAREST_NEAREST: number;
  780. /** Bilinear is mag = linear and min = linear and no mip */
  781. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  782. /** mag = linear and min = linear and mip = none */
  783. static readonly TEXTURE_LINEAR_LINEAR: number;
  784. /** Trilinear is mag = linear and min = linear and mip = linear */
  785. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  788. /** mag = nearest and min = nearest and mip = nearest */
  789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = nearest */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = linear */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = linear and mip = none */
  795. static readonly TEXTURE_NEAREST_LINEAR: number;
  796. /** nearest is mag = nearest and min = nearest and mip = linear */
  797. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  798. /** mag = linear and min = nearest and mip = nearest */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = linear */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  802. /** Bilinear is mag = linear and min = linear and mip = nearest */
  803. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  804. /** mag = linear and min = nearest and mip = none */
  805. static readonly TEXTURE_LINEAR_NEAREST: number;
  806. /** Explicit coordinates mode */
  807. static readonly TEXTURE_EXPLICIT_MODE: number;
  808. /** Spherical coordinates mode */
  809. static readonly TEXTURE_SPHERICAL_MODE: number;
  810. /** Planar coordinates mode */
  811. static readonly TEXTURE_PLANAR_MODE: number;
  812. /** Cubic coordinates mode */
  813. static readonly TEXTURE_CUBIC_MODE: number;
  814. /** Projection coordinates mode */
  815. static readonly TEXTURE_PROJECTION_MODE: number;
  816. /** Skybox coordinates mode */
  817. static readonly TEXTURE_SKYBOX_MODE: number;
  818. /** Inverse Cubic coordinates mode */
  819. static readonly TEXTURE_INVCUBIC_MODE: number;
  820. /** Equirectangular coordinates mode */
  821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed Mirrored coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  826. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  827. static readonly SCALEMODE_FLOOR: number;
  828. /** Defines that texture rescaling will look for the nearest power of 2 size */
  829. static readonly SCALEMODE_NEAREST: number;
  830. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  831. static readonly SCALEMODE_CEILING: number;
  832. /**
  833. * The dirty texture flag value
  834. */
  835. static readonly MATERIAL_TextureDirtyFlag: number;
  836. /**
  837. * The dirty light flag value
  838. */
  839. static readonly MATERIAL_LightDirtyFlag: number;
  840. /**
  841. * The dirty fresnel flag value
  842. */
  843. static readonly MATERIAL_FresnelDirtyFlag: number;
  844. /**
  845. * The dirty attribute flag value
  846. */
  847. static readonly MATERIAL_AttributesDirtyFlag: number;
  848. /**
  849. * The dirty misc flag value
  850. */
  851. static readonly MATERIAL_MiscDirtyFlag: number;
  852. /**
  853. * The all dirty flag value
  854. */
  855. static readonly MATERIAL_AllDirtyFlag: number;
  856. /**
  857. * Returns the triangle fill mode
  858. */
  859. static readonly MATERIAL_TriangleFillMode: number;
  860. /**
  861. * Returns the wireframe mode
  862. */
  863. static readonly MATERIAL_WireFrameFillMode: number;
  864. /**
  865. * Returns the point fill mode
  866. */
  867. static readonly MATERIAL_PointFillMode: number;
  868. /**
  869. * Returns the point list draw mode
  870. */
  871. static readonly MATERIAL_PointListDrawMode: number;
  872. /**
  873. * Returns the line list draw mode
  874. */
  875. static readonly MATERIAL_LineListDrawMode: number;
  876. /**
  877. * Returns the line loop draw mode
  878. */
  879. static readonly MATERIAL_LineLoopDrawMode: number;
  880. /**
  881. * Returns the line strip draw mode
  882. */
  883. static readonly MATERIAL_LineStripDrawMode: number;
  884. /**
  885. * Returns the triangle strip draw mode
  886. */
  887. static readonly MATERIAL_TriangleStripDrawMode: number;
  888. /**
  889. * Returns the triangle fan draw mode
  890. */
  891. static readonly MATERIAL_TriangleFanDrawMode: number;
  892. /**
  893. * Stores the clock-wise side orientation
  894. */
  895. static readonly MATERIAL_ClockWiseSideOrientation: number;
  896. /**
  897. * Stores the counter clock-wise side orientation
  898. */
  899. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  900. /**
  901. * Nothing
  902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  903. */
  904. static readonly ACTION_NothingTrigger: number;
  905. /**
  906. * On pick
  907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  908. */
  909. static readonly ACTION_OnPickTrigger: number;
  910. /**
  911. * On left pick
  912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  913. */
  914. static readonly ACTION_OnLeftPickTrigger: number;
  915. /**
  916. * On right pick
  917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  918. */
  919. static readonly ACTION_OnRightPickTrigger: number;
  920. /**
  921. * On center pick
  922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  923. */
  924. static readonly ACTION_OnCenterPickTrigger: number;
  925. /**
  926. * On pick down
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnPickDownTrigger: number;
  930. /**
  931. * On double pick
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnDoublePickTrigger: number;
  935. /**
  936. * On pick up
  937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  938. */
  939. static readonly ACTION_OnPickUpTrigger: number;
  940. /**
  941. * On pick out.
  942. * This trigger will only be raised if you also declared a OnPickDown
  943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  944. */
  945. static readonly ACTION_OnPickOutTrigger: number;
  946. /**
  947. * On long press
  948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  949. */
  950. static readonly ACTION_OnLongPressTrigger: number;
  951. /**
  952. * On pointer over
  953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  954. */
  955. static readonly ACTION_OnPointerOverTrigger: number;
  956. /**
  957. * On pointer out
  958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  959. */
  960. static readonly ACTION_OnPointerOutTrigger: number;
  961. /**
  962. * On every frame
  963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  964. */
  965. static readonly ACTION_OnEveryFrameTrigger: number;
  966. /**
  967. * On intersection enter
  968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  969. */
  970. static readonly ACTION_OnIntersectionEnterTrigger: number;
  971. /**
  972. * On intersection exit
  973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  974. */
  975. static readonly ACTION_OnIntersectionExitTrigger: number;
  976. /**
  977. * On key down
  978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  979. */
  980. static readonly ACTION_OnKeyDownTrigger: number;
  981. /**
  982. * On key up
  983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  984. */
  985. static readonly ACTION_OnKeyUpTrigger: number;
  986. /**
  987. * Billboard mode will only apply to Y axis
  988. */
  989. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  990. /**
  991. * Billboard mode will apply to all axes
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  994. /**
  995. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  998. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  999. * Test order :
  1000. * Is the bounding sphere outside the frustum ?
  1001. * If not, are the bounding box vertices outside the frustum ?
  1002. * It not, then the cullable object is in the frustum.
  1003. */
  1004. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1005. /** Culling strategy : Bounding Sphere Only.
  1006. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1007. * It's also less accurate than the standard because some not visible objects can still be selected.
  1008. * Test : is the bounding sphere outside the frustum ?
  1009. * If not, then the cullable object is in the frustum.
  1010. */
  1011. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1012. /** Culling strategy : Optimistic Inclusion.
  1013. * This in an inclusion test first, then the standard exclusion test.
  1014. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1015. * 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.
  1016. * Anyway, it's as accurate as the standard strategy.
  1017. * Test :
  1018. * Is the cullable object bounding sphere center in the frustum ?
  1019. * If not, apply the default culling strategy.
  1020. */
  1021. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1022. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1023. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1024. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1025. * 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.
  1026. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1027. * Test :
  1028. * Is the cullable object bounding sphere center in the frustum ?
  1029. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1030. */
  1031. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1032. /**
  1033. * No logging while loading
  1034. */
  1035. static readonly SCENELOADER_NO_LOGGING: number;
  1036. /**
  1037. * Minimal logging while loading
  1038. */
  1039. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1040. /**
  1041. * Summary logging while loading
  1042. */
  1043. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1044. /**
  1045. * Detailled logging while loading
  1046. */
  1047. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1048. }
  1049. }
  1050. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1051. import { Nullable } from "babylonjs/types";
  1052. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1053. /**
  1054. * This represents the required contract to create a new type of texture loader.
  1055. */
  1056. export interface IInternalTextureLoader {
  1057. /**
  1058. * Defines wether the loader supports cascade loading the different faces.
  1059. */
  1060. supportCascades: boolean;
  1061. /**
  1062. * This returns if the loader support the current file information.
  1063. * @param extension defines the file extension of the file being loaded
  1064. * @returns true if the loader can load the specified file
  1065. */
  1066. canLoad(extension: string): boolean;
  1067. /**
  1068. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1069. * @param data contains the texture data
  1070. * @param texture defines the BabylonJS internal texture
  1071. * @param createPolynomials will be true if polynomials have been requested
  1072. * @param onLoad defines the callback to trigger once the texture is ready
  1073. * @param onError defines the callback to trigger in case of error
  1074. */
  1075. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1076. /**
  1077. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1078. * @param data contains the texture data
  1079. * @param texture defines the BabylonJS internal texture
  1080. * @param callback defines the method to call once ready to upload
  1081. */
  1082. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1083. }
  1084. }
  1085. declare module "babylonjs/Engines/IPipelineContext" {
  1086. /**
  1087. * Class used to store and describe the pipeline context associated with an effect
  1088. */
  1089. export interface IPipelineContext {
  1090. /**
  1091. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1092. */
  1093. isAsync: boolean;
  1094. /**
  1095. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1096. */
  1097. isReady: boolean;
  1098. /** @hidden */
  1099. _getVertexShaderCode(): string | null;
  1100. /** @hidden */
  1101. _getFragmentShaderCode(): string | null;
  1102. /** @hidden */
  1103. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1104. }
  1105. }
  1106. declare module "babylonjs/Meshes/dataBuffer" {
  1107. /**
  1108. * Class used to store gfx data (like WebGLBuffer)
  1109. */
  1110. export class DataBuffer {
  1111. /**
  1112. * Gets or sets the number of objects referencing this buffer
  1113. */
  1114. references: number;
  1115. /** Gets or sets the size of the underlying buffer */
  1116. capacity: number;
  1117. /**
  1118. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1119. */
  1120. is32Bits: boolean;
  1121. /**
  1122. * Gets the underlying buffer
  1123. */
  1124. get underlyingResource(): any;
  1125. }
  1126. }
  1127. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1128. /** @hidden */
  1129. export interface IShaderProcessor {
  1130. attributeProcessor?: (attribute: string) => string;
  1131. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1132. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1133. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1134. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1135. lineProcessor?: (line: string, isFragment: boolean) => string;
  1136. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1137. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1138. }
  1139. }
  1140. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1141. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1142. /** @hidden */
  1143. export interface ProcessingOptions {
  1144. defines: string[];
  1145. indexParameters: any;
  1146. isFragment: boolean;
  1147. shouldUseHighPrecisionShader: boolean;
  1148. supportsUniformBuffers: boolean;
  1149. shadersRepository: string;
  1150. includesShadersStore: {
  1151. [key: string]: string;
  1152. };
  1153. processor?: IShaderProcessor;
  1154. version: string;
  1155. platformName: string;
  1156. lookForClosingBracketForUniformBuffer?: boolean;
  1157. }
  1158. }
  1159. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1160. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1161. /** @hidden */
  1162. export class ShaderCodeNode {
  1163. line: string;
  1164. children: ShaderCodeNode[];
  1165. additionalDefineKey?: string;
  1166. additionalDefineValue?: string;
  1167. isValid(preprocessors: {
  1168. [key: string]: string;
  1169. }): boolean;
  1170. process(preprocessors: {
  1171. [key: string]: string;
  1172. }, options: ProcessingOptions): string;
  1173. }
  1174. }
  1175. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1176. /** @hidden */
  1177. export class ShaderCodeCursor {
  1178. private _lines;
  1179. lineIndex: number;
  1180. get currentLine(): string;
  1181. get canRead(): boolean;
  1182. set lines(value: string[]);
  1183. }
  1184. }
  1185. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1186. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1187. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1188. /** @hidden */
  1189. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1190. process(preprocessors: {
  1191. [key: string]: string;
  1192. }, options: ProcessingOptions): string;
  1193. }
  1194. }
  1195. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1196. /** @hidden */
  1197. export class ShaderDefineExpression {
  1198. isTrue(preprocessors: {
  1199. [key: string]: string;
  1200. }): boolean;
  1201. private static _OperatorPriority;
  1202. private static _Stack;
  1203. static postfixToInfix(postfix: string[]): string;
  1204. static infixToPostfix(infix: string): string[];
  1205. }
  1206. }
  1207. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1208. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1209. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1210. /** @hidden */
  1211. export class ShaderCodeTestNode extends ShaderCodeNode {
  1212. testExpression: ShaderDefineExpression;
  1213. isValid(preprocessors: {
  1214. [key: string]: string;
  1215. }): boolean;
  1216. }
  1217. }
  1218. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1219. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1220. /** @hidden */
  1221. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1222. define: string;
  1223. not: boolean;
  1224. constructor(define: string, not?: boolean);
  1225. isTrue(preprocessors: {
  1226. [key: string]: string;
  1227. }): boolean;
  1228. }
  1229. }
  1230. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1231. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1232. /** @hidden */
  1233. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1234. leftOperand: ShaderDefineExpression;
  1235. rightOperand: ShaderDefineExpression;
  1236. isTrue(preprocessors: {
  1237. [key: string]: string;
  1238. }): boolean;
  1239. }
  1240. }
  1241. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1242. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1243. /** @hidden */
  1244. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1245. leftOperand: ShaderDefineExpression;
  1246. rightOperand: ShaderDefineExpression;
  1247. isTrue(preprocessors: {
  1248. [key: string]: string;
  1249. }): boolean;
  1250. }
  1251. }
  1252. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1253. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1254. /** @hidden */
  1255. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1256. define: string;
  1257. operand: string;
  1258. testValue: string;
  1259. constructor(define: string, operand: string, testValue: string);
  1260. isTrue(preprocessors: {
  1261. [key: string]: string;
  1262. }): boolean;
  1263. }
  1264. }
  1265. declare module "babylonjs/Offline/IOfflineProvider" {
  1266. /**
  1267. * Class used to enable access to offline support
  1268. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1269. */
  1270. export interface IOfflineProvider {
  1271. /**
  1272. * Gets a boolean indicating if scene must be saved in the database
  1273. */
  1274. enableSceneOffline: boolean;
  1275. /**
  1276. * Gets a boolean indicating if textures must be saved in the database
  1277. */
  1278. enableTexturesOffline: boolean;
  1279. /**
  1280. * Open the offline support and make it available
  1281. * @param successCallback defines the callback to call on success
  1282. * @param errorCallback defines the callback to call on error
  1283. */
  1284. open(successCallback: () => void, errorCallback: () => void): void;
  1285. /**
  1286. * Loads an image from the offline support
  1287. * @param url defines the url to load from
  1288. * @param image defines the target DOM image
  1289. */
  1290. loadImage(url: string, image: HTMLImageElement): void;
  1291. /**
  1292. * Loads a file from offline support
  1293. * @param url defines the URL to load from
  1294. * @param sceneLoaded defines a callback to call on success
  1295. * @param progressCallBack defines a callback to call when progress changed
  1296. * @param errorCallback defines a callback to call on error
  1297. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1298. */
  1299. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1300. }
  1301. }
  1302. declare module "babylonjs/Misc/filesInputStore" {
  1303. /**
  1304. * Class used to help managing file picking and drag'n'drop
  1305. * File Storage
  1306. */
  1307. export class FilesInputStore {
  1308. /**
  1309. * List of files ready to be loaded
  1310. */
  1311. static FilesToLoad: {
  1312. [key: string]: File;
  1313. };
  1314. }
  1315. }
  1316. declare module "babylonjs/Misc/retryStrategy" {
  1317. import { WebRequest } from "babylonjs/Misc/webRequest";
  1318. /**
  1319. * Class used to define a retry strategy when error happens while loading assets
  1320. */
  1321. export class RetryStrategy {
  1322. /**
  1323. * Function used to defines an exponential back off strategy
  1324. * @param maxRetries defines the maximum number of retries (3 by default)
  1325. * @param baseInterval defines the interval between retries
  1326. * @returns the strategy function to use
  1327. */
  1328. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1329. }
  1330. }
  1331. declare module "babylonjs/Misc/baseError" {
  1332. /**
  1333. * @ignore
  1334. * Application error to support additional information when loading a file
  1335. */
  1336. export abstract class BaseError extends Error {
  1337. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1338. }
  1339. }
  1340. declare module "babylonjs/Misc/fileTools" {
  1341. import { WebRequest } from "babylonjs/Misc/webRequest";
  1342. import { Nullable } from "babylonjs/types";
  1343. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1344. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1345. import { BaseError } from "babylonjs/Misc/baseError";
  1346. /** @ignore */
  1347. export class LoadFileError extends BaseError {
  1348. request?: WebRequest;
  1349. file?: File;
  1350. /**
  1351. * Creates a new LoadFileError
  1352. * @param message defines the message of the error
  1353. * @param request defines the optional web request
  1354. * @param file defines the optional file
  1355. */
  1356. constructor(message: string, object?: WebRequest | File);
  1357. }
  1358. /** @ignore */
  1359. export class RequestFileError extends BaseError {
  1360. request: WebRequest;
  1361. /**
  1362. * Creates a new LoadFileError
  1363. * @param message defines the message of the error
  1364. * @param request defines the optional web request
  1365. */
  1366. constructor(message: string, request: WebRequest);
  1367. }
  1368. /** @ignore */
  1369. export class ReadFileError extends BaseError {
  1370. file: File;
  1371. /**
  1372. * Creates a new ReadFileError
  1373. * @param message defines the message of the error
  1374. * @param file defines the optional file
  1375. */
  1376. constructor(message: string, file: File);
  1377. }
  1378. /**
  1379. * @hidden
  1380. */
  1381. export class FileTools {
  1382. /**
  1383. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1384. */
  1385. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1386. /**
  1387. * Gets or sets the base URL to use to load assets
  1388. */
  1389. static BaseUrl: string;
  1390. /**
  1391. * Default behaviour for cors in the application.
  1392. * It can be a string if the expected behavior is identical in the entire app.
  1393. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1394. */
  1395. static CorsBehavior: string | ((url: string | string[]) => string);
  1396. /**
  1397. * Gets or sets a function used to pre-process url before using them to load assets
  1398. */
  1399. static PreprocessUrl: (url: string) => string;
  1400. /**
  1401. * Removes unwanted characters from an url
  1402. * @param url defines the url to clean
  1403. * @returns the cleaned url
  1404. */
  1405. private static _CleanUrl;
  1406. /**
  1407. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1408. * @param url define the url we are trying
  1409. * @param element define the dom element where to configure the cors policy
  1410. */
  1411. static SetCorsBehavior(url: string | string[], element: {
  1412. crossOrigin: string | null;
  1413. }): void;
  1414. /**
  1415. * Loads an image as an HTMLImageElement.
  1416. * @param input url string, ArrayBuffer, or Blob to load
  1417. * @param onLoad callback called when the image successfully loads
  1418. * @param onError callback called when the image fails to load
  1419. * @param offlineProvider offline provider for caching
  1420. * @param mimeType optional mime type
  1421. * @returns the HTMLImageElement of the loaded image
  1422. */
  1423. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1424. /**
  1425. * Reads a file from a File object
  1426. * @param file defines the file to load
  1427. * @param onSuccess defines the callback to call when data is loaded
  1428. * @param onProgress defines the callback to call during loading process
  1429. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1430. * @param onError defines the callback to call when an error occurs
  1431. * @returns a file request object
  1432. */
  1433. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1434. /**
  1435. * Loads a file from a url
  1436. * @param url url to load
  1437. * @param onSuccess callback called when the file successfully loads
  1438. * @param onProgress callback called while file is loading (if the server supports this mode)
  1439. * @param offlineProvider defines the offline provider for caching
  1440. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1441. * @param onError callback called when the file fails to load
  1442. * @returns a file request object
  1443. */
  1444. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1445. /**
  1446. * Loads a file
  1447. * @param url url to load
  1448. * @param onSuccess callback called when the file successfully loads
  1449. * @param onProgress callback called while file is loading (if the server supports this mode)
  1450. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1451. * @param onError callback called when the file fails to load
  1452. * @param onOpened callback called when the web request is opened
  1453. * @returns a file request object
  1454. */
  1455. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1456. /**
  1457. * Checks if the loaded document was accessed via `file:`-Protocol.
  1458. * @returns boolean
  1459. */
  1460. static IsFileURL(): boolean;
  1461. }
  1462. }
  1463. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1464. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1465. import { WebRequest } from "babylonjs/Misc/webRequest";
  1466. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1467. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1468. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1469. /** @hidden */
  1470. export class ShaderProcessor {
  1471. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1472. private static _ProcessPrecision;
  1473. private static _ExtractOperation;
  1474. private static _BuildSubExpression;
  1475. private static _BuildExpression;
  1476. private static _MoveCursorWithinIf;
  1477. private static _MoveCursor;
  1478. private static _EvaluatePreProcessors;
  1479. private static _PreparePreProcessors;
  1480. private static _ProcessShaderConversion;
  1481. private static _ProcessIncludes;
  1482. /**
  1483. * Loads a file from a url
  1484. * @param url url to load
  1485. * @param onSuccess callback called when the file successfully loads
  1486. * @param onProgress callback called while file is loading (if the server supports this mode)
  1487. * @param offlineProvider defines the offline provider for caching
  1488. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1489. * @param onError callback called when the file fails to load
  1490. * @returns a file request object
  1491. * @hidden
  1492. */
  1493. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1494. }
  1495. }
  1496. declare module "babylonjs/Maths/math.like" {
  1497. import { float, int, DeepImmutable } from "babylonjs/types";
  1498. /**
  1499. * @hidden
  1500. */
  1501. export interface IColor4Like {
  1502. r: float;
  1503. g: float;
  1504. b: float;
  1505. a: float;
  1506. }
  1507. /**
  1508. * @hidden
  1509. */
  1510. export interface IColor3Like {
  1511. r: float;
  1512. g: float;
  1513. b: float;
  1514. }
  1515. /**
  1516. * @hidden
  1517. */
  1518. export interface IVector4Like {
  1519. x: float;
  1520. y: float;
  1521. z: float;
  1522. w: float;
  1523. }
  1524. /**
  1525. * @hidden
  1526. */
  1527. export interface IVector3Like {
  1528. x: float;
  1529. y: float;
  1530. z: float;
  1531. }
  1532. /**
  1533. * @hidden
  1534. */
  1535. export interface IVector2Like {
  1536. x: float;
  1537. y: float;
  1538. }
  1539. /**
  1540. * @hidden
  1541. */
  1542. export interface IMatrixLike {
  1543. toArray(): DeepImmutable<Float32Array>;
  1544. updateFlag: int;
  1545. }
  1546. /**
  1547. * @hidden
  1548. */
  1549. export interface IViewportLike {
  1550. x: float;
  1551. y: float;
  1552. width: float;
  1553. height: float;
  1554. }
  1555. /**
  1556. * @hidden
  1557. */
  1558. export interface IPlaneLike {
  1559. normal: IVector3Like;
  1560. d: float;
  1561. normalize(): void;
  1562. }
  1563. }
  1564. declare module "babylonjs/Materials/iEffectFallbacks" {
  1565. import { Effect } from "babylonjs/Materials/effect";
  1566. /**
  1567. * Interface used to define common properties for effect fallbacks
  1568. */
  1569. export interface IEffectFallbacks {
  1570. /**
  1571. * Removes the defines that should be removed when falling back.
  1572. * @param currentDefines defines the current define statements for the shader.
  1573. * @param effect defines the current effect we try to compile
  1574. * @returns The resulting defines with defines of the current rank removed.
  1575. */
  1576. reduce(currentDefines: string, effect: Effect): string;
  1577. /**
  1578. * Removes the fallback from the bound mesh.
  1579. */
  1580. unBindMesh(): void;
  1581. /**
  1582. * Checks to see if more fallbacks are still availible.
  1583. */
  1584. hasMoreFallbacks: boolean;
  1585. }
  1586. }
  1587. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1588. /**
  1589. * Class used to evalaute queries containing `and` and `or` operators
  1590. */
  1591. export class AndOrNotEvaluator {
  1592. /**
  1593. * Evaluate a query
  1594. * @param query defines the query to evaluate
  1595. * @param evaluateCallback defines the callback used to filter result
  1596. * @returns true if the query matches
  1597. */
  1598. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1599. private static _HandleParenthesisContent;
  1600. private static _SimplifyNegation;
  1601. }
  1602. }
  1603. declare module "babylonjs/Misc/tags" {
  1604. /**
  1605. * Class used to store custom tags
  1606. */
  1607. export class Tags {
  1608. /**
  1609. * Adds support for tags on the given object
  1610. * @param obj defines the object to use
  1611. */
  1612. static EnableFor(obj: any): void;
  1613. /**
  1614. * Removes tags support
  1615. * @param obj defines the object to use
  1616. */
  1617. static DisableFor(obj: any): void;
  1618. /**
  1619. * Gets a boolean indicating if the given object has tags
  1620. * @param obj defines the object to use
  1621. * @returns a boolean
  1622. */
  1623. static HasTags(obj: any): boolean;
  1624. /**
  1625. * Gets the tags available on a given object
  1626. * @param obj defines the object to use
  1627. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1628. * @returns the tags
  1629. */
  1630. static GetTags(obj: any, asString?: boolean): any;
  1631. /**
  1632. * Adds tags to an object
  1633. * @param obj defines the object to use
  1634. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1635. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1636. */
  1637. static AddTagsTo(obj: any, tagsString: string): void;
  1638. /**
  1639. * @hidden
  1640. */
  1641. static _AddTagTo(obj: any, tag: string): void;
  1642. /**
  1643. * Removes specific tags from a specific object
  1644. * @param obj defines the object to use
  1645. * @param tagsString defines the tags to remove
  1646. */
  1647. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1648. /**
  1649. * @hidden
  1650. */
  1651. static _RemoveTagFrom(obj: any, tag: string): void;
  1652. /**
  1653. * Defines if tags hosted on an object match a given query
  1654. * @param obj defines the object to use
  1655. * @param tagsQuery defines the tag query
  1656. * @returns a boolean
  1657. */
  1658. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1659. }
  1660. }
  1661. declare module "babylonjs/Maths/math.scalar" {
  1662. /**
  1663. * Scalar computation library
  1664. */
  1665. export class Scalar {
  1666. /**
  1667. * Two pi constants convenient for computation.
  1668. */
  1669. static TwoPi: number;
  1670. /**
  1671. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1672. * @param a number
  1673. * @param b number
  1674. * @param epsilon (default = 1.401298E-45)
  1675. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1676. */
  1677. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1678. /**
  1679. * Returns a string : the upper case translation of the number i to hexadecimal.
  1680. * @param i number
  1681. * @returns the upper case translation of the number i to hexadecimal.
  1682. */
  1683. static ToHex(i: number): string;
  1684. /**
  1685. * Returns -1 if value is negative and +1 is value is positive.
  1686. * @param value the value
  1687. * @returns the value itself if it's equal to zero.
  1688. */
  1689. static Sign(value: number): number;
  1690. /**
  1691. * Returns the value itself if it's between min and max.
  1692. * Returns min if the value is lower than min.
  1693. * Returns max if the value is greater than max.
  1694. * @param value the value to clmap
  1695. * @param min the min value to clamp to (default: 0)
  1696. * @param max the max value to clamp to (default: 1)
  1697. * @returns the clamped value
  1698. */
  1699. static Clamp(value: number, min?: number, max?: number): number;
  1700. /**
  1701. * the log2 of value.
  1702. * @param value the value to compute log2 of
  1703. * @returns the log2 of value.
  1704. */
  1705. static Log2(value: number): number;
  1706. /**
  1707. * Loops the value, so that it is never larger than length and never smaller than 0.
  1708. *
  1709. * This is similar to the modulo operator but it works with floating point numbers.
  1710. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1711. * With t = 5 and length = 2.5, the result would be 0.0.
  1712. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1713. * @param value the value
  1714. * @param length the length
  1715. * @returns the looped value
  1716. */
  1717. static Repeat(value: number, length: number): number;
  1718. /**
  1719. * Normalize the value between 0.0 and 1.0 using min and max values
  1720. * @param value value to normalize
  1721. * @param min max to normalize between
  1722. * @param max min to normalize between
  1723. * @returns the normalized value
  1724. */
  1725. static Normalize(value: number, min: number, max: number): number;
  1726. /**
  1727. * Denormalize the value from 0.0 and 1.0 using min and max values
  1728. * @param normalized value to denormalize
  1729. * @param min max to denormalize between
  1730. * @param max min to denormalize between
  1731. * @returns the denormalized value
  1732. */
  1733. static Denormalize(normalized: number, min: number, max: number): number;
  1734. /**
  1735. * Calculates the shortest difference between two given angles given in degrees.
  1736. * @param current current angle in degrees
  1737. * @param target target angle in degrees
  1738. * @returns the delta
  1739. */
  1740. static DeltaAngle(current: number, target: number): number;
  1741. /**
  1742. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1743. * @param tx value
  1744. * @param length length
  1745. * @returns The returned value will move back and forth between 0 and length
  1746. */
  1747. static PingPong(tx: number, length: number): number;
  1748. /**
  1749. * Interpolates between min and max with smoothing at the limits.
  1750. *
  1751. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1752. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1753. * @param from from
  1754. * @param to to
  1755. * @param tx value
  1756. * @returns the smooth stepped value
  1757. */
  1758. static SmoothStep(from: number, to: number, tx: number): number;
  1759. /**
  1760. * Moves a value current towards target.
  1761. *
  1762. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1763. * Negative values of maxDelta pushes the value away from target.
  1764. * @param current current value
  1765. * @param target target value
  1766. * @param maxDelta max distance to move
  1767. * @returns resulting value
  1768. */
  1769. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1770. /**
  1771. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1772. *
  1773. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1774. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1775. * @param current current value
  1776. * @param target target value
  1777. * @param maxDelta max distance to move
  1778. * @returns resulting angle
  1779. */
  1780. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1781. /**
  1782. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1783. * @param start start value
  1784. * @param end target value
  1785. * @param amount amount to lerp between
  1786. * @returns the lerped value
  1787. */
  1788. static Lerp(start: number, end: number, amount: number): number;
  1789. /**
  1790. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1791. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1792. * @param start start value
  1793. * @param end target value
  1794. * @param amount amount to lerp between
  1795. * @returns the lerped value
  1796. */
  1797. static LerpAngle(start: number, end: number, amount: number): number;
  1798. /**
  1799. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1800. * @param a start value
  1801. * @param b target value
  1802. * @param value value between a and b
  1803. * @returns the inverseLerp value
  1804. */
  1805. static InverseLerp(a: number, b: number, value: number): number;
  1806. /**
  1807. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1808. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1809. * @param value1 spline value
  1810. * @param tangent1 spline value
  1811. * @param value2 spline value
  1812. * @param tangent2 spline value
  1813. * @param amount input value
  1814. * @returns hermite result
  1815. */
  1816. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1817. /**
  1818. * Returns a random float number between and min and max values
  1819. * @param min min value of random
  1820. * @param max max value of random
  1821. * @returns random value
  1822. */
  1823. static RandomRange(min: number, max: number): number;
  1824. /**
  1825. * This function returns percentage of a number in a given range.
  1826. *
  1827. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1828. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1829. * @param number to convert to percentage
  1830. * @param min min range
  1831. * @param max max range
  1832. * @returns the percentage
  1833. */
  1834. static RangeToPercent(number: number, min: number, max: number): number;
  1835. /**
  1836. * This function returns number that corresponds to the percentage in a given range.
  1837. *
  1838. * PercentToRange(0.34,0,100) will return 34.
  1839. * @param percent to convert to number
  1840. * @param min min range
  1841. * @param max max range
  1842. * @returns the number
  1843. */
  1844. static PercentToRange(percent: number, min: number, max: number): number;
  1845. /**
  1846. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1847. * @param angle The angle to normalize in radian.
  1848. * @return The converted angle.
  1849. */
  1850. static NormalizeRadians(angle: number): number;
  1851. }
  1852. }
  1853. declare module "babylonjs/Maths/math.constants" {
  1854. /**
  1855. * Constant used to convert a value to gamma space
  1856. * @ignorenaming
  1857. */
  1858. export const ToGammaSpace: number;
  1859. /**
  1860. * Constant used to convert a value to linear space
  1861. * @ignorenaming
  1862. */
  1863. export const ToLinearSpace = 2.2;
  1864. /**
  1865. * Constant used to define the minimal number value in Babylon.js
  1866. * @ignorenaming
  1867. */
  1868. let Epsilon: number;
  1869. export { Epsilon };
  1870. }
  1871. declare module "babylonjs/Maths/math.viewport" {
  1872. /**
  1873. * Class used to represent a viewport on screen
  1874. */
  1875. export class Viewport {
  1876. /** viewport left coordinate */
  1877. x: number;
  1878. /** viewport top coordinate */
  1879. y: number;
  1880. /**viewport width */
  1881. width: number;
  1882. /** viewport height */
  1883. height: number;
  1884. /**
  1885. * Creates a Viewport object located at (x, y) and sized (width, height)
  1886. * @param x defines viewport left coordinate
  1887. * @param y defines viewport top coordinate
  1888. * @param width defines the viewport width
  1889. * @param height defines the viewport height
  1890. */
  1891. constructor(
  1892. /** viewport left coordinate */
  1893. x: number,
  1894. /** viewport top coordinate */
  1895. y: number,
  1896. /**viewport width */
  1897. width: number,
  1898. /** viewport height */
  1899. height: number);
  1900. /**
  1901. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1902. * @param renderWidth defines the rendering width
  1903. * @param renderHeight defines the rendering height
  1904. * @returns a new Viewport
  1905. */
  1906. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1907. /**
  1908. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1909. * @param renderWidth defines the rendering width
  1910. * @param renderHeight defines the rendering height
  1911. * @param ref defines the target viewport
  1912. * @returns the current viewport
  1913. */
  1914. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1915. /**
  1916. * Returns a new Viewport copied from the current one
  1917. * @returns a new Viewport
  1918. */
  1919. clone(): Viewport;
  1920. }
  1921. }
  1922. declare module "babylonjs/Misc/arrayTools" {
  1923. /**
  1924. * Class containing a set of static utilities functions for arrays.
  1925. */
  1926. export class ArrayTools {
  1927. /**
  1928. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1929. * @param size the number of element to construct and put in the array
  1930. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1931. * @returns a new array filled with new objects
  1932. */
  1933. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1934. }
  1935. }
  1936. declare module "babylonjs/Maths/math.vector" {
  1937. import { Viewport } from "babylonjs/Maths/math.viewport";
  1938. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1939. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1940. /**
  1941. * Class representing a vector containing 2 coordinates
  1942. */
  1943. export class Vector2 {
  1944. /** defines the first coordinate */
  1945. x: number;
  1946. /** defines the second coordinate */
  1947. y: number;
  1948. /**
  1949. * Creates a new Vector2 from the given x and y coordinates
  1950. * @param x defines the first coordinate
  1951. * @param y defines the second coordinate
  1952. */
  1953. constructor(
  1954. /** defines the first coordinate */
  1955. x?: number,
  1956. /** defines the second coordinate */
  1957. y?: number);
  1958. /**
  1959. * Gets a string with the Vector2 coordinates
  1960. * @returns a string with the Vector2 coordinates
  1961. */
  1962. toString(): string;
  1963. /**
  1964. * Gets class name
  1965. * @returns the string "Vector2"
  1966. */
  1967. getClassName(): string;
  1968. /**
  1969. * Gets current vector hash code
  1970. * @returns the Vector2 hash code as a number
  1971. */
  1972. getHashCode(): number;
  1973. /**
  1974. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1975. * @param array defines the source array
  1976. * @param index defines the offset in source array
  1977. * @returns the current Vector2
  1978. */
  1979. toArray(array: FloatArray, index?: number): Vector2;
  1980. /**
  1981. * Copy the current vector to an array
  1982. * @returns a new array with 2 elements: the Vector2 coordinates.
  1983. */
  1984. asArray(): number[];
  1985. /**
  1986. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1987. * @param source defines the source Vector2
  1988. * @returns the current updated Vector2
  1989. */
  1990. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1991. /**
  1992. * Sets the Vector2 coordinates with the given floats
  1993. * @param x defines the first coordinate
  1994. * @param y defines the second coordinate
  1995. * @returns the current updated Vector2
  1996. */
  1997. copyFromFloats(x: number, y: number): Vector2;
  1998. /**
  1999. * Sets the Vector2 coordinates with the given floats
  2000. * @param x defines the first coordinate
  2001. * @param y defines the second coordinate
  2002. * @returns the current updated Vector2
  2003. */
  2004. set(x: number, y: number): Vector2;
  2005. /**
  2006. * Add another vector with the current one
  2007. * @param otherVector defines the other vector
  2008. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2009. */
  2010. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2011. /**
  2012. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2013. * @param otherVector defines the other vector
  2014. * @param result defines the target vector
  2015. * @returns the unmodified current Vector2
  2016. */
  2017. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2018. /**
  2019. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2020. * @param otherVector defines the other vector
  2021. * @returns the current updated Vector2
  2022. */
  2023. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2024. /**
  2025. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2026. * @param otherVector defines the other vector
  2027. * @returns a new Vector2
  2028. */
  2029. addVector3(otherVector: Vector3): Vector2;
  2030. /**
  2031. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2032. * @param otherVector defines the other vector
  2033. * @returns a new Vector2
  2034. */
  2035. subtract(otherVector: Vector2): Vector2;
  2036. /**
  2037. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2038. * @param otherVector defines the other vector
  2039. * @param result defines the target vector
  2040. * @returns the unmodified current Vector2
  2041. */
  2042. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2043. /**
  2044. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2045. * @param otherVector defines the other vector
  2046. * @returns the current updated Vector2
  2047. */
  2048. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2049. /**
  2050. * Multiplies in place the current Vector2 coordinates by the given ones
  2051. * @param otherVector defines the other vector
  2052. * @returns the current updated Vector2
  2053. */
  2054. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2055. /**
  2056. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2057. * @param otherVector defines the other vector
  2058. * @returns a new Vector2
  2059. */
  2060. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2061. /**
  2062. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2063. * @param otherVector defines the other vector
  2064. * @param result defines the target vector
  2065. * @returns the unmodified current Vector2
  2066. */
  2067. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2068. /**
  2069. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2070. * @param x defines the first coordinate
  2071. * @param y defines the second coordinate
  2072. * @returns a new Vector2
  2073. */
  2074. multiplyByFloats(x: number, y: number): Vector2;
  2075. /**
  2076. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2077. * @param otherVector defines the other vector
  2078. * @returns a new Vector2
  2079. */
  2080. divide(otherVector: Vector2): Vector2;
  2081. /**
  2082. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2083. * @param otherVector defines the other vector
  2084. * @param result defines the target vector
  2085. * @returns the unmodified current Vector2
  2086. */
  2087. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2088. /**
  2089. * Divides the current Vector2 coordinates by the given ones
  2090. * @param otherVector defines the other vector
  2091. * @returns the current updated Vector2
  2092. */
  2093. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2094. /**
  2095. * Gets a new Vector2 with current Vector2 negated coordinates
  2096. * @returns a new Vector2
  2097. */
  2098. negate(): Vector2;
  2099. /**
  2100. * Negate this vector in place
  2101. * @returns this
  2102. */
  2103. negateInPlace(): Vector2;
  2104. /**
  2105. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2106. * @param result defines the Vector3 object where to store the result
  2107. * @returns the current Vector2
  2108. */
  2109. negateToRef(result: Vector2): Vector2;
  2110. /**
  2111. * Multiply the Vector2 coordinates by scale
  2112. * @param scale defines the scaling factor
  2113. * @returns the current updated Vector2
  2114. */
  2115. scaleInPlace(scale: number): Vector2;
  2116. /**
  2117. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2118. * @param scale defines the scaling factor
  2119. * @returns a new Vector2
  2120. */
  2121. scale(scale: number): Vector2;
  2122. /**
  2123. * Scale the current Vector2 values by a factor to a given Vector2
  2124. * @param scale defines the scale factor
  2125. * @param result defines the Vector2 object where to store the result
  2126. * @returns the unmodified current Vector2
  2127. */
  2128. scaleToRef(scale: number, result: Vector2): Vector2;
  2129. /**
  2130. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2131. * @param scale defines the scale factor
  2132. * @param result defines the Vector2 object where to store the result
  2133. * @returns the unmodified current Vector2
  2134. */
  2135. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2136. /**
  2137. * Gets a boolean if two vectors are equals
  2138. * @param otherVector defines the other vector
  2139. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2140. */
  2141. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2142. /**
  2143. * Gets a boolean if two vectors are equals (using an epsilon value)
  2144. * @param otherVector defines the other vector
  2145. * @param epsilon defines the minimal distance to consider equality
  2146. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2147. */
  2148. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2149. /**
  2150. * Gets a new Vector2 from current Vector2 floored values
  2151. * @returns a new Vector2
  2152. */
  2153. floor(): Vector2;
  2154. /**
  2155. * Gets a new Vector2 from current Vector2 floored values
  2156. * @returns a new Vector2
  2157. */
  2158. fract(): Vector2;
  2159. /**
  2160. * Gets the length of the vector
  2161. * @returns the vector length (float)
  2162. */
  2163. length(): number;
  2164. /**
  2165. * Gets the vector squared length
  2166. * @returns the vector squared length (float)
  2167. */
  2168. lengthSquared(): number;
  2169. /**
  2170. * Normalize the vector
  2171. * @returns the current updated Vector2
  2172. */
  2173. normalize(): Vector2;
  2174. /**
  2175. * Gets a new Vector2 copied from the Vector2
  2176. * @returns a new Vector2
  2177. */
  2178. clone(): Vector2;
  2179. /**
  2180. * Gets a new Vector2(0, 0)
  2181. * @returns a new Vector2
  2182. */
  2183. static Zero(): Vector2;
  2184. /**
  2185. * Gets a new Vector2(1, 1)
  2186. * @returns a new Vector2
  2187. */
  2188. static One(): Vector2;
  2189. /**
  2190. * Gets a new Vector2 set from the given index element of the given array
  2191. * @param array defines the data source
  2192. * @param offset defines the offset in the data source
  2193. * @returns a new Vector2
  2194. */
  2195. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2196. /**
  2197. * Sets "result" from the given index element of the given array
  2198. * @param array defines the data source
  2199. * @param offset defines the offset in the data source
  2200. * @param result defines the target vector
  2201. */
  2202. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2203. /**
  2204. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2205. * @param value1 defines 1st point of control
  2206. * @param value2 defines 2nd point of control
  2207. * @param value3 defines 3rd point of control
  2208. * @param value4 defines 4th point of control
  2209. * @param amount defines the interpolation factor
  2210. * @returns a new Vector2
  2211. */
  2212. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2213. /**
  2214. * 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".
  2215. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2216. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2217. * @param value defines the value to clamp
  2218. * @param min defines the lower limit
  2219. * @param max defines the upper limit
  2220. * @returns a new Vector2
  2221. */
  2222. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2223. /**
  2224. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2225. * @param value1 defines the 1st control point
  2226. * @param tangent1 defines the outgoing tangent
  2227. * @param value2 defines the 2nd control point
  2228. * @param tangent2 defines the incoming tangent
  2229. * @param amount defines the interpolation factor
  2230. * @returns a new Vector2
  2231. */
  2232. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2233. /**
  2234. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2235. * @param start defines the start vector
  2236. * @param end defines the end vector
  2237. * @param amount defines the interpolation factor
  2238. * @returns a new Vector2
  2239. */
  2240. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2241. /**
  2242. * Gets the dot product of the vector "left" and the vector "right"
  2243. * @param left defines first vector
  2244. * @param right defines second vector
  2245. * @returns the dot product (float)
  2246. */
  2247. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2248. /**
  2249. * Returns a new Vector2 equal to the normalized given vector
  2250. * @param vector defines the vector to normalize
  2251. * @returns a new Vector2
  2252. */
  2253. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2254. /**
  2255. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2256. * @param left defines 1st vector
  2257. * @param right defines 2nd vector
  2258. * @returns a new Vector2
  2259. */
  2260. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2261. /**
  2262. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2263. * @param left defines 1st vector
  2264. * @param right defines 2nd vector
  2265. * @returns a new Vector2
  2266. */
  2267. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2268. /**
  2269. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2270. * @param vector defines the vector to transform
  2271. * @param transformation defines the matrix to apply
  2272. * @returns a new Vector2
  2273. */
  2274. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2275. /**
  2276. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2277. * @param vector defines the vector to transform
  2278. * @param transformation defines the matrix to apply
  2279. * @param result defines the target vector
  2280. */
  2281. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2282. /**
  2283. * Determines if a given vector is included in a triangle
  2284. * @param p defines the vector to test
  2285. * @param p0 defines 1st triangle point
  2286. * @param p1 defines 2nd triangle point
  2287. * @param p2 defines 3rd triangle point
  2288. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2289. */
  2290. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2291. /**
  2292. * Gets the distance between the vectors "value1" and "value2"
  2293. * @param value1 defines first vector
  2294. * @param value2 defines second vector
  2295. * @returns the distance between vectors
  2296. */
  2297. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2298. /**
  2299. * Returns the squared distance between the vectors "value1" and "value2"
  2300. * @param value1 defines first vector
  2301. * @param value2 defines second vector
  2302. * @returns the squared distance between vectors
  2303. */
  2304. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2305. /**
  2306. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2307. * @param value1 defines first vector
  2308. * @param value2 defines second vector
  2309. * @returns a new Vector2
  2310. */
  2311. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2312. /**
  2313. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2314. * @param p defines the middle point
  2315. * @param segA defines one point of the segment
  2316. * @param segB defines the other point of the segment
  2317. * @returns the shortest distance
  2318. */
  2319. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2320. }
  2321. /**
  2322. * Class used to store (x,y,z) vector representation
  2323. * A Vector3 is the main object used in 3D geometry
  2324. * It can represent etiher the coordinates of a point the space, either a direction
  2325. * Reminder: js uses a left handed forward facing system
  2326. */
  2327. export class Vector3 {
  2328. /**
  2329. * Defines the first coordinates (on X axis)
  2330. */
  2331. x: number;
  2332. /**
  2333. * Defines the second coordinates (on Y axis)
  2334. */
  2335. y: number;
  2336. /**
  2337. * Defines the third coordinates (on Z axis)
  2338. */
  2339. z: number;
  2340. private static _UpReadOnly;
  2341. private static _ZeroReadOnly;
  2342. /**
  2343. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2344. * @param x defines the first coordinates (on X axis)
  2345. * @param y defines the second coordinates (on Y axis)
  2346. * @param z defines the third coordinates (on Z axis)
  2347. */
  2348. constructor(
  2349. /**
  2350. * Defines the first coordinates (on X axis)
  2351. */
  2352. x?: number,
  2353. /**
  2354. * Defines the second coordinates (on Y axis)
  2355. */
  2356. y?: number,
  2357. /**
  2358. * Defines the third coordinates (on Z axis)
  2359. */
  2360. z?: number);
  2361. /**
  2362. * Creates a string representation of the Vector3
  2363. * @returns a string with the Vector3 coordinates.
  2364. */
  2365. toString(): string;
  2366. /**
  2367. * Gets the class name
  2368. * @returns the string "Vector3"
  2369. */
  2370. getClassName(): string;
  2371. /**
  2372. * Creates the Vector3 hash code
  2373. * @returns a number which tends to be unique between Vector3 instances
  2374. */
  2375. getHashCode(): number;
  2376. /**
  2377. * Creates an array containing three elements : the coordinates of the Vector3
  2378. * @returns a new array of numbers
  2379. */
  2380. asArray(): number[];
  2381. /**
  2382. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2383. * @param array defines the destination array
  2384. * @param index defines the offset in the destination array
  2385. * @returns the current Vector3
  2386. */
  2387. toArray(array: FloatArray, index?: number): Vector3;
  2388. /**
  2389. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2390. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2391. */
  2392. toQuaternion(): Quaternion;
  2393. /**
  2394. * Adds the given vector to the current Vector3
  2395. * @param otherVector defines the second operand
  2396. * @returns the current updated Vector3
  2397. */
  2398. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2399. /**
  2400. * Adds the given coordinates to the current Vector3
  2401. * @param x defines the x coordinate of the operand
  2402. * @param y defines the y coordinate of the operand
  2403. * @param z defines the z coordinate of the operand
  2404. * @returns the current updated Vector3
  2405. */
  2406. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2407. /**
  2408. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2409. * @param otherVector defines the second operand
  2410. * @returns the resulting Vector3
  2411. */
  2412. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2413. /**
  2414. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2415. * @param otherVector defines the second operand
  2416. * @param result defines the Vector3 object where to store the result
  2417. * @returns the current Vector3
  2418. */
  2419. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2420. /**
  2421. * Subtract the given vector from the current Vector3
  2422. * @param otherVector defines the second operand
  2423. * @returns the current updated Vector3
  2424. */
  2425. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2426. /**
  2427. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2428. * @param otherVector defines the second operand
  2429. * @returns the resulting Vector3
  2430. */
  2431. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2432. /**
  2433. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2434. * @param otherVector defines the second operand
  2435. * @param result defines the Vector3 object where to store the result
  2436. * @returns the current Vector3
  2437. */
  2438. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2439. /**
  2440. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2441. * @param x defines the x coordinate of the operand
  2442. * @param y defines the y coordinate of the operand
  2443. * @param z defines the z coordinate of the operand
  2444. * @returns the resulting Vector3
  2445. */
  2446. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2447. /**
  2448. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2449. * @param x defines the x coordinate of the operand
  2450. * @param y defines the y coordinate of the operand
  2451. * @param z defines the z coordinate of the operand
  2452. * @param result defines the Vector3 object where to store the result
  2453. * @returns the current Vector3
  2454. */
  2455. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2456. /**
  2457. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2458. * @returns a new Vector3
  2459. */
  2460. negate(): Vector3;
  2461. /**
  2462. * Negate this vector in place
  2463. * @returns this
  2464. */
  2465. negateInPlace(): Vector3;
  2466. /**
  2467. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2468. * @param result defines the Vector3 object where to store the result
  2469. * @returns the current Vector3
  2470. */
  2471. negateToRef(result: Vector3): Vector3;
  2472. /**
  2473. * Multiplies the Vector3 coordinates by the float "scale"
  2474. * @param scale defines the multiplier factor
  2475. * @returns the current updated Vector3
  2476. */
  2477. scaleInPlace(scale: number): Vector3;
  2478. /**
  2479. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2480. * @param scale defines the multiplier factor
  2481. * @returns a new Vector3
  2482. */
  2483. scale(scale: number): Vector3;
  2484. /**
  2485. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2486. * @param scale defines the multiplier factor
  2487. * @param result defines the Vector3 object where to store the result
  2488. * @returns the current Vector3
  2489. */
  2490. scaleToRef(scale: number, result: Vector3): Vector3;
  2491. /**
  2492. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2493. * @param scale defines the scale factor
  2494. * @param result defines the Vector3 object where to store the result
  2495. * @returns the unmodified current Vector3
  2496. */
  2497. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2498. /**
  2499. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2500. * @param otherVector defines the second operand
  2501. * @returns true if both vectors are equals
  2502. */
  2503. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2504. /**
  2505. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2506. * @param otherVector defines the second operand
  2507. * @param epsilon defines the minimal distance to define values as equals
  2508. * @returns true if both vectors are distant less than epsilon
  2509. */
  2510. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2511. /**
  2512. * Returns true if the current Vector3 coordinates equals the given floats
  2513. * @param x defines the x coordinate of the operand
  2514. * @param y defines the y coordinate of the operand
  2515. * @param z defines the z coordinate of the operand
  2516. * @returns true if both vectors are equals
  2517. */
  2518. equalsToFloats(x: number, y: number, z: number): boolean;
  2519. /**
  2520. * Multiplies the current Vector3 coordinates by the given ones
  2521. * @param otherVector defines the second operand
  2522. * @returns the current updated Vector3
  2523. */
  2524. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2525. /**
  2526. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2527. * @param otherVector defines the second operand
  2528. * @returns the new Vector3
  2529. */
  2530. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2531. /**
  2532. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2533. * @param otherVector defines the second operand
  2534. * @param result defines the Vector3 object where to store the result
  2535. * @returns the current Vector3
  2536. */
  2537. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2538. /**
  2539. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2540. * @param x defines the x coordinate of the operand
  2541. * @param y defines the y coordinate of the operand
  2542. * @param z defines the z coordinate of the operand
  2543. * @returns the new Vector3
  2544. */
  2545. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2546. /**
  2547. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2548. * @param otherVector defines the second operand
  2549. * @returns the new Vector3
  2550. */
  2551. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2552. /**
  2553. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2554. * @param otherVector defines the second operand
  2555. * @param result defines the Vector3 object where to store the result
  2556. * @returns the current Vector3
  2557. */
  2558. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2559. /**
  2560. * Divides the current Vector3 coordinates by the given ones.
  2561. * @param otherVector defines the second operand
  2562. * @returns the current updated Vector3
  2563. */
  2564. divideInPlace(otherVector: Vector3): Vector3;
  2565. /**
  2566. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2567. * @param other defines the second operand
  2568. * @returns the current updated Vector3
  2569. */
  2570. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2571. /**
  2572. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2573. * @param other defines the second operand
  2574. * @returns the current updated Vector3
  2575. */
  2576. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2577. /**
  2578. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2579. * @param x defines the x coordinate of the operand
  2580. * @param y defines the y coordinate of the operand
  2581. * @param z defines the z coordinate of the operand
  2582. * @returns the current updated Vector3
  2583. */
  2584. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2585. /**
  2586. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2587. * @param x defines the x coordinate of the operand
  2588. * @param y defines the y coordinate of the operand
  2589. * @param z defines the z coordinate of the operand
  2590. * @returns the current updated Vector3
  2591. */
  2592. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2593. /**
  2594. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2595. * Check if is non uniform within a certain amount of decimal places to account for this
  2596. * @param epsilon the amount the values can differ
  2597. * @returns if the the vector is non uniform to a certain number of decimal places
  2598. */
  2599. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2600. /**
  2601. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2602. */
  2603. get isNonUniform(): boolean;
  2604. /**
  2605. * Gets a new Vector3 from current Vector3 floored values
  2606. * @returns a new Vector3
  2607. */
  2608. floor(): Vector3;
  2609. /**
  2610. * Gets a new Vector3 from current Vector3 floored values
  2611. * @returns a new Vector3
  2612. */
  2613. fract(): Vector3;
  2614. /**
  2615. * Gets the length of the Vector3
  2616. * @returns the length of the Vector3
  2617. */
  2618. length(): number;
  2619. /**
  2620. * Gets the squared length of the Vector3
  2621. * @returns squared length of the Vector3
  2622. */
  2623. lengthSquared(): number;
  2624. /**
  2625. * Normalize the current Vector3.
  2626. * Please note that this is an in place operation.
  2627. * @returns the current updated Vector3
  2628. */
  2629. normalize(): Vector3;
  2630. /**
  2631. * Reorders the x y z properties of the vector in place
  2632. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2633. * @returns the current updated vector
  2634. */
  2635. reorderInPlace(order: string): this;
  2636. /**
  2637. * Rotates the vector around 0,0,0 by a quaternion
  2638. * @param quaternion the rotation quaternion
  2639. * @param result vector to store the result
  2640. * @returns the resulting vector
  2641. */
  2642. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2643. /**
  2644. * Rotates a vector around a given point
  2645. * @param quaternion the rotation quaternion
  2646. * @param point the point to rotate around
  2647. * @param result vector to store the result
  2648. * @returns the resulting vector
  2649. */
  2650. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2651. /**
  2652. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2653. * The cross product is then orthogonal to both current and "other"
  2654. * @param other defines the right operand
  2655. * @returns the cross product
  2656. */
  2657. cross(other: Vector3): Vector3;
  2658. /**
  2659. * Normalize the current Vector3 with the given input length.
  2660. * Please note that this is an in place operation.
  2661. * @param len the length of the vector
  2662. * @returns the current updated Vector3
  2663. */
  2664. normalizeFromLength(len: number): Vector3;
  2665. /**
  2666. * Normalize the current Vector3 to a new vector
  2667. * @returns the new Vector3
  2668. */
  2669. normalizeToNew(): Vector3;
  2670. /**
  2671. * Normalize the current Vector3 to the reference
  2672. * @param reference define the Vector3 to update
  2673. * @returns the updated Vector3
  2674. */
  2675. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2676. /**
  2677. * Creates a new Vector3 copied from the current Vector3
  2678. * @returns the new Vector3
  2679. */
  2680. clone(): Vector3;
  2681. /**
  2682. * Copies the given vector coordinates to the current Vector3 ones
  2683. * @param source defines the source Vector3
  2684. * @returns the current updated Vector3
  2685. */
  2686. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2687. /**
  2688. * Copies the given floats to the current Vector3 coordinates
  2689. * @param x defines the x coordinate of the operand
  2690. * @param y defines the y coordinate of the operand
  2691. * @param z defines the z coordinate of the operand
  2692. * @returns the current updated Vector3
  2693. */
  2694. copyFromFloats(x: number, y: number, z: number): Vector3;
  2695. /**
  2696. * Copies the given floats to the current Vector3 coordinates
  2697. * @param x defines the x coordinate of the operand
  2698. * @param y defines the y coordinate of the operand
  2699. * @param z defines the z coordinate of the operand
  2700. * @returns the current updated Vector3
  2701. */
  2702. set(x: number, y: number, z: number): Vector3;
  2703. /**
  2704. * Copies the given float to the current Vector3 coordinates
  2705. * @param v defines the x, y and z coordinates of the operand
  2706. * @returns the current updated Vector3
  2707. */
  2708. setAll(v: number): Vector3;
  2709. /**
  2710. * Get the clip factor between two vectors
  2711. * @param vector0 defines the first operand
  2712. * @param vector1 defines the second operand
  2713. * @param axis defines the axis to use
  2714. * @param size defines the size along the axis
  2715. * @returns the clip factor
  2716. */
  2717. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2718. /**
  2719. * Get angle between two vectors
  2720. * @param vector0 angle between vector0 and vector1
  2721. * @param vector1 angle between vector0 and vector1
  2722. * @param normal direction of the normal
  2723. * @return the angle between vector0 and vector1
  2724. */
  2725. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2726. /**
  2727. * Returns a new Vector3 set from the index "offset" of the given array
  2728. * @param array defines the source array
  2729. * @param offset defines the offset in the source array
  2730. * @returns the new Vector3
  2731. */
  2732. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2733. /**
  2734. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2735. * @param array defines the source array
  2736. * @param offset defines the offset in the source array
  2737. * @returns the new Vector3
  2738. * @deprecated Please use FromArray instead.
  2739. */
  2740. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2741. /**
  2742. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2743. * @param array defines the source array
  2744. * @param offset defines the offset in the source array
  2745. * @param result defines the Vector3 where to store the result
  2746. */
  2747. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2748. /**
  2749. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2750. * @param array defines the source array
  2751. * @param offset defines the offset in the source array
  2752. * @param result defines the Vector3 where to store the result
  2753. * @deprecated Please use FromArrayToRef instead.
  2754. */
  2755. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2756. /**
  2757. * Sets the given vector "result" with the given floats.
  2758. * @param x defines the x coordinate of the source
  2759. * @param y defines the y coordinate of the source
  2760. * @param z defines the z coordinate of the source
  2761. * @param result defines the Vector3 where to store the result
  2762. */
  2763. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2764. /**
  2765. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2766. * @returns a new empty Vector3
  2767. */
  2768. static Zero(): Vector3;
  2769. /**
  2770. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2771. * @returns a new unit Vector3
  2772. */
  2773. static One(): Vector3;
  2774. /**
  2775. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2776. * @returns a new up Vector3
  2777. */
  2778. static Up(): Vector3;
  2779. /**
  2780. * Gets a up Vector3 that must not be updated
  2781. */
  2782. static get UpReadOnly(): DeepImmutable<Vector3>;
  2783. /**
  2784. * Gets a zero Vector3 that must not be updated
  2785. */
  2786. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2787. /**
  2788. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2789. * @returns a new down Vector3
  2790. */
  2791. static Down(): Vector3;
  2792. /**
  2793. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2794. * @param rightHandedSystem is the scene right-handed (negative z)
  2795. * @returns a new forward Vector3
  2796. */
  2797. static Forward(rightHandedSystem?: boolean): Vector3;
  2798. /**
  2799. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2800. * @param rightHandedSystem is the scene right-handed (negative-z)
  2801. * @returns a new forward Vector3
  2802. */
  2803. static Backward(rightHandedSystem?: boolean): Vector3;
  2804. /**
  2805. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2806. * @returns a new right Vector3
  2807. */
  2808. static Right(): Vector3;
  2809. /**
  2810. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2811. * @returns a new left Vector3
  2812. */
  2813. static Left(): Vector3;
  2814. /**
  2815. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2816. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2817. * @param vector defines the Vector3 to transform
  2818. * @param transformation defines the transformation matrix
  2819. * @returns the transformed Vector3
  2820. */
  2821. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2822. /**
  2823. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2824. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2825. * @param vector defines the Vector3 to transform
  2826. * @param transformation defines the transformation matrix
  2827. * @param result defines the Vector3 where to store the result
  2828. */
  2829. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2830. /**
  2831. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2832. * This method computes tranformed coordinates only, not transformed direction vectors
  2833. * @param x define the x coordinate of the source vector
  2834. * @param y define the y coordinate of the source vector
  2835. * @param z define the z coordinate of the source vector
  2836. * @param transformation defines the transformation matrix
  2837. * @param result defines the Vector3 where to store the result
  2838. */
  2839. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2840. /**
  2841. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2842. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2843. * @param vector defines the Vector3 to transform
  2844. * @param transformation defines the transformation matrix
  2845. * @returns the new Vector3
  2846. */
  2847. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2848. /**
  2849. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2850. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2851. * @param vector defines the Vector3 to transform
  2852. * @param transformation defines the transformation matrix
  2853. * @param result defines the Vector3 where to store the result
  2854. */
  2855. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2856. /**
  2857. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2858. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2859. * @param x define the x coordinate of the source vector
  2860. * @param y define the y coordinate of the source vector
  2861. * @param z define the z coordinate of the source vector
  2862. * @param transformation defines the transformation matrix
  2863. * @param result defines the Vector3 where to store the result
  2864. */
  2865. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2866. /**
  2867. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2868. * @param value1 defines the first control point
  2869. * @param value2 defines the second control point
  2870. * @param value3 defines the third control point
  2871. * @param value4 defines the fourth control point
  2872. * @param amount defines the amount on the spline to use
  2873. * @returns the new Vector3
  2874. */
  2875. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2876. /**
  2877. * 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"
  2878. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2879. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2880. * @param value defines the current value
  2881. * @param min defines the lower range value
  2882. * @param max defines the upper range value
  2883. * @returns the new Vector3
  2884. */
  2885. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2886. /**
  2887. * 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"
  2888. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2889. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2890. * @param value defines the current value
  2891. * @param min defines the lower range value
  2892. * @param max defines the upper range value
  2893. * @param result defines the Vector3 where to store the result
  2894. */
  2895. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2896. /**
  2897. * Checks if a given vector is inside a specific range
  2898. * @param v defines the vector to test
  2899. * @param min defines the minimum range
  2900. * @param max defines the maximum range
  2901. */
  2902. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2903. /**
  2904. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2905. * @param value1 defines the first control point
  2906. * @param tangent1 defines the first tangent vector
  2907. * @param value2 defines the second control point
  2908. * @param tangent2 defines the second tangent vector
  2909. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2910. * @returns the new Vector3
  2911. */
  2912. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2913. /**
  2914. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2915. * @param start defines the start value
  2916. * @param end defines the end value
  2917. * @param amount max defines amount between both (between 0 and 1)
  2918. * @returns the new Vector3
  2919. */
  2920. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2921. /**
  2922. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2923. * @param start defines the start value
  2924. * @param end defines the end value
  2925. * @param amount max defines amount between both (between 0 and 1)
  2926. * @param result defines the Vector3 where to store the result
  2927. */
  2928. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2929. /**
  2930. * Returns the dot product (float) between the vectors "left" and "right"
  2931. * @param left defines the left operand
  2932. * @param right defines the right operand
  2933. * @returns the dot product
  2934. */
  2935. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2936. /**
  2937. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2938. * The cross product is then orthogonal to both "left" and "right"
  2939. * @param left defines the left operand
  2940. * @param right defines the right operand
  2941. * @returns the cross product
  2942. */
  2943. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2944. /**
  2945. * Sets the given vector "result" with the cross product of "left" and "right"
  2946. * The cross product is then orthogonal to both "left" and "right"
  2947. * @param left defines the left operand
  2948. * @param right defines the right operand
  2949. * @param result defines the Vector3 where to store the result
  2950. */
  2951. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2952. /**
  2953. * Returns a new Vector3 as the normalization of the given vector
  2954. * @param vector defines the Vector3 to normalize
  2955. * @returns the new Vector3
  2956. */
  2957. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2958. /**
  2959. * Sets the given vector "result" with the normalization of the given first vector
  2960. * @param vector defines the Vector3 to normalize
  2961. * @param result defines the Vector3 where to store the result
  2962. */
  2963. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2964. /**
  2965. * Project a Vector3 onto screen space
  2966. * @param vector defines the Vector3 to project
  2967. * @param world defines the world matrix to use
  2968. * @param transform defines the transform (view x projection) matrix to use
  2969. * @param viewport defines the screen viewport to use
  2970. * @returns the new Vector3
  2971. */
  2972. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2973. /** @hidden */
  2974. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2975. /**
  2976. * Unproject from screen space to object space
  2977. * @param source defines the screen space Vector3 to use
  2978. * @param viewportWidth defines the current width of the viewport
  2979. * @param viewportHeight defines the current height of the viewport
  2980. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2981. * @param transform defines the transform (view x projection) matrix to use
  2982. * @returns the new Vector3
  2983. */
  2984. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2985. /**
  2986. * Unproject from screen space to object space
  2987. * @param source defines the screen space Vector3 to use
  2988. * @param viewportWidth defines the current width of the viewport
  2989. * @param viewportHeight defines the current height of the viewport
  2990. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2991. * @param view defines the view matrix to use
  2992. * @param projection defines the projection matrix to use
  2993. * @returns the new Vector3
  2994. */
  2995. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2996. /**
  2997. * Unproject from screen space to object space
  2998. * @param source defines the screen space Vector3 to use
  2999. * @param viewportWidth defines the current width of the viewport
  3000. * @param viewportHeight defines the current height of the viewport
  3001. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3002. * @param view defines the view matrix to use
  3003. * @param projection defines the projection matrix to use
  3004. * @param result defines the Vector3 where to store the result
  3005. */
  3006. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3007. /**
  3008. * Unproject from screen space to object space
  3009. * @param sourceX defines the screen space x coordinate to use
  3010. * @param sourceY defines the screen space y coordinate to use
  3011. * @param sourceZ defines the screen space z coordinate to use
  3012. * @param viewportWidth defines the current width of the viewport
  3013. * @param viewportHeight defines the current height of the viewport
  3014. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3015. * @param view defines the view matrix to use
  3016. * @param projection defines the projection matrix to use
  3017. * @param result defines the Vector3 where to store the result
  3018. */
  3019. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3020. /**
  3021. * Gets the minimal coordinate values between two Vector3
  3022. * @param left defines the first operand
  3023. * @param right defines the second operand
  3024. * @returns the new Vector3
  3025. */
  3026. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3027. /**
  3028. * Gets the maximal coordinate values between two Vector3
  3029. * @param left defines the first operand
  3030. * @param right defines the second operand
  3031. * @returns the new Vector3
  3032. */
  3033. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3034. /**
  3035. * Returns the distance between the vectors "value1" and "value2"
  3036. * @param value1 defines the first operand
  3037. * @param value2 defines the second operand
  3038. * @returns the distance
  3039. */
  3040. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3041. /**
  3042. * Returns the squared distance between the vectors "value1" and "value2"
  3043. * @param value1 defines the first operand
  3044. * @param value2 defines the second operand
  3045. * @returns the squared distance
  3046. */
  3047. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3048. /**
  3049. * Returns a new Vector3 located at the center between "value1" and "value2"
  3050. * @param value1 defines the first operand
  3051. * @param value2 defines the second operand
  3052. * @returns the new Vector3
  3053. */
  3054. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3055. /**
  3056. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3057. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3058. * to something in order to rotate it from its local system to the given target system
  3059. * Note: axis1, axis2 and axis3 are normalized during this operation
  3060. * @param axis1 defines the first axis
  3061. * @param axis2 defines the second axis
  3062. * @param axis3 defines the third axis
  3063. * @returns a new Vector3
  3064. */
  3065. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3066. /**
  3067. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3068. * @param axis1 defines the first axis
  3069. * @param axis2 defines the second axis
  3070. * @param axis3 defines the third axis
  3071. * @param ref defines the Vector3 where to store the result
  3072. */
  3073. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3074. }
  3075. /**
  3076. * Vector4 class created for EulerAngle class conversion to Quaternion
  3077. */
  3078. export class Vector4 {
  3079. /** x value of the vector */
  3080. x: number;
  3081. /** y value of the vector */
  3082. y: number;
  3083. /** z value of the vector */
  3084. z: number;
  3085. /** w value of the vector */
  3086. w: number;
  3087. /**
  3088. * Creates a Vector4 object from the given floats.
  3089. * @param x x value of the vector
  3090. * @param y y value of the vector
  3091. * @param z z value of the vector
  3092. * @param w w value of the vector
  3093. */
  3094. constructor(
  3095. /** x value of the vector */
  3096. x: number,
  3097. /** y value of the vector */
  3098. y: number,
  3099. /** z value of the vector */
  3100. z: number,
  3101. /** w value of the vector */
  3102. w: number);
  3103. /**
  3104. * Returns the string with the Vector4 coordinates.
  3105. * @returns a string containing all the vector values
  3106. */
  3107. toString(): string;
  3108. /**
  3109. * Returns the string "Vector4".
  3110. * @returns "Vector4"
  3111. */
  3112. getClassName(): string;
  3113. /**
  3114. * Returns the Vector4 hash code.
  3115. * @returns a unique hash code
  3116. */
  3117. getHashCode(): number;
  3118. /**
  3119. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3120. * @returns the resulting array
  3121. */
  3122. asArray(): number[];
  3123. /**
  3124. * Populates the given array from the given index with the Vector4 coordinates.
  3125. * @param array array to populate
  3126. * @param index index of the array to start at (default: 0)
  3127. * @returns the Vector4.
  3128. */
  3129. toArray(array: FloatArray, index?: number): Vector4;
  3130. /**
  3131. * Adds the given vector to the current Vector4.
  3132. * @param otherVector the vector to add
  3133. * @returns the updated Vector4.
  3134. */
  3135. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3136. /**
  3137. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3138. * @param otherVector the vector to add
  3139. * @returns the resulting vector
  3140. */
  3141. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3142. /**
  3143. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3144. * @param otherVector the vector to add
  3145. * @param result the vector to store the result
  3146. * @returns the current Vector4.
  3147. */
  3148. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3149. /**
  3150. * Subtract in place the given vector from the current Vector4.
  3151. * @param otherVector the vector to subtract
  3152. * @returns the updated Vector4.
  3153. */
  3154. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3155. /**
  3156. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3157. * @param otherVector the vector to add
  3158. * @returns the new vector with the result
  3159. */
  3160. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3161. /**
  3162. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3163. * @param otherVector the vector to subtract
  3164. * @param result the vector to store the result
  3165. * @returns the current Vector4.
  3166. */
  3167. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3168. /**
  3169. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3170. */
  3171. /**
  3172. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3173. * @param x value to subtract
  3174. * @param y value to subtract
  3175. * @param z value to subtract
  3176. * @param w value to subtract
  3177. * @returns new vector containing the result
  3178. */
  3179. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3180. /**
  3181. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3182. * @param x value to subtract
  3183. * @param y value to subtract
  3184. * @param z value to subtract
  3185. * @param w value to subtract
  3186. * @param result the vector to store the result in
  3187. * @returns the current Vector4.
  3188. */
  3189. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3190. /**
  3191. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3192. * @returns a new vector with the negated values
  3193. */
  3194. negate(): Vector4;
  3195. /**
  3196. * Negate this vector in place
  3197. * @returns this
  3198. */
  3199. negateInPlace(): Vector4;
  3200. /**
  3201. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3202. * @param result defines the Vector3 object where to store the result
  3203. * @returns the current Vector4
  3204. */
  3205. negateToRef(result: Vector4): Vector4;
  3206. /**
  3207. * Multiplies the current Vector4 coordinates by scale (float).
  3208. * @param scale the number to scale with
  3209. * @returns the updated Vector4.
  3210. */
  3211. scaleInPlace(scale: number): Vector4;
  3212. /**
  3213. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3214. * @param scale the number to scale with
  3215. * @returns a new vector with the result
  3216. */
  3217. scale(scale: number): Vector4;
  3218. /**
  3219. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3220. * @param scale the number to scale with
  3221. * @param result a vector to store the result in
  3222. * @returns the current Vector4.
  3223. */
  3224. scaleToRef(scale: number, result: Vector4): Vector4;
  3225. /**
  3226. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3227. * @param scale defines the scale factor
  3228. * @param result defines the Vector4 object where to store the result
  3229. * @returns the unmodified current Vector4
  3230. */
  3231. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3232. /**
  3233. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3234. * @param otherVector the vector to compare against
  3235. * @returns true if they are equal
  3236. */
  3237. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3238. /**
  3239. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3240. * @param otherVector vector to compare against
  3241. * @param epsilon (Default: very small number)
  3242. * @returns true if they are equal
  3243. */
  3244. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3245. /**
  3246. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3247. * @param x x value to compare against
  3248. * @param y y value to compare against
  3249. * @param z z value to compare against
  3250. * @param w w value to compare against
  3251. * @returns true if equal
  3252. */
  3253. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3254. /**
  3255. * Multiplies in place the current Vector4 by the given one.
  3256. * @param otherVector vector to multiple with
  3257. * @returns the updated Vector4.
  3258. */
  3259. multiplyInPlace(otherVector: Vector4): Vector4;
  3260. /**
  3261. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3262. * @param otherVector vector to multiple with
  3263. * @returns resulting new vector
  3264. */
  3265. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3266. /**
  3267. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3268. * @param otherVector vector to multiple with
  3269. * @param result vector to store the result
  3270. * @returns the current Vector4.
  3271. */
  3272. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3273. /**
  3274. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3275. * @param x x value multiply with
  3276. * @param y y value multiply with
  3277. * @param z z value multiply with
  3278. * @param w w value multiply with
  3279. * @returns resulting new vector
  3280. */
  3281. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3282. /**
  3283. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3284. * @param otherVector vector to devide with
  3285. * @returns resulting new vector
  3286. */
  3287. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3288. /**
  3289. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3290. * @param otherVector vector to devide with
  3291. * @param result vector to store the result
  3292. * @returns the current Vector4.
  3293. */
  3294. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3295. /**
  3296. * Divides the current Vector3 coordinates by the given ones.
  3297. * @param otherVector vector to devide with
  3298. * @returns the updated Vector3.
  3299. */
  3300. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3301. /**
  3302. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3303. * @param other defines the second operand
  3304. * @returns the current updated Vector4
  3305. */
  3306. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3307. /**
  3308. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3309. * @param other defines the second operand
  3310. * @returns the current updated Vector4
  3311. */
  3312. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3313. /**
  3314. * Gets a new Vector4 from current Vector4 floored values
  3315. * @returns a new Vector4
  3316. */
  3317. floor(): Vector4;
  3318. /**
  3319. * Gets a new Vector4 from current Vector3 floored values
  3320. * @returns a new Vector4
  3321. */
  3322. fract(): Vector4;
  3323. /**
  3324. * Returns the Vector4 length (float).
  3325. * @returns the length
  3326. */
  3327. length(): number;
  3328. /**
  3329. * Returns the Vector4 squared length (float).
  3330. * @returns the length squared
  3331. */
  3332. lengthSquared(): number;
  3333. /**
  3334. * Normalizes in place the Vector4.
  3335. * @returns the updated Vector4.
  3336. */
  3337. normalize(): Vector4;
  3338. /**
  3339. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3340. * @returns this converted to a new vector3
  3341. */
  3342. toVector3(): Vector3;
  3343. /**
  3344. * Returns a new Vector4 copied from the current one.
  3345. * @returns the new cloned vector
  3346. */
  3347. clone(): Vector4;
  3348. /**
  3349. * Updates the current Vector4 with the given one coordinates.
  3350. * @param source the source vector to copy from
  3351. * @returns the updated Vector4.
  3352. */
  3353. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3354. /**
  3355. * Updates the current Vector4 coordinates with the given floats.
  3356. * @param x float to copy from
  3357. * @param y float to copy from
  3358. * @param z float to copy from
  3359. * @param w float to copy from
  3360. * @returns the updated Vector4.
  3361. */
  3362. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3363. /**
  3364. * Updates the current Vector4 coordinates with the given floats.
  3365. * @param x float to set from
  3366. * @param y float to set from
  3367. * @param z float to set from
  3368. * @param w float to set from
  3369. * @returns the updated Vector4.
  3370. */
  3371. set(x: number, y: number, z: number, w: number): Vector4;
  3372. /**
  3373. * Copies the given float to the current Vector3 coordinates
  3374. * @param v defines the x, y, z and w coordinates of the operand
  3375. * @returns the current updated Vector3
  3376. */
  3377. setAll(v: number): Vector4;
  3378. /**
  3379. * Returns a new Vector4 set from the starting index of the given array.
  3380. * @param array the array to pull values from
  3381. * @param offset the offset into the array to start at
  3382. * @returns the new vector
  3383. */
  3384. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3385. /**
  3386. * Updates the given vector "result" from the starting index of the given array.
  3387. * @param array the array to pull values from
  3388. * @param offset the offset into the array to start at
  3389. * @param result the vector to store the result in
  3390. */
  3391. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3392. /**
  3393. * Updates the given vector "result" from the starting index of the given Float32Array.
  3394. * @param array the array to pull values from
  3395. * @param offset the offset into the array to start at
  3396. * @param result the vector to store the result in
  3397. */
  3398. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3399. /**
  3400. * Updates the given vector "result" coordinates from the given floats.
  3401. * @param x float to set from
  3402. * @param y float to set from
  3403. * @param z float to set from
  3404. * @param w float to set from
  3405. * @param result the vector to the floats in
  3406. */
  3407. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3408. /**
  3409. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3410. * @returns the new vector
  3411. */
  3412. static Zero(): Vector4;
  3413. /**
  3414. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3415. * @returns the new vector
  3416. */
  3417. static One(): Vector4;
  3418. /**
  3419. * Returns a new normalized Vector4 from the given one.
  3420. * @param vector the vector to normalize
  3421. * @returns the vector
  3422. */
  3423. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3424. /**
  3425. * Updates the given vector "result" from the normalization of the given one.
  3426. * @param vector the vector to normalize
  3427. * @param result the vector to store the result in
  3428. */
  3429. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3430. /**
  3431. * Returns a vector with the minimum values from the left and right vectors
  3432. * @param left left vector to minimize
  3433. * @param right right vector to minimize
  3434. * @returns a new vector with the minimum of the left and right vector values
  3435. */
  3436. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3437. /**
  3438. * Returns a vector with the maximum values from the left and right vectors
  3439. * @param left left vector to maximize
  3440. * @param right right vector to maximize
  3441. * @returns a new vector with the maximum of the left and right vector values
  3442. */
  3443. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3444. /**
  3445. * Returns the distance (float) between the vectors "value1" and "value2".
  3446. * @param value1 value to calulate the distance between
  3447. * @param value2 value to calulate the distance between
  3448. * @return the distance between the two vectors
  3449. */
  3450. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3451. /**
  3452. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3453. * @param value1 value to calulate the distance between
  3454. * @param value2 value to calulate the distance between
  3455. * @return the distance between the two vectors squared
  3456. */
  3457. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3458. /**
  3459. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3460. * @param value1 value to calulate the center between
  3461. * @param value2 value to calulate the center between
  3462. * @return the center between the two vectors
  3463. */
  3464. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3465. /**
  3466. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3467. * This methods computes transformed normalized direction vectors only.
  3468. * @param vector the vector to transform
  3469. * @param transformation the transformation matrix to apply
  3470. * @returns the new vector
  3471. */
  3472. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3473. /**
  3474. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3475. * This methods computes transformed normalized direction vectors only.
  3476. * @param vector the vector to transform
  3477. * @param transformation the transformation matrix to apply
  3478. * @param result the vector to store the result in
  3479. */
  3480. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3481. /**
  3482. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3483. * This methods computes transformed normalized direction vectors only.
  3484. * @param x value to transform
  3485. * @param y value to transform
  3486. * @param z value to transform
  3487. * @param w value to transform
  3488. * @param transformation the transformation matrix to apply
  3489. * @param result the vector to store the results in
  3490. */
  3491. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3492. /**
  3493. * Creates a new Vector4 from a Vector3
  3494. * @param source defines the source data
  3495. * @param w defines the 4th component (default is 0)
  3496. * @returns a new Vector4
  3497. */
  3498. static FromVector3(source: Vector3, w?: number): Vector4;
  3499. }
  3500. /**
  3501. * Class used to store quaternion data
  3502. * @see https://en.wikipedia.org/wiki/Quaternion
  3503. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3504. */
  3505. export class Quaternion {
  3506. /** defines the first component (0 by default) */
  3507. x: number;
  3508. /** defines the second component (0 by default) */
  3509. y: number;
  3510. /** defines the third component (0 by default) */
  3511. z: number;
  3512. /** defines the fourth component (1.0 by default) */
  3513. w: number;
  3514. /**
  3515. * Creates a new Quaternion from the given floats
  3516. * @param x defines the first component (0 by default)
  3517. * @param y defines the second component (0 by default)
  3518. * @param z defines the third component (0 by default)
  3519. * @param w defines the fourth component (1.0 by default)
  3520. */
  3521. constructor(
  3522. /** defines the first component (0 by default) */
  3523. x?: number,
  3524. /** defines the second component (0 by default) */
  3525. y?: number,
  3526. /** defines the third component (0 by default) */
  3527. z?: number,
  3528. /** defines the fourth component (1.0 by default) */
  3529. w?: number);
  3530. /**
  3531. * Gets a string representation for the current quaternion
  3532. * @returns a string with the Quaternion coordinates
  3533. */
  3534. toString(): string;
  3535. /**
  3536. * Gets the class name of the quaternion
  3537. * @returns the string "Quaternion"
  3538. */
  3539. getClassName(): string;
  3540. /**
  3541. * Gets a hash code for this quaternion
  3542. * @returns the quaternion hash code
  3543. */
  3544. getHashCode(): number;
  3545. /**
  3546. * Copy the quaternion to an array
  3547. * @returns a new array populated with 4 elements from the quaternion coordinates
  3548. */
  3549. asArray(): number[];
  3550. /**
  3551. * Check if two quaternions are equals
  3552. * @param otherQuaternion defines the second operand
  3553. * @return true if the current quaternion and the given one coordinates are strictly equals
  3554. */
  3555. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3556. /**
  3557. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3558. * @param otherQuaternion defines the other quaternion
  3559. * @param epsilon defines the minimal distance to consider equality
  3560. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3561. */
  3562. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3563. /**
  3564. * Clone the current quaternion
  3565. * @returns a new quaternion copied from the current one
  3566. */
  3567. clone(): Quaternion;
  3568. /**
  3569. * Copy a quaternion to the current one
  3570. * @param other defines the other quaternion
  3571. * @returns the updated current quaternion
  3572. */
  3573. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3574. /**
  3575. * Updates the current quaternion with the given float coordinates
  3576. * @param x defines the x coordinate
  3577. * @param y defines the y coordinate
  3578. * @param z defines the z coordinate
  3579. * @param w defines the w coordinate
  3580. * @returns the updated current quaternion
  3581. */
  3582. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3583. /**
  3584. * Updates the current quaternion from the given float coordinates
  3585. * @param x defines the x coordinate
  3586. * @param y defines the y coordinate
  3587. * @param z defines the z coordinate
  3588. * @param w defines the w coordinate
  3589. * @returns the updated current quaternion
  3590. */
  3591. set(x: number, y: number, z: number, w: number): Quaternion;
  3592. /**
  3593. * Adds two quaternions
  3594. * @param other defines the second operand
  3595. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3596. */
  3597. add(other: DeepImmutable<Quaternion>): Quaternion;
  3598. /**
  3599. * Add a quaternion to the current one
  3600. * @param other defines the quaternion to add
  3601. * @returns the current quaternion
  3602. */
  3603. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3604. /**
  3605. * Subtract two quaternions
  3606. * @param other defines the second operand
  3607. * @returns a new quaternion as the subtraction result of the given one from the current one
  3608. */
  3609. subtract(other: Quaternion): Quaternion;
  3610. /**
  3611. * Multiplies the current quaternion by a scale factor
  3612. * @param value defines the scale factor
  3613. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3614. */
  3615. scale(value: number): Quaternion;
  3616. /**
  3617. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3618. * @param scale defines the scale factor
  3619. * @param result defines the Quaternion object where to store the result
  3620. * @returns the unmodified current quaternion
  3621. */
  3622. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3623. /**
  3624. * Multiplies in place the current quaternion by a scale factor
  3625. * @param value defines the scale factor
  3626. * @returns the current modified quaternion
  3627. */
  3628. scaleInPlace(value: number): Quaternion;
  3629. /**
  3630. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3631. * @param scale defines the scale factor
  3632. * @param result defines the Quaternion object where to store the result
  3633. * @returns the unmodified current quaternion
  3634. */
  3635. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3636. /**
  3637. * Multiplies two quaternions
  3638. * @param q1 defines the second operand
  3639. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3640. */
  3641. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3642. /**
  3643. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3644. * @param q1 defines the second operand
  3645. * @param result defines the target quaternion
  3646. * @returns the current quaternion
  3647. */
  3648. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3649. /**
  3650. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3651. * @param q1 defines the second operand
  3652. * @returns the currentupdated quaternion
  3653. */
  3654. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3655. /**
  3656. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3657. * @param ref defines the target quaternion
  3658. * @returns the current quaternion
  3659. */
  3660. conjugateToRef(ref: Quaternion): Quaternion;
  3661. /**
  3662. * Conjugates in place (1-q) the current quaternion
  3663. * @returns the current updated quaternion
  3664. */
  3665. conjugateInPlace(): Quaternion;
  3666. /**
  3667. * Conjugates in place (1-q) the current quaternion
  3668. * @returns a new quaternion
  3669. */
  3670. conjugate(): Quaternion;
  3671. /**
  3672. * Gets length of current quaternion
  3673. * @returns the quaternion length (float)
  3674. */
  3675. length(): number;
  3676. /**
  3677. * Normalize in place the current quaternion
  3678. * @returns the current updated quaternion
  3679. */
  3680. normalize(): Quaternion;
  3681. /**
  3682. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3683. * @param order is a reserved parameter and is ignore for now
  3684. * @returns a new Vector3 containing the Euler angles
  3685. */
  3686. toEulerAngles(order?: string): Vector3;
  3687. /**
  3688. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3689. * @param result defines the vector which will be filled with the Euler angles
  3690. * @param order is a reserved parameter and is ignore for now
  3691. * @returns the current unchanged quaternion
  3692. */
  3693. toEulerAnglesToRef(result: Vector3): Quaternion;
  3694. /**
  3695. * Updates the given rotation matrix with the current quaternion values
  3696. * @param result defines the target matrix
  3697. * @returns the current unchanged quaternion
  3698. */
  3699. toRotationMatrix(result: Matrix): Quaternion;
  3700. /**
  3701. * Updates the current quaternion from the given rotation matrix values
  3702. * @param matrix defines the source matrix
  3703. * @returns the current updated quaternion
  3704. */
  3705. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3706. /**
  3707. * Creates a new quaternion from a rotation matrix
  3708. * @param matrix defines the source matrix
  3709. * @returns a new quaternion created from the given rotation matrix values
  3710. */
  3711. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3712. /**
  3713. * Updates the given quaternion with the given rotation matrix values
  3714. * @param matrix defines the source matrix
  3715. * @param result defines the target quaternion
  3716. */
  3717. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3718. /**
  3719. * Returns the dot product (float) between the quaternions "left" and "right"
  3720. * @param left defines the left operand
  3721. * @param right defines the right operand
  3722. * @returns the dot product
  3723. */
  3724. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3725. /**
  3726. * Checks if the two quaternions are close to each other
  3727. * @param quat0 defines the first quaternion to check
  3728. * @param quat1 defines the second quaternion to check
  3729. * @returns true if the two quaternions are close to each other
  3730. */
  3731. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3732. /**
  3733. * Creates an empty quaternion
  3734. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3735. */
  3736. static Zero(): Quaternion;
  3737. /**
  3738. * Inverse a given quaternion
  3739. * @param q defines the source quaternion
  3740. * @returns a new quaternion as the inverted current quaternion
  3741. */
  3742. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3743. /**
  3744. * Inverse a given quaternion
  3745. * @param q defines the source quaternion
  3746. * @param result the quaternion the result will be stored in
  3747. * @returns the result quaternion
  3748. */
  3749. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3750. /**
  3751. * Creates an identity quaternion
  3752. * @returns the identity quaternion
  3753. */
  3754. static Identity(): Quaternion;
  3755. /**
  3756. * Gets a boolean indicating if the given quaternion is identity
  3757. * @param quaternion defines the quaternion to check
  3758. * @returns true if the quaternion is identity
  3759. */
  3760. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3761. /**
  3762. * Creates a quaternion from a rotation around an axis
  3763. * @param axis defines the axis to use
  3764. * @param angle defines the angle to use
  3765. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3766. */
  3767. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3768. /**
  3769. * Creates a rotation around an axis and stores it into the given quaternion
  3770. * @param axis defines the axis to use
  3771. * @param angle defines the angle to use
  3772. * @param result defines the target quaternion
  3773. * @returns the target quaternion
  3774. */
  3775. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3776. /**
  3777. * Creates a new quaternion from data stored into an array
  3778. * @param array defines the data source
  3779. * @param offset defines the offset in the source array where the data starts
  3780. * @returns a new quaternion
  3781. */
  3782. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3783. /**
  3784. * Updates the given quaternion "result" from the starting index of the given array.
  3785. * @param array the array to pull values from
  3786. * @param offset the offset into the array to start at
  3787. * @param result the quaternion to store the result in
  3788. */
  3789. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3790. /**
  3791. * Create a quaternion from Euler rotation angles
  3792. * @param x Pitch
  3793. * @param y Yaw
  3794. * @param z Roll
  3795. * @returns the new Quaternion
  3796. */
  3797. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3798. /**
  3799. * Updates a quaternion from Euler rotation angles
  3800. * @param x Pitch
  3801. * @param y Yaw
  3802. * @param z Roll
  3803. * @param result the quaternion to store the result
  3804. * @returns the updated quaternion
  3805. */
  3806. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3807. /**
  3808. * Create a quaternion from Euler rotation vector
  3809. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3810. * @returns the new Quaternion
  3811. */
  3812. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3813. /**
  3814. * Updates a quaternion from Euler rotation vector
  3815. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3816. * @param result the quaternion to store the result
  3817. * @returns the updated quaternion
  3818. */
  3819. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3820. /**
  3821. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3822. * @param yaw defines the rotation around Y axis
  3823. * @param pitch defines the rotation around X axis
  3824. * @param roll defines the rotation around Z axis
  3825. * @returns the new quaternion
  3826. */
  3827. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3828. /**
  3829. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3830. * @param yaw defines the rotation around Y axis
  3831. * @param pitch defines the rotation around X axis
  3832. * @param roll defines the rotation around Z axis
  3833. * @param result defines the target quaternion
  3834. */
  3835. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3836. /**
  3837. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3838. * @param alpha defines the rotation around first axis
  3839. * @param beta defines the rotation around second axis
  3840. * @param gamma defines the rotation around third axis
  3841. * @returns the new quaternion
  3842. */
  3843. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3844. /**
  3845. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3846. * @param alpha defines the rotation around first axis
  3847. * @param beta defines the rotation around second axis
  3848. * @param gamma defines the rotation around third axis
  3849. * @param result defines the target quaternion
  3850. */
  3851. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3852. /**
  3853. * 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)
  3854. * @param axis1 defines the first axis
  3855. * @param axis2 defines the second axis
  3856. * @param axis3 defines the third axis
  3857. * @returns the new quaternion
  3858. */
  3859. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3860. /**
  3861. * 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
  3862. * @param axis1 defines the first axis
  3863. * @param axis2 defines the second axis
  3864. * @param axis3 defines the third axis
  3865. * @param ref defines the target quaternion
  3866. */
  3867. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3868. /**
  3869. * Interpolates between two quaternions
  3870. * @param left defines first quaternion
  3871. * @param right defines second quaternion
  3872. * @param amount defines the gradient to use
  3873. * @returns the new interpolated quaternion
  3874. */
  3875. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3876. /**
  3877. * Interpolates between two quaternions and stores it into a target quaternion
  3878. * @param left defines first quaternion
  3879. * @param right defines second quaternion
  3880. * @param amount defines the gradient to use
  3881. * @param result defines the target quaternion
  3882. */
  3883. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3884. /**
  3885. * Interpolate between two quaternions using Hermite interpolation
  3886. * @param value1 defines first quaternion
  3887. * @param tangent1 defines the incoming tangent
  3888. * @param value2 defines second quaternion
  3889. * @param tangent2 defines the outgoing tangent
  3890. * @param amount defines the target quaternion
  3891. * @returns the new interpolated quaternion
  3892. */
  3893. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3894. }
  3895. /**
  3896. * Class used to store matrix data (4x4)
  3897. */
  3898. export class Matrix {
  3899. private static _updateFlagSeed;
  3900. private static _identityReadOnly;
  3901. private _isIdentity;
  3902. private _isIdentityDirty;
  3903. private _isIdentity3x2;
  3904. private _isIdentity3x2Dirty;
  3905. /**
  3906. * Gets the update flag of the matrix which is an unique number for the matrix.
  3907. * It will be incremented every time the matrix data change.
  3908. * You can use it to speed the comparison between two versions of the same matrix.
  3909. */
  3910. updateFlag: number;
  3911. private readonly _m;
  3912. /**
  3913. * Gets the internal data of the matrix
  3914. */
  3915. get m(): DeepImmutable<Float32Array>;
  3916. /** @hidden */
  3917. _markAsUpdated(): void;
  3918. /** @hidden */
  3919. private _updateIdentityStatus;
  3920. /**
  3921. * Creates an empty matrix (filled with zeros)
  3922. */
  3923. constructor();
  3924. /**
  3925. * Check if the current matrix is identity
  3926. * @returns true is the matrix is the identity matrix
  3927. */
  3928. isIdentity(): boolean;
  3929. /**
  3930. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3931. * @returns true is the matrix is the identity matrix
  3932. */
  3933. isIdentityAs3x2(): boolean;
  3934. /**
  3935. * Gets the determinant of the matrix
  3936. * @returns the matrix determinant
  3937. */
  3938. determinant(): number;
  3939. /**
  3940. * Returns the matrix as a Float32Array
  3941. * @returns the matrix underlying array
  3942. */
  3943. toArray(): DeepImmutable<Float32Array>;
  3944. /**
  3945. * Returns the matrix as a Float32Array
  3946. * @returns the matrix underlying array.
  3947. */
  3948. asArray(): DeepImmutable<Float32Array>;
  3949. /**
  3950. * Inverts the current matrix in place
  3951. * @returns the current inverted matrix
  3952. */
  3953. invert(): Matrix;
  3954. /**
  3955. * Sets all the matrix elements to zero
  3956. * @returns the current matrix
  3957. */
  3958. reset(): Matrix;
  3959. /**
  3960. * Adds the current matrix with a second one
  3961. * @param other defines the matrix to add
  3962. * @returns a new matrix as the addition of the current matrix and the given one
  3963. */
  3964. add(other: DeepImmutable<Matrix>): Matrix;
  3965. /**
  3966. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3967. * @param other defines the matrix to add
  3968. * @param result defines the target matrix
  3969. * @returns the current matrix
  3970. */
  3971. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3972. /**
  3973. * Adds in place the given matrix to the current matrix
  3974. * @param other defines the second operand
  3975. * @returns the current updated matrix
  3976. */
  3977. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3978. /**
  3979. * Sets the given matrix to the current inverted Matrix
  3980. * @param other defines the target matrix
  3981. * @returns the unmodified current matrix
  3982. */
  3983. invertToRef(other: Matrix): Matrix;
  3984. /**
  3985. * add a value at the specified position in the current Matrix
  3986. * @param index the index of the value within the matrix. between 0 and 15.
  3987. * @param value the value to be added
  3988. * @returns the current updated matrix
  3989. */
  3990. addAtIndex(index: number, value: number): Matrix;
  3991. /**
  3992. * mutiply the specified position in the current Matrix by a value
  3993. * @param index the index of the value within the matrix. between 0 and 15.
  3994. * @param value the value to be added
  3995. * @returns the current updated matrix
  3996. */
  3997. multiplyAtIndex(index: number, value: number): Matrix;
  3998. /**
  3999. * Inserts the translation vector (using 3 floats) in the current matrix
  4000. * @param x defines the 1st component of the translation
  4001. * @param y defines the 2nd component of the translation
  4002. * @param z defines the 3rd component of the translation
  4003. * @returns the current updated matrix
  4004. */
  4005. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4006. /**
  4007. * Adds the translation vector (using 3 floats) in the current matrix
  4008. * @param x defines the 1st component of the translation
  4009. * @param y defines the 2nd component of the translation
  4010. * @param z defines the 3rd component of the translation
  4011. * @returns the current updated matrix
  4012. */
  4013. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4014. /**
  4015. * Inserts the translation vector in the current matrix
  4016. * @param vector3 defines the translation to insert
  4017. * @returns the current updated matrix
  4018. */
  4019. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4020. /**
  4021. * Gets the translation value of the current matrix
  4022. * @returns a new Vector3 as the extracted translation from the matrix
  4023. */
  4024. getTranslation(): Vector3;
  4025. /**
  4026. * Fill a Vector3 with the extracted translation from the matrix
  4027. * @param result defines the Vector3 where to store the translation
  4028. * @returns the current matrix
  4029. */
  4030. getTranslationToRef(result: Vector3): Matrix;
  4031. /**
  4032. * Remove rotation and scaling part from the matrix
  4033. * @returns the updated matrix
  4034. */
  4035. removeRotationAndScaling(): Matrix;
  4036. /**
  4037. * Multiply two matrices
  4038. * @param other defines the second operand
  4039. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4040. */
  4041. multiply(other: DeepImmutable<Matrix>): Matrix;
  4042. /**
  4043. * Copy the current matrix from the given one
  4044. * @param other defines the source matrix
  4045. * @returns the current updated matrix
  4046. */
  4047. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4048. /**
  4049. * Populates the given array from the starting index with the current matrix values
  4050. * @param array defines the target array
  4051. * @param offset defines the offset in the target array where to start storing values
  4052. * @returns the current matrix
  4053. */
  4054. copyToArray(array: Float32Array, offset?: number): Matrix;
  4055. /**
  4056. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4057. * @param other defines the second operand
  4058. * @param result defines the matrix where to store the multiplication
  4059. * @returns the current matrix
  4060. */
  4061. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4062. /**
  4063. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4064. * @param other defines the second operand
  4065. * @param result defines the array where to store the multiplication
  4066. * @param offset defines the offset in the target array where to start storing values
  4067. * @returns the current matrix
  4068. */
  4069. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4070. /**
  4071. * Check equality between this matrix and a second one
  4072. * @param value defines the second matrix to compare
  4073. * @returns true is the current matrix and the given one values are strictly equal
  4074. */
  4075. equals(value: DeepImmutable<Matrix>): boolean;
  4076. /**
  4077. * Clone the current matrix
  4078. * @returns a new matrix from the current matrix
  4079. */
  4080. clone(): Matrix;
  4081. /**
  4082. * Returns the name of the current matrix class
  4083. * @returns the string "Matrix"
  4084. */
  4085. getClassName(): string;
  4086. /**
  4087. * Gets the hash code of the current matrix
  4088. * @returns the hash code
  4089. */
  4090. getHashCode(): number;
  4091. /**
  4092. * Decomposes the current Matrix into a translation, rotation and scaling components
  4093. * @param scale defines the scale vector3 given as a reference to update
  4094. * @param rotation defines the rotation quaternion given as a reference to update
  4095. * @param translation defines the translation vector3 given as a reference to update
  4096. * @returns true if operation was successful
  4097. */
  4098. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4099. /**
  4100. * Gets specific row of the matrix
  4101. * @param index defines the number of the row to get
  4102. * @returns the index-th row of the current matrix as a new Vector4
  4103. */
  4104. getRow(index: number): Nullable<Vector4>;
  4105. /**
  4106. * Sets the index-th row of the current matrix to the vector4 values
  4107. * @param index defines the number of the row to set
  4108. * @param row defines the target vector4
  4109. * @returns the updated current matrix
  4110. */
  4111. setRow(index: number, row: Vector4): Matrix;
  4112. /**
  4113. * Compute the transpose of the matrix
  4114. * @returns the new transposed matrix
  4115. */
  4116. transpose(): Matrix;
  4117. /**
  4118. * Compute the transpose of the matrix and store it in a given matrix
  4119. * @param result defines the target matrix
  4120. * @returns the current matrix
  4121. */
  4122. transposeToRef(result: Matrix): Matrix;
  4123. /**
  4124. * Sets the index-th row of the current matrix with the given 4 x float values
  4125. * @param index defines the row index
  4126. * @param x defines the x component to set
  4127. * @param y defines the y component to set
  4128. * @param z defines the z component to set
  4129. * @param w defines the w component to set
  4130. * @returns the updated current matrix
  4131. */
  4132. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4133. /**
  4134. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4135. * @param scale defines the scale factor
  4136. * @returns a new matrix
  4137. */
  4138. scale(scale: number): Matrix;
  4139. /**
  4140. * Scale the current matrix values by a factor to a given result matrix
  4141. * @param scale defines the scale factor
  4142. * @param result defines the matrix to store the result
  4143. * @returns the current matrix
  4144. */
  4145. scaleToRef(scale: number, result: Matrix): Matrix;
  4146. /**
  4147. * Scale the current matrix values by a factor and add the result to a given matrix
  4148. * @param scale defines the scale factor
  4149. * @param result defines the Matrix to store the result
  4150. * @returns the current matrix
  4151. */
  4152. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4153. /**
  4154. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4155. * @param ref matrix to store the result
  4156. */
  4157. toNormalMatrix(ref: Matrix): void;
  4158. /**
  4159. * Gets only rotation part of the current matrix
  4160. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4161. */
  4162. getRotationMatrix(): Matrix;
  4163. /**
  4164. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4165. * @param result defines the target matrix to store data to
  4166. * @returns the current matrix
  4167. */
  4168. getRotationMatrixToRef(result: Matrix): Matrix;
  4169. /**
  4170. * Toggles model matrix from being right handed to left handed in place and vice versa
  4171. */
  4172. toggleModelMatrixHandInPlace(): void;
  4173. /**
  4174. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4175. */
  4176. toggleProjectionMatrixHandInPlace(): void;
  4177. /**
  4178. * Creates a matrix from an array
  4179. * @param array defines the source array
  4180. * @param offset defines an offset in the source array
  4181. * @returns a new Matrix set from the starting index of the given array
  4182. */
  4183. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4184. /**
  4185. * Copy the content of an array into a given matrix
  4186. * @param array defines the source array
  4187. * @param offset defines an offset in the source array
  4188. * @param result defines the target matrix
  4189. */
  4190. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4191. /**
  4192. * Stores an array into a matrix after having multiplied each component by a given factor
  4193. * @param array defines the source array
  4194. * @param offset defines the offset in the source array
  4195. * @param scale defines the scaling factor
  4196. * @param result defines the target matrix
  4197. */
  4198. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4199. /**
  4200. * Gets an identity matrix that must not be updated
  4201. */
  4202. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4203. /**
  4204. * Stores a list of values (16) inside a given matrix
  4205. * @param initialM11 defines 1st value of 1st row
  4206. * @param initialM12 defines 2nd value of 1st row
  4207. * @param initialM13 defines 3rd value of 1st row
  4208. * @param initialM14 defines 4th value of 1st row
  4209. * @param initialM21 defines 1st value of 2nd row
  4210. * @param initialM22 defines 2nd value of 2nd row
  4211. * @param initialM23 defines 3rd value of 2nd row
  4212. * @param initialM24 defines 4th value of 2nd row
  4213. * @param initialM31 defines 1st value of 3rd row
  4214. * @param initialM32 defines 2nd value of 3rd row
  4215. * @param initialM33 defines 3rd value of 3rd row
  4216. * @param initialM34 defines 4th value of 3rd row
  4217. * @param initialM41 defines 1st value of 4th row
  4218. * @param initialM42 defines 2nd value of 4th row
  4219. * @param initialM43 defines 3rd value of 4th row
  4220. * @param initialM44 defines 4th value of 4th row
  4221. * @param result defines the target matrix
  4222. */
  4223. 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;
  4224. /**
  4225. * Creates new matrix from a list of values (16)
  4226. * @param initialM11 defines 1st value of 1st row
  4227. * @param initialM12 defines 2nd value of 1st row
  4228. * @param initialM13 defines 3rd value of 1st row
  4229. * @param initialM14 defines 4th value of 1st row
  4230. * @param initialM21 defines 1st value of 2nd row
  4231. * @param initialM22 defines 2nd value of 2nd row
  4232. * @param initialM23 defines 3rd value of 2nd row
  4233. * @param initialM24 defines 4th value of 2nd row
  4234. * @param initialM31 defines 1st value of 3rd row
  4235. * @param initialM32 defines 2nd value of 3rd row
  4236. * @param initialM33 defines 3rd value of 3rd row
  4237. * @param initialM34 defines 4th value of 3rd row
  4238. * @param initialM41 defines 1st value of 4th row
  4239. * @param initialM42 defines 2nd value of 4th row
  4240. * @param initialM43 defines 3rd value of 4th row
  4241. * @param initialM44 defines 4th value of 4th row
  4242. * @returns the new matrix
  4243. */
  4244. 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;
  4245. /**
  4246. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4247. * @param scale defines the scale vector3
  4248. * @param rotation defines the rotation quaternion
  4249. * @param translation defines the translation vector3
  4250. * @returns a new matrix
  4251. */
  4252. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4253. /**
  4254. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4255. * @param scale defines the scale vector3
  4256. * @param rotation defines the rotation quaternion
  4257. * @param translation defines the translation vector3
  4258. * @param result defines the target matrix
  4259. */
  4260. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4261. /**
  4262. * Creates a new identity matrix
  4263. * @returns a new identity matrix
  4264. */
  4265. static Identity(): Matrix;
  4266. /**
  4267. * Creates a new identity matrix and stores the result in a given matrix
  4268. * @param result defines the target matrix
  4269. */
  4270. static IdentityToRef(result: Matrix): void;
  4271. /**
  4272. * Creates a new zero matrix
  4273. * @returns a new zero matrix
  4274. */
  4275. static Zero(): Matrix;
  4276. /**
  4277. * Creates a new rotation matrix for "angle" radians around the X axis
  4278. * @param angle defines the angle (in radians) to use
  4279. * @return the new matrix
  4280. */
  4281. static RotationX(angle: number): Matrix;
  4282. /**
  4283. * Creates a new matrix as the invert of a given matrix
  4284. * @param source defines the source matrix
  4285. * @returns the new matrix
  4286. */
  4287. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4288. /**
  4289. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4290. * @param angle defines the angle (in radians) to use
  4291. * @param result defines the target matrix
  4292. */
  4293. static RotationXToRef(angle: number, result: Matrix): void;
  4294. /**
  4295. * Creates a new rotation matrix for "angle" radians around the Y axis
  4296. * @param angle defines the angle (in radians) to use
  4297. * @return the new matrix
  4298. */
  4299. static RotationY(angle: number): Matrix;
  4300. /**
  4301. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4302. * @param angle defines the angle (in radians) to use
  4303. * @param result defines the target matrix
  4304. */
  4305. static RotationYToRef(angle: number, result: Matrix): void;
  4306. /**
  4307. * Creates a new rotation matrix for "angle" radians around the Z axis
  4308. * @param angle defines the angle (in radians) to use
  4309. * @return the new matrix
  4310. */
  4311. static RotationZ(angle: number): Matrix;
  4312. /**
  4313. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4314. * @param angle defines the angle (in radians) to use
  4315. * @param result defines the target matrix
  4316. */
  4317. static RotationZToRef(angle: number, result: Matrix): void;
  4318. /**
  4319. * Creates a new rotation matrix for "angle" radians around the given axis
  4320. * @param axis defines the axis to use
  4321. * @param angle defines the angle (in radians) to use
  4322. * @return the new matrix
  4323. */
  4324. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4325. /**
  4326. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4327. * @param axis defines the axis to use
  4328. * @param angle defines the angle (in radians) to use
  4329. * @param result defines the target matrix
  4330. */
  4331. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4332. /**
  4333. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4334. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4335. * @param from defines the vector to align
  4336. * @param to defines the vector to align to
  4337. * @param result defines the target matrix
  4338. */
  4339. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4340. /**
  4341. * Creates a rotation matrix
  4342. * @param yaw defines the yaw angle in radians (Y axis)
  4343. * @param pitch defines the pitch angle in radians (X axis)
  4344. * @param roll defines the roll angle in radians (X axis)
  4345. * @returns the new rotation matrix
  4346. */
  4347. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4348. /**
  4349. * Creates a rotation matrix and stores it in a given matrix
  4350. * @param yaw defines the yaw angle in radians (Y axis)
  4351. * @param pitch defines the pitch angle in radians (X axis)
  4352. * @param roll defines the roll angle in radians (X axis)
  4353. * @param result defines the target matrix
  4354. */
  4355. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4356. /**
  4357. * Creates a scaling matrix
  4358. * @param x defines the scale factor on X axis
  4359. * @param y defines the scale factor on Y axis
  4360. * @param z defines the scale factor on Z axis
  4361. * @returns the new matrix
  4362. */
  4363. static Scaling(x: number, y: number, z: number): Matrix;
  4364. /**
  4365. * Creates a scaling matrix and stores it in a given matrix
  4366. * @param x defines the scale factor on X axis
  4367. * @param y defines the scale factor on Y axis
  4368. * @param z defines the scale factor on Z axis
  4369. * @param result defines the target matrix
  4370. */
  4371. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4372. /**
  4373. * Creates a translation matrix
  4374. * @param x defines the translation on X axis
  4375. * @param y defines the translation on Y axis
  4376. * @param z defines the translationon Z axis
  4377. * @returns the new matrix
  4378. */
  4379. static Translation(x: number, y: number, z: number): Matrix;
  4380. /**
  4381. * Creates a translation matrix and stores it in a given matrix
  4382. * @param x defines the translation on X axis
  4383. * @param y defines the translation on Y axis
  4384. * @param z defines the translationon Z axis
  4385. * @param result defines the target matrix
  4386. */
  4387. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4388. /**
  4389. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4390. * @param startValue defines the start value
  4391. * @param endValue defines the end value
  4392. * @param gradient defines the gradient factor
  4393. * @returns the new matrix
  4394. */
  4395. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4396. /**
  4397. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4398. * @param startValue defines the start value
  4399. * @param endValue defines the end value
  4400. * @param gradient defines the gradient factor
  4401. * @param result defines the Matrix object where to store data
  4402. */
  4403. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4404. /**
  4405. * Builds a new matrix whose values are computed by:
  4406. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4407. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4408. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4409. * @param startValue defines the first matrix
  4410. * @param endValue defines the second matrix
  4411. * @param gradient defines the gradient between the two matrices
  4412. * @returns the new matrix
  4413. */
  4414. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4415. /**
  4416. * Update a matrix to values which are computed by:
  4417. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4418. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4419. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4420. * @param startValue defines the first matrix
  4421. * @param endValue defines the second matrix
  4422. * @param gradient defines the gradient between the two matrices
  4423. * @param result defines the target matrix
  4424. */
  4425. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4426. /**
  4427. * 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"
  4428. * This function works in left handed mode
  4429. * @param eye defines the final position of the entity
  4430. * @param target defines where the entity should look at
  4431. * @param up defines the up vector for the entity
  4432. * @returns the new matrix
  4433. */
  4434. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4435. /**
  4436. * 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".
  4437. * This function works in left handed mode
  4438. * @param eye defines the final position of the entity
  4439. * @param target defines where the entity should look at
  4440. * @param up defines the up vector for the entity
  4441. * @param result defines the target matrix
  4442. */
  4443. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4444. /**
  4445. * 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"
  4446. * This function works in right handed mode
  4447. * @param eye defines the final position of the entity
  4448. * @param target defines where the entity should look at
  4449. * @param up defines the up vector for the entity
  4450. * @returns the new matrix
  4451. */
  4452. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4453. /**
  4454. * 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".
  4455. * This function works in right handed mode
  4456. * @param eye defines the final position of the entity
  4457. * @param target defines where the entity should look at
  4458. * @param up defines the up vector for the entity
  4459. * @param result defines the target matrix
  4460. */
  4461. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4462. /**
  4463. * Create a left-handed orthographic projection matrix
  4464. * @param width defines the viewport width
  4465. * @param height defines the viewport height
  4466. * @param znear defines the near clip plane
  4467. * @param zfar defines the far clip plane
  4468. * @returns a new matrix as a left-handed orthographic projection matrix
  4469. */
  4470. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4471. /**
  4472. * Store a left-handed orthographic projection to a given matrix
  4473. * @param width defines the viewport width
  4474. * @param height defines the viewport height
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @param result defines the target matrix
  4478. */
  4479. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4480. /**
  4481. * Create a left-handed orthographic projection matrix
  4482. * @param left defines the viewport left coordinate
  4483. * @param right defines the viewport right coordinate
  4484. * @param bottom defines the viewport bottom coordinate
  4485. * @param top defines the viewport top coordinate
  4486. * @param znear defines the near clip plane
  4487. * @param zfar defines the far clip plane
  4488. * @returns a new matrix as a left-handed orthographic projection matrix
  4489. */
  4490. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4491. /**
  4492. * Stores a left-handed orthographic projection into a given matrix
  4493. * @param left defines the viewport left coordinate
  4494. * @param right defines the viewport right coordinate
  4495. * @param bottom defines the viewport bottom coordinate
  4496. * @param top defines the viewport top coordinate
  4497. * @param znear defines the near clip plane
  4498. * @param zfar defines the far clip plane
  4499. * @param result defines the target matrix
  4500. */
  4501. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4502. /**
  4503. * Creates a right-handed orthographic projection matrix
  4504. * @param left defines the viewport left coordinate
  4505. * @param right defines the viewport right coordinate
  4506. * @param bottom defines the viewport bottom coordinate
  4507. * @param top defines the viewport top coordinate
  4508. * @param znear defines the near clip plane
  4509. * @param zfar defines the far clip plane
  4510. * @returns a new matrix as a right-handed orthographic projection matrix
  4511. */
  4512. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4513. /**
  4514. * Stores a right-handed orthographic projection into a given matrix
  4515. * @param left defines the viewport left coordinate
  4516. * @param right defines the viewport right coordinate
  4517. * @param bottom defines the viewport bottom coordinate
  4518. * @param top defines the viewport top coordinate
  4519. * @param znear defines the near clip plane
  4520. * @param zfar defines the far clip plane
  4521. * @param result defines the target matrix
  4522. */
  4523. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4524. /**
  4525. * Creates a left-handed perspective projection matrix
  4526. * @param width defines the viewport width
  4527. * @param height defines the viewport height
  4528. * @param znear defines the near clip plane
  4529. * @param zfar defines the far clip plane
  4530. * @returns a new matrix as a left-handed perspective projection matrix
  4531. */
  4532. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4533. /**
  4534. * Creates a left-handed perspective projection matrix
  4535. * @param fov defines the horizontal field of view
  4536. * @param aspect defines the aspect ratio
  4537. * @param znear defines the near clip plane
  4538. * @param zfar defines the far clip plane
  4539. * @returns a new matrix as a left-handed perspective projection matrix
  4540. */
  4541. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4542. /**
  4543. * Stores a left-handed perspective projection into a given matrix
  4544. * @param fov defines the horizontal field of view
  4545. * @param aspect defines the aspect ratio
  4546. * @param znear defines the near clip plane
  4547. * @param zfar defines the far clip plane
  4548. * @param result defines the target matrix
  4549. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4550. */
  4551. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4552. /**
  4553. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4554. * @param fov defines the horizontal field of view
  4555. * @param aspect defines the aspect ratio
  4556. * @param znear defines the near clip plane
  4557. * @param zfar not used as infinity is used as far clip
  4558. * @param result defines the target matrix
  4559. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4560. */
  4561. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4562. /**
  4563. * Creates a right-handed perspective projection matrix
  4564. * @param fov defines the horizontal field of view
  4565. * @param aspect defines the aspect ratio
  4566. * @param znear defines the near clip plane
  4567. * @param zfar defines the far clip plane
  4568. * @returns a new matrix as a right-handed perspective projection matrix
  4569. */
  4570. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4571. /**
  4572. * Stores a right-handed perspective projection into a given matrix
  4573. * @param fov defines the horizontal field of view
  4574. * @param aspect defines the aspect ratio
  4575. * @param znear defines the near clip plane
  4576. * @param zfar defines the far clip plane
  4577. * @param result defines the target matrix
  4578. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4579. */
  4580. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4581. /**
  4582. * Stores a right-handed perspective projection into a given matrix
  4583. * @param fov defines the horizontal field of view
  4584. * @param aspect defines the aspect ratio
  4585. * @param znear defines the near clip plane
  4586. * @param zfar not used as infinity is used as far clip
  4587. * @param result defines the target matrix
  4588. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4589. */
  4590. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4591. /**
  4592. * Stores a perspective projection for WebVR info a given matrix
  4593. * @param fov defines the field of view
  4594. * @param znear defines the near clip plane
  4595. * @param zfar defines the far clip plane
  4596. * @param result defines the target matrix
  4597. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4598. */
  4599. static PerspectiveFovWebVRToRef(fov: {
  4600. upDegrees: number;
  4601. downDegrees: number;
  4602. leftDegrees: number;
  4603. rightDegrees: number;
  4604. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4605. /**
  4606. * Computes a complete transformation matrix
  4607. * @param viewport defines the viewport to use
  4608. * @param world defines the world matrix
  4609. * @param view defines the view matrix
  4610. * @param projection defines the projection matrix
  4611. * @param zmin defines the near clip plane
  4612. * @param zmax defines the far clip plane
  4613. * @returns the transformation matrix
  4614. */
  4615. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4616. /**
  4617. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4618. * @param matrix defines the matrix to use
  4619. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4620. */
  4621. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4622. /**
  4623. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4624. * @param matrix defines the matrix to use
  4625. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4626. */
  4627. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4628. /**
  4629. * Compute the transpose of a given matrix
  4630. * @param matrix defines the matrix to transpose
  4631. * @returns the new matrix
  4632. */
  4633. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4634. /**
  4635. * Compute the transpose of a matrix and store it in a target matrix
  4636. * @param matrix defines the matrix to transpose
  4637. * @param result defines the target matrix
  4638. */
  4639. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4640. /**
  4641. * Computes a reflection matrix from a plane
  4642. * @param plane defines the reflection plane
  4643. * @returns a new matrix
  4644. */
  4645. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4646. /**
  4647. * Computes a reflection matrix from a plane
  4648. * @param plane defines the reflection plane
  4649. * @param result defines the target matrix
  4650. */
  4651. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4652. /**
  4653. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4654. * @param xaxis defines the value of the 1st axis
  4655. * @param yaxis defines the value of the 2nd axis
  4656. * @param zaxis defines the value of the 3rd axis
  4657. * @param result defines the target matrix
  4658. */
  4659. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4660. /**
  4661. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4662. * @param quat defines the quaternion to use
  4663. * @param result defines the target matrix
  4664. */
  4665. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4666. }
  4667. /**
  4668. * @hidden
  4669. */
  4670. export class TmpVectors {
  4671. static Vector2: Vector2[];
  4672. static Vector3: Vector3[];
  4673. static Vector4: Vector4[];
  4674. static Quaternion: Quaternion[];
  4675. static Matrix: Matrix[];
  4676. }
  4677. }
  4678. declare module "babylonjs/Maths/math.path" {
  4679. import { DeepImmutable, Nullable } from "babylonjs/types";
  4680. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4681. /**
  4682. * Defines potential orientation for back face culling
  4683. */
  4684. export enum Orientation {
  4685. /**
  4686. * Clockwise
  4687. */
  4688. CW = 0,
  4689. /** Counter clockwise */
  4690. CCW = 1
  4691. }
  4692. /** Class used to represent a Bezier curve */
  4693. export class BezierCurve {
  4694. /**
  4695. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4696. * @param t defines the time
  4697. * @param x1 defines the left coordinate on X axis
  4698. * @param y1 defines the left coordinate on Y axis
  4699. * @param x2 defines the right coordinate on X axis
  4700. * @param y2 defines the right coordinate on Y axis
  4701. * @returns the interpolated value
  4702. */
  4703. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4704. }
  4705. /**
  4706. * Defines angle representation
  4707. */
  4708. export class Angle {
  4709. private _radians;
  4710. /**
  4711. * Creates an Angle object of "radians" radians (float).
  4712. * @param radians the angle in radians
  4713. */
  4714. constructor(radians: number);
  4715. /**
  4716. * Get value in degrees
  4717. * @returns the Angle value in degrees (float)
  4718. */
  4719. degrees(): number;
  4720. /**
  4721. * Get value in radians
  4722. * @returns the Angle value in radians (float)
  4723. */
  4724. radians(): number;
  4725. /**
  4726. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4727. * @param a defines first vector
  4728. * @param b defines second vector
  4729. * @returns a new Angle
  4730. */
  4731. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4732. /**
  4733. * Gets a new Angle object from the given float in radians
  4734. * @param radians defines the angle value in radians
  4735. * @returns a new Angle
  4736. */
  4737. static FromRadians(radians: number): Angle;
  4738. /**
  4739. * Gets a new Angle object from the given float in degrees
  4740. * @param degrees defines the angle value in degrees
  4741. * @returns a new Angle
  4742. */
  4743. static FromDegrees(degrees: number): Angle;
  4744. }
  4745. /**
  4746. * This represents an arc in a 2d space.
  4747. */
  4748. export class Arc2 {
  4749. /** Defines the start point of the arc */
  4750. startPoint: Vector2;
  4751. /** Defines the mid point of the arc */
  4752. midPoint: Vector2;
  4753. /** Defines the end point of the arc */
  4754. endPoint: Vector2;
  4755. /**
  4756. * Defines the center point of the arc.
  4757. */
  4758. centerPoint: Vector2;
  4759. /**
  4760. * Defines the radius of the arc.
  4761. */
  4762. radius: number;
  4763. /**
  4764. * Defines the angle of the arc (from mid point to end point).
  4765. */
  4766. angle: Angle;
  4767. /**
  4768. * Defines the start angle of the arc (from start point to middle point).
  4769. */
  4770. startAngle: Angle;
  4771. /**
  4772. * Defines the orientation of the arc (clock wise/counter clock wise).
  4773. */
  4774. orientation: Orientation;
  4775. /**
  4776. * Creates an Arc object from the three given points : start, middle and end.
  4777. * @param startPoint Defines the start point of the arc
  4778. * @param midPoint Defines the midlle point of the arc
  4779. * @param endPoint Defines the end point of the arc
  4780. */
  4781. constructor(
  4782. /** Defines the start point of the arc */
  4783. startPoint: Vector2,
  4784. /** Defines the mid point of the arc */
  4785. midPoint: Vector2,
  4786. /** Defines the end point of the arc */
  4787. endPoint: Vector2);
  4788. }
  4789. /**
  4790. * Represents a 2D path made up of multiple 2D points
  4791. */
  4792. export class Path2 {
  4793. private _points;
  4794. private _length;
  4795. /**
  4796. * If the path start and end point are the same
  4797. */
  4798. closed: boolean;
  4799. /**
  4800. * Creates a Path2 object from the starting 2D coordinates x and y.
  4801. * @param x the starting points x value
  4802. * @param y the starting points y value
  4803. */
  4804. constructor(x: number, y: number);
  4805. /**
  4806. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4807. * @param x the added points x value
  4808. * @param y the added points y value
  4809. * @returns the updated Path2.
  4810. */
  4811. addLineTo(x: number, y: number): Path2;
  4812. /**
  4813. * 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.
  4814. * @param midX middle point x value
  4815. * @param midY middle point y value
  4816. * @param endX end point x value
  4817. * @param endY end point y value
  4818. * @param numberOfSegments (default: 36)
  4819. * @returns the updated Path2.
  4820. */
  4821. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4822. /**
  4823. * Closes the Path2.
  4824. * @returns the Path2.
  4825. */
  4826. close(): Path2;
  4827. /**
  4828. * Gets the sum of the distance between each sequential point in the path
  4829. * @returns the Path2 total length (float).
  4830. */
  4831. length(): number;
  4832. /**
  4833. * Gets the points which construct the path
  4834. * @returns the Path2 internal array of points.
  4835. */
  4836. getPoints(): Vector2[];
  4837. /**
  4838. * Retreives the point at the distance aways from the starting point
  4839. * @param normalizedLengthPosition the length along the path to retreive the point from
  4840. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4841. */
  4842. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4843. /**
  4844. * Creates a new path starting from an x and y position
  4845. * @param x starting x value
  4846. * @param y starting y value
  4847. * @returns a new Path2 starting at the coordinates (x, y).
  4848. */
  4849. static StartingAt(x: number, y: number): Path2;
  4850. }
  4851. /**
  4852. * Represents a 3D path made up of multiple 3D points
  4853. */
  4854. export class Path3D {
  4855. /**
  4856. * an array of Vector3, the curve axis of the Path3D
  4857. */
  4858. path: Vector3[];
  4859. private _curve;
  4860. private _distances;
  4861. private _tangents;
  4862. private _normals;
  4863. private _binormals;
  4864. private _raw;
  4865. private _alignTangentsWithPath;
  4866. private readonly _pointAtData;
  4867. /**
  4868. * new Path3D(path, normal, raw)
  4869. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4870. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4871. * @param path an array of Vector3, the curve axis of the Path3D
  4872. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4873. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4874. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4875. */
  4876. constructor(
  4877. /**
  4878. * an array of Vector3, the curve axis of the Path3D
  4879. */
  4880. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4881. /**
  4882. * Returns the Path3D array of successive Vector3 designing its curve.
  4883. * @returns the Path3D array of successive Vector3 designing its curve.
  4884. */
  4885. getCurve(): Vector3[];
  4886. /**
  4887. * Returns the Path3D array of successive Vector3 designing its curve.
  4888. * @returns the Path3D array of successive Vector3 designing its curve.
  4889. */
  4890. getPoints(): Vector3[];
  4891. /**
  4892. * @returns the computed length (float) of the path.
  4893. */
  4894. length(): number;
  4895. /**
  4896. * Returns an array populated with tangent vectors on each Path3D curve point.
  4897. * @returns an array populated with tangent vectors on each Path3D curve point.
  4898. */
  4899. getTangents(): Vector3[];
  4900. /**
  4901. * Returns an array populated with normal vectors on each Path3D curve point.
  4902. * @returns an array populated with normal vectors on each Path3D curve point.
  4903. */
  4904. getNormals(): Vector3[];
  4905. /**
  4906. * Returns an array populated with binormal vectors on each Path3D curve point.
  4907. * @returns an array populated with binormal vectors on each Path3D curve point.
  4908. */
  4909. getBinormals(): Vector3[];
  4910. /**
  4911. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4912. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4913. */
  4914. getDistances(): number[];
  4915. /**
  4916. * Returns an interpolated point along this path
  4917. * @param position the position of the point along this path, from 0.0 to 1.0
  4918. * @returns a new Vector3 as the point
  4919. */
  4920. getPointAt(position: number): Vector3;
  4921. /**
  4922. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4923. * @param position the position of the point along this path, from 0.0 to 1.0
  4924. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4925. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4926. */
  4927. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4928. /**
  4929. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4930. * @param position the position of the point along this path, from 0.0 to 1.0
  4931. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4932. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4933. */
  4934. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4935. /**
  4936. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4937. * @param position the position of the point along this path, from 0.0 to 1.0
  4938. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4939. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4940. */
  4941. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4942. /**
  4943. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4944. * @param position the position of the point along this path, from 0.0 to 1.0
  4945. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4946. */
  4947. getDistanceAt(position: number): number;
  4948. /**
  4949. * Returns the array index of the previous point of an interpolated point along this path
  4950. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4951. * @returns the array index
  4952. */
  4953. getPreviousPointIndexAt(position: number): number;
  4954. /**
  4955. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4956. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4957. * @returns the sub position
  4958. */
  4959. getSubPositionAt(position: number): number;
  4960. /**
  4961. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4962. * @param target the vector of which to get the closest position to
  4963. * @returns the position of the closest virtual point on this path to the target vector
  4964. */
  4965. getClosestPositionTo(target: Vector3): number;
  4966. /**
  4967. * Returns a sub path (slice) of this path
  4968. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4969. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4970. * @returns a sub path (slice) of this path
  4971. */
  4972. slice(start?: number, end?: number): Path3D;
  4973. /**
  4974. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4975. * @param path path which all values are copied into the curves points
  4976. * @param firstNormal which should be projected onto the curve
  4977. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4978. * @returns the same object updated.
  4979. */
  4980. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4981. private _compute;
  4982. private _getFirstNonNullVector;
  4983. private _getLastNonNullVector;
  4984. private _normalVector;
  4985. /**
  4986. * Updates the point at data for an interpolated point along this curve
  4987. * @param position the position of the point along this curve, from 0.0 to 1.0
  4988. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4989. * @returns the (updated) point at data
  4990. */
  4991. private _updatePointAtData;
  4992. /**
  4993. * Updates the point at data from the specified parameters
  4994. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4995. * @param point the interpolated point
  4996. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4997. */
  4998. private _setPointAtData;
  4999. /**
  5000. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5001. */
  5002. private _updateInterpolationMatrix;
  5003. }
  5004. /**
  5005. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5006. * A Curve3 is designed from a series of successive Vector3.
  5007. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5008. */
  5009. export class Curve3 {
  5010. private _points;
  5011. private _length;
  5012. /**
  5013. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5014. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5015. * @param v1 (Vector3) the control point
  5016. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5017. * @param nbPoints (integer) the wanted number of points in the curve
  5018. * @returns the created Curve3
  5019. */
  5020. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5021. /**
  5022. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5023. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5024. * @param v1 (Vector3) the first control point
  5025. * @param v2 (Vector3) the second control point
  5026. * @param v3 (Vector3) the end point of the Cubic Bezier
  5027. * @param nbPoints (integer) the wanted number of points in the curve
  5028. * @returns the created Curve3
  5029. */
  5030. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5031. /**
  5032. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5033. * @param p1 (Vector3) the origin point of the Hermite Spline
  5034. * @param t1 (Vector3) the tangent vector at the origin point
  5035. * @param p2 (Vector3) the end point of the Hermite Spline
  5036. * @param t2 (Vector3) the tangent vector at the end point
  5037. * @param nbPoints (integer) the wanted number of points in the curve
  5038. * @returns the created Curve3
  5039. */
  5040. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5041. /**
  5042. * Returns a Curve3 object along a CatmullRom Spline curve :
  5043. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5044. * @param nbPoints (integer) the wanted number of points between each curve control points
  5045. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5046. * @returns the created Curve3
  5047. */
  5048. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5049. /**
  5050. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5051. * A Curve3 is designed from a series of successive Vector3.
  5052. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5053. * @param points points which make up the curve
  5054. */
  5055. constructor(points: Vector3[]);
  5056. /**
  5057. * @returns the Curve3 stored array of successive Vector3
  5058. */
  5059. getPoints(): Vector3[];
  5060. /**
  5061. * @returns the computed length (float) of the curve.
  5062. */
  5063. length(): number;
  5064. /**
  5065. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5066. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5067. * curveA and curveB keep unchanged.
  5068. * @param curve the curve to continue from this curve
  5069. * @returns the newly constructed curve
  5070. */
  5071. continue(curve: DeepImmutable<Curve3>): Curve3;
  5072. private _computeLength;
  5073. }
  5074. }
  5075. declare module "babylonjs/Animations/easing" {
  5076. /**
  5077. * This represents the main contract an easing function should follow.
  5078. * Easing functions are used throughout the animation system.
  5079. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5080. */
  5081. export interface IEasingFunction {
  5082. /**
  5083. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5084. * of the easing function.
  5085. * The link below provides some of the most common examples of easing functions.
  5086. * @see https://easings.net/
  5087. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5088. * @returns the corresponding value on the curve defined by the easing function
  5089. */
  5090. ease(gradient: number): number;
  5091. }
  5092. /**
  5093. * Base class used for every default easing function.
  5094. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5095. */
  5096. export class EasingFunction implements IEasingFunction {
  5097. /**
  5098. * Interpolation follows the mathematical formula associated with the easing function.
  5099. */
  5100. static readonly EASINGMODE_EASEIN: number;
  5101. /**
  5102. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5103. */
  5104. static readonly EASINGMODE_EASEOUT: number;
  5105. /**
  5106. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5107. */
  5108. static readonly EASINGMODE_EASEINOUT: number;
  5109. private _easingMode;
  5110. /**
  5111. * Sets the easing mode of the current function.
  5112. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5113. */
  5114. setEasingMode(easingMode: number): void;
  5115. /**
  5116. * Gets the current easing mode.
  5117. * @returns the easing mode
  5118. */
  5119. getEasingMode(): number;
  5120. /**
  5121. * @hidden
  5122. */
  5123. easeInCore(gradient: number): number;
  5124. /**
  5125. * Given an input gradient between 0 and 1, this returns the corresponding value
  5126. * of the easing function.
  5127. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5128. * @returns the corresponding value on the curve defined by the easing function
  5129. */
  5130. ease(gradient: number): number;
  5131. }
  5132. /**
  5133. * Easing function with a circle shape (see link below).
  5134. * @see https://easings.net/#easeInCirc
  5135. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5136. */
  5137. export class CircleEase extends EasingFunction implements IEasingFunction {
  5138. /** @hidden */
  5139. easeInCore(gradient: number): number;
  5140. }
  5141. /**
  5142. * Easing function with a ease back shape (see link below).
  5143. * @see https://easings.net/#easeInBack
  5144. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5145. */
  5146. export class BackEase extends EasingFunction implements IEasingFunction {
  5147. /** Defines the amplitude of the function */
  5148. amplitude: number;
  5149. /**
  5150. * Instantiates a back ease easing
  5151. * @see https://easings.net/#easeInBack
  5152. * @param amplitude Defines the amplitude of the function
  5153. */
  5154. constructor(
  5155. /** Defines the amplitude of the function */
  5156. amplitude?: number);
  5157. /** @hidden */
  5158. easeInCore(gradient: number): number;
  5159. }
  5160. /**
  5161. * Easing function with a bouncing shape (see link below).
  5162. * @see https://easings.net/#easeInBounce
  5163. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5164. */
  5165. export class BounceEase extends EasingFunction implements IEasingFunction {
  5166. /** Defines the number of bounces */
  5167. bounces: number;
  5168. /** Defines the amplitude of the bounce */
  5169. bounciness: number;
  5170. /**
  5171. * Instantiates a bounce easing
  5172. * @see https://easings.net/#easeInBounce
  5173. * @param bounces Defines the number of bounces
  5174. * @param bounciness Defines the amplitude of the bounce
  5175. */
  5176. constructor(
  5177. /** Defines the number of bounces */
  5178. bounces?: number,
  5179. /** Defines the amplitude of the bounce */
  5180. bounciness?: number);
  5181. /** @hidden */
  5182. easeInCore(gradient: number): number;
  5183. }
  5184. /**
  5185. * Easing function with a power of 3 shape (see link below).
  5186. * @see https://easings.net/#easeInCubic
  5187. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5188. */
  5189. export class CubicEase extends EasingFunction implements IEasingFunction {
  5190. /** @hidden */
  5191. easeInCore(gradient: number): number;
  5192. }
  5193. /**
  5194. * Easing function with an elastic shape (see link below).
  5195. * @see https://easings.net/#easeInElastic
  5196. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5197. */
  5198. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5199. /** Defines the number of oscillations*/
  5200. oscillations: number;
  5201. /** Defines the amplitude of the oscillations*/
  5202. springiness: number;
  5203. /**
  5204. * Instantiates an elastic easing function
  5205. * @see https://easings.net/#easeInElastic
  5206. * @param oscillations Defines the number of oscillations
  5207. * @param springiness Defines the amplitude of the oscillations
  5208. */
  5209. constructor(
  5210. /** Defines the number of oscillations*/
  5211. oscillations?: number,
  5212. /** Defines the amplitude of the oscillations*/
  5213. springiness?: number);
  5214. /** @hidden */
  5215. easeInCore(gradient: number): number;
  5216. }
  5217. /**
  5218. * Easing function with an exponential shape (see link below).
  5219. * @see https://easings.net/#easeInExpo
  5220. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5221. */
  5222. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5223. /** Defines the exponent of the function */
  5224. exponent: number;
  5225. /**
  5226. * Instantiates an exponential easing function
  5227. * @see https://easings.net/#easeInExpo
  5228. * @param exponent Defines the exponent of the function
  5229. */
  5230. constructor(
  5231. /** Defines the exponent of the function */
  5232. exponent?: number);
  5233. /** @hidden */
  5234. easeInCore(gradient: number): number;
  5235. }
  5236. /**
  5237. * Easing function with a power shape (see link below).
  5238. * @see https://easings.net/#easeInQuad
  5239. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5240. */
  5241. export class PowerEase extends EasingFunction implements IEasingFunction {
  5242. /** Defines the power of the function */
  5243. power: number;
  5244. /**
  5245. * Instantiates an power base easing function
  5246. * @see https://easings.net/#easeInQuad
  5247. * @param power Defines the power of the function
  5248. */
  5249. constructor(
  5250. /** Defines the power of the function */
  5251. power?: number);
  5252. /** @hidden */
  5253. easeInCore(gradient: number): number;
  5254. }
  5255. /**
  5256. * Easing function with a power of 2 shape (see link below).
  5257. * @see https://easings.net/#easeInQuad
  5258. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5259. */
  5260. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5261. /** @hidden */
  5262. easeInCore(gradient: number): number;
  5263. }
  5264. /**
  5265. * Easing function with a power of 4 shape (see link below).
  5266. * @see https://easings.net/#easeInQuart
  5267. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5268. */
  5269. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5270. /** @hidden */
  5271. easeInCore(gradient: number): number;
  5272. }
  5273. /**
  5274. * Easing function with a power of 5 shape (see link below).
  5275. * @see https://easings.net/#easeInQuint
  5276. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5277. */
  5278. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5279. /** @hidden */
  5280. easeInCore(gradient: number): number;
  5281. }
  5282. /**
  5283. * Easing function with a sin shape (see link below).
  5284. * @see https://easings.net/#easeInSine
  5285. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5286. */
  5287. export class SineEase extends EasingFunction implements IEasingFunction {
  5288. /** @hidden */
  5289. easeInCore(gradient: number): number;
  5290. }
  5291. /**
  5292. * Easing function with a bezier shape (see link below).
  5293. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5294. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5295. */
  5296. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5297. /** Defines the x component of the start tangent in the bezier curve */
  5298. x1: number;
  5299. /** Defines the y component of the start tangent in the bezier curve */
  5300. y1: number;
  5301. /** Defines the x component of the end tangent in the bezier curve */
  5302. x2: number;
  5303. /** Defines the y component of the end tangent in the bezier curve */
  5304. y2: number;
  5305. /**
  5306. * Instantiates a bezier function
  5307. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5308. * @param x1 Defines the x component of the start tangent in the bezier curve
  5309. * @param y1 Defines the y component of the start tangent in the bezier curve
  5310. * @param x2 Defines the x component of the end tangent in the bezier curve
  5311. * @param y2 Defines the y component of the end tangent in the bezier curve
  5312. */
  5313. constructor(
  5314. /** Defines the x component of the start tangent in the bezier curve */
  5315. x1?: number,
  5316. /** Defines the y component of the start tangent in the bezier curve */
  5317. y1?: number,
  5318. /** Defines the x component of the end tangent in the bezier curve */
  5319. x2?: number,
  5320. /** Defines the y component of the end tangent in the bezier curve */
  5321. y2?: number);
  5322. /** @hidden */
  5323. easeInCore(gradient: number): number;
  5324. }
  5325. }
  5326. declare module "babylonjs/Maths/math.color" {
  5327. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5328. /**
  5329. * Class used to hold a RBG color
  5330. */
  5331. export class Color3 {
  5332. /**
  5333. * Defines the red component (between 0 and 1, default is 0)
  5334. */
  5335. r: number;
  5336. /**
  5337. * Defines the green component (between 0 and 1, default is 0)
  5338. */
  5339. g: number;
  5340. /**
  5341. * Defines the blue component (between 0 and 1, default is 0)
  5342. */
  5343. b: number;
  5344. /**
  5345. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5346. * @param r defines the red component (between 0 and 1, default is 0)
  5347. * @param g defines the green component (between 0 and 1, default is 0)
  5348. * @param b defines the blue component (between 0 and 1, default is 0)
  5349. */
  5350. constructor(
  5351. /**
  5352. * Defines the red component (between 0 and 1, default is 0)
  5353. */
  5354. r?: number,
  5355. /**
  5356. * Defines the green component (between 0 and 1, default is 0)
  5357. */
  5358. g?: number,
  5359. /**
  5360. * Defines the blue component (between 0 and 1, default is 0)
  5361. */
  5362. b?: number);
  5363. /**
  5364. * Creates a string with the Color3 current values
  5365. * @returns the string representation of the Color3 object
  5366. */
  5367. toString(): string;
  5368. /**
  5369. * Returns the string "Color3"
  5370. * @returns "Color3"
  5371. */
  5372. getClassName(): string;
  5373. /**
  5374. * Compute the Color3 hash code
  5375. * @returns an unique number that can be used to hash Color3 objects
  5376. */
  5377. getHashCode(): number;
  5378. /**
  5379. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5380. * @param array defines the array where to store the r,g,b components
  5381. * @param index defines an optional index in the target array to define where to start storing values
  5382. * @returns the current Color3 object
  5383. */
  5384. toArray(array: FloatArray, index?: number): Color3;
  5385. /**
  5386. * Returns a new Color4 object from the current Color3 and the given alpha
  5387. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5388. * @returns a new Color4 object
  5389. */
  5390. toColor4(alpha?: number): Color4;
  5391. /**
  5392. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5393. * @returns the new array
  5394. */
  5395. asArray(): number[];
  5396. /**
  5397. * Returns the luminance value
  5398. * @returns a float value
  5399. */
  5400. toLuminance(): number;
  5401. /**
  5402. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5403. * @param otherColor defines the second operand
  5404. * @returns the new Color3 object
  5405. */
  5406. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5407. /**
  5408. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5409. * @param otherColor defines the second operand
  5410. * @param result defines the Color3 object where to store the result
  5411. * @returns the current Color3
  5412. */
  5413. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5414. /**
  5415. * Determines equality between Color3 objects
  5416. * @param otherColor defines the second operand
  5417. * @returns true if the rgb values are equal to the given ones
  5418. */
  5419. equals(otherColor: DeepImmutable<Color3>): boolean;
  5420. /**
  5421. * Determines equality between the current Color3 object and a set of r,b,g values
  5422. * @param r defines the red component to check
  5423. * @param g defines the green component to check
  5424. * @param b defines the blue component to check
  5425. * @returns true if the rgb values are equal to the given ones
  5426. */
  5427. equalsFloats(r: number, g: number, b: number): boolean;
  5428. /**
  5429. * Multiplies in place each rgb value by scale
  5430. * @param scale defines the scaling factor
  5431. * @returns the updated Color3
  5432. */
  5433. scale(scale: number): Color3;
  5434. /**
  5435. * Multiplies the rgb values by scale and stores the result into "result"
  5436. * @param scale defines the scaling factor
  5437. * @param result defines the Color3 object where to store the result
  5438. * @returns the unmodified current Color3
  5439. */
  5440. scaleToRef(scale: number, result: Color3): Color3;
  5441. /**
  5442. * Scale the current Color3 values by a factor and add the result to a given Color3
  5443. * @param scale defines the scale factor
  5444. * @param result defines color to store the result into
  5445. * @returns the unmodified current Color3
  5446. */
  5447. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5448. /**
  5449. * Clamps the rgb values by the min and max values and stores the result into "result"
  5450. * @param min defines minimum clamping value (default is 0)
  5451. * @param max defines maximum clamping value (default is 1)
  5452. * @param result defines color to store the result into
  5453. * @returns the original Color3
  5454. */
  5455. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5456. /**
  5457. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5458. * @param otherColor defines the second operand
  5459. * @returns the new Color3
  5460. */
  5461. add(otherColor: DeepImmutable<Color3>): Color3;
  5462. /**
  5463. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5464. * @param otherColor defines the second operand
  5465. * @param result defines Color3 object to store the result into
  5466. * @returns the unmodified current Color3
  5467. */
  5468. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5469. /**
  5470. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5471. * @param otherColor defines the second operand
  5472. * @returns the new Color3
  5473. */
  5474. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5475. /**
  5476. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5477. * @param otherColor defines the second operand
  5478. * @param result defines Color3 object to store the result into
  5479. * @returns the unmodified current Color3
  5480. */
  5481. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5482. /**
  5483. * Copy the current object
  5484. * @returns a new Color3 copied the current one
  5485. */
  5486. clone(): Color3;
  5487. /**
  5488. * Copies the rgb values from the source in the current Color3
  5489. * @param source defines the source Color3 object
  5490. * @returns the updated Color3 object
  5491. */
  5492. copyFrom(source: DeepImmutable<Color3>): Color3;
  5493. /**
  5494. * Updates the Color3 rgb values from the given floats
  5495. * @param r defines the red component to read from
  5496. * @param g defines the green component to read from
  5497. * @param b defines the blue component to read from
  5498. * @returns the current Color3 object
  5499. */
  5500. copyFromFloats(r: number, g: number, b: number): Color3;
  5501. /**
  5502. * Updates the Color3 rgb values from the given floats
  5503. * @param r defines the red component to read from
  5504. * @param g defines the green component to read from
  5505. * @param b defines the blue component to read from
  5506. * @returns the current Color3 object
  5507. */
  5508. set(r: number, g: number, b: number): Color3;
  5509. /**
  5510. * Compute the Color3 hexadecimal code as a string
  5511. * @returns a string containing the hexadecimal representation of the Color3 object
  5512. */
  5513. toHexString(): string;
  5514. /**
  5515. * Computes a new Color3 converted from the current one to linear space
  5516. * @returns a new Color3 object
  5517. */
  5518. toLinearSpace(): Color3;
  5519. /**
  5520. * Converts current color in rgb space to HSV values
  5521. * @returns a new color3 representing the HSV values
  5522. */
  5523. toHSV(): Color3;
  5524. /**
  5525. * Converts current color in rgb space to HSV values
  5526. * @param result defines the Color3 where to store the HSV values
  5527. */
  5528. toHSVToRef(result: Color3): void;
  5529. /**
  5530. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5531. * @param convertedColor defines the Color3 object where to store the linear space version
  5532. * @returns the unmodified Color3
  5533. */
  5534. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5535. /**
  5536. * Computes a new Color3 converted from the current one to gamma space
  5537. * @returns a new Color3 object
  5538. */
  5539. toGammaSpace(): Color3;
  5540. /**
  5541. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5542. * @param convertedColor defines the Color3 object where to store the gamma space version
  5543. * @returns the unmodified Color3
  5544. */
  5545. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5546. private static _BlackReadOnly;
  5547. /**
  5548. * Convert Hue, saturation and value to a Color3 (RGB)
  5549. * @param hue defines the hue
  5550. * @param saturation defines the saturation
  5551. * @param value defines the value
  5552. * @param result defines the Color3 where to store the RGB values
  5553. */
  5554. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5555. /**
  5556. * Creates a new Color3 from the string containing valid hexadecimal values
  5557. * @param hex defines a string containing valid hexadecimal values
  5558. * @returns a new Color3 object
  5559. */
  5560. static FromHexString(hex: string): Color3;
  5561. /**
  5562. * Creates a new Color3 from the starting index of the given array
  5563. * @param array defines the source array
  5564. * @param offset defines an offset in the source array
  5565. * @returns a new Color3 object
  5566. */
  5567. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5568. /**
  5569. * Creates a new Color3 from integer values (< 256)
  5570. * @param r defines the red component to read from (value between 0 and 255)
  5571. * @param g defines the green component to read from (value between 0 and 255)
  5572. * @param b defines the blue component to read from (value between 0 and 255)
  5573. * @returns a new Color3 object
  5574. */
  5575. static FromInts(r: number, g: number, b: number): Color3;
  5576. /**
  5577. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5578. * @param start defines the start Color3 value
  5579. * @param end defines the end Color3 value
  5580. * @param amount defines the gradient value between start and end
  5581. * @returns a new Color3 object
  5582. */
  5583. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5584. /**
  5585. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5586. * @param left defines the start value
  5587. * @param right defines the end value
  5588. * @param amount defines the gradient factor
  5589. * @param result defines the Color3 object where to store the result
  5590. */
  5591. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5592. /**
  5593. * Returns a Color3 value containing a red color
  5594. * @returns a new Color3 object
  5595. */
  5596. static Red(): Color3;
  5597. /**
  5598. * Returns a Color3 value containing a green color
  5599. * @returns a new Color3 object
  5600. */
  5601. static Green(): Color3;
  5602. /**
  5603. * Returns a Color3 value containing a blue color
  5604. * @returns a new Color3 object
  5605. */
  5606. static Blue(): Color3;
  5607. /**
  5608. * Returns a Color3 value containing a black color
  5609. * @returns a new Color3 object
  5610. */
  5611. static Black(): Color3;
  5612. /**
  5613. * Gets a Color3 value containing a black color that must not be updated
  5614. */
  5615. static get BlackReadOnly(): DeepImmutable<Color3>;
  5616. /**
  5617. * Returns a Color3 value containing a white color
  5618. * @returns a new Color3 object
  5619. */
  5620. static White(): Color3;
  5621. /**
  5622. * Returns a Color3 value containing a purple color
  5623. * @returns a new Color3 object
  5624. */
  5625. static Purple(): Color3;
  5626. /**
  5627. * Returns a Color3 value containing a magenta color
  5628. * @returns a new Color3 object
  5629. */
  5630. static Magenta(): Color3;
  5631. /**
  5632. * Returns a Color3 value containing a yellow color
  5633. * @returns a new Color3 object
  5634. */
  5635. static Yellow(): Color3;
  5636. /**
  5637. * Returns a Color3 value containing a gray color
  5638. * @returns a new Color3 object
  5639. */
  5640. static Gray(): Color3;
  5641. /**
  5642. * Returns a Color3 value containing a teal color
  5643. * @returns a new Color3 object
  5644. */
  5645. static Teal(): Color3;
  5646. /**
  5647. * Returns a Color3 value containing a random color
  5648. * @returns a new Color3 object
  5649. */
  5650. static Random(): Color3;
  5651. }
  5652. /**
  5653. * Class used to hold a RBGA color
  5654. */
  5655. export class Color4 {
  5656. /**
  5657. * Defines the red component (between 0 and 1, default is 0)
  5658. */
  5659. r: number;
  5660. /**
  5661. * Defines the green component (between 0 and 1, default is 0)
  5662. */
  5663. g: number;
  5664. /**
  5665. * Defines the blue component (between 0 and 1, default is 0)
  5666. */
  5667. b: number;
  5668. /**
  5669. * Defines the alpha component (between 0 and 1, default is 1)
  5670. */
  5671. a: number;
  5672. /**
  5673. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5674. * @param r defines the red component (between 0 and 1, default is 0)
  5675. * @param g defines the green component (between 0 and 1, default is 0)
  5676. * @param b defines the blue component (between 0 and 1, default is 0)
  5677. * @param a defines the alpha component (between 0 and 1, default is 1)
  5678. */
  5679. constructor(
  5680. /**
  5681. * Defines the red component (between 0 and 1, default is 0)
  5682. */
  5683. r?: number,
  5684. /**
  5685. * Defines the green component (between 0 and 1, default is 0)
  5686. */
  5687. g?: number,
  5688. /**
  5689. * Defines the blue component (between 0 and 1, default is 0)
  5690. */
  5691. b?: number,
  5692. /**
  5693. * Defines the alpha component (between 0 and 1, default is 1)
  5694. */
  5695. a?: number);
  5696. /**
  5697. * Adds in place the given Color4 values to the current Color4 object
  5698. * @param right defines the second operand
  5699. * @returns the current updated Color4 object
  5700. */
  5701. addInPlace(right: DeepImmutable<Color4>): Color4;
  5702. /**
  5703. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5704. * @returns the new array
  5705. */
  5706. asArray(): number[];
  5707. /**
  5708. * Stores from the starting index in the given array the Color4 successive values
  5709. * @param array defines the array where to store the r,g,b components
  5710. * @param index defines an optional index in the target array to define where to start storing values
  5711. * @returns the current Color4 object
  5712. */
  5713. toArray(array: number[], index?: number): Color4;
  5714. /**
  5715. * Determines equality between Color4 objects
  5716. * @param otherColor defines the second operand
  5717. * @returns true if the rgba values are equal to the given ones
  5718. */
  5719. equals(otherColor: DeepImmutable<Color4>): boolean;
  5720. /**
  5721. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5722. * @param right defines the second operand
  5723. * @returns a new Color4 object
  5724. */
  5725. add(right: DeepImmutable<Color4>): Color4;
  5726. /**
  5727. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5728. * @param right defines the second operand
  5729. * @returns a new Color4 object
  5730. */
  5731. subtract(right: DeepImmutable<Color4>): Color4;
  5732. /**
  5733. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5734. * @param right defines the second operand
  5735. * @param result defines the Color4 object where to store the result
  5736. * @returns the current Color4 object
  5737. */
  5738. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5739. /**
  5740. * Creates a new Color4 with the current Color4 values multiplied by scale
  5741. * @param scale defines the scaling factor to apply
  5742. * @returns a new Color4 object
  5743. */
  5744. scale(scale: number): Color4;
  5745. /**
  5746. * Multiplies the current Color4 values by scale and stores the result in "result"
  5747. * @param scale defines the scaling factor to apply
  5748. * @param result defines the Color4 object where to store the result
  5749. * @returns the current unmodified Color4
  5750. */
  5751. scaleToRef(scale: number, result: Color4): Color4;
  5752. /**
  5753. * Scale the current Color4 values by a factor and add the result to a given Color4
  5754. * @param scale defines the scale factor
  5755. * @param result defines the Color4 object where to store the result
  5756. * @returns the unmodified current Color4
  5757. */
  5758. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5759. /**
  5760. * Clamps the rgb values by the min and max values and stores the result into "result"
  5761. * @param min defines minimum clamping value (default is 0)
  5762. * @param max defines maximum clamping value (default is 1)
  5763. * @param result defines color to store the result into.
  5764. * @returns the cuurent Color4
  5765. */
  5766. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5767. /**
  5768. * Multipy an Color4 value by another and return a new Color4 object
  5769. * @param color defines the Color4 value to multiply by
  5770. * @returns a new Color4 object
  5771. */
  5772. multiply(color: Color4): Color4;
  5773. /**
  5774. * Multipy a Color4 value by another and push the result in a reference value
  5775. * @param color defines the Color4 value to multiply by
  5776. * @param result defines the Color4 to fill the result in
  5777. * @returns the result Color4
  5778. */
  5779. multiplyToRef(color: Color4, result: Color4): Color4;
  5780. /**
  5781. * Creates a string with the Color4 current values
  5782. * @returns the string representation of the Color4 object
  5783. */
  5784. toString(): string;
  5785. /**
  5786. * Returns the string "Color4"
  5787. * @returns "Color4"
  5788. */
  5789. getClassName(): string;
  5790. /**
  5791. * Compute the Color4 hash code
  5792. * @returns an unique number that can be used to hash Color4 objects
  5793. */
  5794. getHashCode(): number;
  5795. /**
  5796. * Creates a new Color4 copied from the current one
  5797. * @returns a new Color4 object
  5798. */
  5799. clone(): Color4;
  5800. /**
  5801. * Copies the given Color4 values into the current one
  5802. * @param source defines the source Color4 object
  5803. * @returns the current updated Color4 object
  5804. */
  5805. copyFrom(source: Color4): Color4;
  5806. /**
  5807. * Copies the given float values into the current one
  5808. * @param r defines the red component to read from
  5809. * @param g defines the green component to read from
  5810. * @param b defines the blue component to read from
  5811. * @param a defines the alpha component to read from
  5812. * @returns the current updated Color4 object
  5813. */
  5814. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5815. /**
  5816. * Copies the given float values into the current one
  5817. * @param r defines the red component to read from
  5818. * @param g defines the green component to read from
  5819. * @param b defines the blue component to read from
  5820. * @param a defines the alpha component to read from
  5821. * @returns the current updated Color4 object
  5822. */
  5823. set(r: number, g: number, b: number, a: number): Color4;
  5824. /**
  5825. * Compute the Color4 hexadecimal code as a string
  5826. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5827. * @returns a string containing the hexadecimal representation of the Color4 object
  5828. */
  5829. toHexString(returnAsColor3?: boolean): string;
  5830. /**
  5831. * Computes a new Color4 converted from the current one to linear space
  5832. * @returns a new Color4 object
  5833. */
  5834. toLinearSpace(): Color4;
  5835. /**
  5836. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5837. * @param convertedColor defines the Color4 object where to store the linear space version
  5838. * @returns the unmodified Color4
  5839. */
  5840. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5841. /**
  5842. * Computes a new Color4 converted from the current one to gamma space
  5843. * @returns a new Color4 object
  5844. */
  5845. toGammaSpace(): Color4;
  5846. /**
  5847. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5848. * @param convertedColor defines the Color4 object where to store the gamma space version
  5849. * @returns the unmodified Color4
  5850. */
  5851. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5852. /**
  5853. * Creates a new Color4 from the string containing valid hexadecimal values
  5854. * @param hex defines a string containing valid hexadecimal values
  5855. * @returns a new Color4 object
  5856. */
  5857. static FromHexString(hex: string): Color4;
  5858. /**
  5859. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5860. * @param left defines the start value
  5861. * @param right defines the end value
  5862. * @param amount defines the gradient factor
  5863. * @returns a new Color4 object
  5864. */
  5865. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5866. /**
  5867. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5868. * @param left defines the start value
  5869. * @param right defines the end value
  5870. * @param amount defines the gradient factor
  5871. * @param result defines the Color4 object where to store data
  5872. */
  5873. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5874. /**
  5875. * Creates a new Color4 from a Color3 and an alpha value
  5876. * @param color3 defines the source Color3 to read from
  5877. * @param alpha defines the alpha component (1.0 by default)
  5878. * @returns a new Color4 object
  5879. */
  5880. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5881. /**
  5882. * Creates a new Color4 from the starting index element of the given array
  5883. * @param array defines the source array to read from
  5884. * @param offset defines the offset in the source array
  5885. * @returns a new Color4 object
  5886. */
  5887. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5888. /**
  5889. * Creates a new Color3 from integer values (< 256)
  5890. * @param r defines the red component to read from (value between 0 and 255)
  5891. * @param g defines the green component to read from (value between 0 and 255)
  5892. * @param b defines the blue component to read from (value between 0 and 255)
  5893. * @param a defines the alpha component to read from (value between 0 and 255)
  5894. * @returns a new Color3 object
  5895. */
  5896. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5897. /**
  5898. * Check the content of a given array and convert it to an array containing RGBA data
  5899. * If the original array was already containing count * 4 values then it is returned directly
  5900. * @param colors defines the array to check
  5901. * @param count defines the number of RGBA data to expect
  5902. * @returns an array containing count * 4 values (RGBA)
  5903. */
  5904. static CheckColors4(colors: number[], count: number): number[];
  5905. }
  5906. /**
  5907. * @hidden
  5908. */
  5909. export class TmpColors {
  5910. static Color3: Color3[];
  5911. static Color4: Color4[];
  5912. }
  5913. }
  5914. declare module "babylonjs/Animations/animationKey" {
  5915. /**
  5916. * Defines an interface which represents an animation key frame
  5917. */
  5918. export interface IAnimationKey {
  5919. /**
  5920. * Frame of the key frame
  5921. */
  5922. frame: number;
  5923. /**
  5924. * Value at the specifies key frame
  5925. */
  5926. value: any;
  5927. /**
  5928. * The input tangent for the cubic hermite spline
  5929. */
  5930. inTangent?: any;
  5931. /**
  5932. * The output tangent for the cubic hermite spline
  5933. */
  5934. outTangent?: any;
  5935. /**
  5936. * The animation interpolation type
  5937. */
  5938. interpolation?: AnimationKeyInterpolation;
  5939. }
  5940. /**
  5941. * Enum for the animation key frame interpolation type
  5942. */
  5943. export enum AnimationKeyInterpolation {
  5944. /**
  5945. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5946. */
  5947. STEP = 1
  5948. }
  5949. }
  5950. declare module "babylonjs/Animations/animationRange" {
  5951. /**
  5952. * Represents the range of an animation
  5953. */
  5954. export class AnimationRange {
  5955. /**The name of the animation range**/
  5956. name: string;
  5957. /**The starting frame of the animation */
  5958. from: number;
  5959. /**The ending frame of the animation*/
  5960. to: number;
  5961. /**
  5962. * Initializes the range of an animation
  5963. * @param name The name of the animation range
  5964. * @param from The starting frame of the animation
  5965. * @param to The ending frame of the animation
  5966. */
  5967. constructor(
  5968. /**The name of the animation range**/
  5969. name: string,
  5970. /**The starting frame of the animation */
  5971. from: number,
  5972. /**The ending frame of the animation*/
  5973. to: number);
  5974. /**
  5975. * Makes a copy of the animation range
  5976. * @returns A copy of the animation range
  5977. */
  5978. clone(): AnimationRange;
  5979. }
  5980. }
  5981. declare module "babylonjs/Animations/animationEvent" {
  5982. /**
  5983. * Composed of a frame, and an action function
  5984. */
  5985. export class AnimationEvent {
  5986. /** The frame for which the event is triggered **/
  5987. frame: number;
  5988. /** The event to perform when triggered **/
  5989. action: (currentFrame: number) => void;
  5990. /** Specifies if the event should be triggered only once**/
  5991. onlyOnce?: boolean | undefined;
  5992. /**
  5993. * Specifies if the animation event is done
  5994. */
  5995. isDone: boolean;
  5996. /**
  5997. * Initializes the animation event
  5998. * @param frame The frame for which the event is triggered
  5999. * @param action The event to perform when triggered
  6000. * @param onlyOnce Specifies if the event should be triggered only once
  6001. */
  6002. constructor(
  6003. /** The frame for which the event is triggered **/
  6004. frame: number,
  6005. /** The event to perform when triggered **/
  6006. action: (currentFrame: number) => void,
  6007. /** Specifies if the event should be triggered only once**/
  6008. onlyOnce?: boolean | undefined);
  6009. /** @hidden */
  6010. _clone(): AnimationEvent;
  6011. }
  6012. }
  6013. declare module "babylonjs/Behaviors/behavior" {
  6014. import { Nullable } from "babylonjs/types";
  6015. /**
  6016. * Interface used to define a behavior
  6017. */
  6018. export interface Behavior<T> {
  6019. /** gets or sets behavior's name */
  6020. name: string;
  6021. /**
  6022. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6023. */
  6024. init(): void;
  6025. /**
  6026. * Called when the behavior is attached to a target
  6027. * @param target defines the target where the behavior is attached to
  6028. */
  6029. attach(target: T): void;
  6030. /**
  6031. * Called when the behavior is detached from its target
  6032. */
  6033. detach(): void;
  6034. }
  6035. /**
  6036. * Interface implemented by classes supporting behaviors
  6037. */
  6038. export interface IBehaviorAware<T> {
  6039. /**
  6040. * Attach a behavior
  6041. * @param behavior defines the behavior to attach
  6042. * @returns the current host
  6043. */
  6044. addBehavior(behavior: Behavior<T>): T;
  6045. /**
  6046. * Remove a behavior from the current object
  6047. * @param behavior defines the behavior to detach
  6048. * @returns the current host
  6049. */
  6050. removeBehavior(behavior: Behavior<T>): T;
  6051. /**
  6052. * Gets a behavior using its name to search
  6053. * @param name defines the name to search
  6054. * @returns the behavior or null if not found
  6055. */
  6056. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6057. }
  6058. }
  6059. declare module "babylonjs/Misc/smartArray" {
  6060. /**
  6061. * Defines an array and its length.
  6062. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6063. */
  6064. export interface ISmartArrayLike<T> {
  6065. /**
  6066. * The data of the array.
  6067. */
  6068. data: Array<T>;
  6069. /**
  6070. * The active length of the array.
  6071. */
  6072. length: number;
  6073. }
  6074. /**
  6075. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6076. */
  6077. export class SmartArray<T> implements ISmartArrayLike<T> {
  6078. /**
  6079. * The full set of data from the array.
  6080. */
  6081. data: Array<T>;
  6082. /**
  6083. * The active length of the array.
  6084. */
  6085. length: number;
  6086. protected _id: number;
  6087. /**
  6088. * Instantiates a Smart Array.
  6089. * @param capacity defines the default capacity of the array.
  6090. */
  6091. constructor(capacity: number);
  6092. /**
  6093. * Pushes a value at the end of the active data.
  6094. * @param value defines the object to push in the array.
  6095. */
  6096. push(value: T): void;
  6097. /**
  6098. * Iterates over the active data and apply the lambda to them.
  6099. * @param func defines the action to apply on each value.
  6100. */
  6101. forEach(func: (content: T) => void): void;
  6102. /**
  6103. * Sorts the full sets of data.
  6104. * @param compareFn defines the comparison function to apply.
  6105. */
  6106. sort(compareFn: (a: T, b: T) => number): void;
  6107. /**
  6108. * Resets the active data to an empty array.
  6109. */
  6110. reset(): void;
  6111. /**
  6112. * Releases all the data from the array as well as the array.
  6113. */
  6114. dispose(): void;
  6115. /**
  6116. * Concats the active data with a given array.
  6117. * @param array defines the data to concatenate with.
  6118. */
  6119. concat(array: any): void;
  6120. /**
  6121. * Returns the position of a value in the active data.
  6122. * @param value defines the value to find the index for
  6123. * @returns the index if found in the active data otherwise -1
  6124. */
  6125. indexOf(value: T): number;
  6126. /**
  6127. * Returns whether an element is part of the active data.
  6128. * @param value defines the value to look for
  6129. * @returns true if found in the active data otherwise false
  6130. */
  6131. contains(value: T): boolean;
  6132. private static _GlobalId;
  6133. }
  6134. /**
  6135. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6136. * The data in this array can only be present once
  6137. */
  6138. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6139. private _duplicateId;
  6140. /**
  6141. * Pushes a value at the end of the active data.
  6142. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6143. * @param value defines the object to push in the array.
  6144. */
  6145. push(value: T): void;
  6146. /**
  6147. * Pushes a value at the end of the active data.
  6148. * If the data is already present, it won t be added again
  6149. * @param value defines the object to push in the array.
  6150. * @returns true if added false if it was already present
  6151. */
  6152. pushNoDuplicate(value: T): boolean;
  6153. /**
  6154. * Resets the active data to an empty array.
  6155. */
  6156. reset(): void;
  6157. /**
  6158. * Concats the active data with a given array.
  6159. * This ensures no dupplicate will be present in the result.
  6160. * @param array defines the data to concatenate with.
  6161. */
  6162. concatWithNoDuplicate(array: any): void;
  6163. }
  6164. }
  6165. declare module "babylonjs/Cameras/cameraInputsManager" {
  6166. import { Nullable } from "babylonjs/types";
  6167. import { Camera } from "babylonjs/Cameras/camera";
  6168. /**
  6169. * @ignore
  6170. * This is a list of all the different input types that are available in the application.
  6171. * Fo instance: ArcRotateCameraGamepadInput...
  6172. */
  6173. export var CameraInputTypes: {};
  6174. /**
  6175. * This is the contract to implement in order to create a new input class.
  6176. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6177. */
  6178. export interface ICameraInput<TCamera extends Camera> {
  6179. /**
  6180. * Defines the camera the input is attached to.
  6181. */
  6182. camera: Nullable<TCamera>;
  6183. /**
  6184. * Gets the class name of the current intput.
  6185. * @returns the class name
  6186. */
  6187. getClassName(): string;
  6188. /**
  6189. * Get the friendly name associated with the input class.
  6190. * @returns the input friendly name
  6191. */
  6192. getSimpleName(): string;
  6193. /**
  6194. * Attach the input controls to a specific dom element to get the input from.
  6195. * @param element Defines the element the controls should be listened from
  6196. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6197. */
  6198. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6199. /**
  6200. * Detach the current controls from the specified dom element.
  6201. * @param element Defines the element to stop listening the inputs from
  6202. */
  6203. detachControl(element: Nullable<HTMLElement>): void;
  6204. /**
  6205. * Update the current camera state depending on the inputs that have been used this frame.
  6206. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6207. */
  6208. checkInputs?: () => void;
  6209. }
  6210. /**
  6211. * Represents a map of input types to input instance or input index to input instance.
  6212. */
  6213. export interface CameraInputsMap<TCamera extends Camera> {
  6214. /**
  6215. * Accessor to the input by input type.
  6216. */
  6217. [name: string]: ICameraInput<TCamera>;
  6218. /**
  6219. * Accessor to the input by input index.
  6220. */
  6221. [idx: number]: ICameraInput<TCamera>;
  6222. }
  6223. /**
  6224. * This represents the input manager used within a camera.
  6225. * It helps dealing with all the different kind of input attached to a camera.
  6226. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6227. */
  6228. export class CameraInputsManager<TCamera extends Camera> {
  6229. /**
  6230. * Defines the list of inputs attahed to the camera.
  6231. */
  6232. attached: CameraInputsMap<TCamera>;
  6233. /**
  6234. * Defines the dom element the camera is collecting inputs from.
  6235. * This is null if the controls have not been attached.
  6236. */
  6237. attachedElement: Nullable<HTMLElement>;
  6238. /**
  6239. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6240. */
  6241. noPreventDefault: boolean;
  6242. /**
  6243. * Defined the camera the input manager belongs to.
  6244. */
  6245. camera: TCamera;
  6246. /**
  6247. * Update the current camera state depending on the inputs that have been used this frame.
  6248. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6249. */
  6250. checkInputs: () => void;
  6251. /**
  6252. * Instantiate a new Camera Input Manager.
  6253. * @param camera Defines the camera the input manager blongs to
  6254. */
  6255. constructor(camera: TCamera);
  6256. /**
  6257. * Add an input method to a camera
  6258. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6259. * @param input camera input method
  6260. */
  6261. add(input: ICameraInput<TCamera>): void;
  6262. /**
  6263. * Remove a specific input method from a camera
  6264. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6265. * @param inputToRemove camera input method
  6266. */
  6267. remove(inputToRemove: ICameraInput<TCamera>): void;
  6268. /**
  6269. * Remove a specific input type from a camera
  6270. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6271. * @param inputType the type of the input to remove
  6272. */
  6273. removeByType(inputType: string): void;
  6274. private _addCheckInputs;
  6275. /**
  6276. * Attach the input controls to the currently attached dom element to listen the events from.
  6277. * @param input Defines the input to attach
  6278. */
  6279. attachInput(input: ICameraInput<TCamera>): void;
  6280. /**
  6281. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6282. * @param element Defines the dom element to collect the events from
  6283. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6284. */
  6285. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6286. /**
  6287. * Detach the current manager inputs controls from a specific dom element.
  6288. * @param element Defines the dom element to collect the events from
  6289. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6290. */
  6291. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6292. /**
  6293. * Rebuild the dynamic inputCheck function from the current list of
  6294. * defined inputs in the manager.
  6295. */
  6296. rebuildInputCheck(): void;
  6297. /**
  6298. * Remove all attached input methods from a camera
  6299. */
  6300. clear(): void;
  6301. /**
  6302. * Serialize the current input manager attached to a camera.
  6303. * This ensures than once parsed,
  6304. * the input associated to the camera will be identical to the current ones
  6305. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6306. */
  6307. serialize(serializedCamera: any): void;
  6308. /**
  6309. * Parses an input manager serialized JSON to restore the previous list of inputs
  6310. * and states associated to a camera.
  6311. * @param parsedCamera Defines the JSON to parse
  6312. */
  6313. parse(parsedCamera: any): void;
  6314. }
  6315. }
  6316. declare module "babylonjs/Meshes/buffer" {
  6317. import { Nullable, DataArray } from "babylonjs/types";
  6318. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6319. /**
  6320. * Class used to store data that will be store in GPU memory
  6321. */
  6322. export class Buffer {
  6323. private _engine;
  6324. private _buffer;
  6325. /** @hidden */
  6326. _data: Nullable<DataArray>;
  6327. private _updatable;
  6328. private _instanced;
  6329. private _divisor;
  6330. /**
  6331. * Gets the byte stride.
  6332. */
  6333. readonly byteStride: number;
  6334. /**
  6335. * Constructor
  6336. * @param engine the engine
  6337. * @param data the data to use for this buffer
  6338. * @param updatable whether the data is updatable
  6339. * @param stride the stride (optional)
  6340. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6341. * @param instanced whether the buffer is instanced (optional)
  6342. * @param useBytes set to true if the stride in in bytes (optional)
  6343. * @param divisor sets an optional divisor for instances (1 by default)
  6344. */
  6345. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6346. /**
  6347. * Create a new VertexBuffer based on the current buffer
  6348. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6349. * @param offset defines offset in the buffer (0 by default)
  6350. * @param size defines the size in floats of attributes (position is 3 for instance)
  6351. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6352. * @param instanced defines if the vertex buffer contains indexed data
  6353. * @param useBytes defines if the offset and stride are in bytes *
  6354. * @param divisor sets an optional divisor for instances (1 by default)
  6355. * @returns the new vertex buffer
  6356. */
  6357. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6358. /**
  6359. * Gets a boolean indicating if the Buffer is updatable?
  6360. * @returns true if the buffer is updatable
  6361. */
  6362. isUpdatable(): boolean;
  6363. /**
  6364. * Gets current buffer's data
  6365. * @returns a DataArray or null
  6366. */
  6367. getData(): Nullable<DataArray>;
  6368. /**
  6369. * Gets underlying native buffer
  6370. * @returns underlying native buffer
  6371. */
  6372. getBuffer(): Nullable<DataBuffer>;
  6373. /**
  6374. * Gets the stride in float32 units (i.e. byte stride / 4).
  6375. * May not be an integer if the byte stride is not divisible by 4.
  6376. * @returns the stride in float32 units
  6377. * @deprecated Please use byteStride instead.
  6378. */
  6379. getStrideSize(): number;
  6380. /**
  6381. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6382. * @param data defines the data to store
  6383. */
  6384. create(data?: Nullable<DataArray>): void;
  6385. /** @hidden */
  6386. _rebuild(): void;
  6387. /**
  6388. * Update current buffer data
  6389. * @param data defines the data to store
  6390. */
  6391. update(data: DataArray): void;
  6392. /**
  6393. * Updates the data directly.
  6394. * @param data the new data
  6395. * @param offset the new offset
  6396. * @param vertexCount the vertex count (optional)
  6397. * @param useBytes set to true if the offset is in bytes
  6398. */
  6399. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6400. /**
  6401. * Release all resources
  6402. */
  6403. dispose(): void;
  6404. }
  6405. /**
  6406. * Specialized buffer used to store vertex data
  6407. */
  6408. export class VertexBuffer {
  6409. /** @hidden */
  6410. _buffer: Buffer;
  6411. private _kind;
  6412. private _size;
  6413. private _ownsBuffer;
  6414. private _instanced;
  6415. private _instanceDivisor;
  6416. /**
  6417. * The byte type.
  6418. */
  6419. static readonly BYTE: number;
  6420. /**
  6421. * The unsigned byte type.
  6422. */
  6423. static readonly UNSIGNED_BYTE: number;
  6424. /**
  6425. * The short type.
  6426. */
  6427. static readonly SHORT: number;
  6428. /**
  6429. * The unsigned short type.
  6430. */
  6431. static readonly UNSIGNED_SHORT: number;
  6432. /**
  6433. * The integer type.
  6434. */
  6435. static readonly INT: number;
  6436. /**
  6437. * The unsigned integer type.
  6438. */
  6439. static readonly UNSIGNED_INT: number;
  6440. /**
  6441. * The float type.
  6442. */
  6443. static readonly FLOAT: number;
  6444. /**
  6445. * Gets or sets the instance divisor when in instanced mode
  6446. */
  6447. get instanceDivisor(): number;
  6448. set instanceDivisor(value: number);
  6449. /**
  6450. * Gets the byte stride.
  6451. */
  6452. readonly byteStride: number;
  6453. /**
  6454. * Gets the byte offset.
  6455. */
  6456. readonly byteOffset: number;
  6457. /**
  6458. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6459. */
  6460. readonly normalized: boolean;
  6461. /**
  6462. * Gets the data type of each component in the array.
  6463. */
  6464. readonly type: number;
  6465. /**
  6466. * Constructor
  6467. * @param engine the engine
  6468. * @param data the data to use for this vertex buffer
  6469. * @param kind the vertex buffer kind
  6470. * @param updatable whether the data is updatable
  6471. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6472. * @param stride the stride (optional)
  6473. * @param instanced whether the buffer is instanced (optional)
  6474. * @param offset the offset of the data (optional)
  6475. * @param size the number of components (optional)
  6476. * @param type the type of the component (optional)
  6477. * @param normalized whether the data contains normalized data (optional)
  6478. * @param useBytes set to true if stride and offset are in bytes (optional)
  6479. * @param divisor defines the instance divisor to use (1 by default)
  6480. */
  6481. 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, divisor?: number);
  6482. /** @hidden */
  6483. _rebuild(): void;
  6484. /**
  6485. * Returns the kind of the VertexBuffer (string)
  6486. * @returns a string
  6487. */
  6488. getKind(): string;
  6489. /**
  6490. * Gets a boolean indicating if the VertexBuffer is updatable?
  6491. * @returns true if the buffer is updatable
  6492. */
  6493. isUpdatable(): boolean;
  6494. /**
  6495. * Gets current buffer's data
  6496. * @returns a DataArray or null
  6497. */
  6498. getData(): Nullable<DataArray>;
  6499. /**
  6500. * Gets underlying native buffer
  6501. * @returns underlying native buffer
  6502. */
  6503. getBuffer(): Nullable<DataBuffer>;
  6504. /**
  6505. * Gets the stride in float32 units (i.e. byte stride / 4).
  6506. * May not be an integer if the byte stride is not divisible by 4.
  6507. * @returns the stride in float32 units
  6508. * @deprecated Please use byteStride instead.
  6509. */
  6510. getStrideSize(): number;
  6511. /**
  6512. * Returns the offset as a multiple of the type byte length.
  6513. * @returns the offset in bytes
  6514. * @deprecated Please use byteOffset instead.
  6515. */
  6516. getOffset(): number;
  6517. /**
  6518. * Returns the number of components per vertex attribute (integer)
  6519. * @returns the size in float
  6520. */
  6521. getSize(): number;
  6522. /**
  6523. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6524. * @returns true if this buffer is instanced
  6525. */
  6526. getIsInstanced(): boolean;
  6527. /**
  6528. * Returns the instancing divisor, zero for non-instanced (integer).
  6529. * @returns a number
  6530. */
  6531. getInstanceDivisor(): number;
  6532. /**
  6533. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6534. * @param data defines the data to store
  6535. */
  6536. create(data?: DataArray): void;
  6537. /**
  6538. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6539. * This function will create a new buffer if the current one is not updatable
  6540. * @param data defines the data to store
  6541. */
  6542. update(data: DataArray): void;
  6543. /**
  6544. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6545. * Returns the directly updated WebGLBuffer.
  6546. * @param data the new data
  6547. * @param offset the new offset
  6548. * @param useBytes set to true if the offset is in bytes
  6549. */
  6550. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6551. /**
  6552. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6553. */
  6554. dispose(): void;
  6555. /**
  6556. * Enumerates each value of this vertex buffer as numbers.
  6557. * @param count the number of values to enumerate
  6558. * @param callback the callback function called for each value
  6559. */
  6560. forEach(count: number, callback: (value: number, index: number) => void): void;
  6561. /**
  6562. * Positions
  6563. */
  6564. static readonly PositionKind: string;
  6565. /**
  6566. * Normals
  6567. */
  6568. static readonly NormalKind: string;
  6569. /**
  6570. * Tangents
  6571. */
  6572. static readonly TangentKind: string;
  6573. /**
  6574. * Texture coordinates
  6575. */
  6576. static readonly UVKind: string;
  6577. /**
  6578. * Texture coordinates 2
  6579. */
  6580. static readonly UV2Kind: string;
  6581. /**
  6582. * Texture coordinates 3
  6583. */
  6584. static readonly UV3Kind: string;
  6585. /**
  6586. * Texture coordinates 4
  6587. */
  6588. static readonly UV4Kind: string;
  6589. /**
  6590. * Texture coordinates 5
  6591. */
  6592. static readonly UV5Kind: string;
  6593. /**
  6594. * Texture coordinates 6
  6595. */
  6596. static readonly UV6Kind: string;
  6597. /**
  6598. * Colors
  6599. */
  6600. static readonly ColorKind: string;
  6601. /**
  6602. * Matrix indices (for bones)
  6603. */
  6604. static readonly MatricesIndicesKind: string;
  6605. /**
  6606. * Matrix weights (for bones)
  6607. */
  6608. static readonly MatricesWeightsKind: string;
  6609. /**
  6610. * Additional matrix indices (for bones)
  6611. */
  6612. static readonly MatricesIndicesExtraKind: string;
  6613. /**
  6614. * Additional matrix weights (for bones)
  6615. */
  6616. static readonly MatricesWeightsExtraKind: string;
  6617. /**
  6618. * Deduces the stride given a kind.
  6619. * @param kind The kind string to deduce
  6620. * @returns The deduced stride
  6621. */
  6622. static DeduceStride(kind: string): number;
  6623. /**
  6624. * Gets the byte length of the given type.
  6625. * @param type the type
  6626. * @returns the number of bytes
  6627. */
  6628. static GetTypeByteLength(type: number): number;
  6629. /**
  6630. * Enumerates each value of the given parameters as numbers.
  6631. * @param data the data to enumerate
  6632. * @param byteOffset the byte offset of the data
  6633. * @param byteStride the byte stride of the data
  6634. * @param componentCount the number of components per element
  6635. * @param componentType the type of the component
  6636. * @param count the number of values to enumerate
  6637. * @param normalized whether the data is normalized
  6638. * @param callback the callback function called for each value
  6639. */
  6640. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6641. private static _GetFloatValue;
  6642. }
  6643. }
  6644. declare module "babylonjs/Collisions/intersectionInfo" {
  6645. import { Nullable } from "babylonjs/types";
  6646. /**
  6647. * @hidden
  6648. */
  6649. export class IntersectionInfo {
  6650. bu: Nullable<number>;
  6651. bv: Nullable<number>;
  6652. distance: number;
  6653. faceId: number;
  6654. subMeshId: number;
  6655. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6656. }
  6657. }
  6658. declare module "babylonjs/Maths/math.plane" {
  6659. import { DeepImmutable } from "babylonjs/types";
  6660. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6661. /**
  6662. * Represens a plane by the equation ax + by + cz + d = 0
  6663. */
  6664. export class Plane {
  6665. private static _TmpMatrix;
  6666. /**
  6667. * Normal of the plane (a,b,c)
  6668. */
  6669. normal: Vector3;
  6670. /**
  6671. * d component of the plane
  6672. */
  6673. d: number;
  6674. /**
  6675. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6676. * @param a a component of the plane
  6677. * @param b b component of the plane
  6678. * @param c c component of the plane
  6679. * @param d d component of the plane
  6680. */
  6681. constructor(a: number, b: number, c: number, d: number);
  6682. /**
  6683. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6684. */
  6685. asArray(): number[];
  6686. /**
  6687. * @returns a new plane copied from the current Plane.
  6688. */
  6689. clone(): Plane;
  6690. /**
  6691. * @returns the string "Plane".
  6692. */
  6693. getClassName(): string;
  6694. /**
  6695. * @returns the Plane hash code.
  6696. */
  6697. getHashCode(): number;
  6698. /**
  6699. * Normalize the current Plane in place.
  6700. * @returns the updated Plane.
  6701. */
  6702. normalize(): Plane;
  6703. /**
  6704. * Applies a transformation the plane and returns the result
  6705. * @param transformation the transformation matrix to be applied to the plane
  6706. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6707. */
  6708. transform(transformation: DeepImmutable<Matrix>): Plane;
  6709. /**
  6710. * Calcualtte the dot product between the point and the plane normal
  6711. * @param point point to calculate the dot product with
  6712. * @returns the dot product (float) of the point coordinates and the plane normal.
  6713. */
  6714. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6715. /**
  6716. * Updates the current Plane from the plane defined by the three given points.
  6717. * @param point1 one of the points used to contruct the plane
  6718. * @param point2 one of the points used to contruct the plane
  6719. * @param point3 one of the points used to contruct the plane
  6720. * @returns the updated Plane.
  6721. */
  6722. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6723. /**
  6724. * Checks if the plane is facing a given direction
  6725. * @param direction the direction to check if the plane is facing
  6726. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6727. * @returns True is the vector "direction" is the same side than the plane normal.
  6728. */
  6729. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6730. /**
  6731. * Calculates the distance to a point
  6732. * @param point point to calculate distance to
  6733. * @returns the signed distance (float) from the given point to the Plane.
  6734. */
  6735. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6736. /**
  6737. * Creates a plane from an array
  6738. * @param array the array to create a plane from
  6739. * @returns a new Plane from the given array.
  6740. */
  6741. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6742. /**
  6743. * Creates a plane from three points
  6744. * @param point1 point used to create the plane
  6745. * @param point2 point used to create the plane
  6746. * @param point3 point used to create the plane
  6747. * @returns a new Plane defined by the three given points.
  6748. */
  6749. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6750. /**
  6751. * Creates a plane from an origin point and a normal
  6752. * @param origin origin of the plane to be constructed
  6753. * @param normal normal of the plane to be constructed
  6754. * @returns a new Plane the normal vector to this plane at the given origin point.
  6755. * Note : the vector "normal" is updated because normalized.
  6756. */
  6757. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6758. /**
  6759. * Calculates the distance from a plane and a point
  6760. * @param origin origin of the plane to be constructed
  6761. * @param normal normal of the plane to be constructed
  6762. * @param point point to calculate distance to
  6763. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6764. */
  6765. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6766. }
  6767. }
  6768. declare module "babylonjs/Culling/boundingSphere" {
  6769. import { DeepImmutable } from "babylonjs/types";
  6770. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6771. import { Plane } from "babylonjs/Maths/math.plane";
  6772. /**
  6773. * Class used to store bounding sphere information
  6774. */
  6775. export class BoundingSphere {
  6776. /**
  6777. * Gets the center of the bounding sphere in local space
  6778. */
  6779. readonly center: Vector3;
  6780. /**
  6781. * Radius of the bounding sphere in local space
  6782. */
  6783. radius: number;
  6784. /**
  6785. * Gets the center of the bounding sphere in world space
  6786. */
  6787. readonly centerWorld: Vector3;
  6788. /**
  6789. * Radius of the bounding sphere in world space
  6790. */
  6791. radiusWorld: number;
  6792. /**
  6793. * Gets the minimum vector in local space
  6794. */
  6795. readonly minimum: Vector3;
  6796. /**
  6797. * Gets the maximum vector in local space
  6798. */
  6799. readonly maximum: Vector3;
  6800. private _worldMatrix;
  6801. private static readonly TmpVector3;
  6802. /**
  6803. * Creates a new bounding sphere
  6804. * @param min defines the minimum vector (in local space)
  6805. * @param max defines the maximum vector (in local space)
  6806. * @param worldMatrix defines the new world matrix
  6807. */
  6808. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6809. /**
  6810. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6811. * @param min defines the new minimum vector (in local space)
  6812. * @param max defines the new maximum vector (in local space)
  6813. * @param worldMatrix defines the new world matrix
  6814. */
  6815. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6816. /**
  6817. * Scale the current bounding sphere by applying a scale factor
  6818. * @param factor defines the scale factor to apply
  6819. * @returns the current bounding box
  6820. */
  6821. scale(factor: number): BoundingSphere;
  6822. /**
  6823. * Gets the world matrix of the bounding box
  6824. * @returns a matrix
  6825. */
  6826. getWorldMatrix(): DeepImmutable<Matrix>;
  6827. /** @hidden */
  6828. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6829. /**
  6830. * Tests if the bounding sphere is intersecting the frustum planes
  6831. * @param frustumPlanes defines the frustum planes to test
  6832. * @returns true if there is an intersection
  6833. */
  6834. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6835. /**
  6836. * Tests if the bounding sphere center is in between the frustum planes.
  6837. * Used for optimistic fast inclusion.
  6838. * @param frustumPlanes defines the frustum planes to test
  6839. * @returns true if the sphere center is in between the frustum planes
  6840. */
  6841. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6842. /**
  6843. * Tests if a point is inside the bounding sphere
  6844. * @param point defines the point to test
  6845. * @returns true if the point is inside the bounding sphere
  6846. */
  6847. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6848. /**
  6849. * Checks if two sphere intersct
  6850. * @param sphere0 sphere 0
  6851. * @param sphere1 sphere 1
  6852. * @returns true if the speres intersect
  6853. */
  6854. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6855. }
  6856. }
  6857. declare module "babylonjs/Culling/boundingBox" {
  6858. import { DeepImmutable } from "babylonjs/types";
  6859. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6860. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6861. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6862. import { Plane } from "babylonjs/Maths/math.plane";
  6863. /**
  6864. * Class used to store bounding box information
  6865. */
  6866. export class BoundingBox implements ICullable {
  6867. /**
  6868. * Gets the 8 vectors representing the bounding box in local space
  6869. */
  6870. readonly vectors: Vector3[];
  6871. /**
  6872. * Gets the center of the bounding box in local space
  6873. */
  6874. readonly center: Vector3;
  6875. /**
  6876. * Gets the center of the bounding box in world space
  6877. */
  6878. readonly centerWorld: Vector3;
  6879. /**
  6880. * Gets the extend size in local space
  6881. */
  6882. readonly extendSize: Vector3;
  6883. /**
  6884. * Gets the extend size in world space
  6885. */
  6886. readonly extendSizeWorld: Vector3;
  6887. /**
  6888. * Gets the OBB (object bounding box) directions
  6889. */
  6890. readonly directions: Vector3[];
  6891. /**
  6892. * Gets the 8 vectors representing the bounding box in world space
  6893. */
  6894. readonly vectorsWorld: Vector3[];
  6895. /**
  6896. * Gets the minimum vector in world space
  6897. */
  6898. readonly minimumWorld: Vector3;
  6899. /**
  6900. * Gets the maximum vector in world space
  6901. */
  6902. readonly maximumWorld: Vector3;
  6903. /**
  6904. * Gets the minimum vector in local space
  6905. */
  6906. readonly minimum: Vector3;
  6907. /**
  6908. * Gets the maximum vector in local space
  6909. */
  6910. readonly maximum: Vector3;
  6911. private _worldMatrix;
  6912. private static readonly TmpVector3;
  6913. /**
  6914. * @hidden
  6915. */
  6916. _tag: number;
  6917. /**
  6918. * Creates a new bounding box
  6919. * @param min defines the minimum vector (in local space)
  6920. * @param max defines the maximum vector (in local space)
  6921. * @param worldMatrix defines the new world matrix
  6922. */
  6923. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6924. /**
  6925. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6926. * @param min defines the new minimum vector (in local space)
  6927. * @param max defines the new maximum vector (in local space)
  6928. * @param worldMatrix defines the new world matrix
  6929. */
  6930. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6931. /**
  6932. * Scale the current bounding box by applying a scale factor
  6933. * @param factor defines the scale factor to apply
  6934. * @returns the current bounding box
  6935. */
  6936. scale(factor: number): BoundingBox;
  6937. /**
  6938. * Gets the world matrix of the bounding box
  6939. * @returns a matrix
  6940. */
  6941. getWorldMatrix(): DeepImmutable<Matrix>;
  6942. /** @hidden */
  6943. _update(world: DeepImmutable<Matrix>): void;
  6944. /**
  6945. * Tests if the bounding box is intersecting the frustum planes
  6946. * @param frustumPlanes defines the frustum planes to test
  6947. * @returns true if there is an intersection
  6948. */
  6949. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6950. /**
  6951. * Tests if the bounding box is entirely inside the frustum planes
  6952. * @param frustumPlanes defines the frustum planes to test
  6953. * @returns true if there is an inclusion
  6954. */
  6955. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6956. /**
  6957. * Tests if a point is inside the bounding box
  6958. * @param point defines the point to test
  6959. * @returns true if the point is inside the bounding box
  6960. */
  6961. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6962. /**
  6963. * Tests if the bounding box intersects with a bounding sphere
  6964. * @param sphere defines the sphere to test
  6965. * @returns true if there is an intersection
  6966. */
  6967. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6968. /**
  6969. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6970. * @param min defines the min vector to use
  6971. * @param max defines the max vector to use
  6972. * @returns true if there is an intersection
  6973. */
  6974. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6975. /**
  6976. * Tests if two bounding boxes are intersections
  6977. * @param box0 defines the first box to test
  6978. * @param box1 defines the second box to test
  6979. * @returns true if there is an intersection
  6980. */
  6981. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6982. /**
  6983. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6984. * @param minPoint defines the minimum vector of the bounding box
  6985. * @param maxPoint defines the maximum vector of the bounding box
  6986. * @param sphereCenter defines the sphere center
  6987. * @param sphereRadius defines the sphere radius
  6988. * @returns true if there is an intersection
  6989. */
  6990. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6991. /**
  6992. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6993. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6994. * @param frustumPlanes defines the frustum planes to test
  6995. * @return true if there is an inclusion
  6996. */
  6997. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6998. /**
  6999. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7000. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7001. * @param frustumPlanes defines the frustum planes to test
  7002. * @return true if there is an intersection
  7003. */
  7004. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7005. }
  7006. }
  7007. declare module "babylonjs/Collisions/collider" {
  7008. import { Nullable, IndicesArray } from "babylonjs/types";
  7009. import { Vector3 } from "babylonjs/Maths/math.vector";
  7010. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7011. import { Plane } from "babylonjs/Maths/math.plane";
  7012. /** @hidden */
  7013. export class Collider {
  7014. /** Define if a collision was found */
  7015. collisionFound: boolean;
  7016. /**
  7017. * Define last intersection point in local space
  7018. */
  7019. intersectionPoint: Vector3;
  7020. /**
  7021. * Define last collided mesh
  7022. */
  7023. collidedMesh: Nullable<AbstractMesh>;
  7024. private _collisionPoint;
  7025. private _planeIntersectionPoint;
  7026. private _tempVector;
  7027. private _tempVector2;
  7028. private _tempVector3;
  7029. private _tempVector4;
  7030. private _edge;
  7031. private _baseToVertex;
  7032. private _destinationPoint;
  7033. private _slidePlaneNormal;
  7034. private _displacementVector;
  7035. /** @hidden */
  7036. _radius: Vector3;
  7037. /** @hidden */
  7038. _retry: number;
  7039. private _velocity;
  7040. private _basePoint;
  7041. private _epsilon;
  7042. /** @hidden */
  7043. _velocityWorldLength: number;
  7044. /** @hidden */
  7045. _basePointWorld: Vector3;
  7046. private _velocityWorld;
  7047. private _normalizedVelocity;
  7048. /** @hidden */
  7049. _initialVelocity: Vector3;
  7050. /** @hidden */
  7051. _initialPosition: Vector3;
  7052. private _nearestDistance;
  7053. private _collisionMask;
  7054. get collisionMask(): number;
  7055. set collisionMask(mask: number);
  7056. /**
  7057. * Gets the plane normal used to compute the sliding response (in local space)
  7058. */
  7059. get slidePlaneNormal(): Vector3;
  7060. /** @hidden */
  7061. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7062. /** @hidden */
  7063. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7064. /** @hidden */
  7065. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7066. /** @hidden */
  7067. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7068. /** @hidden */
  7069. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7070. /** @hidden */
  7071. _getResponse(pos: Vector3, vel: Vector3): void;
  7072. }
  7073. }
  7074. declare module "babylonjs/Culling/boundingInfo" {
  7075. import { DeepImmutable } from "babylonjs/types";
  7076. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7077. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7078. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7079. import { Plane } from "babylonjs/Maths/math.plane";
  7080. import { Collider } from "babylonjs/Collisions/collider";
  7081. /**
  7082. * Interface for cullable objects
  7083. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7084. */
  7085. export interface ICullable {
  7086. /**
  7087. * Checks if the object or part of the object is in the frustum
  7088. * @param frustumPlanes Camera near/planes
  7089. * @returns true if the object is in frustum otherwise false
  7090. */
  7091. isInFrustum(frustumPlanes: Plane[]): boolean;
  7092. /**
  7093. * Checks if a cullable object (mesh...) is in the camera frustum
  7094. * Unlike isInFrustum this cheks the full bounding box
  7095. * @param frustumPlanes Camera near/planes
  7096. * @returns true if the object is in frustum otherwise false
  7097. */
  7098. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7099. }
  7100. /**
  7101. * Info for a bounding data of a mesh
  7102. */
  7103. export class BoundingInfo implements ICullable {
  7104. /**
  7105. * Bounding box for the mesh
  7106. */
  7107. readonly boundingBox: BoundingBox;
  7108. /**
  7109. * Bounding sphere for the mesh
  7110. */
  7111. readonly boundingSphere: BoundingSphere;
  7112. private _isLocked;
  7113. private static readonly TmpVector3;
  7114. /**
  7115. * Constructs bounding info
  7116. * @param minimum min vector of the bounding box/sphere
  7117. * @param maximum max vector of the bounding box/sphere
  7118. * @param worldMatrix defines the new world matrix
  7119. */
  7120. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7121. /**
  7122. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7123. * @param min defines the new minimum vector (in local space)
  7124. * @param max defines the new maximum vector (in local space)
  7125. * @param worldMatrix defines the new world matrix
  7126. */
  7127. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7128. /**
  7129. * min vector of the bounding box/sphere
  7130. */
  7131. get minimum(): Vector3;
  7132. /**
  7133. * max vector of the bounding box/sphere
  7134. */
  7135. get maximum(): Vector3;
  7136. /**
  7137. * If the info is locked and won't be updated to avoid perf overhead
  7138. */
  7139. get isLocked(): boolean;
  7140. set isLocked(value: boolean);
  7141. /**
  7142. * Updates the bounding sphere and box
  7143. * @param world world matrix to be used to update
  7144. */
  7145. update(world: DeepImmutable<Matrix>): void;
  7146. /**
  7147. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7148. * @param center New center of the bounding info
  7149. * @param extend New extend of the bounding info
  7150. * @returns the current bounding info
  7151. */
  7152. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7153. /**
  7154. * Scale the current bounding info by applying a scale factor
  7155. * @param factor defines the scale factor to apply
  7156. * @returns the current bounding info
  7157. */
  7158. scale(factor: number): BoundingInfo;
  7159. /**
  7160. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7161. * @param frustumPlanes defines the frustum to test
  7162. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7163. * @returns true if the bounding info is in the frustum planes
  7164. */
  7165. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7166. /**
  7167. * Gets the world distance between the min and max points of the bounding box
  7168. */
  7169. get diagonalLength(): number;
  7170. /**
  7171. * Checks if a cullable object (mesh...) is in the camera frustum
  7172. * Unlike isInFrustum this cheks the full bounding box
  7173. * @param frustumPlanes Camera near/planes
  7174. * @returns true if the object is in frustum otherwise false
  7175. */
  7176. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7177. /** @hidden */
  7178. _checkCollision(collider: Collider): boolean;
  7179. /**
  7180. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7181. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7182. * @param point the point to check intersection with
  7183. * @returns if the point intersects
  7184. */
  7185. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7186. /**
  7187. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7188. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7189. * @param boundingInfo the bounding info to check intersection with
  7190. * @param precise if the intersection should be done using OBB
  7191. * @returns if the bounding info intersects
  7192. */
  7193. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7194. }
  7195. }
  7196. declare module "babylonjs/Maths/math.functions" {
  7197. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7198. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7199. /**
  7200. * Extracts minimum and maximum values from a list of indexed positions
  7201. * @param positions defines the positions to use
  7202. * @param indices defines the indices to the positions
  7203. * @param indexStart defines the start index
  7204. * @param indexCount defines the end index
  7205. * @param bias defines bias value to add to the result
  7206. * @return minimum and maximum values
  7207. */
  7208. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7209. minimum: Vector3;
  7210. maximum: Vector3;
  7211. };
  7212. /**
  7213. * Extracts minimum and maximum values from a list of positions
  7214. * @param positions defines the positions to use
  7215. * @param start defines the start index in the positions array
  7216. * @param count defines the number of positions to handle
  7217. * @param bias defines bias value to add to the result
  7218. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7219. * @return minimum and maximum values
  7220. */
  7221. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7222. minimum: Vector3;
  7223. maximum: Vector3;
  7224. };
  7225. }
  7226. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7227. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7228. /** @hidden */
  7229. export class WebGLDataBuffer extends DataBuffer {
  7230. private _buffer;
  7231. constructor(resource: WebGLBuffer);
  7232. get underlyingResource(): any;
  7233. }
  7234. }
  7235. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7236. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7237. import { Nullable } from "babylonjs/types";
  7238. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7239. /** @hidden */
  7240. export class WebGLPipelineContext implements IPipelineContext {
  7241. engine: ThinEngine;
  7242. program: Nullable<WebGLProgram>;
  7243. context?: WebGLRenderingContext;
  7244. vertexShader?: WebGLShader;
  7245. fragmentShader?: WebGLShader;
  7246. isParallelCompiled: boolean;
  7247. onCompiled?: () => void;
  7248. transformFeedback?: WebGLTransformFeedback | null;
  7249. vertexCompilationError: Nullable<string>;
  7250. fragmentCompilationError: Nullable<string>;
  7251. programLinkError: Nullable<string>;
  7252. programValidationError: Nullable<string>;
  7253. get isAsync(): boolean;
  7254. get isReady(): boolean;
  7255. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7256. _getVertexShaderCode(): string | null;
  7257. _getFragmentShaderCode(): string | null;
  7258. }
  7259. }
  7260. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7261. import { FloatArray, Nullable } from "babylonjs/types";
  7262. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7263. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7264. module "babylonjs/Engines/thinEngine" {
  7265. interface ThinEngine {
  7266. /**
  7267. * Create an uniform buffer
  7268. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7269. * @param elements defines the content of the uniform buffer
  7270. * @returns the webGL uniform buffer
  7271. */
  7272. createUniformBuffer(elements: FloatArray): DataBuffer;
  7273. /**
  7274. * Create a dynamic uniform buffer
  7275. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7276. * @param elements defines the content of the uniform buffer
  7277. * @returns the webGL uniform buffer
  7278. */
  7279. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7280. /**
  7281. * Update an existing uniform buffer
  7282. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7283. * @param uniformBuffer defines the target uniform buffer
  7284. * @param elements defines the content to update
  7285. * @param offset defines the offset in the uniform buffer where update should start
  7286. * @param count defines the size of the data to update
  7287. */
  7288. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7289. /**
  7290. * Bind an uniform buffer to the current webGL context
  7291. * @param buffer defines the buffer to bind
  7292. */
  7293. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7294. /**
  7295. * Bind a buffer to the current webGL context at a given location
  7296. * @param buffer defines the buffer to bind
  7297. * @param location defines the index where to bind the buffer
  7298. */
  7299. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7300. /**
  7301. * Bind a specific block at a given index in a specific shader program
  7302. * @param pipelineContext defines the pipeline context to use
  7303. * @param blockName defines the block name
  7304. * @param index defines the index where to bind the block
  7305. */
  7306. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7307. }
  7308. }
  7309. }
  7310. declare module "babylonjs/Materials/uniformBuffer" {
  7311. import { Nullable, FloatArray } from "babylonjs/types";
  7312. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7313. import { Engine } from "babylonjs/Engines/engine";
  7314. import { Effect } from "babylonjs/Materials/effect";
  7315. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7316. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7317. import { Color3 } from "babylonjs/Maths/math.color";
  7318. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7319. /**
  7320. * Uniform buffer objects.
  7321. *
  7322. * Handles blocks of uniform on the GPU.
  7323. *
  7324. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7325. *
  7326. * For more information, please refer to :
  7327. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7328. */
  7329. export class UniformBuffer {
  7330. private _engine;
  7331. private _buffer;
  7332. private _data;
  7333. private _bufferData;
  7334. private _dynamic?;
  7335. private _uniformLocations;
  7336. private _uniformSizes;
  7337. private _uniformLocationPointer;
  7338. private _needSync;
  7339. private _noUBO;
  7340. private _currentEffect;
  7341. /** @hidden */
  7342. _alreadyBound: boolean;
  7343. private static _MAX_UNIFORM_SIZE;
  7344. private static _tempBuffer;
  7345. /**
  7346. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7347. * This is dynamic to allow compat with webgl 1 and 2.
  7348. * You will need to pass the name of the uniform as well as the value.
  7349. */
  7350. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7351. /**
  7352. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7353. * This is dynamic to allow compat with webgl 1 and 2.
  7354. * You will need to pass the name of the uniform as well as the value.
  7355. */
  7356. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7357. /**
  7358. * Lambda to Update a single float in a uniform buffer.
  7359. * This is dynamic to allow compat with webgl 1 and 2.
  7360. * You will need to pass the name of the uniform as well as the value.
  7361. */
  7362. updateFloat: (name: string, x: number) => void;
  7363. /**
  7364. * Lambda to Update a vec2 of float in a uniform buffer.
  7365. * This is dynamic to allow compat with webgl 1 and 2.
  7366. * You will need to pass the name of the uniform as well as the value.
  7367. */
  7368. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7369. /**
  7370. * Lambda to Update a vec3 of float in a uniform buffer.
  7371. * This is dynamic to allow compat with webgl 1 and 2.
  7372. * You will need to pass the name of the uniform as well as the value.
  7373. */
  7374. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7375. /**
  7376. * Lambda to Update a vec4 of float in a uniform buffer.
  7377. * This is dynamic to allow compat with webgl 1 and 2.
  7378. * You will need to pass the name of the uniform as well as the value.
  7379. */
  7380. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7381. /**
  7382. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7383. * This is dynamic to allow compat with webgl 1 and 2.
  7384. * You will need to pass the name of the uniform as well as the value.
  7385. */
  7386. updateMatrix: (name: string, mat: Matrix) => void;
  7387. /**
  7388. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7389. * This is dynamic to allow compat with webgl 1 and 2.
  7390. * You will need to pass the name of the uniform as well as the value.
  7391. */
  7392. updateVector3: (name: string, vector: Vector3) => void;
  7393. /**
  7394. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7395. * This is dynamic to allow compat with webgl 1 and 2.
  7396. * You will need to pass the name of the uniform as well as the value.
  7397. */
  7398. updateVector4: (name: string, vector: Vector4) => void;
  7399. /**
  7400. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7401. * This is dynamic to allow compat with webgl 1 and 2.
  7402. * You will need to pass the name of the uniform as well as the value.
  7403. */
  7404. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7405. /**
  7406. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7407. * This is dynamic to allow compat with webgl 1 and 2.
  7408. * You will need to pass the name of the uniform as well as the value.
  7409. */
  7410. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7411. /**
  7412. * Instantiates a new Uniform buffer objects.
  7413. *
  7414. * Handles blocks of uniform on the GPU.
  7415. *
  7416. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7417. *
  7418. * For more information, please refer to :
  7419. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7420. * @param engine Define the engine the buffer is associated with
  7421. * @param data Define the data contained in the buffer
  7422. * @param dynamic Define if the buffer is updatable
  7423. */
  7424. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7425. /**
  7426. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7427. * or just falling back on setUniformXXX calls.
  7428. */
  7429. get useUbo(): boolean;
  7430. /**
  7431. * Indicates if the WebGL underlying uniform buffer is in sync
  7432. * with the javascript cache data.
  7433. */
  7434. get isSync(): boolean;
  7435. /**
  7436. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7437. * Also, a dynamic UniformBuffer will disable cache verification and always
  7438. * update the underlying WebGL uniform buffer to the GPU.
  7439. * @returns if Dynamic, otherwise false
  7440. */
  7441. isDynamic(): boolean;
  7442. /**
  7443. * The data cache on JS side.
  7444. * @returns the underlying data as a float array
  7445. */
  7446. getData(): Float32Array;
  7447. /**
  7448. * The underlying WebGL Uniform buffer.
  7449. * @returns the webgl buffer
  7450. */
  7451. getBuffer(): Nullable<DataBuffer>;
  7452. /**
  7453. * std140 layout specifies how to align data within an UBO structure.
  7454. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7455. * for specs.
  7456. */
  7457. private _fillAlignment;
  7458. /**
  7459. * Adds an uniform in the buffer.
  7460. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7461. * for the layout to be correct !
  7462. * @param name Name of the uniform, as used in the uniform block in the shader.
  7463. * @param size Data size, or data directly.
  7464. */
  7465. addUniform(name: string, size: number | number[]): void;
  7466. /**
  7467. * Adds a Matrix 4x4 to the uniform buffer.
  7468. * @param name Name of the uniform, as used in the uniform block in the shader.
  7469. * @param mat A 4x4 matrix.
  7470. */
  7471. addMatrix(name: string, mat: Matrix): void;
  7472. /**
  7473. * Adds a vec2 to the uniform buffer.
  7474. * @param name Name of the uniform, as used in the uniform block in the shader.
  7475. * @param x Define the x component value of the vec2
  7476. * @param y Define the y component value of the vec2
  7477. */
  7478. addFloat2(name: string, x: number, y: number): void;
  7479. /**
  7480. * Adds a vec3 to the uniform buffer.
  7481. * @param name Name of the uniform, as used in the uniform block in the shader.
  7482. * @param x Define the x component value of the vec3
  7483. * @param y Define the y component value of the vec3
  7484. * @param z Define the z component value of the vec3
  7485. */
  7486. addFloat3(name: string, x: number, y: number, z: number): void;
  7487. /**
  7488. * Adds a vec3 to the uniform buffer.
  7489. * @param name Name of the uniform, as used in the uniform block in the shader.
  7490. * @param color Define the vec3 from a Color
  7491. */
  7492. addColor3(name: string, color: Color3): void;
  7493. /**
  7494. * Adds a vec4 to the uniform buffer.
  7495. * @param name Name of the uniform, as used in the uniform block in the shader.
  7496. * @param color Define the rgb components from a Color
  7497. * @param alpha Define the a component of the vec4
  7498. */
  7499. addColor4(name: string, color: Color3, alpha: number): void;
  7500. /**
  7501. * Adds a vec3 to the uniform buffer.
  7502. * @param name Name of the uniform, as used in the uniform block in the shader.
  7503. * @param vector Define the vec3 components from a Vector
  7504. */
  7505. addVector3(name: string, vector: Vector3): void;
  7506. /**
  7507. * Adds a Matrix 3x3 to the uniform buffer.
  7508. * @param name Name of the uniform, as used in the uniform block in the shader.
  7509. */
  7510. addMatrix3x3(name: string): void;
  7511. /**
  7512. * Adds a Matrix 2x2 to the uniform buffer.
  7513. * @param name Name of the uniform, as used in the uniform block in the shader.
  7514. */
  7515. addMatrix2x2(name: string): void;
  7516. /**
  7517. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7518. */
  7519. create(): void;
  7520. /** @hidden */
  7521. _rebuild(): void;
  7522. /**
  7523. * Updates the WebGL Uniform Buffer on the GPU.
  7524. * If the `dynamic` flag is set to true, no cache comparison is done.
  7525. * Otherwise, the buffer will be updated only if the cache differs.
  7526. */
  7527. update(): void;
  7528. /**
  7529. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7530. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7531. * @param data Define the flattened data
  7532. * @param size Define the size of the data.
  7533. */
  7534. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7535. private _valueCache;
  7536. private _cacheMatrix;
  7537. private _updateMatrix3x3ForUniform;
  7538. private _updateMatrix3x3ForEffect;
  7539. private _updateMatrix2x2ForEffect;
  7540. private _updateMatrix2x2ForUniform;
  7541. private _updateFloatForEffect;
  7542. private _updateFloatForUniform;
  7543. private _updateFloat2ForEffect;
  7544. private _updateFloat2ForUniform;
  7545. private _updateFloat3ForEffect;
  7546. private _updateFloat3ForUniform;
  7547. private _updateFloat4ForEffect;
  7548. private _updateFloat4ForUniform;
  7549. private _updateMatrixForEffect;
  7550. private _updateMatrixForUniform;
  7551. private _updateVector3ForEffect;
  7552. private _updateVector3ForUniform;
  7553. private _updateVector4ForEffect;
  7554. private _updateVector4ForUniform;
  7555. private _updateColor3ForEffect;
  7556. private _updateColor3ForUniform;
  7557. private _updateColor4ForEffect;
  7558. private _updateColor4ForUniform;
  7559. /**
  7560. * Sets a sampler uniform on the effect.
  7561. * @param name Define the name of the sampler.
  7562. * @param texture Define the texture to set in the sampler
  7563. */
  7564. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7565. /**
  7566. * Directly updates the value of the uniform in the cache AND on the GPU.
  7567. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7568. * @param data Define the flattened data
  7569. */
  7570. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7571. /**
  7572. * Binds this uniform buffer to an effect.
  7573. * @param effect Define the effect to bind the buffer to
  7574. * @param name Name of the uniform block in the shader.
  7575. */
  7576. bindToEffect(effect: Effect, name: string): void;
  7577. /**
  7578. * Disposes the uniform buffer.
  7579. */
  7580. dispose(): void;
  7581. }
  7582. }
  7583. declare module "babylonjs/Misc/iInspectable" {
  7584. /**
  7585. * Enum that determines the text-wrapping mode to use.
  7586. */
  7587. export enum InspectableType {
  7588. /**
  7589. * Checkbox for booleans
  7590. */
  7591. Checkbox = 0,
  7592. /**
  7593. * Sliders for numbers
  7594. */
  7595. Slider = 1,
  7596. /**
  7597. * Vector3
  7598. */
  7599. Vector3 = 2,
  7600. /**
  7601. * Quaternions
  7602. */
  7603. Quaternion = 3,
  7604. /**
  7605. * Color3
  7606. */
  7607. Color3 = 4,
  7608. /**
  7609. * String
  7610. */
  7611. String = 5
  7612. }
  7613. /**
  7614. * Interface used to define custom inspectable properties.
  7615. * This interface is used by the inspector to display custom property grids
  7616. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7617. */
  7618. export interface IInspectable {
  7619. /**
  7620. * Gets the label to display
  7621. */
  7622. label: string;
  7623. /**
  7624. * Gets the name of the property to edit
  7625. */
  7626. propertyName: string;
  7627. /**
  7628. * Gets the type of the editor to use
  7629. */
  7630. type: InspectableType;
  7631. /**
  7632. * Gets the minimum value of the property when using in "slider" mode
  7633. */
  7634. min?: number;
  7635. /**
  7636. * Gets the maximum value of the property when using in "slider" mode
  7637. */
  7638. max?: number;
  7639. /**
  7640. * Gets the setp to use when using in "slider" mode
  7641. */
  7642. step?: number;
  7643. }
  7644. }
  7645. declare module "babylonjs/Misc/timingTools" {
  7646. /**
  7647. * Class used to provide helper for timing
  7648. */
  7649. export class TimingTools {
  7650. /**
  7651. * Polyfill for setImmediate
  7652. * @param action defines the action to execute after the current execution block
  7653. */
  7654. static SetImmediate(action: () => void): void;
  7655. }
  7656. }
  7657. declare module "babylonjs/Misc/instantiationTools" {
  7658. /**
  7659. * Class used to enable instatition of objects by class name
  7660. */
  7661. export class InstantiationTools {
  7662. /**
  7663. * Use this object to register external classes like custom textures or material
  7664. * to allow the laoders to instantiate them
  7665. */
  7666. static RegisteredExternalClasses: {
  7667. [key: string]: Object;
  7668. };
  7669. /**
  7670. * Tries to instantiate a new object from a given class name
  7671. * @param className defines the class name to instantiate
  7672. * @returns the new object or null if the system was not able to do the instantiation
  7673. */
  7674. static Instantiate(className: string): any;
  7675. }
  7676. }
  7677. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7678. /**
  7679. * Define options used to create a depth texture
  7680. */
  7681. export class DepthTextureCreationOptions {
  7682. /** Specifies whether or not a stencil should be allocated in the texture */
  7683. generateStencil?: boolean;
  7684. /** Specifies whether or not bilinear filtering is enable on the texture */
  7685. bilinearFiltering?: boolean;
  7686. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7687. comparisonFunction?: number;
  7688. /** Specifies if the created texture is a cube texture */
  7689. isCube?: boolean;
  7690. }
  7691. }
  7692. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7693. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7694. import { Nullable } from "babylonjs/types";
  7695. import { Scene } from "babylonjs/scene";
  7696. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7697. module "babylonjs/Engines/thinEngine" {
  7698. interface ThinEngine {
  7699. /**
  7700. * Creates a depth stencil cube texture.
  7701. * This is only available in WebGL 2.
  7702. * @param size The size of face edge in the cube texture.
  7703. * @param options The options defining the cube texture.
  7704. * @returns The cube texture
  7705. */
  7706. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7707. /**
  7708. * Creates a cube texture
  7709. * @param rootUrl defines the url where the files to load is located
  7710. * @param scene defines the current scene
  7711. * @param files defines the list of files to load (1 per face)
  7712. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7713. * @param onLoad defines an optional callback raised when the texture is loaded
  7714. * @param onError defines an optional callback raised if there is an issue to load the texture
  7715. * @param format defines the format of the data
  7716. * @param forcedExtension defines the extension to use to pick the right loader
  7717. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7718. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7719. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7720. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7721. * @returns the cube texture as an InternalTexture
  7722. */
  7723. 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>): InternalTexture;
  7724. /**
  7725. * Creates a cube texture
  7726. * @param rootUrl defines the url where the files to load is located
  7727. * @param scene defines the current scene
  7728. * @param files defines the list of files to load (1 per face)
  7729. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7730. * @param onLoad defines an optional callback raised when the texture is loaded
  7731. * @param onError defines an optional callback raised if there is an issue to load the texture
  7732. * @param format defines the format of the data
  7733. * @param forcedExtension defines the extension to use to pick the right loader
  7734. * @returns the cube texture as an InternalTexture
  7735. */
  7736. 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;
  7737. /**
  7738. * Creates a cube texture
  7739. * @param rootUrl defines the url where the files to load is located
  7740. * @param scene defines the current scene
  7741. * @param files defines the list of files to load (1 per face)
  7742. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7743. * @param onLoad defines an optional callback raised when the texture is loaded
  7744. * @param onError defines an optional callback raised if there is an issue to load the texture
  7745. * @param format defines the format of the data
  7746. * @param forcedExtension defines the extension to use to pick the right loader
  7747. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7748. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7749. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7750. * @returns the cube texture as an InternalTexture
  7751. */
  7752. 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;
  7753. /** @hidden */
  7754. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7755. /** @hidden */
  7756. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7757. /** @hidden */
  7758. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7759. /** @hidden */
  7760. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7761. /**
  7762. * @hidden
  7763. */
  7764. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7765. }
  7766. }
  7767. }
  7768. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7769. import { Nullable } from "babylonjs/types";
  7770. import { Scene } from "babylonjs/scene";
  7771. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7772. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7773. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7774. import { Observable } from "babylonjs/Misc/observable";
  7775. /**
  7776. * Class for creating a cube texture
  7777. */
  7778. export class CubeTexture extends BaseTexture {
  7779. private _delayedOnLoad;
  7780. /**
  7781. * Observable triggered once the texture has been loaded.
  7782. */
  7783. onLoadObservable: Observable<CubeTexture>;
  7784. /**
  7785. * The url of the texture
  7786. */
  7787. url: string;
  7788. /**
  7789. * Gets or sets the center of the bounding box associated with the cube texture.
  7790. * It must define where the camera used to render the texture was set
  7791. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7792. */
  7793. boundingBoxPosition: Vector3;
  7794. private _boundingBoxSize;
  7795. /**
  7796. * Gets or sets the size of the bounding box associated with the cube texture
  7797. * When defined, the cubemap will switch to local mode
  7798. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7799. * @example https://www.babylonjs-playground.com/#RNASML
  7800. */
  7801. set boundingBoxSize(value: Vector3);
  7802. /**
  7803. * Returns the bounding box size
  7804. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7805. */
  7806. get boundingBoxSize(): Vector3;
  7807. protected _rotationY: number;
  7808. /**
  7809. * Sets texture matrix rotation angle around Y axis in radians.
  7810. */
  7811. set rotationY(value: number);
  7812. /**
  7813. * Gets texture matrix rotation angle around Y axis radians.
  7814. */
  7815. get rotationY(): number;
  7816. /**
  7817. * Are mip maps generated for this texture or not.
  7818. */
  7819. get noMipmap(): boolean;
  7820. private _noMipmap;
  7821. private _files;
  7822. protected _forcedExtension: Nullable<string>;
  7823. private _extensions;
  7824. private _textureMatrix;
  7825. private _format;
  7826. private _createPolynomials;
  7827. /** @hidden */
  7828. _prefiltered: boolean;
  7829. /**
  7830. * Creates a cube texture from an array of image urls
  7831. * @param files defines an array of image urls
  7832. * @param scene defines the hosting scene
  7833. * @param noMipmap specifies if mip maps are not used
  7834. * @returns a cube texture
  7835. */
  7836. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7837. /**
  7838. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7839. * @param url defines the url of the prefiltered texture
  7840. * @param scene defines the scene the texture is attached to
  7841. * @param forcedExtension defines the extension of the file if different from the url
  7842. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7843. * @return the prefiltered texture
  7844. */
  7845. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7846. /**
  7847. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7848. * as prefiltered data.
  7849. * @param rootUrl defines the url of the texture or the root name of the six images
  7850. * @param scene defines the scene the texture is attached to
  7851. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7852. * @param noMipmap defines if mipmaps should be created or not
  7853. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7854. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7855. * @param onError defines a callback triggered in case of error during load
  7856. * @param format defines the internal format to use for the texture once loaded
  7857. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7858. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7859. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7860. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7861. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7862. * @return the cube texture
  7863. */
  7864. 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);
  7865. /**
  7866. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7867. */
  7868. get isPrefiltered(): boolean;
  7869. /**
  7870. * Get the current class name of the texture useful for serialization or dynamic coding.
  7871. * @returns "CubeTexture"
  7872. */
  7873. getClassName(): string;
  7874. /**
  7875. * Update the url (and optional buffer) of this texture if url was null during construction.
  7876. * @param url the url of the texture
  7877. * @param forcedExtension defines the extension to use
  7878. * @param onLoad callback called when the texture is loaded (defaults to null)
  7879. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7880. */
  7881. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7882. /**
  7883. * Delays loading of the cube texture
  7884. * @param forcedExtension defines the extension to use
  7885. */
  7886. delayLoad(forcedExtension?: string): void;
  7887. /**
  7888. * Returns the reflection texture matrix
  7889. * @returns the reflection texture matrix
  7890. */
  7891. getReflectionTextureMatrix(): Matrix;
  7892. /**
  7893. * Sets the reflection texture matrix
  7894. * @param value Reflection texture matrix
  7895. */
  7896. setReflectionTextureMatrix(value: Matrix): void;
  7897. /**
  7898. * Parses text to create a cube texture
  7899. * @param parsedTexture define the serialized text to read from
  7900. * @param scene defines the hosting scene
  7901. * @param rootUrl defines the root url of the cube texture
  7902. * @returns a cube texture
  7903. */
  7904. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7905. /**
  7906. * Makes a clone, or deep copy, of the cube texture
  7907. * @returns a new cube texture
  7908. */
  7909. clone(): CubeTexture;
  7910. }
  7911. }
  7912. declare module "babylonjs/Materials/materialDefines" {
  7913. /**
  7914. * Manages the defines for the Material
  7915. */
  7916. export class MaterialDefines {
  7917. /** @hidden */
  7918. protected _keys: string[];
  7919. private _isDirty;
  7920. /** @hidden */
  7921. _renderId: number;
  7922. /** @hidden */
  7923. _areLightsDirty: boolean;
  7924. /** @hidden */
  7925. _areLightsDisposed: boolean;
  7926. /** @hidden */
  7927. _areAttributesDirty: boolean;
  7928. /** @hidden */
  7929. _areTexturesDirty: boolean;
  7930. /** @hidden */
  7931. _areFresnelDirty: boolean;
  7932. /** @hidden */
  7933. _areMiscDirty: boolean;
  7934. /** @hidden */
  7935. _areImageProcessingDirty: boolean;
  7936. /** @hidden */
  7937. _normals: boolean;
  7938. /** @hidden */
  7939. _uvs: boolean;
  7940. /** @hidden */
  7941. _needNormals: boolean;
  7942. /** @hidden */
  7943. _needUVs: boolean;
  7944. [id: string]: any;
  7945. /**
  7946. * Specifies if the material needs to be re-calculated
  7947. */
  7948. get isDirty(): boolean;
  7949. /**
  7950. * Marks the material to indicate that it has been re-calculated
  7951. */
  7952. markAsProcessed(): void;
  7953. /**
  7954. * Marks the material to indicate that it needs to be re-calculated
  7955. */
  7956. markAsUnprocessed(): void;
  7957. /**
  7958. * Marks the material to indicate all of its defines need to be re-calculated
  7959. */
  7960. markAllAsDirty(): void;
  7961. /**
  7962. * Marks the material to indicate that image processing needs to be re-calculated
  7963. */
  7964. markAsImageProcessingDirty(): void;
  7965. /**
  7966. * Marks the material to indicate the lights need to be re-calculated
  7967. * @param disposed Defines whether the light is dirty due to dispose or not
  7968. */
  7969. markAsLightDirty(disposed?: boolean): void;
  7970. /**
  7971. * Marks the attribute state as changed
  7972. */
  7973. markAsAttributesDirty(): void;
  7974. /**
  7975. * Marks the texture state as changed
  7976. */
  7977. markAsTexturesDirty(): void;
  7978. /**
  7979. * Marks the fresnel state as changed
  7980. */
  7981. markAsFresnelDirty(): void;
  7982. /**
  7983. * Marks the misc state as changed
  7984. */
  7985. markAsMiscDirty(): void;
  7986. /**
  7987. * Rebuilds the material defines
  7988. */
  7989. rebuild(): void;
  7990. /**
  7991. * Specifies if two material defines are equal
  7992. * @param other - A material define instance to compare to
  7993. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7994. */
  7995. isEqual(other: MaterialDefines): boolean;
  7996. /**
  7997. * Clones this instance's defines to another instance
  7998. * @param other - material defines to clone values to
  7999. */
  8000. cloneTo(other: MaterialDefines): void;
  8001. /**
  8002. * Resets the material define values
  8003. */
  8004. reset(): void;
  8005. /**
  8006. * Converts the material define values to a string
  8007. * @returns - String of material define information
  8008. */
  8009. toString(): string;
  8010. }
  8011. }
  8012. declare module "babylonjs/Materials/colorCurves" {
  8013. import { Effect } from "babylonjs/Materials/effect";
  8014. /**
  8015. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8016. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8017. * 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;
  8018. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8019. */
  8020. export class ColorCurves {
  8021. private _dirty;
  8022. private _tempColor;
  8023. private _globalCurve;
  8024. private _highlightsCurve;
  8025. private _midtonesCurve;
  8026. private _shadowsCurve;
  8027. private _positiveCurve;
  8028. private _negativeCurve;
  8029. private _globalHue;
  8030. private _globalDensity;
  8031. private _globalSaturation;
  8032. private _globalExposure;
  8033. /**
  8034. * Gets the global Hue value.
  8035. * 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).
  8036. */
  8037. get globalHue(): number;
  8038. /**
  8039. * Sets the global Hue value.
  8040. * 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).
  8041. */
  8042. set globalHue(value: number);
  8043. /**
  8044. * Gets the global Density value.
  8045. * 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.
  8046. * Values less than zero provide a filter of opposite hue.
  8047. */
  8048. get globalDensity(): number;
  8049. /**
  8050. * Sets the global Density value.
  8051. * 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.
  8052. * Values less than zero provide a filter of opposite hue.
  8053. */
  8054. set globalDensity(value: number);
  8055. /**
  8056. * Gets the global Saturation value.
  8057. * 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.
  8058. */
  8059. get globalSaturation(): number;
  8060. /**
  8061. * Sets the global Saturation value.
  8062. * 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.
  8063. */
  8064. set globalSaturation(value: number);
  8065. /**
  8066. * Gets the global Exposure value.
  8067. * 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.
  8068. */
  8069. get globalExposure(): number;
  8070. /**
  8071. * Sets the global Exposure value.
  8072. * 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.
  8073. */
  8074. set globalExposure(value: number);
  8075. private _highlightsHue;
  8076. private _highlightsDensity;
  8077. private _highlightsSaturation;
  8078. private _highlightsExposure;
  8079. /**
  8080. * Gets the highlights Hue value.
  8081. * 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).
  8082. */
  8083. get highlightsHue(): number;
  8084. /**
  8085. * Sets the highlights Hue value.
  8086. * 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).
  8087. */
  8088. set highlightsHue(value: number);
  8089. /**
  8090. * Gets the highlights Density value.
  8091. * 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.
  8092. * Values less than zero provide a filter of opposite hue.
  8093. */
  8094. get highlightsDensity(): number;
  8095. /**
  8096. * Sets the highlights Density value.
  8097. * 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.
  8098. * Values less than zero provide a filter of opposite hue.
  8099. */
  8100. set highlightsDensity(value: number);
  8101. /**
  8102. * Gets the highlights Saturation value.
  8103. * 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.
  8104. */
  8105. get highlightsSaturation(): number;
  8106. /**
  8107. * Sets the highlights Saturation value.
  8108. * 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.
  8109. */
  8110. set highlightsSaturation(value: number);
  8111. /**
  8112. * Gets the highlights Exposure value.
  8113. * 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.
  8114. */
  8115. get highlightsExposure(): number;
  8116. /**
  8117. * Sets the highlights Exposure value.
  8118. * 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.
  8119. */
  8120. set highlightsExposure(value: number);
  8121. private _midtonesHue;
  8122. private _midtonesDensity;
  8123. private _midtonesSaturation;
  8124. private _midtonesExposure;
  8125. /**
  8126. * Gets the midtones Hue value.
  8127. * 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).
  8128. */
  8129. get midtonesHue(): number;
  8130. /**
  8131. * Sets the midtones Hue value.
  8132. * 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).
  8133. */
  8134. set midtonesHue(value: number);
  8135. /**
  8136. * Gets the midtones Density value.
  8137. * 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.
  8138. * Values less than zero provide a filter of opposite hue.
  8139. */
  8140. get midtonesDensity(): number;
  8141. /**
  8142. * Sets the midtones Density value.
  8143. * 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.
  8144. * Values less than zero provide a filter of opposite hue.
  8145. */
  8146. set midtonesDensity(value: number);
  8147. /**
  8148. * Gets the midtones Saturation value.
  8149. * 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.
  8150. */
  8151. get midtonesSaturation(): number;
  8152. /**
  8153. * Sets the midtones Saturation value.
  8154. * 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.
  8155. */
  8156. set midtonesSaturation(value: number);
  8157. /**
  8158. * Gets the midtones Exposure value.
  8159. * 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.
  8160. */
  8161. get midtonesExposure(): number;
  8162. /**
  8163. * Sets the midtones Exposure value.
  8164. * 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.
  8165. */
  8166. set midtonesExposure(value: number);
  8167. private _shadowsHue;
  8168. private _shadowsDensity;
  8169. private _shadowsSaturation;
  8170. private _shadowsExposure;
  8171. /**
  8172. * Gets the shadows Hue value.
  8173. * 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).
  8174. */
  8175. get shadowsHue(): number;
  8176. /**
  8177. * Sets the shadows Hue value.
  8178. * 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).
  8179. */
  8180. set shadowsHue(value: number);
  8181. /**
  8182. * Gets the shadows Density value.
  8183. * 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.
  8184. * Values less than zero provide a filter of opposite hue.
  8185. */
  8186. get shadowsDensity(): number;
  8187. /**
  8188. * Sets the shadows Density value.
  8189. * 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.
  8190. * Values less than zero provide a filter of opposite hue.
  8191. */
  8192. set shadowsDensity(value: number);
  8193. /**
  8194. * Gets the shadows Saturation value.
  8195. * 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.
  8196. */
  8197. get shadowsSaturation(): number;
  8198. /**
  8199. * Sets the shadows Saturation value.
  8200. * 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.
  8201. */
  8202. set shadowsSaturation(value: number);
  8203. /**
  8204. * Gets the shadows Exposure value.
  8205. * 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.
  8206. */
  8207. get shadowsExposure(): number;
  8208. /**
  8209. * Sets the shadows Exposure value.
  8210. * 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.
  8211. */
  8212. set shadowsExposure(value: number);
  8213. /**
  8214. * Returns the class name
  8215. * @returns The class name
  8216. */
  8217. getClassName(): string;
  8218. /**
  8219. * Binds the color curves to the shader.
  8220. * @param colorCurves The color curve to bind
  8221. * @param effect The effect to bind to
  8222. * @param positiveUniform The positive uniform shader parameter
  8223. * @param neutralUniform The neutral uniform shader parameter
  8224. * @param negativeUniform The negative uniform shader parameter
  8225. */
  8226. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8227. /**
  8228. * Prepare the list of uniforms associated with the ColorCurves effects.
  8229. * @param uniformsList The list of uniforms used in the effect
  8230. */
  8231. static PrepareUniforms(uniformsList: string[]): void;
  8232. /**
  8233. * Returns color grading data based on a hue, density, saturation and exposure value.
  8234. * @param filterHue The hue of the color filter.
  8235. * @param filterDensity The density of the color filter.
  8236. * @param saturation The saturation.
  8237. * @param exposure The exposure.
  8238. * @param result The result data container.
  8239. */
  8240. private getColorGradingDataToRef;
  8241. /**
  8242. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8243. * @param value The input slider value in range [-100,100].
  8244. * @returns Adjusted value.
  8245. */
  8246. private static applyColorGradingSliderNonlinear;
  8247. /**
  8248. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8249. * @param hue The hue (H) input.
  8250. * @param saturation The saturation (S) input.
  8251. * @param brightness The brightness (B) input.
  8252. * @result An RGBA color represented as Vector4.
  8253. */
  8254. private static fromHSBToRef;
  8255. /**
  8256. * Returns a value clamped between min and max
  8257. * @param value The value to clamp
  8258. * @param min The minimum of value
  8259. * @param max The maximum of value
  8260. * @returns The clamped value.
  8261. */
  8262. private static clamp;
  8263. /**
  8264. * Clones the current color curve instance.
  8265. * @return The cloned curves
  8266. */
  8267. clone(): ColorCurves;
  8268. /**
  8269. * Serializes the current color curve instance to a json representation.
  8270. * @return a JSON representation
  8271. */
  8272. serialize(): any;
  8273. /**
  8274. * Parses the color curve from a json representation.
  8275. * @param source the JSON source to parse
  8276. * @return The parsed curves
  8277. */
  8278. static Parse(source: any): ColorCurves;
  8279. }
  8280. }
  8281. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8282. import { Observable } from "babylonjs/Misc/observable";
  8283. import { Nullable } from "babylonjs/types";
  8284. import { Color4 } from "babylonjs/Maths/math.color";
  8285. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8286. import { Effect } from "babylonjs/Materials/effect";
  8287. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8288. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8289. /**
  8290. * Interface to follow in your material defines to integrate easily the
  8291. * Image proccessing functions.
  8292. * @hidden
  8293. */
  8294. export interface IImageProcessingConfigurationDefines {
  8295. IMAGEPROCESSING: boolean;
  8296. VIGNETTE: boolean;
  8297. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8298. VIGNETTEBLENDMODEOPAQUE: boolean;
  8299. TONEMAPPING: boolean;
  8300. TONEMAPPING_ACES: boolean;
  8301. CONTRAST: boolean;
  8302. EXPOSURE: boolean;
  8303. COLORCURVES: boolean;
  8304. COLORGRADING: boolean;
  8305. COLORGRADING3D: boolean;
  8306. SAMPLER3DGREENDEPTH: boolean;
  8307. SAMPLER3DBGRMAP: boolean;
  8308. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8309. }
  8310. /**
  8311. * @hidden
  8312. */
  8313. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8314. IMAGEPROCESSING: boolean;
  8315. VIGNETTE: boolean;
  8316. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8317. VIGNETTEBLENDMODEOPAQUE: boolean;
  8318. TONEMAPPING: boolean;
  8319. TONEMAPPING_ACES: boolean;
  8320. CONTRAST: boolean;
  8321. COLORCURVES: boolean;
  8322. COLORGRADING: boolean;
  8323. COLORGRADING3D: boolean;
  8324. SAMPLER3DGREENDEPTH: boolean;
  8325. SAMPLER3DBGRMAP: boolean;
  8326. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8327. EXPOSURE: boolean;
  8328. constructor();
  8329. }
  8330. /**
  8331. * This groups together the common properties used for image processing either in direct forward pass
  8332. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8333. * or not.
  8334. */
  8335. export class ImageProcessingConfiguration {
  8336. /**
  8337. * Default tone mapping applied in BabylonJS.
  8338. */
  8339. static readonly TONEMAPPING_STANDARD: number;
  8340. /**
  8341. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8342. * to other engines rendering to increase portability.
  8343. */
  8344. static readonly TONEMAPPING_ACES: number;
  8345. /**
  8346. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8347. */
  8348. colorCurves: Nullable<ColorCurves>;
  8349. private _colorCurvesEnabled;
  8350. /**
  8351. * Gets wether the color curves effect is enabled.
  8352. */
  8353. get colorCurvesEnabled(): boolean;
  8354. /**
  8355. * Sets wether the color curves effect is enabled.
  8356. */
  8357. set colorCurvesEnabled(value: boolean);
  8358. private _colorGradingTexture;
  8359. /**
  8360. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8361. */
  8362. get colorGradingTexture(): Nullable<BaseTexture>;
  8363. /**
  8364. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8365. */
  8366. set colorGradingTexture(value: Nullable<BaseTexture>);
  8367. private _colorGradingEnabled;
  8368. /**
  8369. * Gets wether the color grading effect is enabled.
  8370. */
  8371. get colorGradingEnabled(): boolean;
  8372. /**
  8373. * Sets wether the color grading effect is enabled.
  8374. */
  8375. set colorGradingEnabled(value: boolean);
  8376. private _colorGradingWithGreenDepth;
  8377. /**
  8378. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8379. */
  8380. get colorGradingWithGreenDepth(): boolean;
  8381. /**
  8382. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8383. */
  8384. set colorGradingWithGreenDepth(value: boolean);
  8385. private _colorGradingBGR;
  8386. /**
  8387. * Gets wether the color grading texture contains BGR values.
  8388. */
  8389. get colorGradingBGR(): boolean;
  8390. /**
  8391. * Sets wether the color grading texture contains BGR values.
  8392. */
  8393. set colorGradingBGR(value: boolean);
  8394. /** @hidden */
  8395. _exposure: number;
  8396. /**
  8397. * Gets the Exposure used in the effect.
  8398. */
  8399. get exposure(): number;
  8400. /**
  8401. * Sets the Exposure used in the effect.
  8402. */
  8403. set exposure(value: number);
  8404. private _toneMappingEnabled;
  8405. /**
  8406. * Gets wether the tone mapping effect is enabled.
  8407. */
  8408. get toneMappingEnabled(): boolean;
  8409. /**
  8410. * Sets wether the tone mapping effect is enabled.
  8411. */
  8412. set toneMappingEnabled(value: boolean);
  8413. private _toneMappingType;
  8414. /**
  8415. * Gets the type of tone mapping effect.
  8416. */
  8417. get toneMappingType(): number;
  8418. /**
  8419. * Sets the type of tone mapping effect used in BabylonJS.
  8420. */
  8421. set toneMappingType(value: number);
  8422. protected _contrast: number;
  8423. /**
  8424. * Gets the contrast used in the effect.
  8425. */
  8426. get contrast(): number;
  8427. /**
  8428. * Sets the contrast used in the effect.
  8429. */
  8430. set contrast(value: number);
  8431. /**
  8432. * Vignette stretch size.
  8433. */
  8434. vignetteStretch: number;
  8435. /**
  8436. * Vignette centre X Offset.
  8437. */
  8438. vignetteCentreX: number;
  8439. /**
  8440. * Vignette centre Y Offset.
  8441. */
  8442. vignetteCentreY: number;
  8443. /**
  8444. * Vignette weight or intensity of the vignette effect.
  8445. */
  8446. vignetteWeight: number;
  8447. /**
  8448. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8449. * if vignetteEnabled is set to true.
  8450. */
  8451. vignetteColor: Color4;
  8452. /**
  8453. * Camera field of view used by the Vignette effect.
  8454. */
  8455. vignetteCameraFov: number;
  8456. private _vignetteBlendMode;
  8457. /**
  8458. * Gets the vignette blend mode allowing different kind of effect.
  8459. */
  8460. get vignetteBlendMode(): number;
  8461. /**
  8462. * Sets the vignette blend mode allowing different kind of effect.
  8463. */
  8464. set vignetteBlendMode(value: number);
  8465. private _vignetteEnabled;
  8466. /**
  8467. * Gets wether the vignette effect is enabled.
  8468. */
  8469. get vignetteEnabled(): boolean;
  8470. /**
  8471. * Sets wether the vignette effect is enabled.
  8472. */
  8473. set vignetteEnabled(value: boolean);
  8474. private _applyByPostProcess;
  8475. /**
  8476. * Gets wether the image processing is applied through a post process or not.
  8477. */
  8478. get applyByPostProcess(): boolean;
  8479. /**
  8480. * Sets wether the image processing is applied through a post process or not.
  8481. */
  8482. set applyByPostProcess(value: boolean);
  8483. private _isEnabled;
  8484. /**
  8485. * Gets wether the image processing is enabled or not.
  8486. */
  8487. get isEnabled(): boolean;
  8488. /**
  8489. * Sets wether the image processing is enabled or not.
  8490. */
  8491. set isEnabled(value: boolean);
  8492. /**
  8493. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8494. */
  8495. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8496. /**
  8497. * Method called each time the image processing information changes requires to recompile the effect.
  8498. */
  8499. protected _updateParameters(): void;
  8500. /**
  8501. * Gets the current class name.
  8502. * @return "ImageProcessingConfiguration"
  8503. */
  8504. getClassName(): string;
  8505. /**
  8506. * Prepare the list of uniforms associated with the Image Processing effects.
  8507. * @param uniforms The list of uniforms used in the effect
  8508. * @param defines the list of defines currently in use
  8509. */
  8510. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8511. /**
  8512. * Prepare the list of samplers associated with the Image Processing effects.
  8513. * @param samplersList The list of uniforms used in the effect
  8514. * @param defines the list of defines currently in use
  8515. */
  8516. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8517. /**
  8518. * Prepare the list of defines associated to the shader.
  8519. * @param defines the list of defines to complete
  8520. * @param forPostProcess Define if we are currently in post process mode or not
  8521. */
  8522. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8523. /**
  8524. * Returns true if all the image processing information are ready.
  8525. * @returns True if ready, otherwise, false
  8526. */
  8527. isReady(): boolean;
  8528. /**
  8529. * Binds the image processing to the shader.
  8530. * @param effect The effect to bind to
  8531. * @param overrideAspectRatio Override the aspect ratio of the effect
  8532. */
  8533. bind(effect: Effect, overrideAspectRatio?: number): void;
  8534. /**
  8535. * Clones the current image processing instance.
  8536. * @return The cloned image processing
  8537. */
  8538. clone(): ImageProcessingConfiguration;
  8539. /**
  8540. * Serializes the current image processing instance to a json representation.
  8541. * @return a JSON representation
  8542. */
  8543. serialize(): any;
  8544. /**
  8545. * Parses the image processing from a json representation.
  8546. * @param source the JSON source to parse
  8547. * @return The parsed image processing
  8548. */
  8549. static Parse(source: any): ImageProcessingConfiguration;
  8550. private static _VIGNETTEMODE_MULTIPLY;
  8551. private static _VIGNETTEMODE_OPAQUE;
  8552. /**
  8553. * Used to apply the vignette as a mix with the pixel color.
  8554. */
  8555. static get VIGNETTEMODE_MULTIPLY(): number;
  8556. /**
  8557. * Used to apply the vignette as a replacement of the pixel color.
  8558. */
  8559. static get VIGNETTEMODE_OPAQUE(): number;
  8560. }
  8561. }
  8562. declare module "babylonjs/Shaders/postprocess.vertex" {
  8563. /** @hidden */
  8564. export var postprocessVertexShader: {
  8565. name: string;
  8566. shader: string;
  8567. };
  8568. }
  8569. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8570. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8571. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8572. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8573. module "babylonjs/Engines/thinEngine" {
  8574. interface ThinEngine {
  8575. /**
  8576. * Creates a new render target texture
  8577. * @param size defines the size of the texture
  8578. * @param options defines the options used to create the texture
  8579. * @returns a new render target texture stored in an InternalTexture
  8580. */
  8581. createRenderTargetTexture(size: number | {
  8582. width: number;
  8583. height: number;
  8584. layers?: number;
  8585. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8586. /**
  8587. * Creates a depth stencil texture.
  8588. * This is only available in WebGL 2 or with the depth texture extension available.
  8589. * @param size The size of face edge in the texture.
  8590. * @param options The options defining the texture.
  8591. * @returns The texture
  8592. */
  8593. createDepthStencilTexture(size: number | {
  8594. width: number;
  8595. height: number;
  8596. layers?: number;
  8597. }, options: DepthTextureCreationOptions): InternalTexture;
  8598. /** @hidden */
  8599. _createDepthStencilTexture(size: number | {
  8600. width: number;
  8601. height: number;
  8602. layers?: number;
  8603. }, options: DepthTextureCreationOptions): InternalTexture;
  8604. }
  8605. }
  8606. }
  8607. declare module "babylonjs/Maths/math.axis" {
  8608. import { Vector3 } from "babylonjs/Maths/math.vector";
  8609. /** Defines supported spaces */
  8610. export enum Space {
  8611. /** Local (object) space */
  8612. LOCAL = 0,
  8613. /** World space */
  8614. WORLD = 1,
  8615. /** Bone space */
  8616. BONE = 2
  8617. }
  8618. /** Defines the 3 main axes */
  8619. export class Axis {
  8620. /** X axis */
  8621. static X: Vector3;
  8622. /** Y axis */
  8623. static Y: Vector3;
  8624. /** Z axis */
  8625. static Z: Vector3;
  8626. }
  8627. }
  8628. declare module "babylonjs/Cameras/targetCamera" {
  8629. import { Nullable } from "babylonjs/types";
  8630. import { Camera } from "babylonjs/Cameras/camera";
  8631. import { Scene } from "babylonjs/scene";
  8632. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8633. /**
  8634. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8635. * This is the base of the follow, arc rotate cameras and Free camera
  8636. * @see http://doc.babylonjs.com/features/cameras
  8637. */
  8638. export class TargetCamera extends Camera {
  8639. private static _RigCamTransformMatrix;
  8640. private static _TargetTransformMatrix;
  8641. private static _TargetFocalPoint;
  8642. /**
  8643. * Define the current direction the camera is moving to
  8644. */
  8645. cameraDirection: Vector3;
  8646. /**
  8647. * Define the current rotation the camera is rotating to
  8648. */
  8649. cameraRotation: Vector2;
  8650. /**
  8651. * When set, the up vector of the camera will be updated by the rotation of the camera
  8652. */
  8653. updateUpVectorFromRotation: boolean;
  8654. private _tmpQuaternion;
  8655. /**
  8656. * Define the current rotation of the camera
  8657. */
  8658. rotation: Vector3;
  8659. /**
  8660. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8661. */
  8662. rotationQuaternion: Quaternion;
  8663. /**
  8664. * Define the current speed of the camera
  8665. */
  8666. speed: number;
  8667. /**
  8668. * Add constraint to the camera to prevent it to move freely in all directions and
  8669. * around all axis.
  8670. */
  8671. noRotationConstraint: boolean;
  8672. /**
  8673. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8674. * panning
  8675. */
  8676. invertRotation: boolean;
  8677. /**
  8678. * Speed multiplier for inverse camera panning
  8679. */
  8680. inverseRotationSpeed: number;
  8681. /**
  8682. * Define the current target of the camera as an object or a position.
  8683. */
  8684. lockedTarget: any;
  8685. /** @hidden */
  8686. _currentTarget: Vector3;
  8687. /** @hidden */
  8688. _initialFocalDistance: number;
  8689. /** @hidden */
  8690. _viewMatrix: Matrix;
  8691. /** @hidden */
  8692. _camMatrix: Matrix;
  8693. /** @hidden */
  8694. _cameraTransformMatrix: Matrix;
  8695. /** @hidden */
  8696. _cameraRotationMatrix: Matrix;
  8697. /** @hidden */
  8698. _referencePoint: Vector3;
  8699. /** @hidden */
  8700. _transformedReferencePoint: Vector3;
  8701. protected _globalCurrentTarget: Vector3;
  8702. protected _globalCurrentUpVector: Vector3;
  8703. /** @hidden */
  8704. _reset: () => void;
  8705. private _defaultUp;
  8706. /**
  8707. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8708. * This is the base of the follow, arc rotate cameras and Free camera
  8709. * @see http://doc.babylonjs.com/features/cameras
  8710. * @param name Defines the name of the camera in the scene
  8711. * @param position Defines the start position of the camera in the scene
  8712. * @param scene Defines the scene the camera belongs to
  8713. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8714. */
  8715. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8716. /**
  8717. * Gets the position in front of the camera at a given distance.
  8718. * @param distance The distance from the camera we want the position to be
  8719. * @returns the position
  8720. */
  8721. getFrontPosition(distance: number): Vector3;
  8722. /** @hidden */
  8723. _getLockedTargetPosition(): Nullable<Vector3>;
  8724. private _storedPosition;
  8725. private _storedRotation;
  8726. private _storedRotationQuaternion;
  8727. /**
  8728. * Store current camera state of the camera (fov, position, rotation, etc..)
  8729. * @returns the camera
  8730. */
  8731. storeState(): Camera;
  8732. /**
  8733. * Restored camera state. You must call storeState() first
  8734. * @returns whether it was successful or not
  8735. * @hidden
  8736. */
  8737. _restoreStateValues(): boolean;
  8738. /** @hidden */
  8739. _initCache(): void;
  8740. /** @hidden */
  8741. _updateCache(ignoreParentClass?: boolean): void;
  8742. /** @hidden */
  8743. _isSynchronizedViewMatrix(): boolean;
  8744. /** @hidden */
  8745. _computeLocalCameraSpeed(): number;
  8746. /**
  8747. * Defines the target the camera should look at.
  8748. * @param target Defines the new target as a Vector or a mesh
  8749. */
  8750. setTarget(target: Vector3): void;
  8751. /**
  8752. * Return the current target position of the camera. This value is expressed in local space.
  8753. * @returns the target position
  8754. */
  8755. getTarget(): Vector3;
  8756. /** @hidden */
  8757. _decideIfNeedsToMove(): boolean;
  8758. /** @hidden */
  8759. _updatePosition(): void;
  8760. /** @hidden */
  8761. _checkInputs(): void;
  8762. protected _updateCameraRotationMatrix(): void;
  8763. /**
  8764. * 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)
  8765. * @returns the current camera
  8766. */
  8767. private _rotateUpVectorWithCameraRotationMatrix;
  8768. private _cachedRotationZ;
  8769. private _cachedQuaternionRotationZ;
  8770. /** @hidden */
  8771. _getViewMatrix(): Matrix;
  8772. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8773. /**
  8774. * @hidden
  8775. */
  8776. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8777. /**
  8778. * @hidden
  8779. */
  8780. _updateRigCameras(): void;
  8781. private _getRigCamPositionAndTarget;
  8782. /**
  8783. * Gets the current object class name.
  8784. * @return the class name
  8785. */
  8786. getClassName(): string;
  8787. }
  8788. }
  8789. declare module "babylonjs/Events/keyboardEvents" {
  8790. /**
  8791. * Gather the list of keyboard event types as constants.
  8792. */
  8793. export class KeyboardEventTypes {
  8794. /**
  8795. * The keydown event is fired when a key becomes active (pressed).
  8796. */
  8797. static readonly KEYDOWN: number;
  8798. /**
  8799. * The keyup event is fired when a key has been released.
  8800. */
  8801. static readonly KEYUP: number;
  8802. }
  8803. /**
  8804. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8805. */
  8806. export class KeyboardInfo {
  8807. /**
  8808. * Defines the type of event (KeyboardEventTypes)
  8809. */
  8810. type: number;
  8811. /**
  8812. * Defines the related dom event
  8813. */
  8814. event: KeyboardEvent;
  8815. /**
  8816. * Instantiates a new keyboard info.
  8817. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8818. * @param type Defines the type of event (KeyboardEventTypes)
  8819. * @param event Defines the related dom event
  8820. */
  8821. constructor(
  8822. /**
  8823. * Defines the type of event (KeyboardEventTypes)
  8824. */
  8825. type: number,
  8826. /**
  8827. * Defines the related dom event
  8828. */
  8829. event: KeyboardEvent);
  8830. }
  8831. /**
  8832. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8833. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8834. */
  8835. export class KeyboardInfoPre extends KeyboardInfo {
  8836. /**
  8837. * Defines the type of event (KeyboardEventTypes)
  8838. */
  8839. type: number;
  8840. /**
  8841. * Defines the related dom event
  8842. */
  8843. event: KeyboardEvent;
  8844. /**
  8845. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8846. */
  8847. skipOnPointerObservable: boolean;
  8848. /**
  8849. * Instantiates a new keyboard pre info.
  8850. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8851. * @param type Defines the type of event (KeyboardEventTypes)
  8852. * @param event Defines the related dom event
  8853. */
  8854. constructor(
  8855. /**
  8856. * Defines the type of event (KeyboardEventTypes)
  8857. */
  8858. type: number,
  8859. /**
  8860. * Defines the related dom event
  8861. */
  8862. event: KeyboardEvent);
  8863. }
  8864. }
  8865. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8866. import { Nullable } from "babylonjs/types";
  8867. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8868. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8869. /**
  8870. * Manage the keyboard inputs to control the movement of a free camera.
  8871. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8872. */
  8873. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8874. /**
  8875. * Defines the camera the input is attached to.
  8876. */
  8877. camera: FreeCamera;
  8878. /**
  8879. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8880. */
  8881. keysUp: number[];
  8882. /**
  8883. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8884. */
  8885. keysUpward: number[];
  8886. /**
  8887. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8888. */
  8889. keysDown: number[];
  8890. /**
  8891. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8892. */
  8893. keysDownward: number[];
  8894. /**
  8895. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8896. */
  8897. keysLeft: number[];
  8898. /**
  8899. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8900. */
  8901. keysRight: number[];
  8902. private _keys;
  8903. private _onCanvasBlurObserver;
  8904. private _onKeyboardObserver;
  8905. private _engine;
  8906. private _scene;
  8907. /**
  8908. * Attach the input controls to a specific dom element to get the input from.
  8909. * @param element Defines the element the controls should be listened from
  8910. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8911. */
  8912. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8913. /**
  8914. * Detach the current controls from the specified dom element.
  8915. * @param element Defines the element to stop listening the inputs from
  8916. */
  8917. detachControl(element: Nullable<HTMLElement>): void;
  8918. /**
  8919. * Update the current camera state depending on the inputs that have been used this frame.
  8920. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8921. */
  8922. checkInputs(): void;
  8923. /**
  8924. * Gets the class name of the current intput.
  8925. * @returns the class name
  8926. */
  8927. getClassName(): string;
  8928. /** @hidden */
  8929. _onLostFocus(): void;
  8930. /**
  8931. * Get the friendly name associated with the input class.
  8932. * @returns the input friendly name
  8933. */
  8934. getSimpleName(): string;
  8935. }
  8936. }
  8937. declare module "babylonjs/Lights/shadowLight" {
  8938. import { Camera } from "babylonjs/Cameras/camera";
  8939. import { Scene } from "babylonjs/scene";
  8940. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8941. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8942. import { Light } from "babylonjs/Lights/light";
  8943. /**
  8944. * Interface describing all the common properties and methods a shadow light needs to implement.
  8945. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8946. * as well as binding the different shadow properties to the effects.
  8947. */
  8948. export interface IShadowLight extends Light {
  8949. /**
  8950. * The light id in the scene (used in scene.findLighById for instance)
  8951. */
  8952. id: string;
  8953. /**
  8954. * The position the shdow will be casted from.
  8955. */
  8956. position: Vector3;
  8957. /**
  8958. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8959. */
  8960. direction: Vector3;
  8961. /**
  8962. * The transformed position. Position of the light in world space taking parenting in account.
  8963. */
  8964. transformedPosition: Vector3;
  8965. /**
  8966. * The transformed direction. Direction of the light in world space taking parenting in account.
  8967. */
  8968. transformedDirection: Vector3;
  8969. /**
  8970. * The friendly name of the light in the scene.
  8971. */
  8972. name: string;
  8973. /**
  8974. * Defines the shadow projection clipping minimum z value.
  8975. */
  8976. shadowMinZ: number;
  8977. /**
  8978. * Defines the shadow projection clipping maximum z value.
  8979. */
  8980. shadowMaxZ: number;
  8981. /**
  8982. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8983. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8984. */
  8985. computeTransformedInformation(): boolean;
  8986. /**
  8987. * Gets the scene the light belongs to.
  8988. * @returns The scene
  8989. */
  8990. getScene(): Scene;
  8991. /**
  8992. * Callback defining a custom Projection Matrix Builder.
  8993. * This can be used to override the default projection matrix computation.
  8994. */
  8995. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8996. /**
  8997. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8998. * @param matrix The materix to updated with the projection information
  8999. * @param viewMatrix The transform matrix of the light
  9000. * @param renderList The list of mesh to render in the map
  9001. * @returns The current light
  9002. */
  9003. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9004. /**
  9005. * Gets the current depth scale used in ESM.
  9006. * @returns The scale
  9007. */
  9008. getDepthScale(): number;
  9009. /**
  9010. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9011. * @returns true if a cube texture needs to be use
  9012. */
  9013. needCube(): boolean;
  9014. /**
  9015. * Detects if the projection matrix requires to be recomputed this frame.
  9016. * @returns true if it requires to be recomputed otherwise, false.
  9017. */
  9018. needProjectionMatrixCompute(): boolean;
  9019. /**
  9020. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9021. */
  9022. forceProjectionMatrixCompute(): void;
  9023. /**
  9024. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9025. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9026. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9027. */
  9028. getShadowDirection(faceIndex?: number): Vector3;
  9029. /**
  9030. * Gets the minZ used for shadow according to both the scene and the light.
  9031. * @param activeCamera The camera we are returning the min for
  9032. * @returns the depth min z
  9033. */
  9034. getDepthMinZ(activeCamera: Camera): number;
  9035. /**
  9036. * Gets the maxZ used for shadow according to both the scene and the light.
  9037. * @param activeCamera The camera we are returning the max for
  9038. * @returns the depth max z
  9039. */
  9040. getDepthMaxZ(activeCamera: Camera): number;
  9041. }
  9042. /**
  9043. * Base implementation IShadowLight
  9044. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9045. */
  9046. export abstract class ShadowLight extends Light implements IShadowLight {
  9047. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9048. protected _position: Vector3;
  9049. protected _setPosition(value: Vector3): void;
  9050. /**
  9051. * Sets the position the shadow will be casted from. Also use as the light position for both
  9052. * point and spot lights.
  9053. */
  9054. get position(): Vector3;
  9055. /**
  9056. * Sets the position the shadow will be casted from. Also use as the light position for both
  9057. * point and spot lights.
  9058. */
  9059. set position(value: Vector3);
  9060. protected _direction: Vector3;
  9061. protected _setDirection(value: Vector3): void;
  9062. /**
  9063. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9064. * Also use as the light direction on spot and directional lights.
  9065. */
  9066. get direction(): Vector3;
  9067. /**
  9068. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9069. * Also use as the light direction on spot and directional lights.
  9070. */
  9071. set direction(value: Vector3);
  9072. protected _shadowMinZ: number;
  9073. /**
  9074. * Gets the shadow projection clipping minimum z value.
  9075. */
  9076. get shadowMinZ(): number;
  9077. /**
  9078. * Sets the shadow projection clipping minimum z value.
  9079. */
  9080. set shadowMinZ(value: number);
  9081. protected _shadowMaxZ: number;
  9082. /**
  9083. * Sets the shadow projection clipping maximum z value.
  9084. */
  9085. get shadowMaxZ(): number;
  9086. /**
  9087. * Gets the shadow projection clipping maximum z value.
  9088. */
  9089. set shadowMaxZ(value: number);
  9090. /**
  9091. * Callback defining a custom Projection Matrix Builder.
  9092. * This can be used to override the default projection matrix computation.
  9093. */
  9094. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9095. /**
  9096. * The transformed position. Position of the light in world space taking parenting in account.
  9097. */
  9098. transformedPosition: Vector3;
  9099. /**
  9100. * The transformed direction. Direction of the light in world space taking parenting in account.
  9101. */
  9102. transformedDirection: Vector3;
  9103. private _needProjectionMatrixCompute;
  9104. /**
  9105. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9106. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9107. */
  9108. computeTransformedInformation(): boolean;
  9109. /**
  9110. * Return the depth scale used for the shadow map.
  9111. * @returns the depth scale.
  9112. */
  9113. getDepthScale(): number;
  9114. /**
  9115. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9116. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9117. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9118. */
  9119. getShadowDirection(faceIndex?: number): Vector3;
  9120. /**
  9121. * Returns the ShadowLight absolute position in the World.
  9122. * @returns the position vector in world space
  9123. */
  9124. getAbsolutePosition(): Vector3;
  9125. /**
  9126. * Sets the ShadowLight direction toward the passed target.
  9127. * @param target The point to target in local space
  9128. * @returns the updated ShadowLight direction
  9129. */
  9130. setDirectionToTarget(target: Vector3): Vector3;
  9131. /**
  9132. * Returns the light rotation in euler definition.
  9133. * @returns the x y z rotation in local space.
  9134. */
  9135. getRotation(): Vector3;
  9136. /**
  9137. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9138. * @returns true if a cube texture needs to be use
  9139. */
  9140. needCube(): boolean;
  9141. /**
  9142. * Detects if the projection matrix requires to be recomputed this frame.
  9143. * @returns true if it requires to be recomputed otherwise, false.
  9144. */
  9145. needProjectionMatrixCompute(): boolean;
  9146. /**
  9147. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9148. */
  9149. forceProjectionMatrixCompute(): void;
  9150. /** @hidden */
  9151. _initCache(): void;
  9152. /** @hidden */
  9153. _isSynchronized(): boolean;
  9154. /**
  9155. * Computes the world matrix of the node
  9156. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9157. * @returns the world matrix
  9158. */
  9159. computeWorldMatrix(force?: boolean): Matrix;
  9160. /**
  9161. * Gets the minZ used for shadow according to both the scene and the light.
  9162. * @param activeCamera The camera we are returning the min for
  9163. * @returns the depth min z
  9164. */
  9165. getDepthMinZ(activeCamera: Camera): number;
  9166. /**
  9167. * Gets the maxZ used for shadow according to both the scene and the light.
  9168. * @param activeCamera The camera we are returning the max for
  9169. * @returns the depth max z
  9170. */
  9171. getDepthMaxZ(activeCamera: Camera): number;
  9172. /**
  9173. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9174. * @param matrix The materix to updated with the projection information
  9175. * @param viewMatrix The transform matrix of the light
  9176. * @param renderList The list of mesh to render in the map
  9177. * @returns The current light
  9178. */
  9179. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9180. }
  9181. }
  9182. declare module "babylonjs/Materials/effectFallbacks" {
  9183. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9184. import { Effect } from "babylonjs/Materials/effect";
  9185. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9186. /**
  9187. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9188. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9189. */
  9190. export class EffectFallbacks implements IEffectFallbacks {
  9191. private _defines;
  9192. private _currentRank;
  9193. private _maxRank;
  9194. private _mesh;
  9195. /**
  9196. * Removes the fallback from the bound mesh.
  9197. */
  9198. unBindMesh(): void;
  9199. /**
  9200. * Adds a fallback on the specified property.
  9201. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9202. * @param define The name of the define in the shader
  9203. */
  9204. addFallback(rank: number, define: string): void;
  9205. /**
  9206. * Sets the mesh to use CPU skinning when needing to fallback.
  9207. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9208. * @param mesh The mesh to use the fallbacks.
  9209. */
  9210. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9211. /**
  9212. * Checks to see if more fallbacks are still availible.
  9213. */
  9214. get hasMoreFallbacks(): boolean;
  9215. /**
  9216. * Removes the defines that should be removed when falling back.
  9217. * @param currentDefines defines the current define statements for the shader.
  9218. * @param effect defines the current effect we try to compile
  9219. * @returns The resulting defines with defines of the current rank removed.
  9220. */
  9221. reduce(currentDefines: string, effect: Effect): string;
  9222. }
  9223. }
  9224. declare module "babylonjs/Materials/materialHelper" {
  9225. import { Nullable } from "babylonjs/types";
  9226. import { Scene } from "babylonjs/scene";
  9227. import { Engine } from "babylonjs/Engines/engine";
  9228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9229. import { Light } from "babylonjs/Lights/light";
  9230. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9231. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9232. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9233. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9234. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9235. /**
  9236. * "Static Class" containing the most commonly used helper while dealing with material for
  9237. * rendering purpose.
  9238. *
  9239. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9240. *
  9241. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9242. */
  9243. export class MaterialHelper {
  9244. /**
  9245. * Bind the current view position to an effect.
  9246. * @param effect The effect to be bound
  9247. * @param scene The scene the eyes position is used from
  9248. */
  9249. static BindEyePosition(effect: Effect, scene: Scene): void;
  9250. /**
  9251. * Helps preparing the defines values about the UVs in used in the effect.
  9252. * UVs are shared as much as we can accross channels in the shaders.
  9253. * @param texture The texture we are preparing the UVs for
  9254. * @param defines The defines to update
  9255. * @param key The channel key "diffuse", "specular"... used in the shader
  9256. */
  9257. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9258. /**
  9259. * Binds a texture matrix value to its corrsponding uniform
  9260. * @param texture The texture to bind the matrix for
  9261. * @param uniformBuffer The uniform buffer receivin the data
  9262. * @param key The channel key "diffuse", "specular"... used in the shader
  9263. */
  9264. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9265. /**
  9266. * Gets the current status of the fog (should it be enabled?)
  9267. * @param mesh defines the mesh to evaluate for fog support
  9268. * @param scene defines the hosting scene
  9269. * @returns true if fog must be enabled
  9270. */
  9271. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9272. /**
  9273. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9274. * @param mesh defines the current mesh
  9275. * @param scene defines the current scene
  9276. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9277. * @param pointsCloud defines if point cloud rendering has to be turned on
  9278. * @param fogEnabled defines if fog has to be turned on
  9279. * @param alphaTest defines if alpha testing has to be turned on
  9280. * @param defines defines the current list of defines
  9281. */
  9282. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9283. /**
  9284. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9285. * @param scene defines the current scene
  9286. * @param engine defines the current engine
  9287. * @param defines specifies the list of active defines
  9288. * @param useInstances defines if instances have to be turned on
  9289. * @param useClipPlane defines if clip plane have to be turned on
  9290. */
  9291. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9292. /**
  9293. * Prepares the defines for bones
  9294. * @param mesh The mesh containing the geometry data we will draw
  9295. * @param defines The defines to update
  9296. */
  9297. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9298. /**
  9299. * Prepares the defines for morph targets
  9300. * @param mesh The mesh containing the geometry data we will draw
  9301. * @param defines The defines to update
  9302. */
  9303. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9304. /**
  9305. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9306. * @param mesh The mesh containing the geometry data we will draw
  9307. * @param defines The defines to update
  9308. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9309. * @param useBones Precise whether bones should be used or not (override mesh info)
  9310. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9311. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9312. * @returns false if defines are considered not dirty and have not been checked
  9313. */
  9314. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9315. /**
  9316. * Prepares the defines related to multiview
  9317. * @param scene The scene we are intending to draw
  9318. * @param defines The defines to update
  9319. */
  9320. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9321. /**
  9322. * Prepares the defines related to the light information passed in parameter
  9323. * @param scene The scene we are intending to draw
  9324. * @param mesh The mesh the effect is compiling for
  9325. * @param light The light the effect is compiling for
  9326. * @param lightIndex The index of the light
  9327. * @param defines The defines to update
  9328. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9329. * @param state Defines the current state regarding what is needed (normals, etc...)
  9330. */
  9331. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9332. needNormals: boolean;
  9333. needRebuild: boolean;
  9334. shadowEnabled: boolean;
  9335. specularEnabled: boolean;
  9336. lightmapMode: boolean;
  9337. }): void;
  9338. /**
  9339. * Prepares the defines related to the light information passed in parameter
  9340. * @param scene The scene we are intending to draw
  9341. * @param mesh The mesh the effect is compiling for
  9342. * @param defines The defines to update
  9343. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9344. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9345. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9346. * @returns true if normals will be required for the rest of the effect
  9347. */
  9348. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9349. /**
  9350. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9351. * @param lightIndex defines the light index
  9352. * @param uniformsList The uniform list
  9353. * @param samplersList The sampler list
  9354. * @param projectedLightTexture defines if projected texture must be used
  9355. * @param uniformBuffersList defines an optional list of uniform buffers
  9356. */
  9357. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9358. /**
  9359. * Prepares the uniforms and samplers list to be used in the effect
  9360. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9361. * @param samplersList The sampler list
  9362. * @param defines The defines helping in the list generation
  9363. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9364. */
  9365. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9366. /**
  9367. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9368. * @param defines The defines to update while falling back
  9369. * @param fallbacks The authorized effect fallbacks
  9370. * @param maxSimultaneousLights The maximum number of lights allowed
  9371. * @param rank the current rank of the Effect
  9372. * @returns The newly affected rank
  9373. */
  9374. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9375. private static _TmpMorphInfluencers;
  9376. /**
  9377. * Prepares the list of attributes required for morph targets according to the effect defines.
  9378. * @param attribs The current list of supported attribs
  9379. * @param mesh The mesh to prepare the morph targets attributes for
  9380. * @param influencers The number of influencers
  9381. */
  9382. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9383. /**
  9384. * Prepares the list of attributes required for morph targets according to the effect defines.
  9385. * @param attribs The current list of supported attribs
  9386. * @param mesh The mesh to prepare the morph targets attributes for
  9387. * @param defines The current Defines of the effect
  9388. */
  9389. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9390. /**
  9391. * Prepares the list of attributes required for bones according to the effect defines.
  9392. * @param attribs The current list of supported attribs
  9393. * @param mesh The mesh to prepare the bones attributes for
  9394. * @param defines The current Defines of the effect
  9395. * @param fallbacks The current efffect fallback strategy
  9396. */
  9397. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9398. /**
  9399. * Check and prepare the list of attributes required for instances according to the effect defines.
  9400. * @param attribs The current list of supported attribs
  9401. * @param defines The current MaterialDefines of the effect
  9402. */
  9403. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9404. /**
  9405. * Add the list of attributes required for instances to the attribs array.
  9406. * @param attribs The current list of supported attribs
  9407. */
  9408. static PushAttributesForInstances(attribs: string[]): void;
  9409. /**
  9410. * Binds the light information to the effect.
  9411. * @param light The light containing the generator
  9412. * @param effect The effect we are binding the data to
  9413. * @param lightIndex The light index in the effect used to render
  9414. */
  9415. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9416. /**
  9417. * Binds the lights information from the scene to the effect for the given mesh.
  9418. * @param light Light to bind
  9419. * @param lightIndex Light index
  9420. * @param scene The scene where the light belongs to
  9421. * @param effect The effect we are binding the data to
  9422. * @param useSpecular Defines if specular is supported
  9423. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9424. */
  9425. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9426. /**
  9427. * Binds the lights information from the scene to the effect for the given mesh.
  9428. * @param scene The scene the lights belongs to
  9429. * @param mesh The mesh we are binding the information to render
  9430. * @param effect The effect we are binding the data to
  9431. * @param defines The generated defines for the effect
  9432. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9433. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9434. */
  9435. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9436. private static _tempFogColor;
  9437. /**
  9438. * Binds the fog information from the scene to the effect for the given mesh.
  9439. * @param scene The scene the lights belongs to
  9440. * @param mesh The mesh we are binding the information to render
  9441. * @param effect The effect we are binding the data to
  9442. * @param linearSpace Defines if the fog effect is applied in linear space
  9443. */
  9444. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9445. /**
  9446. * Binds the bones information from the mesh to the effect.
  9447. * @param mesh The mesh we are binding the information to render
  9448. * @param effect The effect we are binding the data to
  9449. */
  9450. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9451. /**
  9452. * Binds the morph targets information from the mesh to the effect.
  9453. * @param abstractMesh The mesh we are binding the information to render
  9454. * @param effect The effect we are binding the data to
  9455. */
  9456. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9457. /**
  9458. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9459. * @param defines The generated defines used in the effect
  9460. * @param effect The effect we are binding the data to
  9461. * @param scene The scene we are willing to render with logarithmic scale for
  9462. */
  9463. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9464. /**
  9465. * Binds the clip plane information from the scene to the effect.
  9466. * @param scene The scene the clip plane information are extracted from
  9467. * @param effect The effect we are binding the data to
  9468. */
  9469. static BindClipPlane(effect: Effect, scene: Scene): void;
  9470. }
  9471. }
  9472. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9473. /** @hidden */
  9474. export var packingFunctions: {
  9475. name: string;
  9476. shader: string;
  9477. };
  9478. }
  9479. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9480. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9481. /** @hidden */
  9482. export var shadowMapFragmentDeclaration: {
  9483. name: string;
  9484. shader: string;
  9485. };
  9486. }
  9487. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9488. /** @hidden */
  9489. export var clipPlaneFragmentDeclaration: {
  9490. name: string;
  9491. shader: string;
  9492. };
  9493. }
  9494. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9495. /** @hidden */
  9496. export var clipPlaneFragment: {
  9497. name: string;
  9498. shader: string;
  9499. };
  9500. }
  9501. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9502. /** @hidden */
  9503. export var shadowMapFragment: {
  9504. name: string;
  9505. shader: string;
  9506. };
  9507. }
  9508. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9509. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9510. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9511. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9512. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9513. /** @hidden */
  9514. export var shadowMapPixelShader: {
  9515. name: string;
  9516. shader: string;
  9517. };
  9518. }
  9519. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9520. /** @hidden */
  9521. export var bonesDeclaration: {
  9522. name: string;
  9523. shader: string;
  9524. };
  9525. }
  9526. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9527. /** @hidden */
  9528. export var morphTargetsVertexGlobalDeclaration: {
  9529. name: string;
  9530. shader: string;
  9531. };
  9532. }
  9533. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9534. /** @hidden */
  9535. export var morphTargetsVertexDeclaration: {
  9536. name: string;
  9537. shader: string;
  9538. };
  9539. }
  9540. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9541. /** @hidden */
  9542. export var instancesDeclaration: {
  9543. name: string;
  9544. shader: string;
  9545. };
  9546. }
  9547. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9548. /** @hidden */
  9549. export var helperFunctions: {
  9550. name: string;
  9551. shader: string;
  9552. };
  9553. }
  9554. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9555. /** @hidden */
  9556. export var shadowMapVertexDeclaration: {
  9557. name: string;
  9558. shader: string;
  9559. };
  9560. }
  9561. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9562. /** @hidden */
  9563. export var clipPlaneVertexDeclaration: {
  9564. name: string;
  9565. shader: string;
  9566. };
  9567. }
  9568. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9569. /** @hidden */
  9570. export var morphTargetsVertex: {
  9571. name: string;
  9572. shader: string;
  9573. };
  9574. }
  9575. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9576. /** @hidden */
  9577. export var instancesVertex: {
  9578. name: string;
  9579. shader: string;
  9580. };
  9581. }
  9582. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9583. /** @hidden */
  9584. export var bonesVertex: {
  9585. name: string;
  9586. shader: string;
  9587. };
  9588. }
  9589. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9590. /** @hidden */
  9591. export var shadowMapVertexNormalBias: {
  9592. name: string;
  9593. shader: string;
  9594. };
  9595. }
  9596. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9597. /** @hidden */
  9598. export var shadowMapVertexMetric: {
  9599. name: string;
  9600. shader: string;
  9601. };
  9602. }
  9603. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9604. /** @hidden */
  9605. export var clipPlaneVertex: {
  9606. name: string;
  9607. shader: string;
  9608. };
  9609. }
  9610. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9611. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9612. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9613. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9614. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9615. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9616. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9617. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9618. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9619. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9620. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9621. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9622. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9623. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9624. /** @hidden */
  9625. export var shadowMapVertexShader: {
  9626. name: string;
  9627. shader: string;
  9628. };
  9629. }
  9630. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9631. /** @hidden */
  9632. export var depthBoxBlurPixelShader: {
  9633. name: string;
  9634. shader: string;
  9635. };
  9636. }
  9637. declare module "babylonjs/Culling/ray" {
  9638. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  9639. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9640. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9641. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9642. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  9643. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  9644. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  9645. import { Plane } from "babylonjs/Maths/math.plane";
  9646. /**
  9647. * Class representing a ray with position and direction
  9648. */
  9649. export class Ray {
  9650. /** origin point */
  9651. origin: Vector3;
  9652. /** direction */
  9653. direction: Vector3;
  9654. /** length of the ray */
  9655. length: number;
  9656. private static readonly TmpVector3;
  9657. private _tmpRay;
  9658. /**
  9659. * Creates a new ray
  9660. * @param origin origin point
  9661. * @param direction direction
  9662. * @param length length of the ray
  9663. */
  9664. constructor(
  9665. /** origin point */
  9666. origin: Vector3,
  9667. /** direction */
  9668. direction: Vector3,
  9669. /** length of the ray */
  9670. length?: number);
  9671. /**
  9672. * Checks if the ray intersects a box
  9673. * This does not account for the ray lenght by design to improve perfs.
  9674. * @param minimum bound of the box
  9675. * @param maximum bound of the box
  9676. * @param intersectionTreshold extra extend to be added to the box in all direction
  9677. * @returns if the box was hit
  9678. */
  9679. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9680. /**
  9681. * Checks if the ray intersects a box
  9682. * This does not account for the ray lenght by design to improve perfs.
  9683. * @param box the bounding box to check
  9684. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9685. * @returns if the box was hit
  9686. */
  9687. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9688. /**
  9689. * If the ray hits a sphere
  9690. * @param sphere the bounding sphere to check
  9691. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9692. * @returns true if it hits the sphere
  9693. */
  9694. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9695. /**
  9696. * If the ray hits a triange
  9697. * @param vertex0 triangle vertex
  9698. * @param vertex1 triangle vertex
  9699. * @param vertex2 triangle vertex
  9700. * @returns intersection information if hit
  9701. */
  9702. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9703. /**
  9704. * Checks if ray intersects a plane
  9705. * @param plane the plane to check
  9706. * @returns the distance away it was hit
  9707. */
  9708. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9709. /**
  9710. * Calculate the intercept of a ray on a given axis
  9711. * @param axis to check 'x' | 'y' | 'z'
  9712. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9713. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9714. */
  9715. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9716. /**
  9717. * Checks if ray intersects a mesh
  9718. * @param mesh the mesh to check
  9719. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9720. * @returns picking info of the intersecton
  9721. */
  9722. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9723. /**
  9724. * Checks if ray intersects a mesh
  9725. * @param meshes the meshes to check
  9726. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9727. * @param results array to store result in
  9728. * @returns Array of picking infos
  9729. */
  9730. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9731. private _comparePickingInfo;
  9732. private static smallnum;
  9733. private static rayl;
  9734. /**
  9735. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9736. * @param sega the first point of the segment to test the intersection against
  9737. * @param segb the second point of the segment to test the intersection against
  9738. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9739. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9740. */
  9741. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9742. /**
  9743. * Update the ray from viewport position
  9744. * @param x position
  9745. * @param y y position
  9746. * @param viewportWidth viewport width
  9747. * @param viewportHeight viewport height
  9748. * @param world world matrix
  9749. * @param view view matrix
  9750. * @param projection projection matrix
  9751. * @returns this ray updated
  9752. */
  9753. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9754. /**
  9755. * Creates a ray with origin and direction of 0,0,0
  9756. * @returns the new ray
  9757. */
  9758. static Zero(): Ray;
  9759. /**
  9760. * Creates a new ray from screen space and viewport
  9761. * @param x position
  9762. * @param y y position
  9763. * @param viewportWidth viewport width
  9764. * @param viewportHeight viewport height
  9765. * @param world world matrix
  9766. * @param view view matrix
  9767. * @param projection projection matrix
  9768. * @returns new ray
  9769. */
  9770. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9771. /**
  9772. * 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
  9773. * transformed to the given world matrix.
  9774. * @param origin The origin point
  9775. * @param end The end point
  9776. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9777. * @returns the new ray
  9778. */
  9779. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9780. /**
  9781. * Transforms a ray by a matrix
  9782. * @param ray ray to transform
  9783. * @param matrix matrix to apply
  9784. * @returns the resulting new ray
  9785. */
  9786. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9787. /**
  9788. * Transforms a ray by a matrix
  9789. * @param ray ray to transform
  9790. * @param matrix matrix to apply
  9791. * @param result ray to store result in
  9792. */
  9793. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9794. /**
  9795. * Unproject a ray from screen space to object space
  9796. * @param sourceX defines the screen space x coordinate to use
  9797. * @param sourceY defines the screen space y coordinate to use
  9798. * @param viewportWidth defines the current width of the viewport
  9799. * @param viewportHeight defines the current height of the viewport
  9800. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9801. * @param view defines the view matrix to use
  9802. * @param projection defines the projection matrix to use
  9803. */
  9804. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9805. }
  9806. /**
  9807. * Type used to define predicate used to select faces when a mesh intersection is detected
  9808. */
  9809. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9810. module "babylonjs/scene" {
  9811. interface Scene {
  9812. /** @hidden */
  9813. _tempPickingRay: Nullable<Ray>;
  9814. /** @hidden */
  9815. _cachedRayForTransform: Ray;
  9816. /** @hidden */
  9817. _pickWithRayInverseMatrix: Matrix;
  9818. /** @hidden */
  9819. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9820. /** @hidden */
  9821. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9822. }
  9823. }
  9824. }
  9825. declare module "babylonjs/sceneComponent" {
  9826. import { Scene } from "babylonjs/scene";
  9827. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9828. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9829. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  9830. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  9831. import { Nullable } from "babylonjs/types";
  9832. import { Camera } from "babylonjs/Cameras/camera";
  9833. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9834. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9835. import { AbstractScene } from "babylonjs/abstractScene";
  9836. import { Mesh } from "babylonjs/Meshes/mesh";
  9837. /**
  9838. * Groups all the scene component constants in one place to ease maintenance.
  9839. * @hidden
  9840. */
  9841. export class SceneComponentConstants {
  9842. static readonly NAME_EFFECTLAYER: string;
  9843. static readonly NAME_LAYER: string;
  9844. static readonly NAME_LENSFLARESYSTEM: string;
  9845. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9846. static readonly NAME_PARTICLESYSTEM: string;
  9847. static readonly NAME_GAMEPAD: string;
  9848. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9849. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9850. static readonly NAME_DEPTHRENDERER: string;
  9851. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9852. static readonly NAME_SPRITE: string;
  9853. static readonly NAME_OUTLINERENDERER: string;
  9854. static readonly NAME_PROCEDURALTEXTURE: string;
  9855. static readonly NAME_SHADOWGENERATOR: string;
  9856. static readonly NAME_OCTREE: string;
  9857. static readonly NAME_PHYSICSENGINE: string;
  9858. static readonly NAME_AUDIO: string;
  9859. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9860. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9861. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9862. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9863. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9864. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9865. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9866. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9867. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9868. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9869. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9870. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9871. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9872. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9873. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9874. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9875. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9876. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9877. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9878. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9879. static readonly STEP_AFTERRENDER_AUDIO: number;
  9880. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9881. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9882. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9883. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9884. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9885. static readonly STEP_POINTERMOVE_SPRITE: number;
  9886. static readonly STEP_POINTERDOWN_SPRITE: number;
  9887. static readonly STEP_POINTERUP_SPRITE: number;
  9888. }
  9889. /**
  9890. * This represents a scene component.
  9891. *
  9892. * This is used to decouple the dependency the scene is having on the different workloads like
  9893. * layers, post processes...
  9894. */
  9895. export interface ISceneComponent {
  9896. /**
  9897. * The name of the component. Each component must have a unique name.
  9898. */
  9899. name: string;
  9900. /**
  9901. * The scene the component belongs to.
  9902. */
  9903. scene: Scene;
  9904. /**
  9905. * Register the component to one instance of a scene.
  9906. */
  9907. register(): void;
  9908. /**
  9909. * Rebuilds the elements related to this component in case of
  9910. * context lost for instance.
  9911. */
  9912. rebuild(): void;
  9913. /**
  9914. * Disposes the component and the associated ressources.
  9915. */
  9916. dispose(): void;
  9917. }
  9918. /**
  9919. * This represents a SERIALIZABLE scene component.
  9920. *
  9921. * This extends Scene Component to add Serialization methods on top.
  9922. */
  9923. export interface ISceneSerializableComponent extends ISceneComponent {
  9924. /**
  9925. * Adds all the elements from the container to the scene
  9926. * @param container the container holding the elements
  9927. */
  9928. addFromContainer(container: AbstractScene): void;
  9929. /**
  9930. * Removes all the elements in the container from the scene
  9931. * @param container contains the elements to remove
  9932. * @param dispose if the removed element should be disposed (default: false)
  9933. */
  9934. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9935. /**
  9936. * Serializes the component data to the specified json object
  9937. * @param serializationObject The object to serialize to
  9938. */
  9939. serialize(serializationObject: any): void;
  9940. }
  9941. /**
  9942. * Strong typing of a Mesh related stage step action
  9943. */
  9944. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9945. /**
  9946. * Strong typing of a Evaluate Sub Mesh related stage step action
  9947. */
  9948. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9949. /**
  9950. * Strong typing of a Active Mesh related stage step action
  9951. */
  9952. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9953. /**
  9954. * Strong typing of a Camera related stage step action
  9955. */
  9956. export type CameraStageAction = (camera: Camera) => void;
  9957. /**
  9958. * Strong typing of a Camera Frame buffer related stage step action
  9959. */
  9960. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9961. /**
  9962. * Strong typing of a Render Target related stage step action
  9963. */
  9964. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9965. /**
  9966. * Strong typing of a RenderingGroup related stage step action
  9967. */
  9968. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9969. /**
  9970. * Strong typing of a Mesh Render related stage step action
  9971. */
  9972. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9973. /**
  9974. * Strong typing of a simple stage step action
  9975. */
  9976. export type SimpleStageAction = () => void;
  9977. /**
  9978. * Strong typing of a render target action.
  9979. */
  9980. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9981. /**
  9982. * Strong typing of a pointer move action.
  9983. */
  9984. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9985. /**
  9986. * Strong typing of a pointer up/down action.
  9987. */
  9988. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9989. /**
  9990. * Representation of a stage in the scene (Basically a list of ordered steps)
  9991. * @hidden
  9992. */
  9993. export class Stage<T extends Function> extends Array<{
  9994. index: number;
  9995. component: ISceneComponent;
  9996. action: T;
  9997. }> {
  9998. /**
  9999. * Hide ctor from the rest of the world.
  10000. * @param items The items to add.
  10001. */
  10002. private constructor();
  10003. /**
  10004. * Creates a new Stage.
  10005. * @returns A new instance of a Stage
  10006. */
  10007. static Create<T extends Function>(): Stage<T>;
  10008. /**
  10009. * Registers a step in an ordered way in the targeted stage.
  10010. * @param index Defines the position to register the step in
  10011. * @param component Defines the component attached to the step
  10012. * @param action Defines the action to launch during the step
  10013. */
  10014. registerStep(index: number, component: ISceneComponent, action: T): void;
  10015. /**
  10016. * Clears all the steps from the stage.
  10017. */
  10018. clear(): void;
  10019. }
  10020. }
  10021. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10022. import { Nullable } from "babylonjs/types";
  10023. import { Observable } from "babylonjs/Misc/observable";
  10024. import { Scene } from "babylonjs/scene";
  10025. import { Sprite } from "babylonjs/Sprites/sprite";
  10026. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10027. import { Ray } from "babylonjs/Culling/ray";
  10028. import { Camera } from "babylonjs/Cameras/camera";
  10029. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10030. import { ISceneComponent } from "babylonjs/sceneComponent";
  10031. module "babylonjs/scene" {
  10032. interface Scene {
  10033. /** @hidden */
  10034. _pointerOverSprite: Nullable<Sprite>;
  10035. /** @hidden */
  10036. _pickedDownSprite: Nullable<Sprite>;
  10037. /** @hidden */
  10038. _tempSpritePickingRay: Nullable<Ray>;
  10039. /**
  10040. * All of the sprite managers added to this scene
  10041. * @see http://doc.babylonjs.com/babylon101/sprites
  10042. */
  10043. spriteManagers: Array<ISpriteManager>;
  10044. /**
  10045. * An event triggered when sprites rendering is about to start
  10046. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10047. */
  10048. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10049. /**
  10050. * An event triggered when sprites rendering is done
  10051. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10052. */
  10053. onAfterSpritesRenderingObservable: Observable<Scene>;
  10054. /** @hidden */
  10055. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10056. /** Launch a ray to try to pick a sprite in the scene
  10057. * @param x position on screen
  10058. * @param y position on screen
  10059. * @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
  10060. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10061. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10062. * @returns a PickingInfo
  10063. */
  10064. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10065. /** Use the given ray to pick a sprite in the scene
  10066. * @param ray The ray (in world space) to use to pick meshes
  10067. * @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
  10068. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10069. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10070. * @returns a PickingInfo
  10071. */
  10072. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10073. /** @hidden */
  10074. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10075. /** Launch a ray to try to pick sprites in the scene
  10076. * @param x position on screen
  10077. * @param y position on screen
  10078. * @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
  10079. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10080. * @returns a PickingInfo array
  10081. */
  10082. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10083. /** Use the given ray to pick sprites in the scene
  10084. * @param ray The ray (in world space) to use to pick meshes
  10085. * @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
  10086. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10087. * @returns a PickingInfo array
  10088. */
  10089. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10090. /**
  10091. * Force the sprite under the pointer
  10092. * @param sprite defines the sprite to use
  10093. */
  10094. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10095. /**
  10096. * Gets the sprite under the pointer
  10097. * @returns a Sprite or null if no sprite is under the pointer
  10098. */
  10099. getPointerOverSprite(): Nullable<Sprite>;
  10100. }
  10101. }
  10102. /**
  10103. * Defines the sprite scene component responsible to manage sprites
  10104. * in a given scene.
  10105. */
  10106. export class SpriteSceneComponent implements ISceneComponent {
  10107. /**
  10108. * The component name helpfull to identify the component in the list of scene components.
  10109. */
  10110. readonly name: string;
  10111. /**
  10112. * The scene the component belongs to.
  10113. */
  10114. scene: Scene;
  10115. /** @hidden */
  10116. private _spritePredicate;
  10117. /**
  10118. * Creates a new instance of the component for the given scene
  10119. * @param scene Defines the scene to register the component in
  10120. */
  10121. constructor(scene: Scene);
  10122. /**
  10123. * Registers the component in a given scene
  10124. */
  10125. register(): void;
  10126. /**
  10127. * Rebuilds the elements related to this component in case of
  10128. * context lost for instance.
  10129. */
  10130. rebuild(): void;
  10131. /**
  10132. * Disposes the component and the associated ressources.
  10133. */
  10134. dispose(): void;
  10135. private _pickSpriteButKeepRay;
  10136. private _pointerMove;
  10137. private _pointerDown;
  10138. private _pointerUp;
  10139. }
  10140. }
  10141. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  10142. /** @hidden */
  10143. export var fogFragmentDeclaration: {
  10144. name: string;
  10145. shader: string;
  10146. };
  10147. }
  10148. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  10149. /** @hidden */
  10150. export var fogFragment: {
  10151. name: string;
  10152. shader: string;
  10153. };
  10154. }
  10155. declare module "babylonjs/Shaders/sprites.fragment" {
  10156. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  10157. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  10158. /** @hidden */
  10159. export var spritesPixelShader: {
  10160. name: string;
  10161. shader: string;
  10162. };
  10163. }
  10164. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  10165. /** @hidden */
  10166. export var fogVertexDeclaration: {
  10167. name: string;
  10168. shader: string;
  10169. };
  10170. }
  10171. declare module "babylonjs/Shaders/sprites.vertex" {
  10172. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  10173. /** @hidden */
  10174. export var spritesVertexShader: {
  10175. name: string;
  10176. shader: string;
  10177. };
  10178. }
  10179. declare module "babylonjs/Sprites/spriteManager" {
  10180. import { IDisposable, Scene } from "babylonjs/scene";
  10181. import { Nullable } from "babylonjs/types";
  10182. import { Observable } from "babylonjs/Misc/observable";
  10183. import { Sprite } from "babylonjs/Sprites/sprite";
  10184. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10185. import { Camera } from "babylonjs/Cameras/camera";
  10186. import { Texture } from "babylonjs/Materials/Textures/texture";
  10187. import "babylonjs/Shaders/sprites.fragment";
  10188. import "babylonjs/Shaders/sprites.vertex";
  10189. import { Ray } from "babylonjs/Culling/ray";
  10190. /**
  10191. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10192. */
  10193. export interface ISpriteManager extends IDisposable {
  10194. /**
  10195. * Restricts the camera to viewing objects with the same layerMask.
  10196. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10197. */
  10198. layerMask: number;
  10199. /**
  10200. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10201. */
  10202. isPickable: boolean;
  10203. /**
  10204. * Specifies the rendering group id for this mesh (0 by default)
  10205. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10206. */
  10207. renderingGroupId: number;
  10208. /**
  10209. * Defines the list of sprites managed by the manager.
  10210. */
  10211. sprites: Array<Sprite>;
  10212. /**
  10213. * Tests the intersection of a sprite with a specific ray.
  10214. * @param ray The ray we are sending to test the collision
  10215. * @param camera The camera space we are sending rays in
  10216. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10217. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10218. * @returns picking info or null.
  10219. */
  10220. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10221. /**
  10222. * Intersects the sprites with a ray
  10223. * @param ray defines the ray to intersect with
  10224. * @param camera defines the current active camera
  10225. * @param predicate defines a predicate used to select candidate sprites
  10226. * @returns null if no hit or a PickingInfo array
  10227. */
  10228. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10229. /**
  10230. * Renders the list of sprites on screen.
  10231. */
  10232. render(): void;
  10233. }
  10234. /**
  10235. * Class used to manage multiple sprites on the same spritesheet
  10236. * @see http://doc.babylonjs.com/babylon101/sprites
  10237. */
  10238. export class SpriteManager implements ISpriteManager {
  10239. /** defines the manager's name */
  10240. name: string;
  10241. /** Gets the list of sprites */
  10242. sprites: Sprite[];
  10243. /** Gets or sets the rendering group id (0 by default) */
  10244. renderingGroupId: number;
  10245. /** Gets or sets camera layer mask */
  10246. layerMask: number;
  10247. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10248. fogEnabled: boolean;
  10249. /** Gets or sets a boolean indicating if the sprites are pickable */
  10250. isPickable: boolean;
  10251. /** Defines the default width of a cell in the spritesheet */
  10252. cellWidth: number;
  10253. /** Defines the default height of a cell in the spritesheet */
  10254. cellHeight: number;
  10255. /** Associative array from JSON sprite data file */
  10256. private _cellData;
  10257. /** Array of sprite names from JSON sprite data file */
  10258. private _spriteMap;
  10259. /** True when packed cell data from JSON file is ready*/
  10260. private _packedAndReady;
  10261. private _textureContent;
  10262. /**
  10263. * An event triggered when the manager is disposed.
  10264. */
  10265. onDisposeObservable: Observable<SpriteManager>;
  10266. private _onDisposeObserver;
  10267. /**
  10268. * Callback called when the manager is disposed
  10269. */
  10270. set onDispose(callback: () => void);
  10271. private _capacity;
  10272. private _fromPacked;
  10273. private _spriteTexture;
  10274. private _epsilon;
  10275. private _scene;
  10276. private _vertexData;
  10277. private _buffer;
  10278. private _vertexBuffers;
  10279. private _indexBuffer;
  10280. private _effectBase;
  10281. private _effectFog;
  10282. /**
  10283. * Gets or sets the spritesheet texture
  10284. */
  10285. get texture(): Texture;
  10286. set texture(value: Texture);
  10287. private _blendMode;
  10288. /**
  10289. * Blend mode use to render the particle, it can be any of
  10290. * the static Constants.ALPHA_x properties provided in this class.
  10291. * Default value is Constants.ALPHA_COMBINE
  10292. */
  10293. get blendMode(): number;
  10294. set blendMode(blendMode: number);
  10295. /** Disables writing to the depth buffer when rendering the sprites.
  10296. * It can be handy to disable depth writing when using textures without alpha channel
  10297. * and setting some specific blend modes.
  10298. */
  10299. disableDepthWrite: boolean;
  10300. /**
  10301. * Creates a new sprite manager
  10302. * @param name defines the manager's name
  10303. * @param imgUrl defines the sprite sheet url
  10304. * @param capacity defines the maximum allowed number of sprites
  10305. * @param cellSize defines the size of a sprite cell
  10306. * @param scene defines the hosting scene
  10307. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10308. * @param samplingMode defines the smapling mode to use with spritesheet
  10309. * @param fromPacked set to false; do not alter
  10310. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10311. */
  10312. constructor(
  10313. /** defines the manager's name */
  10314. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10315. private _makePacked;
  10316. private _appendSpriteVertex;
  10317. private _checkTextureAlpha;
  10318. /**
  10319. * Intersects the sprites with a ray
  10320. * @param ray defines the ray to intersect with
  10321. * @param camera defines the current active camera
  10322. * @param predicate defines a predicate used to select candidate sprites
  10323. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10324. * @returns null if no hit or a PickingInfo
  10325. */
  10326. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10327. /**
  10328. * Intersects the sprites with a ray
  10329. * @param ray defines the ray to intersect with
  10330. * @param camera defines the current active camera
  10331. * @param predicate defines a predicate used to select candidate sprites
  10332. * @returns null if no hit or a PickingInfo array
  10333. */
  10334. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10335. /**
  10336. * Render all child sprites
  10337. */
  10338. render(): void;
  10339. /**
  10340. * Release associated resources
  10341. */
  10342. dispose(): void;
  10343. }
  10344. }
  10345. declare module "babylonjs/Misc/gradients" {
  10346. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  10347. /** Interface used by value gradients (color, factor, ...) */
  10348. export interface IValueGradient {
  10349. /**
  10350. * Gets or sets the gradient value (between 0 and 1)
  10351. */
  10352. gradient: number;
  10353. }
  10354. /** Class used to store color4 gradient */
  10355. export class ColorGradient implements IValueGradient {
  10356. /**
  10357. * Gets or sets the gradient value (between 0 and 1)
  10358. */
  10359. gradient: number;
  10360. /**
  10361. * Gets or sets first associated color
  10362. */
  10363. color1: Color4;
  10364. /**
  10365. * Gets or sets second associated color
  10366. */
  10367. color2?: Color4 | undefined;
  10368. /**
  10369. * Creates a new color4 gradient
  10370. * @param gradient gets or sets the gradient value (between 0 and 1)
  10371. * @param color1 gets or sets first associated color
  10372. * @param color2 gets or sets first second color
  10373. */
  10374. constructor(
  10375. /**
  10376. * Gets or sets the gradient value (between 0 and 1)
  10377. */
  10378. gradient: number,
  10379. /**
  10380. * Gets or sets first associated color
  10381. */
  10382. color1: Color4,
  10383. /**
  10384. * Gets or sets second associated color
  10385. */
  10386. color2?: Color4 | undefined);
  10387. /**
  10388. * Will get a color picked randomly between color1 and color2.
  10389. * If color2 is undefined then color1 will be used
  10390. * @param result defines the target Color4 to store the result in
  10391. */
  10392. getColorToRef(result: Color4): void;
  10393. }
  10394. /** Class used to store color 3 gradient */
  10395. export class Color3Gradient implements IValueGradient {
  10396. /**
  10397. * Gets or sets the gradient value (between 0 and 1)
  10398. */
  10399. gradient: number;
  10400. /**
  10401. * Gets or sets the associated color
  10402. */
  10403. color: Color3;
  10404. /**
  10405. * Creates a new color3 gradient
  10406. * @param gradient gets or sets the gradient value (between 0 and 1)
  10407. * @param color gets or sets associated color
  10408. */
  10409. constructor(
  10410. /**
  10411. * Gets or sets the gradient value (between 0 and 1)
  10412. */
  10413. gradient: number,
  10414. /**
  10415. * Gets or sets the associated color
  10416. */
  10417. color: Color3);
  10418. }
  10419. /** Class used to store factor gradient */
  10420. export class FactorGradient implements IValueGradient {
  10421. /**
  10422. * Gets or sets the gradient value (between 0 and 1)
  10423. */
  10424. gradient: number;
  10425. /**
  10426. * Gets or sets first associated factor
  10427. */
  10428. factor1: number;
  10429. /**
  10430. * Gets or sets second associated factor
  10431. */
  10432. factor2?: number | undefined;
  10433. /**
  10434. * Creates a new factor gradient
  10435. * @param gradient gets or sets the gradient value (between 0 and 1)
  10436. * @param factor1 gets or sets first associated factor
  10437. * @param factor2 gets or sets second associated factor
  10438. */
  10439. constructor(
  10440. /**
  10441. * Gets or sets the gradient value (between 0 and 1)
  10442. */
  10443. gradient: number,
  10444. /**
  10445. * Gets or sets first associated factor
  10446. */
  10447. factor1: number,
  10448. /**
  10449. * Gets or sets second associated factor
  10450. */
  10451. factor2?: number | undefined);
  10452. /**
  10453. * Will get a number picked randomly between factor1 and factor2.
  10454. * If factor2 is undefined then factor1 will be used
  10455. * @returns the picked number
  10456. */
  10457. getFactor(): number;
  10458. }
  10459. /**
  10460. * Helper used to simplify some generic gradient tasks
  10461. */
  10462. export class GradientHelper {
  10463. /**
  10464. * Gets the current gradient from an array of IValueGradient
  10465. * @param ratio defines the current ratio to get
  10466. * @param gradients defines the array of IValueGradient
  10467. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10468. */
  10469. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10470. }
  10471. }
  10472. declare module "babylonjs/Maths/math.size" {
  10473. /**
  10474. * Interface for the size containing width and height
  10475. */
  10476. export interface ISize {
  10477. /**
  10478. * Width
  10479. */
  10480. width: number;
  10481. /**
  10482. * Heighht
  10483. */
  10484. height: number;
  10485. }
  10486. /**
  10487. * Size containing widht and height
  10488. */
  10489. export class Size implements ISize {
  10490. /**
  10491. * Width
  10492. */
  10493. width: number;
  10494. /**
  10495. * Height
  10496. */
  10497. height: number;
  10498. /**
  10499. * Creates a Size object from the given width and height (floats).
  10500. * @param width width of the new size
  10501. * @param height height of the new size
  10502. */
  10503. constructor(width: number, height: number);
  10504. /**
  10505. * Returns a string with the Size width and height
  10506. * @returns a string with the Size width and height
  10507. */
  10508. toString(): string;
  10509. /**
  10510. * "Size"
  10511. * @returns the string "Size"
  10512. */
  10513. getClassName(): string;
  10514. /**
  10515. * Returns the Size hash code.
  10516. * @returns a hash code for a unique width and height
  10517. */
  10518. getHashCode(): number;
  10519. /**
  10520. * Updates the current size from the given one.
  10521. * @param src the given size
  10522. */
  10523. copyFrom(src: Size): void;
  10524. /**
  10525. * Updates in place the current Size from the given floats.
  10526. * @param width width of the new size
  10527. * @param height height of the new size
  10528. * @returns the updated Size.
  10529. */
  10530. copyFromFloats(width: number, height: number): Size;
  10531. /**
  10532. * Updates in place the current Size from the given floats.
  10533. * @param width width to set
  10534. * @param height height to set
  10535. * @returns the updated Size.
  10536. */
  10537. set(width: number, height: number): Size;
  10538. /**
  10539. * Multiplies the width and height by numbers
  10540. * @param w factor to multiple the width by
  10541. * @param h factor to multiple the height by
  10542. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10543. */
  10544. multiplyByFloats(w: number, h: number): Size;
  10545. /**
  10546. * Clones the size
  10547. * @returns a new Size copied from the given one.
  10548. */
  10549. clone(): Size;
  10550. /**
  10551. * True if the current Size and the given one width and height are strictly equal.
  10552. * @param other the other size to compare against
  10553. * @returns True if the current Size and the given one width and height are strictly equal.
  10554. */
  10555. equals(other: Size): boolean;
  10556. /**
  10557. * The surface of the Size : width * height (float).
  10558. */
  10559. get surface(): number;
  10560. /**
  10561. * Create a new size of zero
  10562. * @returns a new Size set to (0.0, 0.0)
  10563. */
  10564. static Zero(): Size;
  10565. /**
  10566. * Sums the width and height of two sizes
  10567. * @param otherSize size to add to this size
  10568. * @returns a new Size set as the addition result of the current Size and the given one.
  10569. */
  10570. add(otherSize: Size): Size;
  10571. /**
  10572. * Subtracts the width and height of two
  10573. * @param otherSize size to subtract to this size
  10574. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10575. */
  10576. subtract(otherSize: Size): Size;
  10577. /**
  10578. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10579. * @param start starting size to lerp between
  10580. * @param end end size to lerp between
  10581. * @param amount amount to lerp between the start and end values
  10582. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10583. */
  10584. static Lerp(start: Size, end: Size, amount: number): Size;
  10585. }
  10586. }
  10587. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  10588. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10589. import { Nullable } from "babylonjs/types";
  10590. module "babylonjs/Engines/thinEngine" {
  10591. interface ThinEngine {
  10592. /**
  10593. * Creates a dynamic texture
  10594. * @param width defines the width of the texture
  10595. * @param height defines the height of the texture
  10596. * @param generateMipMaps defines if the engine should generate the mip levels
  10597. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10598. * @returns the dynamic texture inside an InternalTexture
  10599. */
  10600. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10601. /**
  10602. * Update the content of a dynamic texture
  10603. * @param texture defines the texture to update
  10604. * @param canvas defines the canvas containing the source
  10605. * @param invertY defines if data must be stored with Y axis inverted
  10606. * @param premulAlpha defines if alpha is stored as premultiplied
  10607. * @param format defines the format of the data
  10608. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10609. */
  10610. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10611. }
  10612. }
  10613. }
  10614. declare module "babylonjs/Misc/canvasGenerator" {
  10615. /**
  10616. * Helper class used to generate a canvas to manipulate images
  10617. */
  10618. export class CanvasGenerator {
  10619. /**
  10620. * Create a new canvas (or offscreen canvas depending on the context)
  10621. * @param width defines the expected width
  10622. * @param height defines the expected height
  10623. * @return a new canvas or offscreen canvas
  10624. */
  10625. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10626. }
  10627. }
  10628. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  10629. import { Scene } from "babylonjs/scene";
  10630. import { Texture } from "babylonjs/Materials/Textures/texture";
  10631. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  10632. /**
  10633. * A class extending Texture allowing drawing on a texture
  10634. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10635. */
  10636. export class DynamicTexture extends Texture {
  10637. private _generateMipMaps;
  10638. private _canvas;
  10639. private _context;
  10640. private _engine;
  10641. /**
  10642. * Creates a DynamicTexture
  10643. * @param name defines the name of the texture
  10644. * @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
  10645. * @param scene defines the scene where you want the texture
  10646. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10647. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10648. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10649. */
  10650. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10651. /**
  10652. * Get the current class name of the texture useful for serialization or dynamic coding.
  10653. * @returns "DynamicTexture"
  10654. */
  10655. getClassName(): string;
  10656. /**
  10657. * Gets the current state of canRescale
  10658. */
  10659. get canRescale(): boolean;
  10660. private _recreate;
  10661. /**
  10662. * Scales the texture
  10663. * @param ratio the scale factor to apply to both width and height
  10664. */
  10665. scale(ratio: number): void;
  10666. /**
  10667. * Resizes the texture
  10668. * @param width the new width
  10669. * @param height the new height
  10670. */
  10671. scaleTo(width: number, height: number): void;
  10672. /**
  10673. * Gets the context of the canvas used by the texture
  10674. * @returns the canvas context of the dynamic texture
  10675. */
  10676. getContext(): CanvasRenderingContext2D;
  10677. /**
  10678. * Clears the texture
  10679. */
  10680. clear(): void;
  10681. /**
  10682. * Updates the texture
  10683. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10684. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10685. */
  10686. update(invertY?: boolean, premulAlpha?: boolean): void;
  10687. /**
  10688. * Draws text onto the texture
  10689. * @param text defines the text to be drawn
  10690. * @param x defines the placement of the text from the left
  10691. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10692. * @param font defines the font to be used with font-style, font-size, font-name
  10693. * @param color defines the color used for the text
  10694. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10695. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10696. * @param update defines whether texture is immediately update (default is true)
  10697. */
  10698. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  10699. /**
  10700. * Clones the texture
  10701. * @returns the clone of the texture.
  10702. */
  10703. clone(): DynamicTexture;
  10704. /**
  10705. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10706. * @returns a serialized dynamic texture object
  10707. */
  10708. serialize(): any;
  10709. /** @hidden */
  10710. _rebuild(): void;
  10711. }
  10712. }
  10713. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  10714. import { Nullable } from "babylonjs/types";
  10715. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10716. import { Scene } from "babylonjs/scene";
  10717. module "babylonjs/Engines/thinEngine" {
  10718. interface ThinEngine {
  10719. /**
  10720. * Creates a raw texture
  10721. * @param data defines the data to store in the texture
  10722. * @param width defines the width of the texture
  10723. * @param height defines the height of the texture
  10724. * @param format defines the format of the data
  10725. * @param generateMipMaps defines if the engine should generate the mip levels
  10726. * @param invertY defines if data must be stored with Y axis inverted
  10727. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10728. * @param compression defines the compression used (null by default)
  10729. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10730. * @returns the raw texture inside an InternalTexture
  10731. */
  10732. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10733. /**
  10734. * Update a raw texture
  10735. * @param texture defines the texture to update
  10736. * @param data defines the data to store in the texture
  10737. * @param format defines the format of the data
  10738. * @param invertY defines if data must be stored with Y axis inverted
  10739. */
  10740. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10741. /**
  10742. * Update a raw texture
  10743. * @param texture defines the texture to update
  10744. * @param data defines the data to store in the texture
  10745. * @param format defines the format of the data
  10746. * @param invertY defines if data must be stored with Y axis inverted
  10747. * @param compression defines the compression used (null by default)
  10748. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10749. */
  10750. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10751. /**
  10752. * Creates a new raw cube texture
  10753. * @param data defines the array of data to use to create each face
  10754. * @param size defines the size of the textures
  10755. * @param format defines the format of the data
  10756. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10757. * @param generateMipMaps defines if the engine should generate the mip levels
  10758. * @param invertY defines if data must be stored with Y axis inverted
  10759. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10760. * @param compression defines the compression used (null by default)
  10761. * @returns the cube texture as an InternalTexture
  10762. */
  10763. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10764. /**
  10765. * Update a raw cube texture
  10766. * @param texture defines the texture to udpdate
  10767. * @param data defines the data to store
  10768. * @param format defines the data format
  10769. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10770. * @param invertY defines if data must be stored with Y axis inverted
  10771. */
  10772. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10773. /**
  10774. * Update a raw cube texture
  10775. * @param texture defines the texture to udpdate
  10776. * @param data defines the data to store
  10777. * @param format defines the data format
  10778. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10779. * @param invertY defines if data must be stored with Y axis inverted
  10780. * @param compression defines the compression used (null by default)
  10781. */
  10782. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10783. /**
  10784. * Update a raw cube texture
  10785. * @param texture defines the texture to udpdate
  10786. * @param data defines the data to store
  10787. * @param format defines the data format
  10788. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10789. * @param invertY defines if data must be stored with Y axis inverted
  10790. * @param compression defines the compression used (null by default)
  10791. * @param level defines which level of the texture to update
  10792. */
  10793. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10794. /**
  10795. * Creates a new raw cube texture from a specified url
  10796. * @param url defines the url where the data is located
  10797. * @param scene defines the current scene
  10798. * @param size defines the size of the textures
  10799. * @param format defines the format of the data
  10800. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10801. * @param noMipmap defines if the engine should avoid generating the mip levels
  10802. * @param callback defines a callback used to extract texture data from loaded data
  10803. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10804. * @param onLoad defines a callback called when texture is loaded
  10805. * @param onError defines a callback called if there is an error
  10806. * @returns the cube texture as an InternalTexture
  10807. */
  10808. 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;
  10809. /**
  10810. * Creates a new raw cube texture from a specified url
  10811. * @param url defines the url where the data is located
  10812. * @param scene defines the current scene
  10813. * @param size defines the size of the textures
  10814. * @param format defines the format of the data
  10815. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10816. * @param noMipmap defines if the engine should avoid generating the mip levels
  10817. * @param callback defines a callback used to extract texture data from loaded data
  10818. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10819. * @param onLoad defines a callback called when texture is loaded
  10820. * @param onError defines a callback called if there is an error
  10821. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10822. * @param invertY defines if data must be stored with Y axis inverted
  10823. * @returns the cube texture as an InternalTexture
  10824. */
  10825. 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;
  10826. /**
  10827. * Creates a new raw 3D texture
  10828. * @param data defines the data used to create the texture
  10829. * @param width defines the width of the texture
  10830. * @param height defines the height of the texture
  10831. * @param depth defines the depth of the texture
  10832. * @param format defines the format of the texture
  10833. * @param generateMipMaps defines if the engine must generate mip levels
  10834. * @param invertY defines if data must be stored with Y axis inverted
  10835. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10836. * @param compression defines the compressed used (can be null)
  10837. * @param textureType defines the compressed used (can be null)
  10838. * @returns a new raw 3D texture (stored in an InternalTexture)
  10839. */
  10840. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10841. /**
  10842. * Update a raw 3D texture
  10843. * @param texture defines the texture to update
  10844. * @param data defines the data to store
  10845. * @param format defines the data format
  10846. * @param invertY defines if data must be stored with Y axis inverted
  10847. */
  10848. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10849. /**
  10850. * Update a raw 3D texture
  10851. * @param texture defines the texture to update
  10852. * @param data defines the data to store
  10853. * @param format defines the data format
  10854. * @param invertY defines if data must be stored with Y axis inverted
  10855. * @param compression defines the used compression (can be null)
  10856. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10857. */
  10858. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10859. /**
  10860. * Creates a new raw 2D array texture
  10861. * @param data defines the data used to create the texture
  10862. * @param width defines the width of the texture
  10863. * @param height defines the height of the texture
  10864. * @param depth defines the number of layers of the texture
  10865. * @param format defines the format of the texture
  10866. * @param generateMipMaps defines if the engine must generate mip levels
  10867. * @param invertY defines if data must be stored with Y axis inverted
  10868. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10869. * @param compression defines the compressed used (can be null)
  10870. * @param textureType defines the compressed used (can be null)
  10871. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10872. */
  10873. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10874. /**
  10875. * Update a raw 2D array texture
  10876. * @param texture defines the texture to update
  10877. * @param data defines the data to store
  10878. * @param format defines the data format
  10879. * @param invertY defines if data must be stored with Y axis inverted
  10880. */
  10881. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10882. /**
  10883. * Update a raw 2D array texture
  10884. * @param texture defines the texture to update
  10885. * @param data defines the data to store
  10886. * @param format defines the data format
  10887. * @param invertY defines if data must be stored with Y axis inverted
  10888. * @param compression defines the used compression (can be null)
  10889. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10890. */
  10891. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10892. }
  10893. }
  10894. }
  10895. declare module "babylonjs/Materials/Textures/rawTexture" {
  10896. import { Scene } from "babylonjs/scene";
  10897. import { Texture } from "babylonjs/Materials/Textures/texture";
  10898. import "babylonjs/Engines/Extensions/engine.rawTexture";
  10899. /**
  10900. * Raw texture can help creating a texture directly from an array of data.
  10901. * This can be super useful if you either get the data from an uncompressed source or
  10902. * if you wish to create your texture pixel by pixel.
  10903. */
  10904. export class RawTexture extends Texture {
  10905. /**
  10906. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10907. */
  10908. format: number;
  10909. private _engine;
  10910. /**
  10911. * Instantiates a new RawTexture.
  10912. * Raw texture can help creating a texture directly from an array of data.
  10913. * This can be super useful if you either get the data from an uncompressed source or
  10914. * if you wish to create your texture pixel by pixel.
  10915. * @param data define the array of data to use to create the texture
  10916. * @param width define the width of the texture
  10917. * @param height define the height of the texture
  10918. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10919. * @param scene define the scene the texture belongs to
  10920. * @param generateMipMaps define whether mip maps should be generated or not
  10921. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10922. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10923. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10924. */
  10925. constructor(data: ArrayBufferView, width: number, height: number,
  10926. /**
  10927. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10928. */
  10929. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10930. /**
  10931. * Updates the texture underlying data.
  10932. * @param data Define the new data of the texture
  10933. */
  10934. update(data: ArrayBufferView): void;
  10935. /**
  10936. * Creates a luminance texture from some data.
  10937. * @param data Define the texture data
  10938. * @param width Define the width of the texture
  10939. * @param height Define the height of the texture
  10940. * @param scene Define the scene the texture belongs to
  10941. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10942. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10943. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10944. * @returns the luminance texture
  10945. */
  10946. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10947. /**
  10948. * Creates a luminance alpha texture from some data.
  10949. * @param data Define the texture data
  10950. * @param width Define the width of the texture
  10951. * @param height Define the height of the texture
  10952. * @param scene Define the scene the texture belongs to
  10953. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10954. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10955. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10956. * @returns the luminance alpha texture
  10957. */
  10958. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10959. /**
  10960. * Creates an alpha texture from some data.
  10961. * @param data Define the texture data
  10962. * @param width Define the width of the texture
  10963. * @param height Define the height of the texture
  10964. * @param scene Define the scene the texture belongs to
  10965. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10966. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10967. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10968. * @returns the alpha texture
  10969. */
  10970. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10971. /**
  10972. * Creates a RGB texture from some data.
  10973. * @param data Define the texture data
  10974. * @param width Define the width of the texture
  10975. * @param height Define the height of the texture
  10976. * @param scene Define the scene the texture belongs to
  10977. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10978. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10979. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10980. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10981. * @returns the RGB alpha texture
  10982. */
  10983. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10984. /**
  10985. * Creates a RGBA texture from some data.
  10986. * @param data Define the texture data
  10987. * @param width Define the width of the texture
  10988. * @param height Define the height of the texture
  10989. * @param scene Define the scene the texture belongs to
  10990. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10991. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10992. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10993. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10994. * @returns the RGBA texture
  10995. */
  10996. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10997. /**
  10998. * Creates a R texture from some data.
  10999. * @param data Define the texture data
  11000. * @param width Define the width of the texture
  11001. * @param height Define the height of the texture
  11002. * @param scene Define the scene the texture belongs to
  11003. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11004. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11005. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11006. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11007. * @returns the R texture
  11008. */
  11009. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11010. }
  11011. }
  11012. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11013. import { Scene } from "babylonjs/scene";
  11014. import { ISceneComponent } from "babylonjs/sceneComponent";
  11015. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11016. module "babylonjs/abstractScene" {
  11017. interface AbstractScene {
  11018. /**
  11019. * The list of procedural textures added to the scene
  11020. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11021. */
  11022. proceduralTextures: Array<ProceduralTexture>;
  11023. }
  11024. }
  11025. /**
  11026. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11027. * in a given scene.
  11028. */
  11029. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11030. /**
  11031. * The component name helpfull to identify the component in the list of scene components.
  11032. */
  11033. readonly name: string;
  11034. /**
  11035. * The scene the component belongs to.
  11036. */
  11037. scene: Scene;
  11038. /**
  11039. * Creates a new instance of the component for the given scene
  11040. * @param scene Defines the scene to register the component in
  11041. */
  11042. constructor(scene: Scene);
  11043. /**
  11044. * Registers the component in a given scene
  11045. */
  11046. register(): void;
  11047. /**
  11048. * Rebuilds the elements related to this component in case of
  11049. * context lost for instance.
  11050. */
  11051. rebuild(): void;
  11052. /**
  11053. * Disposes the component and the associated ressources.
  11054. */
  11055. dispose(): void;
  11056. private _beforeClear;
  11057. }
  11058. }
  11059. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11060. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11061. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11062. module "babylonjs/Engines/thinEngine" {
  11063. interface ThinEngine {
  11064. /**
  11065. * Creates a new render target cube texture
  11066. * @param size defines the size of the texture
  11067. * @param options defines the options used to create the texture
  11068. * @returns a new render target cube texture stored in an InternalTexture
  11069. */
  11070. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11071. }
  11072. }
  11073. }
  11074. declare module "babylonjs/Shaders/procedural.vertex" {
  11075. /** @hidden */
  11076. export var proceduralVertexShader: {
  11077. name: string;
  11078. shader: string;
  11079. };
  11080. }
  11081. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11082. import { Observable } from "babylonjs/Misc/observable";
  11083. import { Nullable } from "babylonjs/types";
  11084. import { Scene } from "babylonjs/scene";
  11085. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11086. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11087. import { Effect } from "babylonjs/Materials/effect";
  11088. import { Texture } from "babylonjs/Materials/Textures/texture";
  11089. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11090. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11091. import "babylonjs/Shaders/procedural.vertex";
  11092. /**
  11093. * 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.
  11094. * This is the base class of any Procedural texture and contains most of the shareable code.
  11095. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11096. */
  11097. export class ProceduralTexture extends Texture {
  11098. isCube: boolean;
  11099. /**
  11100. * Define if the texture is enabled or not (disabled texture will not render)
  11101. */
  11102. isEnabled: boolean;
  11103. /**
  11104. * Define if the texture must be cleared before rendering (default is true)
  11105. */
  11106. autoClear: boolean;
  11107. /**
  11108. * Callback called when the texture is generated
  11109. */
  11110. onGenerated: () => void;
  11111. /**
  11112. * Event raised when the texture is generated
  11113. */
  11114. onGeneratedObservable: Observable<ProceduralTexture>;
  11115. /** @hidden */
  11116. _generateMipMaps: boolean;
  11117. /** @hidden **/
  11118. _effect: Effect;
  11119. /** @hidden */
  11120. _textures: {
  11121. [key: string]: Texture;
  11122. };
  11123. /** @hidden */
  11124. protected _fallbackTexture: Nullable<Texture>;
  11125. private _size;
  11126. private _currentRefreshId;
  11127. private _frameId;
  11128. private _refreshRate;
  11129. private _vertexBuffers;
  11130. private _indexBuffer;
  11131. private _uniforms;
  11132. private _samplers;
  11133. private _fragment;
  11134. private _floats;
  11135. private _ints;
  11136. private _floatsArrays;
  11137. private _colors3;
  11138. private _colors4;
  11139. private _vectors2;
  11140. private _vectors3;
  11141. private _matrices;
  11142. private _fallbackTextureUsed;
  11143. private _engine;
  11144. private _cachedDefines;
  11145. private _contentUpdateId;
  11146. private _contentData;
  11147. /**
  11148. * Instantiates a new procedural texture.
  11149. * 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.
  11150. * This is the base class of any Procedural texture and contains most of the shareable code.
  11151. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11152. * @param name Define the name of the texture
  11153. * @param size Define the size of the texture to create
  11154. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11155. * @param scene Define the scene the texture belongs to
  11156. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11157. * @param generateMipMaps Define if the texture should creates mip maps or not
  11158. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11159. */
  11160. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11161. /**
  11162. * The effect that is created when initializing the post process.
  11163. * @returns The created effect corresponding the the postprocess.
  11164. */
  11165. getEffect(): Effect;
  11166. /**
  11167. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11168. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11169. */
  11170. getContent(): Nullable<ArrayBufferView>;
  11171. private _createIndexBuffer;
  11172. /** @hidden */
  11173. _rebuild(): void;
  11174. /**
  11175. * Resets the texture in order to recreate its associated resources.
  11176. * This can be called in case of context loss
  11177. */
  11178. reset(): void;
  11179. protected _getDefines(): string;
  11180. /**
  11181. * Is the texture ready to be used ? (rendered at least once)
  11182. * @returns true if ready, otherwise, false.
  11183. */
  11184. isReady(): boolean;
  11185. /**
  11186. * Resets the refresh counter of the texture and start bak from scratch.
  11187. * Could be useful to regenerate the texture if it is setup to render only once.
  11188. */
  11189. resetRefreshCounter(): void;
  11190. /**
  11191. * Set the fragment shader to use in order to render the texture.
  11192. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11193. */
  11194. setFragment(fragment: any): void;
  11195. /**
  11196. * Define the refresh rate of the texture or the rendering frequency.
  11197. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11198. */
  11199. get refreshRate(): number;
  11200. set refreshRate(value: number);
  11201. /** @hidden */
  11202. _shouldRender(): boolean;
  11203. /**
  11204. * Get the size the texture is rendering at.
  11205. * @returns the size (texture is always squared)
  11206. */
  11207. getRenderSize(): number;
  11208. /**
  11209. * Resize the texture to new value.
  11210. * @param size Define the new size the texture should have
  11211. * @param generateMipMaps Define whether the new texture should create mip maps
  11212. */
  11213. resize(size: number, generateMipMaps: boolean): void;
  11214. private _checkUniform;
  11215. /**
  11216. * Set a texture in the shader program used to render.
  11217. * @param name Define the name of the uniform samplers as defined in the shader
  11218. * @param texture Define the texture to bind to this sampler
  11219. * @return the texture itself allowing "fluent" like uniform updates
  11220. */
  11221. setTexture(name: string, texture: Texture): ProceduralTexture;
  11222. /**
  11223. * Set a float in the shader.
  11224. * @param name Define the name of the uniform as defined in the shader
  11225. * @param value Define the value to give to the uniform
  11226. * @return the texture itself allowing "fluent" like uniform updates
  11227. */
  11228. setFloat(name: string, value: number): ProceduralTexture;
  11229. /**
  11230. * Set a int in the shader.
  11231. * @param name Define the name of the uniform as defined in the shader
  11232. * @param value Define the value to give to the uniform
  11233. * @return the texture itself allowing "fluent" like uniform updates
  11234. */
  11235. setInt(name: string, value: number): ProceduralTexture;
  11236. /**
  11237. * Set an array of floats in the shader.
  11238. * @param name Define the name of the uniform as defined in the shader
  11239. * @param value Define the value to give to the uniform
  11240. * @return the texture itself allowing "fluent" like uniform updates
  11241. */
  11242. setFloats(name: string, value: number[]): ProceduralTexture;
  11243. /**
  11244. * Set a vec3 in the shader from a Color3.
  11245. * @param name Define the name of the uniform as defined in the shader
  11246. * @param value Define the value to give to the uniform
  11247. * @return the texture itself allowing "fluent" like uniform updates
  11248. */
  11249. setColor3(name: string, value: Color3): ProceduralTexture;
  11250. /**
  11251. * Set a vec4 in the shader from a Color4.
  11252. * @param name Define the name of the uniform as defined in the shader
  11253. * @param value Define the value to give to the uniform
  11254. * @return the texture itself allowing "fluent" like uniform updates
  11255. */
  11256. setColor4(name: string, value: Color4): ProceduralTexture;
  11257. /**
  11258. * Set a vec2 in the shader from a Vector2.
  11259. * @param name Define the name of the uniform as defined in the shader
  11260. * @param value Define the value to give to the uniform
  11261. * @return the texture itself allowing "fluent" like uniform updates
  11262. */
  11263. setVector2(name: string, value: Vector2): ProceduralTexture;
  11264. /**
  11265. * Set a vec3 in the shader from a Vector3.
  11266. * @param name Define the name of the uniform as defined in the shader
  11267. * @param value Define the value to give to the uniform
  11268. * @return the texture itself allowing "fluent" like uniform updates
  11269. */
  11270. setVector3(name: string, value: Vector3): ProceduralTexture;
  11271. /**
  11272. * Set a mat4 in the shader from a MAtrix.
  11273. * @param name Define the name of the uniform as defined in the shader
  11274. * @param value Define the value to give to the uniform
  11275. * @return the texture itself allowing "fluent" like uniform updates
  11276. */
  11277. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11278. /**
  11279. * Render the texture to its associated render target.
  11280. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11281. */
  11282. render(useCameraPostProcess?: boolean): void;
  11283. /**
  11284. * Clone the texture.
  11285. * @returns the cloned texture
  11286. */
  11287. clone(): ProceduralTexture;
  11288. /**
  11289. * Dispose the texture and release its asoociated resources.
  11290. */
  11291. dispose(): void;
  11292. }
  11293. }
  11294. declare module "babylonjs/Particles/baseParticleSystem" {
  11295. import { Nullable } from "babylonjs/types";
  11296. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  11297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11298. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  11299. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11300. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  11301. import { Scene } from "babylonjs/scene";
  11302. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  11303. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  11304. import { Texture } from "babylonjs/Materials/Textures/texture";
  11305. import { Color4 } from "babylonjs/Maths/math.color";
  11306. import { Animation } from "babylonjs/Animations/animation";
  11307. /**
  11308. * This represents the base class for particle system in Babylon.
  11309. * 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.
  11310. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11311. * @example https://doc.babylonjs.com/babylon101/particles
  11312. */
  11313. export class BaseParticleSystem {
  11314. /**
  11315. * Source color is added to the destination color without alpha affecting the result
  11316. */
  11317. static BLENDMODE_ONEONE: number;
  11318. /**
  11319. * Blend current color and particle color using particle’s alpha
  11320. */
  11321. static BLENDMODE_STANDARD: number;
  11322. /**
  11323. * Add current color and particle color multiplied by particle’s alpha
  11324. */
  11325. static BLENDMODE_ADD: number;
  11326. /**
  11327. * Multiply current color with particle color
  11328. */
  11329. static BLENDMODE_MULTIPLY: number;
  11330. /**
  11331. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11332. */
  11333. static BLENDMODE_MULTIPLYADD: number;
  11334. /**
  11335. * List of animations used by the particle system.
  11336. */
  11337. animations: Animation[];
  11338. /**
  11339. * Gets or sets the unique id of the particle system
  11340. */
  11341. uniqueId: number;
  11342. /**
  11343. * The id of the Particle system.
  11344. */
  11345. id: string;
  11346. /**
  11347. * The friendly name of the Particle system.
  11348. */
  11349. name: string;
  11350. /**
  11351. * Snippet ID if the particle system was created from the snippet server
  11352. */
  11353. snippetId: string;
  11354. /**
  11355. * The rendering group used by the Particle system to chose when to render.
  11356. */
  11357. renderingGroupId: number;
  11358. /**
  11359. * The emitter represents the Mesh or position we are attaching the particle system to.
  11360. */
  11361. emitter: Nullable<AbstractMesh | Vector3>;
  11362. /**
  11363. * The maximum number of particles to emit per frame
  11364. */
  11365. emitRate: number;
  11366. /**
  11367. * If you want to launch only a few particles at once, that can be done, as well.
  11368. */
  11369. manualEmitCount: number;
  11370. /**
  11371. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11372. */
  11373. updateSpeed: number;
  11374. /**
  11375. * The amount of time the particle system is running (depends of the overall update speed).
  11376. */
  11377. targetStopDuration: number;
  11378. /**
  11379. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11380. */
  11381. disposeOnStop: boolean;
  11382. /**
  11383. * Minimum power of emitting particles.
  11384. */
  11385. minEmitPower: number;
  11386. /**
  11387. * Maximum power of emitting particles.
  11388. */
  11389. maxEmitPower: number;
  11390. /**
  11391. * Minimum life time of emitting particles.
  11392. */
  11393. minLifeTime: number;
  11394. /**
  11395. * Maximum life time of emitting particles.
  11396. */
  11397. maxLifeTime: number;
  11398. /**
  11399. * Minimum Size of emitting particles.
  11400. */
  11401. minSize: number;
  11402. /**
  11403. * Maximum Size of emitting particles.
  11404. */
  11405. maxSize: number;
  11406. /**
  11407. * Minimum scale of emitting particles on X axis.
  11408. */
  11409. minScaleX: number;
  11410. /**
  11411. * Maximum scale of emitting particles on X axis.
  11412. */
  11413. maxScaleX: number;
  11414. /**
  11415. * Minimum scale of emitting particles on Y axis.
  11416. */
  11417. minScaleY: number;
  11418. /**
  11419. * Maximum scale of emitting particles on Y axis.
  11420. */
  11421. maxScaleY: number;
  11422. /**
  11423. * Gets or sets the minimal initial rotation in radians.
  11424. */
  11425. minInitialRotation: number;
  11426. /**
  11427. * Gets or sets the maximal initial rotation in radians.
  11428. */
  11429. maxInitialRotation: number;
  11430. /**
  11431. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11432. */
  11433. minAngularSpeed: number;
  11434. /**
  11435. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11436. */
  11437. maxAngularSpeed: number;
  11438. /**
  11439. * The texture used to render each particle. (this can be a spritesheet)
  11440. */
  11441. particleTexture: Nullable<Texture>;
  11442. /**
  11443. * The layer mask we are rendering the particles through.
  11444. */
  11445. layerMask: number;
  11446. /**
  11447. * This can help using your own shader to render the particle system.
  11448. * The according effect will be created
  11449. */
  11450. customShader: any;
  11451. /**
  11452. * By default particle system starts as soon as they are created. This prevents the
  11453. * automatic start to happen and let you decide when to start emitting particles.
  11454. */
  11455. preventAutoStart: boolean;
  11456. private _noiseTexture;
  11457. /**
  11458. * Gets or sets a texture used to add random noise to particle positions
  11459. */
  11460. get noiseTexture(): Nullable<ProceduralTexture>;
  11461. set noiseTexture(value: Nullable<ProceduralTexture>);
  11462. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11463. noiseStrength: Vector3;
  11464. /**
  11465. * Callback triggered when the particle animation is ending.
  11466. */
  11467. onAnimationEnd: Nullable<() => void>;
  11468. /**
  11469. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11470. */
  11471. blendMode: number;
  11472. /**
  11473. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11474. * to override the particles.
  11475. */
  11476. forceDepthWrite: boolean;
  11477. /** 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 */
  11478. preWarmCycles: number;
  11479. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11480. preWarmStepOffset: number;
  11481. /**
  11482. * 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)
  11483. */
  11484. spriteCellChangeSpeed: number;
  11485. /**
  11486. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11487. */
  11488. startSpriteCellID: number;
  11489. /**
  11490. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11491. */
  11492. endSpriteCellID: number;
  11493. /**
  11494. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11495. */
  11496. spriteCellWidth: number;
  11497. /**
  11498. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11499. */
  11500. spriteCellHeight: number;
  11501. /**
  11502. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11503. */
  11504. spriteRandomStartCell: boolean;
  11505. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11506. translationPivot: Vector2;
  11507. /** @hidden */
  11508. protected _isAnimationSheetEnabled: boolean;
  11509. /**
  11510. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11511. */
  11512. beginAnimationOnStart: boolean;
  11513. /**
  11514. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11515. */
  11516. beginAnimationFrom: number;
  11517. /**
  11518. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11519. */
  11520. beginAnimationTo: number;
  11521. /**
  11522. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11523. */
  11524. beginAnimationLoop: boolean;
  11525. /**
  11526. * Gets or sets a world offset applied to all particles
  11527. */
  11528. worldOffset: Vector3;
  11529. /**
  11530. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11531. */
  11532. get isAnimationSheetEnabled(): boolean;
  11533. set isAnimationSheetEnabled(value: boolean);
  11534. /**
  11535. * Get hosting scene
  11536. * @returns the scene
  11537. */
  11538. getScene(): Scene;
  11539. /**
  11540. * You can use gravity if you want to give an orientation to your particles.
  11541. */
  11542. gravity: Vector3;
  11543. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11544. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11545. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11546. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11547. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11548. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11549. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11550. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11551. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11552. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11553. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11554. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11555. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11556. /**
  11557. * Defines the delay in milliseconds before starting the system (0 by default)
  11558. */
  11559. startDelay: number;
  11560. /**
  11561. * Gets the current list of drag gradients.
  11562. * You must use addDragGradient and removeDragGradient to udpate this list
  11563. * @returns the list of drag gradients
  11564. */
  11565. getDragGradients(): Nullable<Array<FactorGradient>>;
  11566. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11567. limitVelocityDamping: number;
  11568. /**
  11569. * Gets the current list of limit velocity gradients.
  11570. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11571. * @returns the list of limit velocity gradients
  11572. */
  11573. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11574. /**
  11575. * Gets the current list of color gradients.
  11576. * You must use addColorGradient and removeColorGradient to udpate this list
  11577. * @returns the list of color gradients
  11578. */
  11579. getColorGradients(): Nullable<Array<ColorGradient>>;
  11580. /**
  11581. * Gets the current list of size gradients.
  11582. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11583. * @returns the list of size gradients
  11584. */
  11585. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11586. /**
  11587. * Gets the current list of color remap gradients.
  11588. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11589. * @returns the list of color remap gradients
  11590. */
  11591. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11592. /**
  11593. * Gets the current list of alpha remap gradients.
  11594. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11595. * @returns the list of alpha remap gradients
  11596. */
  11597. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11598. /**
  11599. * Gets the current list of life time gradients.
  11600. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11601. * @returns the list of life time gradients
  11602. */
  11603. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11604. /**
  11605. * Gets the current list of angular speed gradients.
  11606. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11607. * @returns the list of angular speed gradients
  11608. */
  11609. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11610. /**
  11611. * Gets the current list of velocity gradients.
  11612. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11613. * @returns the list of velocity gradients
  11614. */
  11615. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11616. /**
  11617. * Gets the current list of start size gradients.
  11618. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11619. * @returns the list of start size gradients
  11620. */
  11621. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11622. /**
  11623. * Gets the current list of emit rate gradients.
  11624. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11625. * @returns the list of emit rate gradients
  11626. */
  11627. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11628. /**
  11629. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11630. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11631. */
  11632. get direction1(): Vector3;
  11633. set direction1(value: Vector3);
  11634. /**
  11635. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11636. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11637. */
  11638. get direction2(): Vector3;
  11639. set direction2(value: Vector3);
  11640. /**
  11641. * 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.
  11642. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11643. */
  11644. get minEmitBox(): Vector3;
  11645. set minEmitBox(value: Vector3);
  11646. /**
  11647. * 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.
  11648. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11649. */
  11650. get maxEmitBox(): Vector3;
  11651. set maxEmitBox(value: Vector3);
  11652. /**
  11653. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11654. */
  11655. color1: Color4;
  11656. /**
  11657. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11658. */
  11659. color2: Color4;
  11660. /**
  11661. * Color the particle will have at the end of its lifetime
  11662. */
  11663. colorDead: Color4;
  11664. /**
  11665. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11666. */
  11667. textureMask: Color4;
  11668. /**
  11669. * The particle emitter type defines the emitter used by the particle system.
  11670. * It can be for example box, sphere, or cone...
  11671. */
  11672. particleEmitterType: IParticleEmitterType;
  11673. /** @hidden */
  11674. _isSubEmitter: boolean;
  11675. /**
  11676. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11677. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11678. */
  11679. billboardMode: number;
  11680. protected _isBillboardBased: boolean;
  11681. /**
  11682. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11683. */
  11684. get isBillboardBased(): boolean;
  11685. set isBillboardBased(value: boolean);
  11686. /**
  11687. * The scene the particle system belongs to.
  11688. */
  11689. protected _scene: Scene;
  11690. /**
  11691. * Local cache of defines for image processing.
  11692. */
  11693. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11694. /**
  11695. * Default configuration related to image processing available in the standard Material.
  11696. */
  11697. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11698. /**
  11699. * Gets the image processing configuration used either in this material.
  11700. */
  11701. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11702. /**
  11703. * Sets the Default image processing configuration used either in the this material.
  11704. *
  11705. * If sets to null, the scene one is in use.
  11706. */
  11707. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11708. /**
  11709. * Attaches a new image processing configuration to the Standard Material.
  11710. * @param configuration
  11711. */
  11712. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11713. /** @hidden */
  11714. protected _reset(): void;
  11715. /** @hidden */
  11716. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11717. /**
  11718. * Instantiates a particle system.
  11719. * 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.
  11720. * @param name The name of the particle system
  11721. */
  11722. constructor(name: string);
  11723. /**
  11724. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11725. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11726. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11727. * @returns the emitter
  11728. */
  11729. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11730. /**
  11731. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11732. * @param radius The radius of the hemisphere to emit from
  11733. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11734. * @returns the emitter
  11735. */
  11736. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11737. /**
  11738. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11739. * @param radius The radius of the sphere to emit from
  11740. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11741. * @returns the emitter
  11742. */
  11743. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11744. /**
  11745. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11746. * @param radius The radius of the sphere to emit from
  11747. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11748. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11749. * @returns the emitter
  11750. */
  11751. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11752. /**
  11753. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11754. * @param radius The radius of the emission cylinder
  11755. * @param height The height of the emission cylinder
  11756. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11757. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11758. * @returns the emitter
  11759. */
  11760. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11761. /**
  11762. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11763. * @param radius The radius of the cylinder to emit from
  11764. * @param height The height of the emission cylinder
  11765. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11766. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11767. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11768. * @returns the emitter
  11769. */
  11770. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11771. /**
  11772. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11773. * @param radius The radius of the cone to emit from
  11774. * @param angle The base angle of the cone
  11775. * @returns the emitter
  11776. */
  11777. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11778. /**
  11779. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11780. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11781. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11782. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11783. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11784. * @returns the emitter
  11785. */
  11786. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11787. }
  11788. }
  11789. declare module "babylonjs/Particles/subEmitter" {
  11790. import { Scene } from "babylonjs/scene";
  11791. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  11792. /**
  11793. * Type of sub emitter
  11794. */
  11795. export enum SubEmitterType {
  11796. /**
  11797. * Attached to the particle over it's lifetime
  11798. */
  11799. ATTACHED = 0,
  11800. /**
  11801. * Created when the particle dies
  11802. */
  11803. END = 1
  11804. }
  11805. /**
  11806. * Sub emitter class used to emit particles from an existing particle
  11807. */
  11808. export class SubEmitter {
  11809. /**
  11810. * the particle system to be used by the sub emitter
  11811. */
  11812. particleSystem: ParticleSystem;
  11813. /**
  11814. * Type of the submitter (Default: END)
  11815. */
  11816. type: SubEmitterType;
  11817. /**
  11818. * 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)
  11819. * Note: This only is supported when using an emitter of type Mesh
  11820. */
  11821. inheritDirection: boolean;
  11822. /**
  11823. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11824. */
  11825. inheritedVelocityAmount: number;
  11826. /**
  11827. * Creates a sub emitter
  11828. * @param particleSystem the particle system to be used by the sub emitter
  11829. */
  11830. constructor(
  11831. /**
  11832. * the particle system to be used by the sub emitter
  11833. */
  11834. particleSystem: ParticleSystem);
  11835. /**
  11836. * Clones the sub emitter
  11837. * @returns the cloned sub emitter
  11838. */
  11839. clone(): SubEmitter;
  11840. /**
  11841. * Serialize current object to a JSON object
  11842. * @returns the serialized object
  11843. */
  11844. serialize(): any;
  11845. /** @hidden */
  11846. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11847. /**
  11848. * Creates a new SubEmitter from a serialized JSON version
  11849. * @param serializationObject defines the JSON object to read from
  11850. * @param scene defines the hosting scene
  11851. * @param rootUrl defines the rootUrl for data loading
  11852. * @returns a new SubEmitter
  11853. */
  11854. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11855. /** Release associated resources */
  11856. dispose(): void;
  11857. }
  11858. }
  11859. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  11860. /** @hidden */
  11861. export var imageProcessingDeclaration: {
  11862. name: string;
  11863. shader: string;
  11864. };
  11865. }
  11866. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  11867. /** @hidden */
  11868. export var imageProcessingFunctions: {
  11869. name: string;
  11870. shader: string;
  11871. };
  11872. }
  11873. declare module "babylonjs/Shaders/particles.fragment" {
  11874. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  11875. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  11876. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11877. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  11878. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  11879. /** @hidden */
  11880. export var particlesPixelShader: {
  11881. name: string;
  11882. shader: string;
  11883. };
  11884. }
  11885. declare module "babylonjs/Shaders/particles.vertex" {
  11886. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  11887. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  11888. /** @hidden */
  11889. export var particlesVertexShader: {
  11890. name: string;
  11891. shader: string;
  11892. };
  11893. }
  11894. declare module "babylonjs/Particles/particleSystem" {
  11895. import { Nullable } from "babylonjs/types";
  11896. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  11897. import { Observable } from "babylonjs/Misc/observable";
  11898. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  11899. import { Effect } from "babylonjs/Materials/effect";
  11900. import { Scene, IDisposable } from "babylonjs/scene";
  11901. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  11902. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  11903. import { Particle } from "babylonjs/Particles/particle";
  11904. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  11905. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  11906. import "babylonjs/Shaders/particles.fragment";
  11907. import "babylonjs/Shaders/particles.vertex";
  11908. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11909. /**
  11910. * This represents a particle system in Babylon.
  11911. * 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.
  11912. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11913. * @example https://doc.babylonjs.com/babylon101/particles
  11914. */
  11915. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11916. /**
  11917. * Billboard mode will only apply to Y axis
  11918. */
  11919. static readonly BILLBOARDMODE_Y: number;
  11920. /**
  11921. * Billboard mode will apply to all axes
  11922. */
  11923. static readonly BILLBOARDMODE_ALL: number;
  11924. /**
  11925. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11926. */
  11927. static readonly BILLBOARDMODE_STRETCHED: number;
  11928. /**
  11929. * This function can be defined to provide custom update for active particles.
  11930. * This function will be called instead of regular update (age, position, color, etc.).
  11931. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11932. */
  11933. updateFunction: (particles: Particle[]) => void;
  11934. private _emitterWorldMatrix;
  11935. /**
  11936. * This function can be defined to specify initial direction for every new particle.
  11937. * It by default use the emitterType defined function
  11938. */
  11939. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11940. /**
  11941. * This function can be defined to specify initial position for every new particle.
  11942. * It by default use the emitterType defined function
  11943. */
  11944. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11945. /**
  11946. * @hidden
  11947. */
  11948. _inheritedVelocityOffset: Vector3;
  11949. /**
  11950. * An event triggered when the system is disposed
  11951. */
  11952. onDisposeObservable: Observable<ParticleSystem>;
  11953. private _onDisposeObserver;
  11954. /**
  11955. * Sets a callback that will be triggered when the system is disposed
  11956. */
  11957. set onDispose(callback: () => void);
  11958. private _particles;
  11959. private _epsilon;
  11960. private _capacity;
  11961. private _stockParticles;
  11962. private _newPartsExcess;
  11963. private _vertexData;
  11964. private _vertexBuffer;
  11965. private _vertexBuffers;
  11966. private _spriteBuffer;
  11967. private _indexBuffer;
  11968. private _effect;
  11969. private _customEffect;
  11970. private _cachedDefines;
  11971. private _scaledColorStep;
  11972. private _colorDiff;
  11973. private _scaledDirection;
  11974. private _scaledGravity;
  11975. private _currentRenderId;
  11976. private _alive;
  11977. private _useInstancing;
  11978. private _started;
  11979. private _stopped;
  11980. private _actualFrame;
  11981. private _scaledUpdateSpeed;
  11982. private _vertexBufferSize;
  11983. /** @hidden */
  11984. _currentEmitRateGradient: Nullable<FactorGradient>;
  11985. /** @hidden */
  11986. _currentEmitRate1: number;
  11987. /** @hidden */
  11988. _currentEmitRate2: number;
  11989. /** @hidden */
  11990. _currentStartSizeGradient: Nullable<FactorGradient>;
  11991. /** @hidden */
  11992. _currentStartSize1: number;
  11993. /** @hidden */
  11994. _currentStartSize2: number;
  11995. private readonly _rawTextureWidth;
  11996. private _rampGradientsTexture;
  11997. private _useRampGradients;
  11998. /** Gets or sets a boolean indicating that ramp gradients must be used
  11999. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12000. */
  12001. get useRampGradients(): boolean;
  12002. set useRampGradients(value: boolean);
  12003. /**
  12004. * 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.
  12005. * 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: [])
  12006. */
  12007. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12008. private _subEmitters;
  12009. /**
  12010. * @hidden
  12011. * If the particle systems emitter should be disposed when the particle system is disposed
  12012. */
  12013. _disposeEmitterOnDispose: boolean;
  12014. /**
  12015. * The current active Sub-systems, this property is used by the root particle system only.
  12016. */
  12017. activeSubSystems: Array<ParticleSystem>;
  12018. /**
  12019. * Specifies if the particles are updated in emitter local space or world space
  12020. */
  12021. isLocal: boolean;
  12022. private _rootParticleSystem;
  12023. /**
  12024. * Gets the current list of active particles
  12025. */
  12026. get particles(): Particle[];
  12027. /**
  12028. * Gets the number of particles active at the same time.
  12029. * @returns The number of active particles.
  12030. */
  12031. getActiveCount(): number;
  12032. /**
  12033. * Returns the string "ParticleSystem"
  12034. * @returns a string containing the class name
  12035. */
  12036. getClassName(): string;
  12037. /**
  12038. * Gets a boolean indicating that the system is stopping
  12039. * @returns true if the system is currently stopping
  12040. */
  12041. isStopping(): boolean;
  12042. /**
  12043. * Instantiates a particle system.
  12044. * 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.
  12045. * @param name The name of the particle system
  12046. * @param capacity The max number of particles alive at the same time
  12047. * @param scene The scene the particle system belongs to
  12048. * @param customEffect a custom effect used to change the way particles are rendered by default
  12049. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12050. * @param epsilon Offset used to render the particles
  12051. */
  12052. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12053. private _addFactorGradient;
  12054. private _removeFactorGradient;
  12055. /**
  12056. * Adds a new life time gradient
  12057. * @param gradient defines the gradient to use (between 0 and 1)
  12058. * @param factor defines the life time factor to affect to the specified gradient
  12059. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12060. * @returns the current particle system
  12061. */
  12062. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12063. /**
  12064. * Remove a specific life time gradient
  12065. * @param gradient defines the gradient to remove
  12066. * @returns the current particle system
  12067. */
  12068. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12069. /**
  12070. * Adds a new size gradient
  12071. * @param gradient defines the gradient to use (between 0 and 1)
  12072. * @param factor defines the size factor to affect to the specified gradient
  12073. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12074. * @returns the current particle system
  12075. */
  12076. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12077. /**
  12078. * Remove a specific size gradient
  12079. * @param gradient defines the gradient to remove
  12080. * @returns the current particle system
  12081. */
  12082. removeSizeGradient(gradient: number): IParticleSystem;
  12083. /**
  12084. * Adds a new color remap gradient
  12085. * @param gradient defines the gradient to use (between 0 and 1)
  12086. * @param min defines the color remap minimal range
  12087. * @param max defines the color remap maximal range
  12088. * @returns the current particle system
  12089. */
  12090. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12091. /**
  12092. * Remove a specific color remap gradient
  12093. * @param gradient defines the gradient to remove
  12094. * @returns the current particle system
  12095. */
  12096. removeColorRemapGradient(gradient: number): IParticleSystem;
  12097. /**
  12098. * Adds a new alpha remap gradient
  12099. * @param gradient defines the gradient to use (between 0 and 1)
  12100. * @param min defines the alpha remap minimal range
  12101. * @param max defines the alpha remap maximal range
  12102. * @returns the current particle system
  12103. */
  12104. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12105. /**
  12106. * Remove a specific alpha remap gradient
  12107. * @param gradient defines the gradient to remove
  12108. * @returns the current particle system
  12109. */
  12110. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12111. /**
  12112. * Adds a new angular speed gradient
  12113. * @param gradient defines the gradient to use (between 0 and 1)
  12114. * @param factor defines the angular speed to affect to the specified gradient
  12115. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12116. * @returns the current particle system
  12117. */
  12118. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12119. /**
  12120. * Remove a specific angular speed gradient
  12121. * @param gradient defines the gradient to remove
  12122. * @returns the current particle system
  12123. */
  12124. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12125. /**
  12126. * Adds a new velocity gradient
  12127. * @param gradient defines the gradient to use (between 0 and 1)
  12128. * @param factor defines the velocity to affect to the specified gradient
  12129. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12130. * @returns the current particle system
  12131. */
  12132. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12133. /**
  12134. * Remove a specific velocity gradient
  12135. * @param gradient defines the gradient to remove
  12136. * @returns the current particle system
  12137. */
  12138. removeVelocityGradient(gradient: number): IParticleSystem;
  12139. /**
  12140. * Adds a new limit velocity gradient
  12141. * @param gradient defines the gradient to use (between 0 and 1)
  12142. * @param factor defines the limit velocity value to affect to the specified gradient
  12143. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12144. * @returns the current particle system
  12145. */
  12146. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12147. /**
  12148. * Remove a specific limit velocity gradient
  12149. * @param gradient defines the gradient to remove
  12150. * @returns the current particle system
  12151. */
  12152. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12153. /**
  12154. * Adds a new drag gradient
  12155. * @param gradient defines the gradient to use (between 0 and 1)
  12156. * @param factor defines the drag value to affect to the specified gradient
  12157. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12158. * @returns the current particle system
  12159. */
  12160. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12161. /**
  12162. * Remove a specific drag gradient
  12163. * @param gradient defines the gradient to remove
  12164. * @returns the current particle system
  12165. */
  12166. removeDragGradient(gradient: number): IParticleSystem;
  12167. /**
  12168. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12169. * @param gradient defines the gradient to use (between 0 and 1)
  12170. * @param factor defines the emit rate value to affect to the specified gradient
  12171. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12172. * @returns the current particle system
  12173. */
  12174. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12175. /**
  12176. * Remove a specific emit rate gradient
  12177. * @param gradient defines the gradient to remove
  12178. * @returns the current particle system
  12179. */
  12180. removeEmitRateGradient(gradient: number): IParticleSystem;
  12181. /**
  12182. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12183. * @param gradient defines the gradient to use (between 0 and 1)
  12184. * @param factor defines the start size value to affect to the specified gradient
  12185. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12186. * @returns the current particle system
  12187. */
  12188. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12189. /**
  12190. * Remove a specific start size gradient
  12191. * @param gradient defines the gradient to remove
  12192. * @returns the current particle system
  12193. */
  12194. removeStartSizeGradient(gradient: number): IParticleSystem;
  12195. private _createRampGradientTexture;
  12196. /**
  12197. * Gets the current list of ramp gradients.
  12198. * You must use addRampGradient and removeRampGradient to udpate this list
  12199. * @returns the list of ramp gradients
  12200. */
  12201. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12202. /** Force the system to rebuild all gradients that need to be resync */
  12203. forceRefreshGradients(): void;
  12204. private _syncRampGradientTexture;
  12205. /**
  12206. * Adds a new ramp gradient used to remap particle colors
  12207. * @param gradient defines the gradient to use (between 0 and 1)
  12208. * @param color defines the color to affect to the specified gradient
  12209. * @returns the current particle system
  12210. */
  12211. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12212. /**
  12213. * Remove a specific ramp gradient
  12214. * @param gradient defines the gradient to remove
  12215. * @returns the current particle system
  12216. */
  12217. removeRampGradient(gradient: number): ParticleSystem;
  12218. /**
  12219. * Adds a new color gradient
  12220. * @param gradient defines the gradient to use (between 0 and 1)
  12221. * @param color1 defines the color to affect to the specified gradient
  12222. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12223. * @returns this particle system
  12224. */
  12225. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12226. /**
  12227. * Remove a specific color gradient
  12228. * @param gradient defines the gradient to remove
  12229. * @returns this particle system
  12230. */
  12231. removeColorGradient(gradient: number): IParticleSystem;
  12232. private _fetchR;
  12233. protected _reset(): void;
  12234. private _resetEffect;
  12235. private _createVertexBuffers;
  12236. private _createIndexBuffer;
  12237. /**
  12238. * Gets the maximum number of particles active at the same time.
  12239. * @returns The max number of active particles.
  12240. */
  12241. getCapacity(): number;
  12242. /**
  12243. * Gets whether there are still active particles in the system.
  12244. * @returns True if it is alive, otherwise false.
  12245. */
  12246. isAlive(): boolean;
  12247. /**
  12248. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12249. * @returns True if it has been started, otherwise false.
  12250. */
  12251. isStarted(): boolean;
  12252. private _prepareSubEmitterInternalArray;
  12253. /**
  12254. * Starts the particle system and begins to emit
  12255. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12256. */
  12257. start(delay?: number): void;
  12258. /**
  12259. * Stops the particle system.
  12260. * @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.
  12261. */
  12262. stop(stopSubEmitters?: boolean): void;
  12263. /**
  12264. * Remove all active particles
  12265. */
  12266. reset(): void;
  12267. /**
  12268. * @hidden (for internal use only)
  12269. */
  12270. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12271. /**
  12272. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12273. * Its lifetime will start back at 0.
  12274. */
  12275. recycleParticle: (particle: Particle) => void;
  12276. private _stopSubEmitters;
  12277. private _createParticle;
  12278. private _removeFromRoot;
  12279. private _emitFromParticle;
  12280. private _update;
  12281. /** @hidden */
  12282. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12283. /** @hidden */
  12284. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12285. /** @hidden */
  12286. private _getEffect;
  12287. /**
  12288. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12289. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12290. */
  12291. animate(preWarmOnly?: boolean): void;
  12292. private _appendParticleVertices;
  12293. /**
  12294. * Rebuilds the particle system.
  12295. */
  12296. rebuild(): void;
  12297. /**
  12298. * Is this system ready to be used/rendered
  12299. * @return true if the system is ready
  12300. */
  12301. isReady(): boolean;
  12302. private _render;
  12303. /**
  12304. * Renders the particle system in its current state.
  12305. * @returns the current number of particles
  12306. */
  12307. render(): number;
  12308. /**
  12309. * Disposes the particle system and free the associated resources
  12310. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12311. */
  12312. dispose(disposeTexture?: boolean): void;
  12313. /**
  12314. * Clones the particle system.
  12315. * @param name The name of the cloned object
  12316. * @param newEmitter The new emitter to use
  12317. * @returns the cloned particle system
  12318. */
  12319. clone(name: string, newEmitter: any): ParticleSystem;
  12320. /**
  12321. * Serializes the particle system to a JSON object
  12322. * @param serializeTexture defines if the texture must be serialized as well
  12323. * @returns the JSON object
  12324. */
  12325. serialize(serializeTexture?: boolean): any;
  12326. /** @hidden */
  12327. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12328. /** @hidden */
  12329. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12330. /**
  12331. * Parses a JSON object to create a particle system.
  12332. * @param parsedParticleSystem The JSON object to parse
  12333. * @param scene The scene to create the particle system in
  12334. * @param rootUrl The root url to use to load external dependencies like texture
  12335. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12336. * @returns the Parsed particle system
  12337. */
  12338. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12339. }
  12340. }
  12341. declare module "babylonjs/Particles/particle" {
  12342. import { Nullable } from "babylonjs/types";
  12343. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  12344. import { Color4 } from "babylonjs/Maths/math.color";
  12345. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12346. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12347. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  12348. /**
  12349. * A particle represents one of the element emitted by a particle system.
  12350. * This is mainly define by its coordinates, direction, velocity and age.
  12351. */
  12352. export class Particle {
  12353. /**
  12354. * The particle system the particle belongs to.
  12355. */
  12356. particleSystem: ParticleSystem;
  12357. private static _Count;
  12358. /**
  12359. * Unique ID of the particle
  12360. */
  12361. id: number;
  12362. /**
  12363. * The world position of the particle in the scene.
  12364. */
  12365. position: Vector3;
  12366. /**
  12367. * The world direction of the particle in the scene.
  12368. */
  12369. direction: Vector3;
  12370. /**
  12371. * The color of the particle.
  12372. */
  12373. color: Color4;
  12374. /**
  12375. * The color change of the particle per step.
  12376. */
  12377. colorStep: Color4;
  12378. /**
  12379. * Defines how long will the life of the particle be.
  12380. */
  12381. lifeTime: number;
  12382. /**
  12383. * The current age of the particle.
  12384. */
  12385. age: number;
  12386. /**
  12387. * The current size of the particle.
  12388. */
  12389. size: number;
  12390. /**
  12391. * The current scale of the particle.
  12392. */
  12393. scale: Vector2;
  12394. /**
  12395. * The current angle of the particle.
  12396. */
  12397. angle: number;
  12398. /**
  12399. * Defines how fast is the angle changing.
  12400. */
  12401. angularSpeed: number;
  12402. /**
  12403. * Defines the cell index used by the particle to be rendered from a sprite.
  12404. */
  12405. cellIndex: number;
  12406. /**
  12407. * The information required to support color remapping
  12408. */
  12409. remapData: Vector4;
  12410. /** @hidden */
  12411. _randomCellOffset?: number;
  12412. /** @hidden */
  12413. _initialDirection: Nullable<Vector3>;
  12414. /** @hidden */
  12415. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12416. /** @hidden */
  12417. _initialStartSpriteCellID: number;
  12418. /** @hidden */
  12419. _initialEndSpriteCellID: number;
  12420. /** @hidden */
  12421. _currentColorGradient: Nullable<ColorGradient>;
  12422. /** @hidden */
  12423. _currentColor1: Color4;
  12424. /** @hidden */
  12425. _currentColor2: Color4;
  12426. /** @hidden */
  12427. _currentSizeGradient: Nullable<FactorGradient>;
  12428. /** @hidden */
  12429. _currentSize1: number;
  12430. /** @hidden */
  12431. _currentSize2: number;
  12432. /** @hidden */
  12433. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12434. /** @hidden */
  12435. _currentAngularSpeed1: number;
  12436. /** @hidden */
  12437. _currentAngularSpeed2: number;
  12438. /** @hidden */
  12439. _currentVelocityGradient: Nullable<FactorGradient>;
  12440. /** @hidden */
  12441. _currentVelocity1: number;
  12442. /** @hidden */
  12443. _currentVelocity2: number;
  12444. /** @hidden */
  12445. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12446. /** @hidden */
  12447. _currentLimitVelocity1: number;
  12448. /** @hidden */
  12449. _currentLimitVelocity2: number;
  12450. /** @hidden */
  12451. _currentDragGradient: Nullable<FactorGradient>;
  12452. /** @hidden */
  12453. _currentDrag1: number;
  12454. /** @hidden */
  12455. _currentDrag2: number;
  12456. /** @hidden */
  12457. _randomNoiseCoordinates1: Vector3;
  12458. /** @hidden */
  12459. _randomNoiseCoordinates2: Vector3;
  12460. /** @hidden */
  12461. _localPosition?: Vector3;
  12462. /**
  12463. * Creates a new instance Particle
  12464. * @param particleSystem the particle system the particle belongs to
  12465. */
  12466. constructor(
  12467. /**
  12468. * The particle system the particle belongs to.
  12469. */
  12470. particleSystem: ParticleSystem);
  12471. private updateCellInfoFromSystem;
  12472. /**
  12473. * Defines how the sprite cell index is updated for the particle
  12474. */
  12475. updateCellIndex(): void;
  12476. /** @hidden */
  12477. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12478. /** @hidden */
  12479. _inheritParticleInfoToSubEmitters(): void;
  12480. /** @hidden */
  12481. _reset(): void;
  12482. /**
  12483. * Copy the properties of particle to another one.
  12484. * @param other the particle to copy the information to.
  12485. */
  12486. copyTo(other: Particle): void;
  12487. }
  12488. }
  12489. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  12490. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12491. import { Effect } from "babylonjs/Materials/effect";
  12492. import { Particle } from "babylonjs/Particles/particle";
  12493. import { Scene } from "babylonjs/scene";
  12494. /**
  12495. * Particle emitter represents a volume emitting particles.
  12496. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12497. */
  12498. export interface IParticleEmitterType {
  12499. /**
  12500. * Called by the particle System when the direction is computed for the created particle.
  12501. * @param worldMatrix is the world matrix of the particle system
  12502. * @param directionToUpdate is the direction vector to update with the result
  12503. * @param particle is the particle we are computed the direction for
  12504. * @param isLocal defines if the direction should be set in local space
  12505. */
  12506. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12507. /**
  12508. * Called by the particle System when the position is computed for the created particle.
  12509. * @param worldMatrix is the world matrix of the particle system
  12510. * @param positionToUpdate is the position vector to update with the result
  12511. * @param particle is the particle we are computed the position for
  12512. * @param isLocal defines if the position should be set in local space
  12513. */
  12514. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12515. /**
  12516. * Clones the current emitter and returns a copy of it
  12517. * @returns the new emitter
  12518. */
  12519. clone(): IParticleEmitterType;
  12520. /**
  12521. * Called by the GPUParticleSystem to setup the update shader
  12522. * @param effect defines the update shader
  12523. */
  12524. applyToShader(effect: Effect): void;
  12525. /**
  12526. * Returns a string to use to update the GPU particles update shader
  12527. * @returns the effect defines string
  12528. */
  12529. getEffectDefines(): string;
  12530. /**
  12531. * Returns a string representing the class name
  12532. * @returns a string containing the class name
  12533. */
  12534. getClassName(): string;
  12535. /**
  12536. * Serializes the particle system to a JSON object.
  12537. * @returns the JSON object
  12538. */
  12539. serialize(): any;
  12540. /**
  12541. * Parse properties from a JSON object
  12542. * @param serializationObject defines the JSON object
  12543. * @param scene defines the hosting scene
  12544. */
  12545. parse(serializationObject: any, scene: Scene): void;
  12546. }
  12547. }
  12548. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  12549. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12550. import { Effect } from "babylonjs/Materials/effect";
  12551. import { Particle } from "babylonjs/Particles/particle";
  12552. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12553. /**
  12554. * Particle emitter emitting particles from the inside of a box.
  12555. * It emits the particles randomly between 2 given directions.
  12556. */
  12557. export class BoxParticleEmitter implements IParticleEmitterType {
  12558. /**
  12559. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12560. */
  12561. direction1: Vector3;
  12562. /**
  12563. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12564. */
  12565. direction2: Vector3;
  12566. /**
  12567. * 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.
  12568. */
  12569. minEmitBox: Vector3;
  12570. /**
  12571. * 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.
  12572. */
  12573. maxEmitBox: Vector3;
  12574. /**
  12575. * Creates a new instance BoxParticleEmitter
  12576. */
  12577. constructor();
  12578. /**
  12579. * Called by the particle System when the direction is computed for the created particle.
  12580. * @param worldMatrix is the world matrix of the particle system
  12581. * @param directionToUpdate is the direction vector to update with the result
  12582. * @param particle is the particle we are computed the direction for
  12583. * @param isLocal defines if the direction should be set in local space
  12584. */
  12585. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12586. /**
  12587. * Called by the particle System when the position is computed for the created particle.
  12588. * @param worldMatrix is the world matrix of the particle system
  12589. * @param positionToUpdate is the position vector to update with the result
  12590. * @param particle is the particle we are computed the position for
  12591. * @param isLocal defines if the position should be set in local space
  12592. */
  12593. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12594. /**
  12595. * Clones the current emitter and returns a copy of it
  12596. * @returns the new emitter
  12597. */
  12598. clone(): BoxParticleEmitter;
  12599. /**
  12600. * Called by the GPUParticleSystem to setup the update shader
  12601. * @param effect defines the update shader
  12602. */
  12603. applyToShader(effect: Effect): void;
  12604. /**
  12605. * Returns a string to use to update the GPU particles update shader
  12606. * @returns a string containng the defines string
  12607. */
  12608. getEffectDefines(): string;
  12609. /**
  12610. * Returns the string "BoxParticleEmitter"
  12611. * @returns a string containing the class name
  12612. */
  12613. getClassName(): string;
  12614. /**
  12615. * Serializes the particle system to a JSON object.
  12616. * @returns the JSON object
  12617. */
  12618. serialize(): any;
  12619. /**
  12620. * Parse properties from a JSON object
  12621. * @param serializationObject defines the JSON object
  12622. */
  12623. parse(serializationObject: any): void;
  12624. }
  12625. }
  12626. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  12627. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12628. import { Effect } from "babylonjs/Materials/effect";
  12629. import { Particle } from "babylonjs/Particles/particle";
  12630. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12631. /**
  12632. * Particle emitter emitting particles from the inside of a cone.
  12633. * It emits the particles alongside the cone volume from the base to the particle.
  12634. * The emission direction might be randomized.
  12635. */
  12636. export class ConeParticleEmitter implements IParticleEmitterType {
  12637. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12638. directionRandomizer: number;
  12639. private _radius;
  12640. private _angle;
  12641. private _height;
  12642. /**
  12643. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12644. */
  12645. radiusRange: number;
  12646. /**
  12647. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12648. */
  12649. heightRange: number;
  12650. /**
  12651. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12652. */
  12653. emitFromSpawnPointOnly: boolean;
  12654. /**
  12655. * Gets or sets the radius of the emission cone
  12656. */
  12657. get radius(): number;
  12658. set radius(value: number);
  12659. /**
  12660. * Gets or sets the angle of the emission cone
  12661. */
  12662. get angle(): number;
  12663. set angle(value: number);
  12664. private _buildHeight;
  12665. /**
  12666. * Creates a new instance ConeParticleEmitter
  12667. * @param radius the radius of the emission cone (1 by default)
  12668. * @param angle the cone base angle (PI by default)
  12669. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12670. */
  12671. constructor(radius?: number, angle?: number,
  12672. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12673. directionRandomizer?: number);
  12674. /**
  12675. * Called by the particle System when the direction is computed for the created particle.
  12676. * @param worldMatrix is the world matrix of the particle system
  12677. * @param directionToUpdate is the direction vector to update with the result
  12678. * @param particle is the particle we are computed the direction for
  12679. * @param isLocal defines if the direction should be set in local space
  12680. */
  12681. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12682. /**
  12683. * Called by the particle System when the position is computed for the created particle.
  12684. * @param worldMatrix is the world matrix of the particle system
  12685. * @param positionToUpdate is the position vector to update with the result
  12686. * @param particle is the particle we are computed the position for
  12687. * @param isLocal defines if the position should be set in local space
  12688. */
  12689. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12690. /**
  12691. * Clones the current emitter and returns a copy of it
  12692. * @returns the new emitter
  12693. */
  12694. clone(): ConeParticleEmitter;
  12695. /**
  12696. * Called by the GPUParticleSystem to setup the update shader
  12697. * @param effect defines the update shader
  12698. */
  12699. applyToShader(effect: Effect): void;
  12700. /**
  12701. * Returns a string to use to update the GPU particles update shader
  12702. * @returns a string containng the defines string
  12703. */
  12704. getEffectDefines(): string;
  12705. /**
  12706. * Returns the string "ConeParticleEmitter"
  12707. * @returns a string containing the class name
  12708. */
  12709. getClassName(): string;
  12710. /**
  12711. * Serializes the particle system to a JSON object.
  12712. * @returns the JSON object
  12713. */
  12714. serialize(): any;
  12715. /**
  12716. * Parse properties from a JSON object
  12717. * @param serializationObject defines the JSON object
  12718. */
  12719. parse(serializationObject: any): void;
  12720. }
  12721. }
  12722. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  12723. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12724. import { Effect } from "babylonjs/Materials/effect";
  12725. import { Particle } from "babylonjs/Particles/particle";
  12726. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12727. /**
  12728. * Particle emitter emitting particles from the inside of a cylinder.
  12729. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12730. */
  12731. export class CylinderParticleEmitter implements IParticleEmitterType {
  12732. /**
  12733. * The radius of the emission cylinder.
  12734. */
  12735. radius: number;
  12736. /**
  12737. * The height of the emission cylinder.
  12738. */
  12739. height: number;
  12740. /**
  12741. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12742. */
  12743. radiusRange: number;
  12744. /**
  12745. * How much to randomize the particle direction [0-1].
  12746. */
  12747. directionRandomizer: number;
  12748. /**
  12749. * Creates a new instance CylinderParticleEmitter
  12750. * @param radius the radius of the emission cylinder (1 by default)
  12751. * @param height the height of the emission cylinder (1 by default)
  12752. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12753. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12754. */
  12755. constructor(
  12756. /**
  12757. * The radius of the emission cylinder.
  12758. */
  12759. radius?: number,
  12760. /**
  12761. * The height of the emission cylinder.
  12762. */
  12763. height?: number,
  12764. /**
  12765. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12766. */
  12767. radiusRange?: number,
  12768. /**
  12769. * How much to randomize the particle direction [0-1].
  12770. */
  12771. directionRandomizer?: number);
  12772. /**
  12773. * Called by the particle System when the direction is computed for the created particle.
  12774. * @param worldMatrix is the world matrix of the particle system
  12775. * @param directionToUpdate is the direction vector to update with the result
  12776. * @param particle is the particle we are computed the direction for
  12777. * @param isLocal defines if the direction should be set in local space
  12778. */
  12779. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12780. /**
  12781. * Called by the particle System when the position is computed for the created particle.
  12782. * @param worldMatrix is the world matrix of the particle system
  12783. * @param positionToUpdate is the position vector to update with the result
  12784. * @param particle is the particle we are computed the position for
  12785. * @param isLocal defines if the position should be set in local space
  12786. */
  12787. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12788. /**
  12789. * Clones the current emitter and returns a copy of it
  12790. * @returns the new emitter
  12791. */
  12792. clone(): CylinderParticleEmitter;
  12793. /**
  12794. * Called by the GPUParticleSystem to setup the update shader
  12795. * @param effect defines the update shader
  12796. */
  12797. applyToShader(effect: Effect): void;
  12798. /**
  12799. * Returns a string to use to update the GPU particles update shader
  12800. * @returns a string containng the defines string
  12801. */
  12802. getEffectDefines(): string;
  12803. /**
  12804. * Returns the string "CylinderParticleEmitter"
  12805. * @returns a string containing the class name
  12806. */
  12807. getClassName(): string;
  12808. /**
  12809. * Serializes the particle system to a JSON object.
  12810. * @returns the JSON object
  12811. */
  12812. serialize(): any;
  12813. /**
  12814. * Parse properties from a JSON object
  12815. * @param serializationObject defines the JSON object
  12816. */
  12817. parse(serializationObject: any): void;
  12818. }
  12819. /**
  12820. * Particle emitter emitting particles from the inside of a cylinder.
  12821. * It emits the particles randomly between two vectors.
  12822. */
  12823. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12824. /**
  12825. * The min limit of the emission direction.
  12826. */
  12827. direction1: Vector3;
  12828. /**
  12829. * The max limit of the emission direction.
  12830. */
  12831. direction2: Vector3;
  12832. /**
  12833. * Creates a new instance CylinderDirectedParticleEmitter
  12834. * @param radius the radius of the emission cylinder (1 by default)
  12835. * @param height the height of the emission cylinder (1 by default)
  12836. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12837. * @param direction1 the min limit of the emission direction (up vector by default)
  12838. * @param direction2 the max limit of the emission direction (up vector by default)
  12839. */
  12840. constructor(radius?: number, height?: number, radiusRange?: number,
  12841. /**
  12842. * The min limit of the emission direction.
  12843. */
  12844. direction1?: Vector3,
  12845. /**
  12846. * The max limit of the emission direction.
  12847. */
  12848. direction2?: Vector3);
  12849. /**
  12850. * Called by the particle System when the direction is computed for the created particle.
  12851. * @param worldMatrix is the world matrix of the particle system
  12852. * @param directionToUpdate is the direction vector to update with the result
  12853. * @param particle is the particle we are computed the direction for
  12854. */
  12855. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12856. /**
  12857. * Clones the current emitter and returns a copy of it
  12858. * @returns the new emitter
  12859. */
  12860. clone(): CylinderDirectedParticleEmitter;
  12861. /**
  12862. * Called by the GPUParticleSystem to setup the update shader
  12863. * @param effect defines the update shader
  12864. */
  12865. applyToShader(effect: Effect): void;
  12866. /**
  12867. * Returns a string to use to update the GPU particles update shader
  12868. * @returns a string containng the defines string
  12869. */
  12870. getEffectDefines(): string;
  12871. /**
  12872. * Returns the string "CylinderDirectedParticleEmitter"
  12873. * @returns a string containing the class name
  12874. */
  12875. getClassName(): string;
  12876. /**
  12877. * Serializes the particle system to a JSON object.
  12878. * @returns the JSON object
  12879. */
  12880. serialize(): any;
  12881. /**
  12882. * Parse properties from a JSON object
  12883. * @param serializationObject defines the JSON object
  12884. */
  12885. parse(serializationObject: any): void;
  12886. }
  12887. }
  12888. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  12889. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12890. import { Effect } from "babylonjs/Materials/effect";
  12891. import { Particle } from "babylonjs/Particles/particle";
  12892. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12893. /**
  12894. * Particle emitter emitting particles from the inside of a hemisphere.
  12895. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12896. */
  12897. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12898. /**
  12899. * The radius of the emission hemisphere.
  12900. */
  12901. radius: number;
  12902. /**
  12903. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12904. */
  12905. radiusRange: number;
  12906. /**
  12907. * How much to randomize the particle direction [0-1].
  12908. */
  12909. directionRandomizer: number;
  12910. /**
  12911. * Creates a new instance HemisphericParticleEmitter
  12912. * @param radius the radius of the emission hemisphere (1 by default)
  12913. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12914. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12915. */
  12916. constructor(
  12917. /**
  12918. * The radius of the emission hemisphere.
  12919. */
  12920. radius?: number,
  12921. /**
  12922. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12923. */
  12924. radiusRange?: number,
  12925. /**
  12926. * How much to randomize the particle direction [0-1].
  12927. */
  12928. directionRandomizer?: number);
  12929. /**
  12930. * Called by the particle System when the direction is computed for the created particle.
  12931. * @param worldMatrix is the world matrix of the particle system
  12932. * @param directionToUpdate is the direction vector to update with the result
  12933. * @param particle is the particle we are computed the direction for
  12934. * @param isLocal defines if the direction should be set in local space
  12935. */
  12936. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12937. /**
  12938. * Called by the particle System when the position is computed for the created particle.
  12939. * @param worldMatrix is the world matrix of the particle system
  12940. * @param positionToUpdate is the position vector to update with the result
  12941. * @param particle is the particle we are computed the position for
  12942. * @param isLocal defines if the position should be set in local space
  12943. */
  12944. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12945. /**
  12946. * Clones the current emitter and returns a copy of it
  12947. * @returns the new emitter
  12948. */
  12949. clone(): HemisphericParticleEmitter;
  12950. /**
  12951. * Called by the GPUParticleSystem to setup the update shader
  12952. * @param effect defines the update shader
  12953. */
  12954. applyToShader(effect: Effect): void;
  12955. /**
  12956. * Returns a string to use to update the GPU particles update shader
  12957. * @returns a string containng the defines string
  12958. */
  12959. getEffectDefines(): string;
  12960. /**
  12961. * Returns the string "HemisphericParticleEmitter"
  12962. * @returns a string containing the class name
  12963. */
  12964. getClassName(): string;
  12965. /**
  12966. * Serializes the particle system to a JSON object.
  12967. * @returns the JSON object
  12968. */
  12969. serialize(): any;
  12970. /**
  12971. * Parse properties from a JSON object
  12972. * @param serializationObject defines the JSON object
  12973. */
  12974. parse(serializationObject: any): void;
  12975. }
  12976. }
  12977. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  12978. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12979. import { Effect } from "babylonjs/Materials/effect";
  12980. import { Particle } from "babylonjs/Particles/particle";
  12981. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12982. /**
  12983. * Particle emitter emitting particles from a point.
  12984. * It emits the particles randomly between 2 given directions.
  12985. */
  12986. export class PointParticleEmitter implements IParticleEmitterType {
  12987. /**
  12988. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12989. */
  12990. direction1: Vector3;
  12991. /**
  12992. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12993. */
  12994. direction2: Vector3;
  12995. /**
  12996. * Creates a new instance PointParticleEmitter
  12997. */
  12998. constructor();
  12999. /**
  13000. * Called by the particle System when the direction is computed for the created particle.
  13001. * @param worldMatrix is the world matrix of the particle system
  13002. * @param directionToUpdate is the direction vector to update with the result
  13003. * @param particle is the particle we are computed the direction for
  13004. * @param isLocal defines if the direction should be set in local space
  13005. */
  13006. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13007. /**
  13008. * Called by the particle System when the position is computed for the created particle.
  13009. * @param worldMatrix is the world matrix of the particle system
  13010. * @param positionToUpdate is the position vector to update with the result
  13011. * @param particle is the particle we are computed the position for
  13012. * @param isLocal defines if the position should be set in local space
  13013. */
  13014. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13015. /**
  13016. * Clones the current emitter and returns a copy of it
  13017. * @returns the new emitter
  13018. */
  13019. clone(): PointParticleEmitter;
  13020. /**
  13021. * Called by the GPUParticleSystem to setup the update shader
  13022. * @param effect defines the update shader
  13023. */
  13024. applyToShader(effect: Effect): void;
  13025. /**
  13026. * Returns a string to use to update the GPU particles update shader
  13027. * @returns a string containng the defines string
  13028. */
  13029. getEffectDefines(): string;
  13030. /**
  13031. * Returns the string "PointParticleEmitter"
  13032. * @returns a string containing the class name
  13033. */
  13034. getClassName(): string;
  13035. /**
  13036. * Serializes the particle system to a JSON object.
  13037. * @returns the JSON object
  13038. */
  13039. serialize(): any;
  13040. /**
  13041. * Parse properties from a JSON object
  13042. * @param serializationObject defines the JSON object
  13043. */
  13044. parse(serializationObject: any): void;
  13045. }
  13046. }
  13047. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  13048. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13049. import { Effect } from "babylonjs/Materials/effect";
  13050. import { Particle } from "babylonjs/Particles/particle";
  13051. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13052. /**
  13053. * Particle emitter emitting particles from the inside of a sphere.
  13054. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13055. */
  13056. export class SphereParticleEmitter implements IParticleEmitterType {
  13057. /**
  13058. * The radius of the emission sphere.
  13059. */
  13060. radius: number;
  13061. /**
  13062. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13063. */
  13064. radiusRange: number;
  13065. /**
  13066. * How much to randomize the particle direction [0-1].
  13067. */
  13068. directionRandomizer: number;
  13069. /**
  13070. * Creates a new instance SphereParticleEmitter
  13071. * @param radius the radius of the emission sphere (1 by default)
  13072. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13073. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13074. */
  13075. constructor(
  13076. /**
  13077. * The radius of the emission sphere.
  13078. */
  13079. radius?: number,
  13080. /**
  13081. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13082. */
  13083. radiusRange?: number,
  13084. /**
  13085. * How much to randomize the particle direction [0-1].
  13086. */
  13087. directionRandomizer?: number);
  13088. /**
  13089. * Called by the particle System when the direction is computed for the created particle.
  13090. * @param worldMatrix is the world matrix of the particle system
  13091. * @param directionToUpdate is the direction vector to update with the result
  13092. * @param particle is the particle we are computed the direction for
  13093. * @param isLocal defines if the direction should be set in local space
  13094. */
  13095. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13096. /**
  13097. * Called by the particle System when the position is computed for the created particle.
  13098. * @param worldMatrix is the world matrix of the particle system
  13099. * @param positionToUpdate is the position vector to update with the result
  13100. * @param particle is the particle we are computed the position for
  13101. * @param isLocal defines if the position should be set in local space
  13102. */
  13103. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13104. /**
  13105. * Clones the current emitter and returns a copy of it
  13106. * @returns the new emitter
  13107. */
  13108. clone(): SphereParticleEmitter;
  13109. /**
  13110. * Called by the GPUParticleSystem to setup the update shader
  13111. * @param effect defines the update shader
  13112. */
  13113. applyToShader(effect: Effect): void;
  13114. /**
  13115. * Returns a string to use to update the GPU particles update shader
  13116. * @returns a string containng the defines string
  13117. */
  13118. getEffectDefines(): string;
  13119. /**
  13120. * Returns the string "SphereParticleEmitter"
  13121. * @returns a string containing the class name
  13122. */
  13123. getClassName(): string;
  13124. /**
  13125. * Serializes the particle system to a JSON object.
  13126. * @returns the JSON object
  13127. */
  13128. serialize(): any;
  13129. /**
  13130. * Parse properties from a JSON object
  13131. * @param serializationObject defines the JSON object
  13132. */
  13133. parse(serializationObject: any): void;
  13134. }
  13135. /**
  13136. * Particle emitter emitting particles from the inside of a sphere.
  13137. * It emits the particles randomly between two vectors.
  13138. */
  13139. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13140. /**
  13141. * The min limit of the emission direction.
  13142. */
  13143. direction1: Vector3;
  13144. /**
  13145. * The max limit of the emission direction.
  13146. */
  13147. direction2: Vector3;
  13148. /**
  13149. * Creates a new instance SphereDirectedParticleEmitter
  13150. * @param radius the radius of the emission sphere (1 by default)
  13151. * @param direction1 the min limit of the emission direction (up vector by default)
  13152. * @param direction2 the max limit of the emission direction (up vector by default)
  13153. */
  13154. constructor(radius?: number,
  13155. /**
  13156. * The min limit of the emission direction.
  13157. */
  13158. direction1?: Vector3,
  13159. /**
  13160. * The max limit of the emission direction.
  13161. */
  13162. direction2?: Vector3);
  13163. /**
  13164. * Called by the particle System when the direction is computed for the created particle.
  13165. * @param worldMatrix is the world matrix of the particle system
  13166. * @param directionToUpdate is the direction vector to update with the result
  13167. * @param particle is the particle we are computed the direction for
  13168. */
  13169. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13170. /**
  13171. * Clones the current emitter and returns a copy of it
  13172. * @returns the new emitter
  13173. */
  13174. clone(): SphereDirectedParticleEmitter;
  13175. /**
  13176. * Called by the GPUParticleSystem to setup the update shader
  13177. * @param effect defines the update shader
  13178. */
  13179. applyToShader(effect: Effect): void;
  13180. /**
  13181. * Returns a string to use to update the GPU particles update shader
  13182. * @returns a string containng the defines string
  13183. */
  13184. getEffectDefines(): string;
  13185. /**
  13186. * Returns the string "SphereDirectedParticleEmitter"
  13187. * @returns a string containing the class name
  13188. */
  13189. getClassName(): string;
  13190. /**
  13191. * Serializes the particle system to a JSON object.
  13192. * @returns the JSON object
  13193. */
  13194. serialize(): any;
  13195. /**
  13196. * Parse properties from a JSON object
  13197. * @param serializationObject defines the JSON object
  13198. */
  13199. parse(serializationObject: any): void;
  13200. }
  13201. }
  13202. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13203. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13204. import { Effect } from "babylonjs/Materials/effect";
  13205. import { Particle } from "babylonjs/Particles/particle";
  13206. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13207. import { Nullable } from "babylonjs/types";
  13208. /**
  13209. * Particle emitter emitting particles from a custom list of positions.
  13210. */
  13211. export class CustomParticleEmitter implements IParticleEmitterType {
  13212. /**
  13213. * Gets or sets the position generator that will create the inital position of each particle.
  13214. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13215. */
  13216. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13217. /**
  13218. * Gets or sets the destination generator that will create the final destination of each particle.
  13219. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13220. */
  13221. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13222. /**
  13223. * Creates a new instance CustomParticleEmitter
  13224. */
  13225. constructor();
  13226. /**
  13227. * Called by the particle System when the direction is computed for the created particle.
  13228. * @param worldMatrix is the world matrix of the particle system
  13229. * @param directionToUpdate is the direction vector to update with the result
  13230. * @param particle is the particle we are computed the direction for
  13231. * @param isLocal defines if the direction should be set in local space
  13232. */
  13233. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13234. /**
  13235. * Called by the particle System when the position is computed for the created particle.
  13236. * @param worldMatrix is the world matrix of the particle system
  13237. * @param positionToUpdate is the position vector to update with the result
  13238. * @param particle is the particle we are computed the position for
  13239. * @param isLocal defines if the position should be set in local space
  13240. */
  13241. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13242. /**
  13243. * Clones the current emitter and returns a copy of it
  13244. * @returns the new emitter
  13245. */
  13246. clone(): CustomParticleEmitter;
  13247. /**
  13248. * Called by the GPUParticleSystem to setup the update shader
  13249. * @param effect defines the update shader
  13250. */
  13251. applyToShader(effect: Effect): void;
  13252. /**
  13253. * Returns a string to use to update the GPU particles update shader
  13254. * @returns a string containng the defines string
  13255. */
  13256. getEffectDefines(): string;
  13257. /**
  13258. * Returns the string "PointParticleEmitter"
  13259. * @returns a string containing the class name
  13260. */
  13261. getClassName(): string;
  13262. /**
  13263. * Serializes the particle system to a JSON object.
  13264. * @returns the JSON object
  13265. */
  13266. serialize(): any;
  13267. /**
  13268. * Parse properties from a JSON object
  13269. * @param serializationObject defines the JSON object
  13270. */
  13271. parse(serializationObject: any): void;
  13272. }
  13273. }
  13274. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  13275. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13276. import { Effect } from "babylonjs/Materials/effect";
  13277. import { Particle } from "babylonjs/Particles/particle";
  13278. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13279. import { Nullable } from "babylonjs/types";
  13280. import { Scene } from "babylonjs/scene";
  13281. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13282. /**
  13283. * Particle emitter emitting particles from the inside of a box.
  13284. * It emits the particles randomly between 2 given directions.
  13285. */
  13286. export class MeshParticleEmitter implements IParticleEmitterType {
  13287. private _indices;
  13288. private _positions;
  13289. private _normals;
  13290. private _storedNormal;
  13291. private _mesh;
  13292. /**
  13293. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13294. */
  13295. direction1: Vector3;
  13296. /**
  13297. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13298. */
  13299. direction2: Vector3;
  13300. /**
  13301. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13302. */
  13303. useMeshNormalsForDirection: boolean;
  13304. /** Defines the mesh to use as source */
  13305. get mesh(): Nullable<AbstractMesh>;
  13306. set mesh(value: Nullable<AbstractMesh>);
  13307. /**
  13308. * Creates a new instance MeshParticleEmitter
  13309. * @param mesh defines the mesh to use as source
  13310. */
  13311. constructor(mesh?: Nullable<AbstractMesh>);
  13312. /**
  13313. * Called by the particle System when the direction is computed for the created particle.
  13314. * @param worldMatrix is the world matrix of the particle system
  13315. * @param directionToUpdate is the direction vector to update with the result
  13316. * @param particle is the particle we are computed the direction for
  13317. * @param isLocal defines if the direction should be set in local space
  13318. */
  13319. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13320. /**
  13321. * Called by the particle System when the position is computed for the created particle.
  13322. * @param worldMatrix is the world matrix of the particle system
  13323. * @param positionToUpdate is the position vector to update with the result
  13324. * @param particle is the particle we are computed the position for
  13325. * @param isLocal defines if the position should be set in local space
  13326. */
  13327. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13328. /**
  13329. * Clones the current emitter and returns a copy of it
  13330. * @returns the new emitter
  13331. */
  13332. clone(): MeshParticleEmitter;
  13333. /**
  13334. * Called by the GPUParticleSystem to setup the update shader
  13335. * @param effect defines the update shader
  13336. */
  13337. applyToShader(effect: Effect): void;
  13338. /**
  13339. * Returns a string to use to update the GPU particles update shader
  13340. * @returns a string containng the defines string
  13341. */
  13342. getEffectDefines(): string;
  13343. /**
  13344. * Returns the string "BoxParticleEmitter"
  13345. * @returns a string containing the class name
  13346. */
  13347. getClassName(): string;
  13348. /**
  13349. * Serializes the particle system to a JSON object.
  13350. * @returns the JSON object
  13351. */
  13352. serialize(): any;
  13353. /**
  13354. * Parse properties from a JSON object
  13355. * @param serializationObject defines the JSON object
  13356. * @param scene defines the hosting scene
  13357. */
  13358. parse(serializationObject: any, scene: Scene): void;
  13359. }
  13360. }
  13361. declare module "babylonjs/Particles/EmitterTypes/index" {
  13362. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  13363. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  13364. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  13365. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  13366. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13367. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  13368. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  13369. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  13370. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  13371. }
  13372. declare module "babylonjs/Particles/IParticleSystem" {
  13373. import { Nullable } from "babylonjs/types";
  13374. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  13375. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13376. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13377. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13378. import { Texture } from "babylonjs/Materials/Textures/texture";
  13379. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  13380. import { Scene } from "babylonjs/scene";
  13381. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  13382. import { Animation } from "babylonjs/Animations/animation";
  13383. /**
  13384. * Interface representing a particle system in Babylon.js.
  13385. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13386. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13387. */
  13388. export interface IParticleSystem {
  13389. /**
  13390. * List of animations used by the particle system.
  13391. */
  13392. animations: Animation[];
  13393. /**
  13394. * The id of the Particle system.
  13395. */
  13396. id: string;
  13397. /**
  13398. * The name of the Particle system.
  13399. */
  13400. name: string;
  13401. /**
  13402. * The emitter represents the Mesh or position we are attaching the particle system to.
  13403. */
  13404. emitter: Nullable<AbstractMesh | Vector3>;
  13405. /**
  13406. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13407. */
  13408. isBillboardBased: boolean;
  13409. /**
  13410. * The rendering group used by the Particle system to chose when to render.
  13411. */
  13412. renderingGroupId: number;
  13413. /**
  13414. * The layer mask we are rendering the particles through.
  13415. */
  13416. layerMask: number;
  13417. /**
  13418. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13419. */
  13420. updateSpeed: number;
  13421. /**
  13422. * The amount of time the particle system is running (depends of the overall update speed).
  13423. */
  13424. targetStopDuration: number;
  13425. /**
  13426. * The texture used to render each particle. (this can be a spritesheet)
  13427. */
  13428. particleTexture: Nullable<Texture>;
  13429. /**
  13430. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13431. */
  13432. blendMode: number;
  13433. /**
  13434. * Minimum life time of emitting particles.
  13435. */
  13436. minLifeTime: number;
  13437. /**
  13438. * Maximum life time of emitting particles.
  13439. */
  13440. maxLifeTime: number;
  13441. /**
  13442. * Minimum Size of emitting particles.
  13443. */
  13444. minSize: number;
  13445. /**
  13446. * Maximum Size of emitting particles.
  13447. */
  13448. maxSize: number;
  13449. /**
  13450. * Minimum scale of emitting particles on X axis.
  13451. */
  13452. minScaleX: number;
  13453. /**
  13454. * Maximum scale of emitting particles on X axis.
  13455. */
  13456. maxScaleX: number;
  13457. /**
  13458. * Minimum scale of emitting particles on Y axis.
  13459. */
  13460. minScaleY: number;
  13461. /**
  13462. * Maximum scale of emitting particles on Y axis.
  13463. */
  13464. maxScaleY: number;
  13465. /**
  13466. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13467. */
  13468. color1: Color4;
  13469. /**
  13470. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13471. */
  13472. color2: Color4;
  13473. /**
  13474. * Color the particle will have at the end of its lifetime.
  13475. */
  13476. colorDead: Color4;
  13477. /**
  13478. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13479. */
  13480. emitRate: number;
  13481. /**
  13482. * You can use gravity if you want to give an orientation to your particles.
  13483. */
  13484. gravity: Vector3;
  13485. /**
  13486. * Minimum power of emitting particles.
  13487. */
  13488. minEmitPower: number;
  13489. /**
  13490. * Maximum power of emitting particles.
  13491. */
  13492. maxEmitPower: number;
  13493. /**
  13494. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13495. */
  13496. minAngularSpeed: number;
  13497. /**
  13498. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13499. */
  13500. maxAngularSpeed: number;
  13501. /**
  13502. * Gets or sets the minimal initial rotation in radians.
  13503. */
  13504. minInitialRotation: number;
  13505. /**
  13506. * Gets or sets the maximal initial rotation in radians.
  13507. */
  13508. maxInitialRotation: number;
  13509. /**
  13510. * The particle emitter type defines the emitter used by the particle system.
  13511. * It can be for example box, sphere, or cone...
  13512. */
  13513. particleEmitterType: Nullable<IParticleEmitterType>;
  13514. /**
  13515. * Defines the delay in milliseconds before starting the system (0 by default)
  13516. */
  13517. startDelay: number;
  13518. /**
  13519. * 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
  13520. */
  13521. preWarmCycles: number;
  13522. /**
  13523. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13524. */
  13525. preWarmStepOffset: number;
  13526. /**
  13527. * 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)
  13528. */
  13529. spriteCellChangeSpeed: number;
  13530. /**
  13531. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13532. */
  13533. startSpriteCellID: number;
  13534. /**
  13535. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13536. */
  13537. endSpriteCellID: number;
  13538. /**
  13539. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13540. */
  13541. spriteCellWidth: number;
  13542. /**
  13543. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13544. */
  13545. spriteCellHeight: number;
  13546. /**
  13547. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13548. */
  13549. spriteRandomStartCell: boolean;
  13550. /**
  13551. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13552. */
  13553. isAnimationSheetEnabled: boolean;
  13554. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13555. translationPivot: Vector2;
  13556. /**
  13557. * Gets or sets a texture used to add random noise to particle positions
  13558. */
  13559. noiseTexture: Nullable<BaseTexture>;
  13560. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13561. noiseStrength: Vector3;
  13562. /**
  13563. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13564. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13565. */
  13566. billboardMode: number;
  13567. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13568. limitVelocityDamping: number;
  13569. /**
  13570. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13571. */
  13572. beginAnimationOnStart: boolean;
  13573. /**
  13574. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13575. */
  13576. beginAnimationFrom: number;
  13577. /**
  13578. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13579. */
  13580. beginAnimationTo: number;
  13581. /**
  13582. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13583. */
  13584. beginAnimationLoop: boolean;
  13585. /**
  13586. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13587. */
  13588. disposeOnStop: boolean;
  13589. /**
  13590. * Specifies if the particles are updated in emitter local space or world space
  13591. */
  13592. isLocal: boolean;
  13593. /** Snippet ID if the particle system was created from the snippet server */
  13594. snippetId: string;
  13595. /**
  13596. * Gets the maximum number of particles active at the same time.
  13597. * @returns The max number of active particles.
  13598. */
  13599. getCapacity(): number;
  13600. /**
  13601. * Gets the number of particles active at the same time.
  13602. * @returns The number of active particles.
  13603. */
  13604. getActiveCount(): number;
  13605. /**
  13606. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13607. * @returns True if it has been started, otherwise false.
  13608. */
  13609. isStarted(): boolean;
  13610. /**
  13611. * Animates the particle system for this frame.
  13612. */
  13613. animate(): void;
  13614. /**
  13615. * Renders the particle system in its current state.
  13616. * @returns the current number of particles
  13617. */
  13618. render(): number;
  13619. /**
  13620. * Dispose the particle system and frees its associated resources.
  13621. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13622. */
  13623. dispose(disposeTexture?: boolean): void;
  13624. /**
  13625. * Clones the particle system.
  13626. * @param name The name of the cloned object
  13627. * @param newEmitter The new emitter to use
  13628. * @returns the cloned particle system
  13629. */
  13630. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13631. /**
  13632. * Serializes the particle system to a JSON object
  13633. * @param serializeTexture defines if the texture must be serialized as well
  13634. * @returns the JSON object
  13635. */
  13636. serialize(serializeTexture: boolean): any;
  13637. /**
  13638. * Rebuild the particle system
  13639. */
  13640. rebuild(): void;
  13641. /** Force the system to rebuild all gradients that need to be resync */
  13642. forceRefreshGradients(): void;
  13643. /**
  13644. * Starts the particle system and begins to emit
  13645. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13646. */
  13647. start(delay?: number): void;
  13648. /**
  13649. * Stops the particle system.
  13650. */
  13651. stop(): void;
  13652. /**
  13653. * Remove all active particles
  13654. */
  13655. reset(): void;
  13656. /**
  13657. * Gets a boolean indicating that the system is stopping
  13658. * @returns true if the system is currently stopping
  13659. */
  13660. isStopping(): boolean;
  13661. /**
  13662. * Is this system ready to be used/rendered
  13663. * @return true if the system is ready
  13664. */
  13665. isReady(): boolean;
  13666. /**
  13667. * Returns the string "ParticleSystem"
  13668. * @returns a string containing the class name
  13669. */
  13670. getClassName(): string;
  13671. /**
  13672. * Adds a new color gradient
  13673. * @param gradient defines the gradient to use (between 0 and 1)
  13674. * @param color1 defines the color to affect to the specified gradient
  13675. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13676. * @returns the current particle system
  13677. */
  13678. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13679. /**
  13680. * Remove a specific color gradient
  13681. * @param gradient defines the gradient to remove
  13682. * @returns the current particle system
  13683. */
  13684. removeColorGradient(gradient: number): IParticleSystem;
  13685. /**
  13686. * Adds a new size gradient
  13687. * @param gradient defines the gradient to use (between 0 and 1)
  13688. * @param factor defines the size factor to affect to the specified gradient
  13689. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13690. * @returns the current particle system
  13691. */
  13692. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13693. /**
  13694. * Remove a specific size gradient
  13695. * @param gradient defines the gradient to remove
  13696. * @returns the current particle system
  13697. */
  13698. removeSizeGradient(gradient: number): IParticleSystem;
  13699. /**
  13700. * Gets the current list of color gradients.
  13701. * You must use addColorGradient and removeColorGradient to udpate this list
  13702. * @returns the list of color gradients
  13703. */
  13704. getColorGradients(): Nullable<Array<ColorGradient>>;
  13705. /**
  13706. * Gets the current list of size gradients.
  13707. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13708. * @returns the list of size gradients
  13709. */
  13710. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13711. /**
  13712. * Gets the current list of angular speed gradients.
  13713. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13714. * @returns the list of angular speed gradients
  13715. */
  13716. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13717. /**
  13718. * Adds a new angular speed gradient
  13719. * @param gradient defines the gradient to use (between 0 and 1)
  13720. * @param factor defines the angular speed to affect to the specified gradient
  13721. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13722. * @returns the current particle system
  13723. */
  13724. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13725. /**
  13726. * Remove a specific angular speed gradient
  13727. * @param gradient defines the gradient to remove
  13728. * @returns the current particle system
  13729. */
  13730. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13731. /**
  13732. * Gets the current list of velocity gradients.
  13733. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13734. * @returns the list of velocity gradients
  13735. */
  13736. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13737. /**
  13738. * Adds a new velocity gradient
  13739. * @param gradient defines the gradient to use (between 0 and 1)
  13740. * @param factor defines the velocity to affect to the specified gradient
  13741. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13742. * @returns the current particle system
  13743. */
  13744. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13745. /**
  13746. * Remove a specific velocity gradient
  13747. * @param gradient defines the gradient to remove
  13748. * @returns the current particle system
  13749. */
  13750. removeVelocityGradient(gradient: number): IParticleSystem;
  13751. /**
  13752. * Gets the current list of limit velocity gradients.
  13753. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13754. * @returns the list of limit velocity gradients
  13755. */
  13756. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13757. /**
  13758. * Adds a new limit velocity gradient
  13759. * @param gradient defines the gradient to use (between 0 and 1)
  13760. * @param factor defines the limit velocity to affect to the specified gradient
  13761. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13762. * @returns the current particle system
  13763. */
  13764. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13765. /**
  13766. * Remove a specific limit velocity gradient
  13767. * @param gradient defines the gradient to remove
  13768. * @returns the current particle system
  13769. */
  13770. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13771. /**
  13772. * Adds a new drag gradient
  13773. * @param gradient defines the gradient to use (between 0 and 1)
  13774. * @param factor defines the drag to affect to the specified gradient
  13775. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13776. * @returns the current particle system
  13777. */
  13778. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13779. /**
  13780. * Remove a specific drag gradient
  13781. * @param gradient defines the gradient to remove
  13782. * @returns the current particle system
  13783. */
  13784. removeDragGradient(gradient: number): IParticleSystem;
  13785. /**
  13786. * Gets the current list of drag gradients.
  13787. * You must use addDragGradient and removeDragGradient to udpate this list
  13788. * @returns the list of drag gradients
  13789. */
  13790. getDragGradients(): Nullable<Array<FactorGradient>>;
  13791. /**
  13792. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13793. * @param gradient defines the gradient to use (between 0 and 1)
  13794. * @param factor defines the emit rate to affect to the specified gradient
  13795. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13796. * @returns the current particle system
  13797. */
  13798. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13799. /**
  13800. * Remove a specific emit rate gradient
  13801. * @param gradient defines the gradient to remove
  13802. * @returns the current particle system
  13803. */
  13804. removeEmitRateGradient(gradient: number): IParticleSystem;
  13805. /**
  13806. * Gets the current list of emit rate gradients.
  13807. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13808. * @returns the list of emit rate gradients
  13809. */
  13810. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13811. /**
  13812. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13813. * @param gradient defines the gradient to use (between 0 and 1)
  13814. * @param factor defines the start size to affect to the specified gradient
  13815. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13816. * @returns the current particle system
  13817. */
  13818. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13819. /**
  13820. * Remove a specific start size gradient
  13821. * @param gradient defines the gradient to remove
  13822. * @returns the current particle system
  13823. */
  13824. removeStartSizeGradient(gradient: number): IParticleSystem;
  13825. /**
  13826. * Gets the current list of start size gradients.
  13827. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13828. * @returns the list of start size gradients
  13829. */
  13830. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13831. /**
  13832. * Adds a new life time gradient
  13833. * @param gradient defines the gradient to use (between 0 and 1)
  13834. * @param factor defines the life time factor to affect to the specified gradient
  13835. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13836. * @returns the current particle system
  13837. */
  13838. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13839. /**
  13840. * Remove a specific life time gradient
  13841. * @param gradient defines the gradient to remove
  13842. * @returns the current particle system
  13843. */
  13844. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13845. /**
  13846. * Gets the current list of life time gradients.
  13847. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13848. * @returns the list of life time gradients
  13849. */
  13850. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13851. /**
  13852. * Gets the current list of color gradients.
  13853. * You must use addColorGradient and removeColorGradient to udpate this list
  13854. * @returns the list of color gradients
  13855. */
  13856. getColorGradients(): Nullable<Array<ColorGradient>>;
  13857. /**
  13858. * Adds a new ramp gradient used to remap particle colors
  13859. * @param gradient defines the gradient to use (between 0 and 1)
  13860. * @param color defines the color to affect to the specified gradient
  13861. * @returns the current particle system
  13862. */
  13863. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13864. /**
  13865. * Gets the current list of ramp gradients.
  13866. * You must use addRampGradient and removeRampGradient to udpate this list
  13867. * @returns the list of ramp gradients
  13868. */
  13869. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13870. /** Gets or sets a boolean indicating that ramp gradients must be used
  13871. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13872. */
  13873. useRampGradients: boolean;
  13874. /**
  13875. * Adds a new color remap gradient
  13876. * @param gradient defines the gradient to use (between 0 and 1)
  13877. * @param min defines the color remap minimal range
  13878. * @param max defines the color remap maximal range
  13879. * @returns the current particle system
  13880. */
  13881. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13882. /**
  13883. * Gets the current list of color remap gradients.
  13884. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13885. * @returns the list of color remap gradients
  13886. */
  13887. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13888. /**
  13889. * Adds a new alpha remap gradient
  13890. * @param gradient defines the gradient to use (between 0 and 1)
  13891. * @param min defines the alpha remap minimal range
  13892. * @param max defines the alpha remap maximal range
  13893. * @returns the current particle system
  13894. */
  13895. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13896. /**
  13897. * Gets the current list of alpha remap gradients.
  13898. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13899. * @returns the list of alpha remap gradients
  13900. */
  13901. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13902. /**
  13903. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13904. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13905. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13906. * @returns the emitter
  13907. */
  13908. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13909. /**
  13910. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13911. * @param radius The radius of the hemisphere to emit from
  13912. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13913. * @returns the emitter
  13914. */
  13915. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13916. /**
  13917. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13918. * @param radius The radius of the sphere to emit from
  13919. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13920. * @returns the emitter
  13921. */
  13922. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13923. /**
  13924. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13925. * @param radius The radius of the sphere to emit from
  13926. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13927. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13928. * @returns the emitter
  13929. */
  13930. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13931. /**
  13932. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13933. * @param radius The radius of the emission cylinder
  13934. * @param height The height of the emission cylinder
  13935. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13936. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13937. * @returns the emitter
  13938. */
  13939. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13940. /**
  13941. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13942. * @param radius The radius of the cylinder to emit from
  13943. * @param height The height of the emission cylinder
  13944. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13945. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13946. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13947. * @returns the emitter
  13948. */
  13949. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13950. /**
  13951. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13952. * @param radius The radius of the cone to emit from
  13953. * @param angle The base angle of the cone
  13954. * @returns the emitter
  13955. */
  13956. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13957. /**
  13958. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13959. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13960. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13961. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13962. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13963. * @returns the emitter
  13964. */
  13965. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13966. /**
  13967. * Get hosting scene
  13968. * @returns the scene
  13969. */
  13970. getScene(): Scene;
  13971. }
  13972. }
  13973. declare module "babylonjs/Meshes/transformNode" {
  13974. import { DeepImmutable } from "babylonjs/types";
  13975. import { Observable } from "babylonjs/Misc/observable";
  13976. import { Nullable } from "babylonjs/types";
  13977. import { Camera } from "babylonjs/Cameras/camera";
  13978. import { Scene } from "babylonjs/scene";
  13979. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13980. import { Node } from "babylonjs/node";
  13981. import { Bone } from "babylonjs/Bones/bone";
  13982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13983. import { Space } from "babylonjs/Maths/math.axis";
  13984. /**
  13985. * 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.
  13986. * @see https://doc.babylonjs.com/how_to/transformnode
  13987. */
  13988. export class TransformNode extends Node {
  13989. /**
  13990. * Object will not rotate to face the camera
  13991. */
  13992. static BILLBOARDMODE_NONE: number;
  13993. /**
  13994. * Object will rotate to face the camera but only on the x axis
  13995. */
  13996. static BILLBOARDMODE_X: number;
  13997. /**
  13998. * Object will rotate to face the camera but only on the y axis
  13999. */
  14000. static BILLBOARDMODE_Y: number;
  14001. /**
  14002. * Object will rotate to face the camera but only on the z axis
  14003. */
  14004. static BILLBOARDMODE_Z: number;
  14005. /**
  14006. * Object will rotate to face the camera
  14007. */
  14008. static BILLBOARDMODE_ALL: number;
  14009. /**
  14010. * Object will rotate to face the camera's position instead of orientation
  14011. */
  14012. static BILLBOARDMODE_USE_POSITION: number;
  14013. private _forward;
  14014. private _forwardInverted;
  14015. private _up;
  14016. private _right;
  14017. private _rightInverted;
  14018. private _position;
  14019. private _rotation;
  14020. private _rotationQuaternion;
  14021. protected _scaling: Vector3;
  14022. protected _isDirty: boolean;
  14023. private _transformToBoneReferal;
  14024. private _isAbsoluteSynced;
  14025. private _billboardMode;
  14026. /**
  14027. * Gets or sets the billboard mode. Default is 0.
  14028. *
  14029. * | Value | Type | Description |
  14030. * | --- | --- | --- |
  14031. * | 0 | BILLBOARDMODE_NONE | |
  14032. * | 1 | BILLBOARDMODE_X | |
  14033. * | 2 | BILLBOARDMODE_Y | |
  14034. * | 4 | BILLBOARDMODE_Z | |
  14035. * | 7 | BILLBOARDMODE_ALL | |
  14036. *
  14037. */
  14038. get billboardMode(): number;
  14039. set billboardMode(value: number);
  14040. private _preserveParentRotationForBillboard;
  14041. /**
  14042. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14043. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14044. */
  14045. get preserveParentRotationForBillboard(): boolean;
  14046. set preserveParentRotationForBillboard(value: boolean);
  14047. /**
  14048. * 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
  14049. */
  14050. scalingDeterminant: number;
  14051. private _infiniteDistance;
  14052. /**
  14053. * Gets or sets the distance of the object to max, often used by skybox
  14054. */
  14055. get infiniteDistance(): boolean;
  14056. set infiniteDistance(value: boolean);
  14057. /**
  14058. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14059. * By default the system will update normals to compensate
  14060. */
  14061. ignoreNonUniformScaling: boolean;
  14062. /**
  14063. * 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
  14064. */
  14065. reIntegrateRotationIntoRotationQuaternion: boolean;
  14066. /** @hidden */
  14067. _poseMatrix: Nullable<Matrix>;
  14068. /** @hidden */
  14069. _localMatrix: Matrix;
  14070. private _usePivotMatrix;
  14071. private _absolutePosition;
  14072. private _absoluteScaling;
  14073. private _absoluteRotationQuaternion;
  14074. private _pivotMatrix;
  14075. private _pivotMatrixInverse;
  14076. protected _postMultiplyPivotMatrix: boolean;
  14077. protected _isWorldMatrixFrozen: boolean;
  14078. /** @hidden */
  14079. _indexInSceneTransformNodesArray: number;
  14080. /**
  14081. * An event triggered after the world matrix is updated
  14082. */
  14083. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14084. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14085. /**
  14086. * Gets a string identifying the name of the class
  14087. * @returns "TransformNode" string
  14088. */
  14089. getClassName(): string;
  14090. /**
  14091. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14092. */
  14093. get position(): Vector3;
  14094. set position(newPosition: Vector3);
  14095. /**
  14096. * 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)).
  14097. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14098. */
  14099. get rotation(): Vector3;
  14100. set rotation(newRotation: Vector3);
  14101. /**
  14102. * 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)).
  14103. */
  14104. get scaling(): Vector3;
  14105. set scaling(newScaling: Vector3);
  14106. /**
  14107. * 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).
  14108. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14109. */
  14110. get rotationQuaternion(): Nullable<Quaternion>;
  14111. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14112. /**
  14113. * The forward direction of that transform in world space.
  14114. */
  14115. get forward(): Vector3;
  14116. /**
  14117. * The up direction of that transform in world space.
  14118. */
  14119. get up(): Vector3;
  14120. /**
  14121. * The right direction of that transform in world space.
  14122. */
  14123. get right(): Vector3;
  14124. /**
  14125. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14126. * @param matrix the matrix to copy the pose from
  14127. * @returns this TransformNode.
  14128. */
  14129. updatePoseMatrix(matrix: Matrix): TransformNode;
  14130. /**
  14131. * Returns the mesh Pose matrix.
  14132. * @returns the pose matrix
  14133. */
  14134. getPoseMatrix(): Matrix;
  14135. /** @hidden */
  14136. _isSynchronized(): boolean;
  14137. /** @hidden */
  14138. _initCache(): void;
  14139. /**
  14140. * Flag the transform node as dirty (Forcing it to update everything)
  14141. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14142. * @returns this transform node
  14143. */
  14144. markAsDirty(property: string): TransformNode;
  14145. /**
  14146. * Returns the current mesh absolute position.
  14147. * Returns a Vector3.
  14148. */
  14149. get absolutePosition(): Vector3;
  14150. /**
  14151. * Returns the current mesh absolute scaling.
  14152. * Returns a Vector3.
  14153. */
  14154. get absoluteScaling(): Vector3;
  14155. /**
  14156. * Returns the current mesh absolute rotation.
  14157. * Returns a Quaternion.
  14158. */
  14159. get absoluteRotationQuaternion(): Quaternion;
  14160. /**
  14161. * Sets a new matrix to apply before all other transformation
  14162. * @param matrix defines the transform matrix
  14163. * @returns the current TransformNode
  14164. */
  14165. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14166. /**
  14167. * Sets a new pivot matrix to the current node
  14168. * @param matrix defines the new pivot matrix to use
  14169. * @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
  14170. * @returns the current TransformNode
  14171. */
  14172. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14173. /**
  14174. * Returns the mesh pivot matrix.
  14175. * Default : Identity.
  14176. * @returns the matrix
  14177. */
  14178. getPivotMatrix(): Matrix;
  14179. /**
  14180. * Instantiate (when possible) or clone that node with its hierarchy
  14181. * @param newParent defines the new parent to use for the instance (or clone)
  14182. * @param options defines options to configure how copy is done
  14183. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14184. * @returns an instance (or a clone) of the current node with its hiearchy
  14185. */
  14186. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14187. doNotInstantiate: boolean;
  14188. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14189. /**
  14190. * Prevents the World matrix to be computed any longer
  14191. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14192. * @returns the TransformNode.
  14193. */
  14194. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14195. /**
  14196. * Allows back the World matrix computation.
  14197. * @returns the TransformNode.
  14198. */
  14199. unfreezeWorldMatrix(): this;
  14200. /**
  14201. * True if the World matrix has been frozen.
  14202. */
  14203. get isWorldMatrixFrozen(): boolean;
  14204. /**
  14205. * Retuns the mesh absolute position in the World.
  14206. * @returns a Vector3.
  14207. */
  14208. getAbsolutePosition(): Vector3;
  14209. /**
  14210. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14211. * @param absolutePosition the absolute position to set
  14212. * @returns the TransformNode.
  14213. */
  14214. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14215. /**
  14216. * Sets the mesh position in its local space.
  14217. * @param vector3 the position to set in localspace
  14218. * @returns the TransformNode.
  14219. */
  14220. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14221. /**
  14222. * Returns the mesh position in the local space from the current World matrix values.
  14223. * @returns a new Vector3.
  14224. */
  14225. getPositionExpressedInLocalSpace(): Vector3;
  14226. /**
  14227. * Translates the mesh along the passed Vector3 in its local space.
  14228. * @param vector3 the distance to translate in localspace
  14229. * @returns the TransformNode.
  14230. */
  14231. locallyTranslate(vector3: Vector3): TransformNode;
  14232. private static _lookAtVectorCache;
  14233. /**
  14234. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14235. * @param targetPoint the position (must be in same space as current mesh) to look at
  14236. * @param yawCor optional yaw (y-axis) correction in radians
  14237. * @param pitchCor optional pitch (x-axis) correction in radians
  14238. * @param rollCor optional roll (z-axis) correction in radians
  14239. * @param space the choosen space of the target
  14240. * @returns the TransformNode.
  14241. */
  14242. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14243. /**
  14244. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14245. * This Vector3 is expressed in the World space.
  14246. * @param localAxis axis to rotate
  14247. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14248. */
  14249. getDirection(localAxis: Vector3): Vector3;
  14250. /**
  14251. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14252. * localAxis is expressed in the mesh local space.
  14253. * result is computed in the Wordl space from the mesh World matrix.
  14254. * @param localAxis axis to rotate
  14255. * @param result the resulting transformnode
  14256. * @returns this TransformNode.
  14257. */
  14258. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14259. /**
  14260. * Sets this transform node rotation to the given local axis.
  14261. * @param localAxis the axis in local space
  14262. * @param yawCor optional yaw (y-axis) correction in radians
  14263. * @param pitchCor optional pitch (x-axis) correction in radians
  14264. * @param rollCor optional roll (z-axis) correction in radians
  14265. * @returns this TransformNode
  14266. */
  14267. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14268. /**
  14269. * Sets a new pivot point to the current node
  14270. * @param point defines the new pivot point to use
  14271. * @param space defines if the point is in world or local space (local by default)
  14272. * @returns the current TransformNode
  14273. */
  14274. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14275. /**
  14276. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14277. * @returns the pivot point
  14278. */
  14279. getPivotPoint(): Vector3;
  14280. /**
  14281. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14282. * @param result the vector3 to store the result
  14283. * @returns this TransformNode.
  14284. */
  14285. getPivotPointToRef(result: Vector3): TransformNode;
  14286. /**
  14287. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14288. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14289. */
  14290. getAbsolutePivotPoint(): Vector3;
  14291. /**
  14292. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14293. * @param result vector3 to store the result
  14294. * @returns this TransformNode.
  14295. */
  14296. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14297. /**
  14298. * Defines the passed node as the parent of the current node.
  14299. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14300. * @see https://doc.babylonjs.com/how_to/parenting
  14301. * @param node the node ot set as the parent
  14302. * @returns this TransformNode.
  14303. */
  14304. setParent(node: Nullable<Node>): TransformNode;
  14305. private _nonUniformScaling;
  14306. /**
  14307. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14308. */
  14309. get nonUniformScaling(): boolean;
  14310. /** @hidden */
  14311. _updateNonUniformScalingState(value: boolean): boolean;
  14312. /**
  14313. * Attach the current TransformNode to another TransformNode associated with a bone
  14314. * @param bone Bone affecting the TransformNode
  14315. * @param affectedTransformNode TransformNode associated with the bone
  14316. * @returns this object
  14317. */
  14318. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14319. /**
  14320. * Detach the transform node if its associated with a bone
  14321. * @returns this object
  14322. */
  14323. detachFromBone(): TransformNode;
  14324. private static _rotationAxisCache;
  14325. /**
  14326. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14327. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14328. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14329. * The passed axis is also normalized.
  14330. * @param axis the axis to rotate around
  14331. * @param amount the amount to rotate in radians
  14332. * @param space Space to rotate in (Default: local)
  14333. * @returns the TransformNode.
  14334. */
  14335. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14336. /**
  14337. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14338. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14339. * The passed axis is also normalized. .
  14340. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14341. * @param point the point to rotate around
  14342. * @param axis the axis to rotate around
  14343. * @param amount the amount to rotate in radians
  14344. * @returns the TransformNode
  14345. */
  14346. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14347. /**
  14348. * Translates the mesh along the axis vector for the passed distance in the given space.
  14349. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14350. * @param axis the axis to translate in
  14351. * @param distance the distance to translate
  14352. * @param space Space to rotate in (Default: local)
  14353. * @returns the TransformNode.
  14354. */
  14355. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14356. /**
  14357. * Adds a rotation step to the mesh current rotation.
  14358. * x, y, z are Euler angles expressed in radians.
  14359. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14360. * This means this rotation is made in the mesh local space only.
  14361. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14362. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14363. * ```javascript
  14364. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14365. * ```
  14366. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14367. * 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.
  14368. * @param x Rotation to add
  14369. * @param y Rotation to add
  14370. * @param z Rotation to add
  14371. * @returns the TransformNode.
  14372. */
  14373. addRotation(x: number, y: number, z: number): TransformNode;
  14374. /**
  14375. * @hidden
  14376. */
  14377. protected _getEffectiveParent(): Nullable<Node>;
  14378. /**
  14379. * Computes the world matrix of the node
  14380. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14381. * @returns the world matrix
  14382. */
  14383. computeWorldMatrix(force?: boolean): Matrix;
  14384. /**
  14385. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14386. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14387. */
  14388. resetLocalMatrix(independentOfChildren?: boolean): void;
  14389. protected _afterComputeWorldMatrix(): void;
  14390. /**
  14391. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14392. * @param func callback function to add
  14393. *
  14394. * @returns the TransformNode.
  14395. */
  14396. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14397. /**
  14398. * Removes a registered callback function.
  14399. * @param func callback function to remove
  14400. * @returns the TransformNode.
  14401. */
  14402. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14403. /**
  14404. * Gets the position of the current mesh in camera space
  14405. * @param camera defines the camera to use
  14406. * @returns a position
  14407. */
  14408. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14409. /**
  14410. * Returns the distance from the mesh to the active camera
  14411. * @param camera defines the camera to use
  14412. * @returns the distance
  14413. */
  14414. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14415. /**
  14416. * Clone the current transform node
  14417. * @param name Name of the new clone
  14418. * @param newParent New parent for the clone
  14419. * @param doNotCloneChildren Do not clone children hierarchy
  14420. * @returns the new transform node
  14421. */
  14422. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14423. /**
  14424. * Serializes the objects information.
  14425. * @param currentSerializationObject defines the object to serialize in
  14426. * @returns the serialized object
  14427. */
  14428. serialize(currentSerializationObject?: any): any;
  14429. /**
  14430. * Returns a new TransformNode object parsed from the source provided.
  14431. * @param parsedTransformNode is the source.
  14432. * @param scene the scne the object belongs to
  14433. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14434. * @returns a new TransformNode object parsed from the source provided.
  14435. */
  14436. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14437. /**
  14438. * Get all child-transformNodes of this node
  14439. * @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
  14440. * @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
  14441. * @returns an array of TransformNode
  14442. */
  14443. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14444. /**
  14445. * Releases resources associated with this transform node.
  14446. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14447. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14448. */
  14449. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14450. /**
  14451. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14452. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14453. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14454. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14455. * @returns the current mesh
  14456. */
  14457. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14458. private _syncAbsoluteScalingAndRotation;
  14459. }
  14460. }
  14461. declare module "babylonjs/Animations/animationPropertiesOverride" {
  14462. /**
  14463. * Class used to override all child animations of a given target
  14464. */
  14465. export class AnimationPropertiesOverride {
  14466. /**
  14467. * Gets or sets a value indicating if animation blending must be used
  14468. */
  14469. enableBlending: boolean;
  14470. /**
  14471. * Gets or sets the blending speed to use when enableBlending is true
  14472. */
  14473. blendingSpeed: number;
  14474. /**
  14475. * Gets or sets the default loop mode to use
  14476. */
  14477. loopMode: number;
  14478. }
  14479. }
  14480. declare module "babylonjs/Bones/bone" {
  14481. import { Skeleton } from "babylonjs/Bones/skeleton";
  14482. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  14483. import { Nullable } from "babylonjs/types";
  14484. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14485. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14486. import { Node } from "babylonjs/node";
  14487. import { Space } from "babylonjs/Maths/math.axis";
  14488. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  14489. /**
  14490. * Class used to store bone information
  14491. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14492. */
  14493. export class Bone extends Node {
  14494. /**
  14495. * defines the bone name
  14496. */
  14497. name: string;
  14498. private static _tmpVecs;
  14499. private static _tmpQuat;
  14500. private static _tmpMats;
  14501. /**
  14502. * Gets the list of child bones
  14503. */
  14504. children: Bone[];
  14505. /** Gets the animations associated with this bone */
  14506. animations: import("babylonjs/Animations/animation").Animation[];
  14507. /**
  14508. * Gets or sets bone length
  14509. */
  14510. length: number;
  14511. /**
  14512. * @hidden Internal only
  14513. * Set this value to map this bone to a different index in the transform matrices
  14514. * Set this value to -1 to exclude the bone from the transform matrices
  14515. */
  14516. _index: Nullable<number>;
  14517. private _skeleton;
  14518. private _localMatrix;
  14519. private _restPose;
  14520. private _baseMatrix;
  14521. private _absoluteTransform;
  14522. private _invertedAbsoluteTransform;
  14523. private _parent;
  14524. private _scalingDeterminant;
  14525. private _worldTransform;
  14526. private _localScaling;
  14527. private _localRotation;
  14528. private _localPosition;
  14529. private _needToDecompose;
  14530. private _needToCompose;
  14531. /** @hidden */
  14532. _linkedTransformNode: Nullable<TransformNode>;
  14533. /** @hidden */
  14534. _waitingTransformNodeId: Nullable<string>;
  14535. /** @hidden */
  14536. get _matrix(): Matrix;
  14537. /** @hidden */
  14538. set _matrix(value: Matrix);
  14539. /**
  14540. * Create a new bone
  14541. * @param name defines the bone name
  14542. * @param skeleton defines the parent skeleton
  14543. * @param parentBone defines the parent (can be null if the bone is the root)
  14544. * @param localMatrix defines the local matrix
  14545. * @param restPose defines the rest pose matrix
  14546. * @param baseMatrix defines the base matrix
  14547. * @param index defines index of the bone in the hiearchy
  14548. */
  14549. constructor(
  14550. /**
  14551. * defines the bone name
  14552. */
  14553. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14554. /**
  14555. * Gets the current object class name.
  14556. * @return the class name
  14557. */
  14558. getClassName(): string;
  14559. /**
  14560. * Gets the parent skeleton
  14561. * @returns a skeleton
  14562. */
  14563. getSkeleton(): Skeleton;
  14564. /**
  14565. * Gets parent bone
  14566. * @returns a bone or null if the bone is the root of the bone hierarchy
  14567. */
  14568. getParent(): Nullable<Bone>;
  14569. /**
  14570. * Returns an array containing the root bones
  14571. * @returns an array containing the root bones
  14572. */
  14573. getChildren(): Array<Bone>;
  14574. /**
  14575. * Gets the node index in matrix array generated for rendering
  14576. * @returns the node index
  14577. */
  14578. getIndex(): number;
  14579. /**
  14580. * Sets the parent bone
  14581. * @param parent defines the parent (can be null if the bone is the root)
  14582. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14583. */
  14584. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14585. /**
  14586. * Gets the local matrix
  14587. * @returns a matrix
  14588. */
  14589. getLocalMatrix(): Matrix;
  14590. /**
  14591. * Gets the base matrix (initial matrix which remains unchanged)
  14592. * @returns a matrix
  14593. */
  14594. getBaseMatrix(): Matrix;
  14595. /**
  14596. * Gets the rest pose matrix
  14597. * @returns a matrix
  14598. */
  14599. getRestPose(): Matrix;
  14600. /**
  14601. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14602. */
  14603. getWorldMatrix(): Matrix;
  14604. /**
  14605. * Sets the local matrix to rest pose matrix
  14606. */
  14607. returnToRest(): void;
  14608. /**
  14609. * Gets the inverse of the absolute transform matrix.
  14610. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14611. * @returns a matrix
  14612. */
  14613. getInvertedAbsoluteTransform(): Matrix;
  14614. /**
  14615. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14616. * @returns a matrix
  14617. */
  14618. getAbsoluteTransform(): Matrix;
  14619. /**
  14620. * Links with the given transform node.
  14621. * The local matrix of this bone is copied from the transform node every frame.
  14622. * @param transformNode defines the transform node to link to
  14623. */
  14624. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14625. /**
  14626. * Gets the node used to drive the bone's transformation
  14627. * @returns a transform node or null
  14628. */
  14629. getTransformNode(): Nullable<TransformNode>;
  14630. /** Gets or sets current position (in local space) */
  14631. get position(): Vector3;
  14632. set position(newPosition: Vector3);
  14633. /** Gets or sets current rotation (in local space) */
  14634. get rotation(): Vector3;
  14635. set rotation(newRotation: Vector3);
  14636. /** Gets or sets current rotation quaternion (in local space) */
  14637. get rotationQuaternion(): Quaternion;
  14638. set rotationQuaternion(newRotation: Quaternion);
  14639. /** Gets or sets current scaling (in local space) */
  14640. get scaling(): Vector3;
  14641. set scaling(newScaling: Vector3);
  14642. /**
  14643. * Gets the animation properties override
  14644. */
  14645. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14646. private _decompose;
  14647. private _compose;
  14648. /**
  14649. * Update the base and local matrices
  14650. * @param matrix defines the new base or local matrix
  14651. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14652. * @param updateLocalMatrix defines if the local matrix should be updated
  14653. */
  14654. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14655. /** @hidden */
  14656. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14657. /**
  14658. * Flag the bone as dirty (Forcing it to update everything)
  14659. */
  14660. markAsDirty(): void;
  14661. /** @hidden */
  14662. _markAsDirtyAndCompose(): void;
  14663. private _markAsDirtyAndDecompose;
  14664. /**
  14665. * Translate the bone in local or world space
  14666. * @param vec The amount to translate the bone
  14667. * @param space The space that the translation is in
  14668. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14669. */
  14670. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14671. /**
  14672. * Set the postion of the bone in local or world space
  14673. * @param position The position to set the bone
  14674. * @param space The space that the position is in
  14675. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14676. */
  14677. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14678. /**
  14679. * Set the absolute position of the bone (world space)
  14680. * @param position The position to set the bone
  14681. * @param mesh The mesh that this bone is attached to
  14682. */
  14683. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14684. /**
  14685. * Scale the bone on the x, y and z axes (in local space)
  14686. * @param x The amount to scale the bone on the x axis
  14687. * @param y The amount to scale the bone on the y axis
  14688. * @param z The amount to scale the bone on the z axis
  14689. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14690. */
  14691. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14692. /**
  14693. * Set the bone scaling in local space
  14694. * @param scale defines the scaling vector
  14695. */
  14696. setScale(scale: Vector3): void;
  14697. /**
  14698. * Gets the current scaling in local space
  14699. * @returns the current scaling vector
  14700. */
  14701. getScale(): Vector3;
  14702. /**
  14703. * Gets the current scaling in local space and stores it in a target vector
  14704. * @param result defines the target vector
  14705. */
  14706. getScaleToRef(result: Vector3): void;
  14707. /**
  14708. * Set the yaw, pitch, and roll of the bone in local or world space
  14709. * @param yaw The rotation of the bone on the y axis
  14710. * @param pitch The rotation of the bone on the x axis
  14711. * @param roll The rotation of the bone on the z axis
  14712. * @param space The space that the axes of rotation are in
  14713. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14714. */
  14715. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14716. /**
  14717. * Add a rotation to the bone on an axis in local or world space
  14718. * @param axis The axis to rotate the bone on
  14719. * @param amount The amount to rotate the bone
  14720. * @param space The space that the axis is in
  14721. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14722. */
  14723. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14724. /**
  14725. * Set the rotation of the bone to a particular axis angle in local or world space
  14726. * @param axis The axis to rotate the bone on
  14727. * @param angle The angle that the bone should be rotated to
  14728. * @param space The space that the axis is in
  14729. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14730. */
  14731. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14732. /**
  14733. * Set the euler rotation of the bone in local of world space
  14734. * @param rotation The euler rotation that the bone should be set to
  14735. * @param space The space that the rotation is in
  14736. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14737. */
  14738. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14739. /**
  14740. * Set the quaternion rotation of the bone in local of world space
  14741. * @param quat The quaternion rotation that the bone should be set to
  14742. * @param space The space that the rotation is in
  14743. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14744. */
  14745. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14746. /**
  14747. * Set the rotation matrix of the bone in local of world space
  14748. * @param rotMat The rotation matrix that the bone should be set to
  14749. * @param space The space that the rotation is in
  14750. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14751. */
  14752. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14753. private _rotateWithMatrix;
  14754. private _getNegativeRotationToRef;
  14755. /**
  14756. * Get the position of the bone in local or world space
  14757. * @param space The space that the returned position is in
  14758. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14759. * @returns The position of the bone
  14760. */
  14761. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14762. /**
  14763. * Copy the position of the bone to a vector3 in local or world space
  14764. * @param space The space that the returned position is in
  14765. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14766. * @param result The vector3 to copy the position to
  14767. */
  14768. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14769. /**
  14770. * Get the absolute position of the bone (world space)
  14771. * @param mesh The mesh that this bone is attached to
  14772. * @returns The absolute position of the bone
  14773. */
  14774. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14775. /**
  14776. * Copy the absolute position of the bone (world space) to the result param
  14777. * @param mesh The mesh that this bone is attached to
  14778. * @param result The vector3 to copy the absolute position to
  14779. */
  14780. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14781. /**
  14782. * Compute the absolute transforms of this bone and its children
  14783. */
  14784. computeAbsoluteTransforms(): void;
  14785. /**
  14786. * Get the world direction from an axis that is in the local space of the bone
  14787. * @param localAxis The local direction that is used to compute the world direction
  14788. * @param mesh The mesh that this bone is attached to
  14789. * @returns The world direction
  14790. */
  14791. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14792. /**
  14793. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14794. * @param localAxis The local direction that is used to compute the world direction
  14795. * @param mesh The mesh that this bone is attached to
  14796. * @param result The vector3 that the world direction will be copied to
  14797. */
  14798. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14799. /**
  14800. * Get the euler rotation of the bone in local or world space
  14801. * @param space The space that the rotation should be in
  14802. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14803. * @returns The euler rotation
  14804. */
  14805. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14806. /**
  14807. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14808. * @param space The space that the rotation should be in
  14809. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14810. * @param result The vector3 that the rotation should be copied to
  14811. */
  14812. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14813. /**
  14814. * Get the quaternion rotation of the bone in either local or world space
  14815. * @param space The space that the rotation should be in
  14816. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14817. * @returns The quaternion rotation
  14818. */
  14819. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14820. /**
  14821. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14822. * @param space The space that the rotation should be in
  14823. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14824. * @param result The quaternion that the rotation should be copied to
  14825. */
  14826. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14827. /**
  14828. * Get the rotation matrix of the bone in local or world space
  14829. * @param space The space that the rotation should be in
  14830. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14831. * @returns The rotation matrix
  14832. */
  14833. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14834. /**
  14835. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14836. * @param space The space that the rotation should be in
  14837. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14838. * @param result The quaternion that the rotation should be copied to
  14839. */
  14840. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14841. /**
  14842. * Get the world position of a point that is in the local space of the bone
  14843. * @param position The local position
  14844. * @param mesh The mesh that this bone is attached to
  14845. * @returns The world position
  14846. */
  14847. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14848. /**
  14849. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14850. * @param position The local position
  14851. * @param mesh The mesh that this bone is attached to
  14852. * @param result The vector3 that the world position should be copied to
  14853. */
  14854. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14855. /**
  14856. * Get the local position of a point that is in world space
  14857. * @param position The world position
  14858. * @param mesh The mesh that this bone is attached to
  14859. * @returns The local position
  14860. */
  14861. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14862. /**
  14863. * Get the local position of a point that is in world space and copy it to the result param
  14864. * @param position The world position
  14865. * @param mesh The mesh that this bone is attached to
  14866. * @param result The vector3 that the local position should be copied to
  14867. */
  14868. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14869. }
  14870. }
  14871. declare module "babylonjs/Animations/runtimeAnimation" {
  14872. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  14873. import { Animatable } from "babylonjs/Animations/animatable";
  14874. import { Scene } from "babylonjs/scene";
  14875. /**
  14876. * Defines a runtime animation
  14877. */
  14878. export class RuntimeAnimation {
  14879. private _events;
  14880. /**
  14881. * The current frame of the runtime animation
  14882. */
  14883. private _currentFrame;
  14884. /**
  14885. * The animation used by the runtime animation
  14886. */
  14887. private _animation;
  14888. /**
  14889. * The target of the runtime animation
  14890. */
  14891. private _target;
  14892. /**
  14893. * The initiating animatable
  14894. */
  14895. private _host;
  14896. /**
  14897. * The original value of the runtime animation
  14898. */
  14899. private _originalValue;
  14900. /**
  14901. * The original blend value of the runtime animation
  14902. */
  14903. private _originalBlendValue;
  14904. /**
  14905. * The offsets cache of the runtime animation
  14906. */
  14907. private _offsetsCache;
  14908. /**
  14909. * The high limits cache of the runtime animation
  14910. */
  14911. private _highLimitsCache;
  14912. /**
  14913. * Specifies if the runtime animation has been stopped
  14914. */
  14915. private _stopped;
  14916. /**
  14917. * The blending factor of the runtime animation
  14918. */
  14919. private _blendingFactor;
  14920. /**
  14921. * The BabylonJS scene
  14922. */
  14923. private _scene;
  14924. /**
  14925. * The current value of the runtime animation
  14926. */
  14927. private _currentValue;
  14928. /** @hidden */
  14929. _animationState: _IAnimationState;
  14930. /**
  14931. * The active target of the runtime animation
  14932. */
  14933. private _activeTargets;
  14934. private _currentActiveTarget;
  14935. private _directTarget;
  14936. /**
  14937. * The target path of the runtime animation
  14938. */
  14939. private _targetPath;
  14940. /**
  14941. * The weight of the runtime animation
  14942. */
  14943. private _weight;
  14944. /**
  14945. * The ratio offset of the runtime animation
  14946. */
  14947. private _ratioOffset;
  14948. /**
  14949. * The previous delay of the runtime animation
  14950. */
  14951. private _previousDelay;
  14952. /**
  14953. * The previous ratio of the runtime animation
  14954. */
  14955. private _previousRatio;
  14956. private _enableBlending;
  14957. private _keys;
  14958. private _minFrame;
  14959. private _maxFrame;
  14960. private _minValue;
  14961. private _maxValue;
  14962. private _targetIsArray;
  14963. /**
  14964. * Gets the current frame of the runtime animation
  14965. */
  14966. get currentFrame(): number;
  14967. /**
  14968. * Gets the weight of the runtime animation
  14969. */
  14970. get weight(): number;
  14971. /**
  14972. * Gets the current value of the runtime animation
  14973. */
  14974. get currentValue(): any;
  14975. /**
  14976. * Gets the target path of the runtime animation
  14977. */
  14978. get targetPath(): string;
  14979. /**
  14980. * Gets the actual target of the runtime animation
  14981. */
  14982. get target(): any;
  14983. /**
  14984. * Gets the additive state of the runtime animation
  14985. */
  14986. get isAdditive(): boolean;
  14987. /** @hidden */
  14988. _onLoop: () => void;
  14989. /**
  14990. * Create a new RuntimeAnimation object
  14991. * @param target defines the target of the animation
  14992. * @param animation defines the source animation object
  14993. * @param scene defines the hosting scene
  14994. * @param host defines the initiating Animatable
  14995. */
  14996. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14997. private _preparePath;
  14998. /**
  14999. * Gets the animation from the runtime animation
  15000. */
  15001. get animation(): Animation;
  15002. /**
  15003. * Resets the runtime animation to the beginning
  15004. * @param restoreOriginal defines whether to restore the target property to the original value
  15005. */
  15006. reset(restoreOriginal?: boolean): void;
  15007. /**
  15008. * Specifies if the runtime animation is stopped
  15009. * @returns Boolean specifying if the runtime animation is stopped
  15010. */
  15011. isStopped(): boolean;
  15012. /**
  15013. * Disposes of the runtime animation
  15014. */
  15015. dispose(): void;
  15016. /**
  15017. * Apply the interpolated value to the target
  15018. * @param currentValue defines the value computed by the animation
  15019. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15020. */
  15021. setValue(currentValue: any, weight: number): void;
  15022. private _getOriginalValues;
  15023. private _setValue;
  15024. /**
  15025. * Gets the loop pmode of the runtime animation
  15026. * @returns Loop Mode
  15027. */
  15028. private _getCorrectLoopMode;
  15029. /**
  15030. * Move the current animation to a given frame
  15031. * @param frame defines the frame to move to
  15032. */
  15033. goToFrame(frame: number): void;
  15034. /**
  15035. * @hidden Internal use only
  15036. */
  15037. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15038. /**
  15039. * Execute the current animation
  15040. * @param delay defines the delay to add to the current frame
  15041. * @param from defines the lower bound of the animation range
  15042. * @param to defines the upper bound of the animation range
  15043. * @param loop defines if the current animation must loop
  15044. * @param speedRatio defines the current speed ratio
  15045. * @param weight defines the weight of the animation (default is -1 so no weight)
  15046. * @param onLoop optional callback called when animation loops
  15047. * @returns a boolean indicating if the animation is running
  15048. */
  15049. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15050. }
  15051. }
  15052. declare module "babylonjs/Animations/animatable" {
  15053. import { Animation } from "babylonjs/Animations/animation";
  15054. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  15055. import { Nullable } from "babylonjs/types";
  15056. import { Observable } from "babylonjs/Misc/observable";
  15057. import { Scene } from "babylonjs/scene";
  15058. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  15059. import { Node } from "babylonjs/node";
  15060. /**
  15061. * Class used to store an actual running animation
  15062. */
  15063. export class Animatable {
  15064. /** defines the target object */
  15065. target: any;
  15066. /** defines the starting frame number (default is 0) */
  15067. fromFrame: number;
  15068. /** defines the ending frame number (default is 100) */
  15069. toFrame: number;
  15070. /** defines if the animation must loop (default is false) */
  15071. loopAnimation: boolean;
  15072. /** defines a callback to call when animation ends if it is not looping */
  15073. onAnimationEnd?: (() => void) | null | undefined;
  15074. /** defines a callback to call when animation loops */
  15075. onAnimationLoop?: (() => void) | null | undefined;
  15076. /** defines whether the animation should be evaluated additively */
  15077. isAdditive: boolean;
  15078. private _localDelayOffset;
  15079. private _pausedDelay;
  15080. private _runtimeAnimations;
  15081. private _paused;
  15082. private _scene;
  15083. private _speedRatio;
  15084. private _weight;
  15085. private _syncRoot;
  15086. /**
  15087. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15088. * This will only apply for non looping animation (default is true)
  15089. */
  15090. disposeOnEnd: boolean;
  15091. /**
  15092. * Gets a boolean indicating if the animation has started
  15093. */
  15094. animationStarted: boolean;
  15095. /**
  15096. * Observer raised when the animation ends
  15097. */
  15098. onAnimationEndObservable: Observable<Animatable>;
  15099. /**
  15100. * Observer raised when the animation loops
  15101. */
  15102. onAnimationLoopObservable: Observable<Animatable>;
  15103. /**
  15104. * Gets the root Animatable used to synchronize and normalize animations
  15105. */
  15106. get syncRoot(): Nullable<Animatable>;
  15107. /**
  15108. * Gets the current frame of the first RuntimeAnimation
  15109. * Used to synchronize Animatables
  15110. */
  15111. get masterFrame(): number;
  15112. /**
  15113. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15114. */
  15115. get weight(): number;
  15116. set weight(value: number);
  15117. /**
  15118. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15119. */
  15120. get speedRatio(): number;
  15121. set speedRatio(value: number);
  15122. /**
  15123. * Creates a new Animatable
  15124. * @param scene defines the hosting scene
  15125. * @param target defines the target object
  15126. * @param fromFrame defines the starting frame number (default is 0)
  15127. * @param toFrame defines the ending frame number (default is 100)
  15128. * @param loopAnimation defines if the animation must loop (default is false)
  15129. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15130. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15131. * @param animations defines a group of animation to add to the new Animatable
  15132. * @param onAnimationLoop defines a callback to call when animation loops
  15133. * @param isAdditive defines whether the animation should be evaluated additively
  15134. */
  15135. constructor(scene: Scene,
  15136. /** defines the target object */
  15137. target: any,
  15138. /** defines the starting frame number (default is 0) */
  15139. fromFrame?: number,
  15140. /** defines the ending frame number (default is 100) */
  15141. toFrame?: number,
  15142. /** defines if the animation must loop (default is false) */
  15143. loopAnimation?: boolean, speedRatio?: number,
  15144. /** defines a callback to call when animation ends if it is not looping */
  15145. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15146. /** defines a callback to call when animation loops */
  15147. onAnimationLoop?: (() => void) | null | undefined,
  15148. /** defines whether the animation should be evaluated additively */
  15149. isAdditive?: boolean);
  15150. /**
  15151. * Synchronize and normalize current Animatable with a source Animatable
  15152. * This is useful when using animation weights and when animations are not of the same length
  15153. * @param root defines the root Animatable to synchronize with
  15154. * @returns the current Animatable
  15155. */
  15156. syncWith(root: Animatable): Animatable;
  15157. /**
  15158. * Gets the list of runtime animations
  15159. * @returns an array of RuntimeAnimation
  15160. */
  15161. getAnimations(): RuntimeAnimation[];
  15162. /**
  15163. * Adds more animations to the current animatable
  15164. * @param target defines the target of the animations
  15165. * @param animations defines the new animations to add
  15166. */
  15167. appendAnimations(target: any, animations: Animation[]): void;
  15168. /**
  15169. * Gets the source animation for a specific property
  15170. * @param property defines the propertyu to look for
  15171. * @returns null or the source animation for the given property
  15172. */
  15173. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15174. /**
  15175. * Gets the runtime animation for a specific property
  15176. * @param property defines the propertyu to look for
  15177. * @returns null or the runtime animation for the given property
  15178. */
  15179. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15180. /**
  15181. * Resets the animatable to its original state
  15182. */
  15183. reset(): void;
  15184. /**
  15185. * Allows the animatable to blend with current running animations
  15186. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15187. * @param blendingSpeed defines the blending speed to use
  15188. */
  15189. enableBlending(blendingSpeed: number): void;
  15190. /**
  15191. * Disable animation blending
  15192. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15193. */
  15194. disableBlending(): void;
  15195. /**
  15196. * Jump directly to a given frame
  15197. * @param frame defines the frame to jump to
  15198. */
  15199. goToFrame(frame: number): void;
  15200. /**
  15201. * Pause the animation
  15202. */
  15203. pause(): void;
  15204. /**
  15205. * Restart the animation
  15206. */
  15207. restart(): void;
  15208. private _raiseOnAnimationEnd;
  15209. /**
  15210. * Stop and delete the current animation
  15211. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15212. * @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)
  15213. */
  15214. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15215. /**
  15216. * Wait asynchronously for the animation to end
  15217. * @returns a promise which will be fullfilled when the animation ends
  15218. */
  15219. waitAsync(): Promise<Animatable>;
  15220. /** @hidden */
  15221. _animate(delay: number): boolean;
  15222. }
  15223. module "babylonjs/scene" {
  15224. interface Scene {
  15225. /** @hidden */
  15226. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15227. /** @hidden */
  15228. _processLateAnimationBindingsForMatrices(holder: {
  15229. totalWeight: number;
  15230. totalAdditiveWeight: number;
  15231. animations: RuntimeAnimation[];
  15232. additiveAnimations: RuntimeAnimation[];
  15233. originalValue: Matrix;
  15234. }): any;
  15235. /** @hidden */
  15236. _processLateAnimationBindingsForQuaternions(holder: {
  15237. totalWeight: number;
  15238. totalAdditiveWeight: number;
  15239. animations: RuntimeAnimation[];
  15240. additiveAnimations: RuntimeAnimation[];
  15241. originalValue: Quaternion;
  15242. }, refQuaternion: Quaternion): Quaternion;
  15243. /** @hidden */
  15244. _processLateAnimationBindings(): void;
  15245. /**
  15246. * Will start the animation sequence of a given target
  15247. * @param target defines the target
  15248. * @param from defines from which frame should animation start
  15249. * @param to defines until which frame should animation run.
  15250. * @param weight defines the weight to apply to the animation (1.0 by default)
  15251. * @param loop defines if the animation loops
  15252. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15253. * @param onAnimationEnd defines the function to be executed when the animation ends
  15254. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15255. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15256. * @param onAnimationLoop defines the callback to call when an animation loops
  15257. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15258. * @returns the animatable object created for this animation
  15259. */
  15260. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15261. /**
  15262. * Will start the animation sequence of a given target
  15263. * @param target defines the target
  15264. * @param from defines from which frame should animation start
  15265. * @param to defines until which frame should animation run.
  15266. * @param loop defines if the animation loops
  15267. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15268. * @param onAnimationEnd defines the function to be executed when the animation ends
  15269. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15270. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15271. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15272. * @param onAnimationLoop defines the callback to call when an animation loops
  15273. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15274. * @returns the animatable object created for this animation
  15275. */
  15276. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15277. /**
  15278. * Will start the animation sequence of a given target and its hierarchy
  15279. * @param target defines the target
  15280. * @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.
  15281. * @param from defines from which frame should animation start
  15282. * @param to defines until which frame should animation run.
  15283. * @param loop defines if the animation loops
  15284. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15285. * @param onAnimationEnd defines the function to be executed when the animation ends
  15286. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15287. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15288. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15289. * @param onAnimationLoop defines the callback to call when an animation loops
  15290. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15291. * @returns the list of created animatables
  15292. */
  15293. 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, isAdditive?: boolean): Animatable[];
  15294. /**
  15295. * Begin a new animation on a given node
  15296. * @param target defines the target where the animation will take place
  15297. * @param animations defines the list of animations to start
  15298. * @param from defines the initial value
  15299. * @param to defines the final value
  15300. * @param loop defines if you want animation to loop (off by default)
  15301. * @param speedRatio defines the speed ratio to apply to all animations
  15302. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15303. * @param onAnimationLoop defines the callback to call when an animation loops
  15304. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15305. * @returns the list of created animatables
  15306. */
  15307. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15308. /**
  15309. * Begin a new animation on a given node and its hierarchy
  15310. * @param target defines the root node where the animation will take place
  15311. * @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.
  15312. * @param animations defines the list of animations to start
  15313. * @param from defines the initial value
  15314. * @param to defines the final value
  15315. * @param loop defines if you want animation to loop (off by default)
  15316. * @param speedRatio defines the speed ratio to apply to all animations
  15317. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15318. * @param onAnimationLoop defines the callback to call when an animation loops
  15319. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15320. * @returns the list of animatables created for all nodes
  15321. */
  15322. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15323. /**
  15324. * Gets the animatable associated with a specific target
  15325. * @param target defines the target of the animatable
  15326. * @returns the required animatable if found
  15327. */
  15328. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15329. /**
  15330. * Gets all animatables associated with a given target
  15331. * @param target defines the target to look animatables for
  15332. * @returns an array of Animatables
  15333. */
  15334. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15335. /**
  15336. * Stops and removes all animations that have been applied to the scene
  15337. */
  15338. stopAllAnimations(): void;
  15339. /**
  15340. * Gets the current delta time used by animation engine
  15341. */
  15342. deltaTime: number;
  15343. }
  15344. }
  15345. module "babylonjs/Bones/bone" {
  15346. interface Bone {
  15347. /**
  15348. * Copy an animation range from another bone
  15349. * @param source defines the source bone
  15350. * @param rangeName defines the range name to copy
  15351. * @param frameOffset defines the frame offset
  15352. * @param rescaleAsRequired defines if rescaling must be applied if required
  15353. * @param skelDimensionsRatio defines the scaling ratio
  15354. * @returns true if operation was successful
  15355. */
  15356. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15357. }
  15358. }
  15359. }
  15360. declare module "babylonjs/Bones/skeleton" {
  15361. import { Bone } from "babylonjs/Bones/bone";
  15362. import { Observable } from "babylonjs/Misc/observable";
  15363. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15364. import { Scene } from "babylonjs/scene";
  15365. import { Nullable } from "babylonjs/types";
  15366. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15367. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  15368. import { Animatable } from "babylonjs/Animations/animatable";
  15369. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15370. import { Animation } from "babylonjs/Animations/animation";
  15371. import { AnimationRange } from "babylonjs/Animations/animationRange";
  15372. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15373. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15374. /**
  15375. * Class used to handle skinning animations
  15376. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15377. */
  15378. export class Skeleton implements IAnimatable {
  15379. /** defines the skeleton name */
  15380. name: string;
  15381. /** defines the skeleton Id */
  15382. id: string;
  15383. /**
  15384. * Defines the list of child bones
  15385. */
  15386. bones: Bone[];
  15387. /**
  15388. * Defines an estimate of the dimension of the skeleton at rest
  15389. */
  15390. dimensionsAtRest: Vector3;
  15391. /**
  15392. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15393. */
  15394. needInitialSkinMatrix: boolean;
  15395. /**
  15396. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15397. */
  15398. overrideMesh: Nullable<AbstractMesh>;
  15399. /**
  15400. * Gets the list of animations attached to this skeleton
  15401. */
  15402. animations: Array<Animation>;
  15403. private _scene;
  15404. private _isDirty;
  15405. private _transformMatrices;
  15406. private _transformMatrixTexture;
  15407. private _meshesWithPoseMatrix;
  15408. private _animatables;
  15409. private _identity;
  15410. private _synchronizedWithMesh;
  15411. private _ranges;
  15412. private _lastAbsoluteTransformsUpdateId;
  15413. private _canUseTextureForBones;
  15414. private _uniqueId;
  15415. /** @hidden */
  15416. _numBonesWithLinkedTransformNode: number;
  15417. /** @hidden */
  15418. _hasWaitingData: Nullable<boolean>;
  15419. /**
  15420. * Specifies if the skeleton should be serialized
  15421. */
  15422. doNotSerialize: boolean;
  15423. private _useTextureToStoreBoneMatrices;
  15424. /**
  15425. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15426. * Please note that this option is not available if the hardware does not support it
  15427. */
  15428. get useTextureToStoreBoneMatrices(): boolean;
  15429. set useTextureToStoreBoneMatrices(value: boolean);
  15430. private _animationPropertiesOverride;
  15431. /**
  15432. * Gets or sets the animation properties override
  15433. */
  15434. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15435. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15436. /**
  15437. * List of inspectable custom properties (used by the Inspector)
  15438. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15439. */
  15440. inspectableCustomProperties: IInspectable[];
  15441. /**
  15442. * An observable triggered before computing the skeleton's matrices
  15443. */
  15444. onBeforeComputeObservable: Observable<Skeleton>;
  15445. /**
  15446. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15447. */
  15448. get isUsingTextureForMatrices(): boolean;
  15449. /**
  15450. * Gets the unique ID of this skeleton
  15451. */
  15452. get uniqueId(): number;
  15453. /**
  15454. * Creates a new skeleton
  15455. * @param name defines the skeleton name
  15456. * @param id defines the skeleton Id
  15457. * @param scene defines the hosting scene
  15458. */
  15459. constructor(
  15460. /** defines the skeleton name */
  15461. name: string,
  15462. /** defines the skeleton Id */
  15463. id: string, scene: Scene);
  15464. /**
  15465. * Gets the current object class name.
  15466. * @return the class name
  15467. */
  15468. getClassName(): string;
  15469. /**
  15470. * Returns an array containing the root bones
  15471. * @returns an array containing the root bones
  15472. */
  15473. getChildren(): Array<Bone>;
  15474. /**
  15475. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15476. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15477. * @returns a Float32Array containing matrices data
  15478. */
  15479. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15480. /**
  15481. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15482. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15483. * @returns a raw texture containing the data
  15484. */
  15485. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15486. /**
  15487. * Gets the current hosting scene
  15488. * @returns a scene object
  15489. */
  15490. getScene(): Scene;
  15491. /**
  15492. * Gets a string representing the current skeleton data
  15493. * @param fullDetails defines a boolean indicating if we want a verbose version
  15494. * @returns a string representing the current skeleton data
  15495. */
  15496. toString(fullDetails?: boolean): string;
  15497. /**
  15498. * Get bone's index searching by name
  15499. * @param name defines bone's name to search for
  15500. * @return the indice of the bone. Returns -1 if not found
  15501. */
  15502. getBoneIndexByName(name: string): number;
  15503. /**
  15504. * Creater a new animation range
  15505. * @param name defines the name of the range
  15506. * @param from defines the start key
  15507. * @param to defines the end key
  15508. */
  15509. createAnimationRange(name: string, from: number, to: number): void;
  15510. /**
  15511. * Delete a specific animation range
  15512. * @param name defines the name of the range
  15513. * @param deleteFrames defines if frames must be removed as well
  15514. */
  15515. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15516. /**
  15517. * Gets a specific animation range
  15518. * @param name defines the name of the range to look for
  15519. * @returns the requested animation range or null if not found
  15520. */
  15521. getAnimationRange(name: string): Nullable<AnimationRange>;
  15522. /**
  15523. * Gets the list of all animation ranges defined on this skeleton
  15524. * @returns an array
  15525. */
  15526. getAnimationRanges(): Nullable<AnimationRange>[];
  15527. /**
  15528. * Copy animation range from a source skeleton.
  15529. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15530. * @param source defines the source skeleton
  15531. * @param name defines the name of the range to copy
  15532. * @param rescaleAsRequired defines if rescaling must be applied if required
  15533. * @returns true if operation was successful
  15534. */
  15535. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15536. /**
  15537. * Forces the skeleton to go to rest pose
  15538. */
  15539. returnToRest(): void;
  15540. private _getHighestAnimationFrame;
  15541. /**
  15542. * Begin a specific animation range
  15543. * @param name defines the name of the range to start
  15544. * @param loop defines if looping must be turned on (false by default)
  15545. * @param speedRatio defines the speed ratio to apply (1 by default)
  15546. * @param onAnimationEnd defines a callback which will be called when animation will end
  15547. * @returns a new animatable
  15548. */
  15549. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15550. /**
  15551. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15552. * @param skeleton defines the Skeleton containing the animation range to convert
  15553. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15554. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15555. * @returns the original skeleton
  15556. */
  15557. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15558. /** @hidden */
  15559. _markAsDirty(): void;
  15560. /** @hidden */
  15561. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15562. /** @hidden */
  15563. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15564. private _computeTransformMatrices;
  15565. /**
  15566. * Build all resources required to render a skeleton
  15567. */
  15568. prepare(): void;
  15569. /**
  15570. * Gets the list of animatables currently running for this skeleton
  15571. * @returns an array of animatables
  15572. */
  15573. getAnimatables(): IAnimatable[];
  15574. /**
  15575. * Clone the current skeleton
  15576. * @param name defines the name of the new skeleton
  15577. * @param id defines the id of the new skeleton
  15578. * @returns the new skeleton
  15579. */
  15580. clone(name: string, id?: string): Skeleton;
  15581. /**
  15582. * Enable animation blending for this skeleton
  15583. * @param blendingSpeed defines the blending speed to apply
  15584. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15585. */
  15586. enableBlending(blendingSpeed?: number): void;
  15587. /**
  15588. * Releases all resources associated with the current skeleton
  15589. */
  15590. dispose(): void;
  15591. /**
  15592. * Serialize the skeleton in a JSON object
  15593. * @returns a JSON object
  15594. */
  15595. serialize(): any;
  15596. /**
  15597. * Creates a new skeleton from serialized data
  15598. * @param parsedSkeleton defines the serialized data
  15599. * @param scene defines the hosting scene
  15600. * @returns a new skeleton
  15601. */
  15602. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15603. /**
  15604. * Compute all node absolute transforms
  15605. * @param forceUpdate defines if computation must be done even if cache is up to date
  15606. */
  15607. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15608. /**
  15609. * Gets the root pose matrix
  15610. * @returns a matrix
  15611. */
  15612. getPoseMatrix(): Nullable<Matrix>;
  15613. /**
  15614. * Sorts bones per internal index
  15615. */
  15616. sortBones(): void;
  15617. private _sortBones;
  15618. }
  15619. }
  15620. declare module "babylonjs/Meshes/instancedMesh" {
  15621. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  15622. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15623. import { Camera } from "babylonjs/Cameras/camera";
  15624. import { Node } from "babylonjs/node";
  15625. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15626. import { Mesh } from "babylonjs/Meshes/mesh";
  15627. import { Material } from "babylonjs/Materials/material";
  15628. import { Skeleton } from "babylonjs/Bones/skeleton";
  15629. import { Light } from "babylonjs/Lights/light";
  15630. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  15631. /**
  15632. * Creates an instance based on a source mesh.
  15633. */
  15634. export class InstancedMesh extends AbstractMesh {
  15635. private _sourceMesh;
  15636. private _currentLOD;
  15637. /** @hidden */
  15638. _indexInSourceMeshInstanceArray: number;
  15639. constructor(name: string, source: Mesh);
  15640. /**
  15641. * Returns the string "InstancedMesh".
  15642. */
  15643. getClassName(): string;
  15644. /** Gets the list of lights affecting that mesh */
  15645. get lightSources(): Light[];
  15646. _resyncLightSources(): void;
  15647. _resyncLightSource(light: Light): void;
  15648. _removeLightSource(light: Light, dispose: boolean): void;
  15649. /**
  15650. * If the source mesh receives shadows
  15651. */
  15652. get receiveShadows(): boolean;
  15653. /**
  15654. * The material of the source mesh
  15655. */
  15656. get material(): Nullable<Material>;
  15657. /**
  15658. * Visibility of the source mesh
  15659. */
  15660. get visibility(): number;
  15661. /**
  15662. * Skeleton of the source mesh
  15663. */
  15664. get skeleton(): Nullable<Skeleton>;
  15665. /**
  15666. * Rendering ground id of the source mesh
  15667. */
  15668. get renderingGroupId(): number;
  15669. set renderingGroupId(value: number);
  15670. /**
  15671. * Returns the total number of vertices (integer).
  15672. */
  15673. getTotalVertices(): number;
  15674. /**
  15675. * Returns a positive integer : the total number of indices in this mesh geometry.
  15676. * @returns the numner of indices or zero if the mesh has no geometry.
  15677. */
  15678. getTotalIndices(): number;
  15679. /**
  15680. * The source mesh of the instance
  15681. */
  15682. get sourceMesh(): Mesh;
  15683. /**
  15684. * Is this node ready to be used/rendered
  15685. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15686. * @return {boolean} is it ready
  15687. */
  15688. isReady(completeCheck?: boolean): boolean;
  15689. /**
  15690. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15691. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15692. * @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.
  15693. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15694. */
  15695. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15696. /**
  15697. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15698. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15699. * The `data` are either a numeric array either a Float32Array.
  15700. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15701. * 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).
  15702. * Note that a new underlying VertexBuffer object is created each call.
  15703. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15704. *
  15705. * Possible `kind` values :
  15706. * - VertexBuffer.PositionKind
  15707. * - VertexBuffer.UVKind
  15708. * - VertexBuffer.UV2Kind
  15709. * - VertexBuffer.UV3Kind
  15710. * - VertexBuffer.UV4Kind
  15711. * - VertexBuffer.UV5Kind
  15712. * - VertexBuffer.UV6Kind
  15713. * - VertexBuffer.ColorKind
  15714. * - VertexBuffer.MatricesIndicesKind
  15715. * - VertexBuffer.MatricesIndicesExtraKind
  15716. * - VertexBuffer.MatricesWeightsKind
  15717. * - VertexBuffer.MatricesWeightsExtraKind
  15718. *
  15719. * Returns the Mesh.
  15720. */
  15721. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15722. /**
  15723. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15724. * If the mesh has no geometry, it is simply returned as it is.
  15725. * The `data` are either a numeric array either a Float32Array.
  15726. * No new underlying VertexBuffer object is created.
  15727. * 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.
  15728. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15729. *
  15730. * Possible `kind` values :
  15731. * - VertexBuffer.PositionKind
  15732. * - VertexBuffer.UVKind
  15733. * - VertexBuffer.UV2Kind
  15734. * - VertexBuffer.UV3Kind
  15735. * - VertexBuffer.UV4Kind
  15736. * - VertexBuffer.UV5Kind
  15737. * - VertexBuffer.UV6Kind
  15738. * - VertexBuffer.ColorKind
  15739. * - VertexBuffer.MatricesIndicesKind
  15740. * - VertexBuffer.MatricesIndicesExtraKind
  15741. * - VertexBuffer.MatricesWeightsKind
  15742. * - VertexBuffer.MatricesWeightsExtraKind
  15743. *
  15744. * Returns the Mesh.
  15745. */
  15746. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15747. /**
  15748. * Sets the mesh indices.
  15749. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15750. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15751. * This method creates a new index buffer each call.
  15752. * Returns the Mesh.
  15753. */
  15754. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15755. /**
  15756. * Boolean : True if the mesh owns the requested kind of data.
  15757. */
  15758. isVerticesDataPresent(kind: string): boolean;
  15759. /**
  15760. * Returns an array of indices (IndicesArray).
  15761. */
  15762. getIndices(): Nullable<IndicesArray>;
  15763. get _positions(): Nullable<Vector3[]>;
  15764. /**
  15765. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15766. * This means the mesh underlying bounding box and sphere are recomputed.
  15767. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15768. * @returns the current mesh
  15769. */
  15770. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15771. /** @hidden */
  15772. _preActivate(): InstancedMesh;
  15773. /** @hidden */
  15774. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15775. /** @hidden */
  15776. _postActivate(): void;
  15777. getWorldMatrix(): Matrix;
  15778. get isAnInstance(): boolean;
  15779. /**
  15780. * Returns the current associated LOD AbstractMesh.
  15781. */
  15782. getLOD(camera: Camera): AbstractMesh;
  15783. /** @hidden */
  15784. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15785. /** @hidden */
  15786. _syncSubMeshes(): InstancedMesh;
  15787. /** @hidden */
  15788. _generatePointsArray(): boolean;
  15789. /**
  15790. * Creates a new InstancedMesh from the current mesh.
  15791. * - name (string) : the cloned mesh name
  15792. * - newParent (optional Node) : the optional Node to parent the clone to.
  15793. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15794. *
  15795. * Returns the clone.
  15796. */
  15797. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15798. /**
  15799. * Disposes the InstancedMesh.
  15800. * Returns nothing.
  15801. */
  15802. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15803. }
  15804. module "babylonjs/Meshes/mesh" {
  15805. interface Mesh {
  15806. /**
  15807. * Register a custom buffer that will be instanced
  15808. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15809. * @param kind defines the buffer kind
  15810. * @param stride defines the stride in floats
  15811. */
  15812. registerInstancedBuffer(kind: string, stride: number): void;
  15813. /** @hidden */
  15814. _userInstancedBuffersStorage: {
  15815. data: {
  15816. [key: string]: Float32Array;
  15817. };
  15818. sizes: {
  15819. [key: string]: number;
  15820. };
  15821. vertexBuffers: {
  15822. [key: string]: Nullable<VertexBuffer>;
  15823. };
  15824. strides: {
  15825. [key: string]: number;
  15826. };
  15827. };
  15828. }
  15829. }
  15830. module "babylonjs/Meshes/abstractMesh" {
  15831. interface AbstractMesh {
  15832. /**
  15833. * Object used to store instanced buffers defined by user
  15834. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15835. */
  15836. instancedBuffers: {
  15837. [key: string]: any;
  15838. };
  15839. }
  15840. }
  15841. }
  15842. declare module "babylonjs/Materials/shaderMaterial" {
  15843. import { Nullable } from "babylonjs/types";
  15844. import { Scene } from "babylonjs/scene";
  15845. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  15846. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15847. import { Mesh } from "babylonjs/Meshes/mesh";
  15848. import { SubMesh, BaseSubMesh } from "babylonjs/Meshes/subMesh";
  15849. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15850. import { Effect } from "babylonjs/Materials/effect";
  15851. import { Material } from "babylonjs/Materials/material";
  15852. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  15853. /**
  15854. * Defines the options associated with the creation of a shader material.
  15855. */
  15856. export interface IShaderMaterialOptions {
  15857. /**
  15858. * Does the material work in alpha blend mode
  15859. */
  15860. needAlphaBlending: boolean;
  15861. /**
  15862. * Does the material work in alpha test mode
  15863. */
  15864. needAlphaTesting: boolean;
  15865. /**
  15866. * The list of attribute names used in the shader
  15867. */
  15868. attributes: string[];
  15869. /**
  15870. * The list of unifrom names used in the shader
  15871. */
  15872. uniforms: string[];
  15873. /**
  15874. * The list of UBO names used in the shader
  15875. */
  15876. uniformBuffers: string[];
  15877. /**
  15878. * The list of sampler names used in the shader
  15879. */
  15880. samplers: string[];
  15881. /**
  15882. * The list of defines used in the shader
  15883. */
  15884. defines: string[];
  15885. }
  15886. /**
  15887. * 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.
  15888. *
  15889. * This returned material effects how the mesh will look based on the code in the shaders.
  15890. *
  15891. * @see http://doc.babylonjs.com/how_to/shader_material
  15892. */
  15893. export class ShaderMaterial extends Material {
  15894. private _shaderPath;
  15895. private _options;
  15896. private _textures;
  15897. private _textureArrays;
  15898. private _floats;
  15899. private _ints;
  15900. private _floatsArrays;
  15901. private _colors3;
  15902. private _colors3Arrays;
  15903. private _colors4;
  15904. private _colors4Arrays;
  15905. private _vectors2;
  15906. private _vectors3;
  15907. private _vectors4;
  15908. private _matrices;
  15909. private _matrixArrays;
  15910. private _matrices3x3;
  15911. private _matrices2x2;
  15912. private _vectors2Arrays;
  15913. private _vectors3Arrays;
  15914. private _vectors4Arrays;
  15915. private _cachedWorldViewMatrix;
  15916. private _cachedWorldViewProjectionMatrix;
  15917. private _renderId;
  15918. private _multiview;
  15919. private _cachedDefines;
  15920. /**
  15921. * Instantiate a new shader material.
  15922. * 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.
  15923. * This returned material effects how the mesh will look based on the code in the shaders.
  15924. * @see http://doc.babylonjs.com/how_to/shader_material
  15925. * @param name Define the name of the material in the scene
  15926. * @param scene Define the scene the material belongs to
  15927. * @param shaderPath Defines the route to the shader code in one of three ways:
  15928. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15929. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15930. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15931. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15932. * @param options Define the options used to create the shader
  15933. */
  15934. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15935. /**
  15936. * Gets the shader path used to define the shader code
  15937. * It can be modified to trigger a new compilation
  15938. */
  15939. get shaderPath(): any;
  15940. /**
  15941. * Sets the shader path used to define the shader code
  15942. * It can be modified to trigger a new compilation
  15943. */
  15944. set shaderPath(shaderPath: any);
  15945. /**
  15946. * Gets the options used to compile the shader.
  15947. * They can be modified to trigger a new compilation
  15948. */
  15949. get options(): IShaderMaterialOptions;
  15950. /**
  15951. * Gets the current class name of the material e.g. "ShaderMaterial"
  15952. * Mainly use in serialization.
  15953. * @returns the class name
  15954. */
  15955. getClassName(): string;
  15956. /**
  15957. * Specifies if the material will require alpha blending
  15958. * @returns a boolean specifying if alpha blending is needed
  15959. */
  15960. needAlphaBlending(): boolean;
  15961. /**
  15962. * Specifies if this material should be rendered in alpha test mode
  15963. * @returns a boolean specifying if an alpha test is needed.
  15964. */
  15965. needAlphaTesting(): boolean;
  15966. private _checkUniform;
  15967. /**
  15968. * Set a texture in the shader.
  15969. * @param name Define the name of the uniform samplers as defined in the shader
  15970. * @param texture Define the texture to bind to this sampler
  15971. * @return the material itself allowing "fluent" like uniform updates
  15972. */
  15973. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  15974. /**
  15975. * Set a texture array in the shader.
  15976. * @param name Define the name of the uniform sampler array as defined in the shader
  15977. * @param textures Define the list of textures to bind to this sampler
  15978. * @return the material itself allowing "fluent" like uniform updates
  15979. */
  15980. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  15981. /**
  15982. * Set a float in the shader.
  15983. * @param name Define the name of the uniform as defined in the shader
  15984. * @param value Define the value to give to the uniform
  15985. * @return the material itself allowing "fluent" like uniform updates
  15986. */
  15987. setFloat(name: string, value: number): ShaderMaterial;
  15988. /**
  15989. * Set a int in the shader.
  15990. * @param name Define the name of the uniform as defined in the shader
  15991. * @param value Define the value to give to the uniform
  15992. * @return the material itself allowing "fluent" like uniform updates
  15993. */
  15994. setInt(name: string, value: number): ShaderMaterial;
  15995. /**
  15996. * Set an array of floats in the shader.
  15997. * @param name Define the name of the uniform as defined in the shader
  15998. * @param value Define the value to give to the uniform
  15999. * @return the material itself allowing "fluent" like uniform updates
  16000. */
  16001. setFloats(name: string, value: number[]): ShaderMaterial;
  16002. /**
  16003. * Set a vec3 in the shader from a Color3.
  16004. * @param name Define the name of the uniform as defined in the shader
  16005. * @param value Define the value to give to the uniform
  16006. * @return the material itself allowing "fluent" like uniform updates
  16007. */
  16008. setColor3(name: string, value: Color3): ShaderMaterial;
  16009. /**
  16010. * Set a vec3 array in the shader from a Color3 array.
  16011. * @param name Define the name of the uniform as defined in the shader
  16012. * @param value Define the value to give to the uniform
  16013. * @return the material itself allowing "fluent" like uniform updates
  16014. */
  16015. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16016. /**
  16017. * Set a vec4 in the shader from a Color4.
  16018. * @param name Define the name of the uniform as defined in the shader
  16019. * @param value Define the value to give to the uniform
  16020. * @return the material itself allowing "fluent" like uniform updates
  16021. */
  16022. setColor4(name: string, value: Color4): ShaderMaterial;
  16023. /**
  16024. * Set a vec4 array in the shader from a Color4 array.
  16025. * @param name Define the name of the uniform as defined in the shader
  16026. * @param value Define the value to give to the uniform
  16027. * @return the material itself allowing "fluent" like uniform updates
  16028. */
  16029. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16030. /**
  16031. * Set a vec2 in the shader from a Vector2.
  16032. * @param name Define the name of the uniform as defined in the shader
  16033. * @param value Define the value to give to the uniform
  16034. * @return the material itself allowing "fluent" like uniform updates
  16035. */
  16036. setVector2(name: string, value: Vector2): ShaderMaterial;
  16037. /**
  16038. * Set a vec3 in the shader from a Vector3.
  16039. * @param name Define the name of the uniform as defined in the shader
  16040. * @param value Define the value to give to the uniform
  16041. * @return the material itself allowing "fluent" like uniform updates
  16042. */
  16043. setVector3(name: string, value: Vector3): ShaderMaterial;
  16044. /**
  16045. * Set a vec4 in the shader from a Vector4.
  16046. * @param name Define the name of the uniform as defined in the shader
  16047. * @param value Define the value to give to the uniform
  16048. * @return the material itself allowing "fluent" like uniform updates
  16049. */
  16050. setVector4(name: string, value: Vector4): ShaderMaterial;
  16051. /**
  16052. * Set a mat4 in the shader from a Matrix.
  16053. * @param name Define the name of the uniform as defined in the shader
  16054. * @param value Define the value to give to the uniform
  16055. * @return the material itself allowing "fluent" like uniform updates
  16056. */
  16057. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16058. /**
  16059. * Set a float32Array in the shader from a matrix array.
  16060. * @param name Define the name of the uniform as defined in the shader
  16061. * @param value Define the value to give to the uniform
  16062. * @return the material itself allowing "fluent" like uniform updates
  16063. */
  16064. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16065. /**
  16066. * Set a mat3 in the shader from a Float32Array.
  16067. * @param name Define the name of the uniform as defined in the shader
  16068. * @param value Define the value to give to the uniform
  16069. * @return the material itself allowing "fluent" like uniform updates
  16070. */
  16071. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16072. /**
  16073. * Set a mat2 in the shader from a Float32Array.
  16074. * @param name Define the name of the uniform as defined in the shader
  16075. * @param value Define the value to give to the uniform
  16076. * @return the material itself allowing "fluent" like uniform updates
  16077. */
  16078. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16079. /**
  16080. * Set a vec2 array in the shader from a number array.
  16081. * @param name Define the name of the uniform as defined in the shader
  16082. * @param value Define the value to give to the uniform
  16083. * @return the material itself allowing "fluent" like uniform updates
  16084. */
  16085. setArray2(name: string, value: number[]): ShaderMaterial;
  16086. /**
  16087. * Set a vec3 array in the shader from a number array.
  16088. * @param name Define the name of the uniform as defined in the shader
  16089. * @param value Define the value to give to the uniform
  16090. * @return the material itself allowing "fluent" like uniform updates
  16091. */
  16092. setArray3(name: string, value: number[]): ShaderMaterial;
  16093. /**
  16094. * Set a vec4 array in the shader from a number array.
  16095. * @param name Define the name of the uniform as defined in the shader
  16096. * @param value Define the value to give to the uniform
  16097. * @return the material itself allowing "fluent" like uniform updates
  16098. */
  16099. setArray4(name: string, value: number[]): ShaderMaterial;
  16100. private _checkCache;
  16101. /**
  16102. * Specifies that the submesh is ready to be used
  16103. * @param mesh defines the mesh to check
  16104. * @param subMesh defines which submesh to check
  16105. * @param useInstances specifies that instances should be used
  16106. * @returns a boolean indicating that the submesh is ready or not
  16107. */
  16108. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16109. /**
  16110. * Checks if the material is ready to render the requested mesh
  16111. * @param mesh Define the mesh to render
  16112. * @param useInstances Define whether or not the material is used with instances
  16113. * @returns true if ready, otherwise false
  16114. */
  16115. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16116. /**
  16117. * Binds the world matrix to the material
  16118. * @param world defines the world transformation matrix
  16119. * @param effectOverride - If provided, use this effect instead of internal effect
  16120. */
  16121. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16122. /**
  16123. * Binds the submesh to this material by preparing the effect and shader to draw
  16124. * @param world defines the world transformation matrix
  16125. * @param mesh defines the mesh containing the submesh
  16126. * @param subMesh defines the submesh to bind the material to
  16127. */
  16128. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16129. /**
  16130. * Binds the material to the mesh
  16131. * @param world defines the world transformation matrix
  16132. * @param mesh defines the mesh to bind the material to
  16133. * @param effectOverride - If provided, use this effect instead of internal effect
  16134. */
  16135. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16136. protected _afterBind(mesh?: Mesh): void;
  16137. /**
  16138. * Gets the active textures from the material
  16139. * @returns an array of textures
  16140. */
  16141. getActiveTextures(): BaseTexture[];
  16142. /**
  16143. * Specifies if the material uses a texture
  16144. * @param texture defines the texture to check against the material
  16145. * @returns a boolean specifying if the material uses the texture
  16146. */
  16147. hasTexture(texture: BaseTexture): boolean;
  16148. /**
  16149. * Makes a duplicate of the material, and gives it a new name
  16150. * @param name defines the new name for the duplicated material
  16151. * @returns the cloned material
  16152. */
  16153. clone(name: string): ShaderMaterial;
  16154. /**
  16155. * Disposes the material
  16156. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16157. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16158. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16159. */
  16160. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16161. /**
  16162. * Serializes this material in a JSON representation
  16163. * @returns the serialized material object
  16164. */
  16165. serialize(): any;
  16166. /**
  16167. * Creates a shader material from parsed shader material data
  16168. * @param source defines the JSON represnetation of the material
  16169. * @param scene defines the hosting scene
  16170. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16171. * @returns a new material
  16172. */
  16173. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16174. }
  16175. }
  16176. declare module "babylonjs/Shaders/color.fragment" {
  16177. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  16178. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  16179. /** @hidden */
  16180. export var colorPixelShader: {
  16181. name: string;
  16182. shader: string;
  16183. };
  16184. }
  16185. declare module "babylonjs/Shaders/color.vertex" {
  16186. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  16187. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  16188. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  16189. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  16190. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  16191. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  16192. /** @hidden */
  16193. export var colorVertexShader: {
  16194. name: string;
  16195. shader: string;
  16196. };
  16197. }
  16198. declare module "babylonjs/Meshes/linesMesh" {
  16199. import { Nullable } from "babylonjs/types";
  16200. import { Scene } from "babylonjs/scene";
  16201. import { Color3 } from "babylonjs/Maths/math.color";
  16202. import { Node } from "babylonjs/node";
  16203. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16204. import { Mesh } from "babylonjs/Meshes/mesh";
  16205. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  16206. import { Effect } from "babylonjs/Materials/effect";
  16207. import { Material } from "babylonjs/Materials/material";
  16208. import "babylonjs/Shaders/color.fragment";
  16209. import "babylonjs/Shaders/color.vertex";
  16210. /**
  16211. * Line mesh
  16212. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16213. */
  16214. export class LinesMesh extends Mesh {
  16215. /**
  16216. * If vertex color should be applied to the mesh
  16217. */
  16218. readonly useVertexColor?: boolean | undefined;
  16219. /**
  16220. * If vertex alpha should be applied to the mesh
  16221. */
  16222. readonly useVertexAlpha?: boolean | undefined;
  16223. /**
  16224. * Color of the line (Default: White)
  16225. */
  16226. color: Color3;
  16227. /**
  16228. * Alpha of the line (Default: 1)
  16229. */
  16230. alpha: number;
  16231. /**
  16232. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16233. * This margin is expressed in world space coordinates, so its value may vary.
  16234. * Default value is 0.1
  16235. */
  16236. intersectionThreshold: number;
  16237. private _colorShader;
  16238. private color4;
  16239. /**
  16240. * Creates a new LinesMesh
  16241. * @param name defines the name
  16242. * @param scene defines the hosting scene
  16243. * @param parent defines the parent mesh if any
  16244. * @param source defines the optional source LinesMesh used to clone data from
  16245. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16246. * When false, achieved by calling a clone(), also passing False.
  16247. * This will make creation of children, recursive.
  16248. * @param useVertexColor defines if this LinesMesh supports vertex color
  16249. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16250. */
  16251. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16252. /**
  16253. * If vertex color should be applied to the mesh
  16254. */
  16255. useVertexColor?: boolean | undefined,
  16256. /**
  16257. * If vertex alpha should be applied to the mesh
  16258. */
  16259. useVertexAlpha?: boolean | undefined);
  16260. private _addClipPlaneDefine;
  16261. private _removeClipPlaneDefine;
  16262. isReady(): boolean;
  16263. /**
  16264. * Returns the string "LineMesh"
  16265. */
  16266. getClassName(): string;
  16267. /**
  16268. * @hidden
  16269. */
  16270. get material(): Material;
  16271. /**
  16272. * @hidden
  16273. */
  16274. set material(value: Material);
  16275. /**
  16276. * @hidden
  16277. */
  16278. get checkCollisions(): boolean;
  16279. /** @hidden */
  16280. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16281. /** @hidden */
  16282. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16283. /**
  16284. * Disposes of the line mesh
  16285. * @param doNotRecurse If children should be disposed
  16286. */
  16287. dispose(doNotRecurse?: boolean): void;
  16288. /**
  16289. * Returns a new LineMesh object cloned from the current one.
  16290. */
  16291. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16292. /**
  16293. * Creates a new InstancedLinesMesh object from the mesh model.
  16294. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16295. * @param name defines the name of the new instance
  16296. * @returns a new InstancedLinesMesh
  16297. */
  16298. createInstance(name: string): InstancedLinesMesh;
  16299. }
  16300. /**
  16301. * Creates an instance based on a source LinesMesh
  16302. */
  16303. export class InstancedLinesMesh extends InstancedMesh {
  16304. /**
  16305. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16306. * This margin is expressed in world space coordinates, so its value may vary.
  16307. * Initilized with the intersectionThreshold value of the source LinesMesh
  16308. */
  16309. intersectionThreshold: number;
  16310. constructor(name: string, source: LinesMesh);
  16311. /**
  16312. * Returns the string "InstancedLinesMesh".
  16313. */
  16314. getClassName(): string;
  16315. }
  16316. }
  16317. declare module "babylonjs/Shaders/line.fragment" {
  16318. /** @hidden */
  16319. export var linePixelShader: {
  16320. name: string;
  16321. shader: string;
  16322. };
  16323. }
  16324. declare module "babylonjs/Shaders/line.vertex" {
  16325. /** @hidden */
  16326. export var lineVertexShader: {
  16327. name: string;
  16328. shader: string;
  16329. };
  16330. }
  16331. declare module "babylonjs/Rendering/edgesRenderer" {
  16332. import { Nullable } from "babylonjs/types";
  16333. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16334. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16335. import { Vector3 } from "babylonjs/Maths/math.vector";
  16336. import { IDisposable } from "babylonjs/scene";
  16337. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16338. import "babylonjs/Shaders/line.fragment";
  16339. import "babylonjs/Shaders/line.vertex";
  16340. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  16341. module "babylonjs/Meshes/abstractMesh" {
  16342. interface AbstractMesh {
  16343. /**
  16344. * Gets the edgesRenderer associated with the mesh
  16345. */
  16346. edgesRenderer: Nullable<EdgesRenderer>;
  16347. }
  16348. }
  16349. module "babylonjs/Meshes/linesMesh" {
  16350. interface LinesMesh {
  16351. /**
  16352. * Enables the edge rendering mode on the mesh.
  16353. * This mode makes the mesh edges visible
  16354. * @param epsilon defines the maximal distance between two angles to detect a face
  16355. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16356. * @returns the currentAbstractMesh
  16357. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16358. */
  16359. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16360. }
  16361. }
  16362. module "babylonjs/Meshes/linesMesh" {
  16363. interface InstancedLinesMesh {
  16364. /**
  16365. * Enables the edge rendering mode on the mesh.
  16366. * This mode makes the mesh edges visible
  16367. * @param epsilon defines the maximal distance between two angles to detect a face
  16368. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16369. * @returns the current InstancedLinesMesh
  16370. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16371. */
  16372. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16373. }
  16374. }
  16375. /**
  16376. * Defines the minimum contract an Edges renderer should follow.
  16377. */
  16378. export interface IEdgesRenderer extends IDisposable {
  16379. /**
  16380. * Gets or sets a boolean indicating if the edgesRenderer is active
  16381. */
  16382. isEnabled: boolean;
  16383. /**
  16384. * Renders the edges of the attached mesh,
  16385. */
  16386. render(): void;
  16387. /**
  16388. * Checks wether or not the edges renderer is ready to render.
  16389. * @return true if ready, otherwise false.
  16390. */
  16391. isReady(): boolean;
  16392. }
  16393. /**
  16394. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16395. */
  16396. export class EdgesRenderer implements IEdgesRenderer {
  16397. /**
  16398. * Define the size of the edges with an orthographic camera
  16399. */
  16400. edgesWidthScalerForOrthographic: number;
  16401. /**
  16402. * Define the size of the edges with a perspective camera
  16403. */
  16404. edgesWidthScalerForPerspective: number;
  16405. protected _source: AbstractMesh;
  16406. protected _linesPositions: number[];
  16407. protected _linesNormals: number[];
  16408. protected _linesIndices: number[];
  16409. protected _epsilon: number;
  16410. protected _indicesCount: number;
  16411. protected _lineShader: ShaderMaterial;
  16412. protected _ib: DataBuffer;
  16413. protected _buffers: {
  16414. [key: string]: Nullable<VertexBuffer>;
  16415. };
  16416. protected _checkVerticesInsteadOfIndices: boolean;
  16417. private _meshRebuildObserver;
  16418. private _meshDisposeObserver;
  16419. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16420. isEnabled: boolean;
  16421. /**
  16422. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16423. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16424. * @param source Mesh used to create edges
  16425. * @param epsilon sum of angles in adjacency to check for edge
  16426. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16427. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16428. */
  16429. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16430. protected _prepareRessources(): void;
  16431. /** @hidden */
  16432. _rebuild(): void;
  16433. /**
  16434. * Releases the required resources for the edges renderer
  16435. */
  16436. dispose(): void;
  16437. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16438. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16439. /**
  16440. * Checks if the pair of p0 and p1 is en edge
  16441. * @param faceIndex
  16442. * @param edge
  16443. * @param faceNormals
  16444. * @param p0
  16445. * @param p1
  16446. * @private
  16447. */
  16448. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16449. /**
  16450. * push line into the position, normal and index buffer
  16451. * @protected
  16452. */
  16453. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16454. /**
  16455. * Generates lines edges from adjacencjes
  16456. * @private
  16457. */
  16458. _generateEdgesLines(): void;
  16459. /**
  16460. * Checks wether or not the edges renderer is ready to render.
  16461. * @return true if ready, otherwise false.
  16462. */
  16463. isReady(): boolean;
  16464. /**
  16465. * Renders the edges of the attached mesh,
  16466. */
  16467. render(): void;
  16468. }
  16469. /**
  16470. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16471. */
  16472. export class LineEdgesRenderer extends EdgesRenderer {
  16473. /**
  16474. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16475. * @param source LineMesh used to generate edges
  16476. * @param epsilon not important (specified angle for edge detection)
  16477. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16478. */
  16479. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16480. /**
  16481. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16482. */
  16483. _generateEdgesLines(): void;
  16484. }
  16485. }
  16486. declare module "babylonjs/Rendering/renderingGroup" {
  16487. import { SmartArray } from "babylonjs/Misc/smartArray";
  16488. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16490. import { Nullable } from "babylonjs/types";
  16491. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16492. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  16493. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16494. import { Material } from "babylonjs/Materials/material";
  16495. import { Scene } from "babylonjs/scene";
  16496. /**
  16497. * This represents the object necessary to create a rendering group.
  16498. * This is exclusively used and created by the rendering manager.
  16499. * To modify the behavior, you use the available helpers in your scene or meshes.
  16500. * @hidden
  16501. */
  16502. export class RenderingGroup {
  16503. index: number;
  16504. private static _zeroVector;
  16505. private _scene;
  16506. private _opaqueSubMeshes;
  16507. private _transparentSubMeshes;
  16508. private _alphaTestSubMeshes;
  16509. private _depthOnlySubMeshes;
  16510. private _particleSystems;
  16511. private _spriteManagers;
  16512. private _opaqueSortCompareFn;
  16513. private _alphaTestSortCompareFn;
  16514. private _transparentSortCompareFn;
  16515. private _renderOpaque;
  16516. private _renderAlphaTest;
  16517. private _renderTransparent;
  16518. /** @hidden */
  16519. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16520. onBeforeTransparentRendering: () => void;
  16521. /**
  16522. * Set the opaque sort comparison function.
  16523. * If null the sub meshes will be render in the order they were created
  16524. */
  16525. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16526. /**
  16527. * Set the alpha test sort comparison function.
  16528. * If null the sub meshes will be render in the order they were created
  16529. */
  16530. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16531. /**
  16532. * Set the transparent sort comparison function.
  16533. * If null the sub meshes will be render in the order they were created
  16534. */
  16535. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16536. /**
  16537. * Creates a new rendering group.
  16538. * @param index The rendering group index
  16539. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16540. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16541. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16542. */
  16543. 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>);
  16544. /**
  16545. * Render all the sub meshes contained in the group.
  16546. * @param customRenderFunction Used to override the default render behaviour of the group.
  16547. * @returns true if rendered some submeshes.
  16548. */
  16549. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16550. /**
  16551. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16552. * @param subMeshes The submeshes to render
  16553. */
  16554. private renderOpaqueSorted;
  16555. /**
  16556. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16557. * @param subMeshes The submeshes to render
  16558. */
  16559. private renderAlphaTestSorted;
  16560. /**
  16561. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16562. * @param subMeshes The submeshes to render
  16563. */
  16564. private renderTransparentSorted;
  16565. /**
  16566. * Renders the submeshes in a specified order.
  16567. * @param subMeshes The submeshes to sort before render
  16568. * @param sortCompareFn The comparison function use to sort
  16569. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16570. * @param transparent Specifies to activate blending if true
  16571. */
  16572. private static renderSorted;
  16573. /**
  16574. * Renders the submeshes in the order they were dispatched (no sort applied).
  16575. * @param subMeshes The submeshes to render
  16576. */
  16577. private static renderUnsorted;
  16578. /**
  16579. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16580. * are rendered back to front if in the same alpha index.
  16581. *
  16582. * @param a The first submesh
  16583. * @param b The second submesh
  16584. * @returns The result of the comparison
  16585. */
  16586. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16587. /**
  16588. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16589. * are rendered back to front.
  16590. *
  16591. * @param a The first submesh
  16592. * @param b The second submesh
  16593. * @returns The result of the comparison
  16594. */
  16595. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16596. /**
  16597. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16598. * are rendered front to back (prevent overdraw).
  16599. *
  16600. * @param a The first submesh
  16601. * @param b The second submesh
  16602. * @returns The result of the comparison
  16603. */
  16604. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16605. /**
  16606. * Resets the different lists of submeshes to prepare a new frame.
  16607. */
  16608. prepare(): void;
  16609. dispose(): void;
  16610. /**
  16611. * Inserts the submesh in its correct queue depending on its material.
  16612. * @param subMesh The submesh to dispatch
  16613. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16614. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16615. */
  16616. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16617. dispatchSprites(spriteManager: ISpriteManager): void;
  16618. dispatchParticles(particleSystem: IParticleSystem): void;
  16619. private _renderParticles;
  16620. private _renderSprites;
  16621. }
  16622. }
  16623. declare module "babylonjs/Rendering/renderingManager" {
  16624. import { Nullable } from "babylonjs/types";
  16625. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16626. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16627. import { SmartArray } from "babylonjs/Misc/smartArray";
  16628. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16629. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16630. import { Material } from "babylonjs/Materials/material";
  16631. import { Scene } from "babylonjs/scene";
  16632. import { Camera } from "babylonjs/Cameras/camera";
  16633. /**
  16634. * Interface describing the different options available in the rendering manager
  16635. * regarding Auto Clear between groups.
  16636. */
  16637. export interface IRenderingManagerAutoClearSetup {
  16638. /**
  16639. * Defines whether or not autoclear is enable.
  16640. */
  16641. autoClear: boolean;
  16642. /**
  16643. * Defines whether or not to autoclear the depth buffer.
  16644. */
  16645. depth: boolean;
  16646. /**
  16647. * Defines whether or not to autoclear the stencil buffer.
  16648. */
  16649. stencil: boolean;
  16650. }
  16651. /**
  16652. * This class is used by the onRenderingGroupObservable
  16653. */
  16654. export class RenderingGroupInfo {
  16655. /**
  16656. * The Scene that being rendered
  16657. */
  16658. scene: Scene;
  16659. /**
  16660. * The camera currently used for the rendering pass
  16661. */
  16662. camera: Nullable<Camera>;
  16663. /**
  16664. * The ID of the renderingGroup being processed
  16665. */
  16666. renderingGroupId: number;
  16667. }
  16668. /**
  16669. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16670. * It is enable to manage the different groups as well as the different necessary sort functions.
  16671. * This should not be used directly aside of the few static configurations
  16672. */
  16673. export class RenderingManager {
  16674. /**
  16675. * The max id used for rendering groups (not included)
  16676. */
  16677. static MAX_RENDERINGGROUPS: number;
  16678. /**
  16679. * The min id used for rendering groups (included)
  16680. */
  16681. static MIN_RENDERINGGROUPS: number;
  16682. /**
  16683. * Used to globally prevent autoclearing scenes.
  16684. */
  16685. static AUTOCLEAR: boolean;
  16686. /**
  16687. * @hidden
  16688. */
  16689. _useSceneAutoClearSetup: boolean;
  16690. private _scene;
  16691. private _renderingGroups;
  16692. private _depthStencilBufferAlreadyCleaned;
  16693. private _autoClearDepthStencil;
  16694. private _customOpaqueSortCompareFn;
  16695. private _customAlphaTestSortCompareFn;
  16696. private _customTransparentSortCompareFn;
  16697. private _renderingGroupInfo;
  16698. /**
  16699. * Instantiates a new rendering group for a particular scene
  16700. * @param scene Defines the scene the groups belongs to
  16701. */
  16702. constructor(scene: Scene);
  16703. private _clearDepthStencilBuffer;
  16704. /**
  16705. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16706. * @hidden
  16707. */
  16708. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16709. /**
  16710. * Resets the different information of the group to prepare a new frame
  16711. * @hidden
  16712. */
  16713. reset(): void;
  16714. /**
  16715. * Dispose and release the group and its associated resources.
  16716. * @hidden
  16717. */
  16718. dispose(): void;
  16719. /**
  16720. * Clear the info related to rendering groups preventing retention points during dispose.
  16721. */
  16722. freeRenderingGroups(): void;
  16723. private _prepareRenderingGroup;
  16724. /**
  16725. * Add a sprite manager to the rendering manager in order to render it this frame.
  16726. * @param spriteManager Define the sprite manager to render
  16727. */
  16728. dispatchSprites(spriteManager: ISpriteManager): void;
  16729. /**
  16730. * Add a particle system to the rendering manager in order to render it this frame.
  16731. * @param particleSystem Define the particle system to render
  16732. */
  16733. dispatchParticles(particleSystem: IParticleSystem): void;
  16734. /**
  16735. * Add a submesh to the manager in order to render it this frame
  16736. * @param subMesh The submesh to dispatch
  16737. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16738. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16739. */
  16740. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16741. /**
  16742. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16743. * This allowed control for front to back rendering or reversly depending of the special needs.
  16744. *
  16745. * @param renderingGroupId The rendering group id corresponding to its index
  16746. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16747. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16748. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16749. */
  16750. 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;
  16751. /**
  16752. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16753. *
  16754. * @param renderingGroupId The rendering group id corresponding to its index
  16755. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16756. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16757. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16758. */
  16759. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16760. /**
  16761. * Gets the current auto clear configuration for one rendering group of the rendering
  16762. * manager.
  16763. * @param index the rendering group index to get the information for
  16764. * @returns The auto clear setup for the requested rendering group
  16765. */
  16766. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16767. }
  16768. }
  16769. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  16770. import { SmartArray } from "babylonjs/Misc/smartArray";
  16771. import { Nullable } from "babylonjs/types";
  16772. import { Scene } from "babylonjs/scene";
  16773. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  16774. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16775. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16776. import { Mesh } from "babylonjs/Meshes/mesh";
  16777. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  16778. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  16779. import { Effect } from "babylonjs/Materials/effect";
  16780. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16781. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16782. import "babylonjs/Shaders/shadowMap.fragment";
  16783. import "babylonjs/Shaders/shadowMap.vertex";
  16784. import "babylonjs/Shaders/depthBoxBlur.fragment";
  16785. import { Observable } from "babylonjs/Misc/observable";
  16786. /**
  16787. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16788. */
  16789. export interface ICustomShaderOptions {
  16790. /**
  16791. * Gets or sets the custom shader name to use
  16792. */
  16793. shaderName: string;
  16794. /**
  16795. * The list of attribute names used in the shader
  16796. */
  16797. attributes?: string[];
  16798. /**
  16799. * The list of unifrom names used in the shader
  16800. */
  16801. uniforms?: string[];
  16802. /**
  16803. * The list of sampler names used in the shader
  16804. */
  16805. samplers?: string[];
  16806. /**
  16807. * The list of defines used in the shader
  16808. */
  16809. defines?: string[];
  16810. }
  16811. /**
  16812. * Interface to implement to create a shadow generator compatible with BJS.
  16813. */
  16814. export interface IShadowGenerator {
  16815. /**
  16816. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16817. * @returns The render target texture if present otherwise, null
  16818. */
  16819. getShadowMap(): Nullable<RenderTargetTexture>;
  16820. /**
  16821. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16822. * @param subMesh The submesh we want to render in the shadow map
  16823. * @param useInstances Defines wether will draw in the map using instances
  16824. * @returns true if ready otherwise, false
  16825. */
  16826. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16827. /**
  16828. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16829. * @param defines Defines of the material we want to update
  16830. * @param lightIndex Index of the light in the enabled light list of the material
  16831. */
  16832. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16833. /**
  16834. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16835. * defined in the generator but impacting the effect).
  16836. * It implies the unifroms available on the materials are the standard BJS ones.
  16837. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16838. * @param effect The effect we are binfing the information for
  16839. */
  16840. bindShadowLight(lightIndex: string, effect: Effect): void;
  16841. /**
  16842. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16843. * (eq to shadow prjection matrix * light transform matrix)
  16844. * @returns The transform matrix used to create the shadow map
  16845. */
  16846. getTransformMatrix(): Matrix;
  16847. /**
  16848. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16849. * Cube and 2D textures for instance.
  16850. */
  16851. recreateShadowMap(): void;
  16852. /**
  16853. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16854. * @param onCompiled Callback triggered at the and of the effects compilation
  16855. * @param options Sets of optional options forcing the compilation with different modes
  16856. */
  16857. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16858. useInstances: boolean;
  16859. }>): void;
  16860. /**
  16861. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16862. * @param options Sets of optional options forcing the compilation with different modes
  16863. * @returns A promise that resolves when the compilation completes
  16864. */
  16865. forceCompilationAsync(options?: Partial<{
  16866. useInstances: boolean;
  16867. }>): Promise<void>;
  16868. /**
  16869. * Serializes the shadow generator setup to a json object.
  16870. * @returns The serialized JSON object
  16871. */
  16872. serialize(): any;
  16873. /**
  16874. * Disposes the Shadow map and related Textures and effects.
  16875. */
  16876. dispose(): void;
  16877. }
  16878. /**
  16879. * Default implementation IShadowGenerator.
  16880. * This is the main object responsible of generating shadows in the framework.
  16881. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16882. */
  16883. export class ShadowGenerator implements IShadowGenerator {
  16884. /**
  16885. * Name of the shadow generator class
  16886. */
  16887. static CLASSNAME: string;
  16888. /**
  16889. * Shadow generator mode None: no filtering applied.
  16890. */
  16891. static readonly FILTER_NONE: number;
  16892. /**
  16893. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16894. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16895. */
  16896. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16897. /**
  16898. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16899. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16900. */
  16901. static readonly FILTER_POISSONSAMPLING: number;
  16902. /**
  16903. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16904. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16905. */
  16906. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16907. /**
  16908. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16909. * edge artifacts on steep falloff.
  16910. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16911. */
  16912. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16913. /**
  16914. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16915. * edge artifacts on steep falloff.
  16916. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16917. */
  16918. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16919. /**
  16920. * Shadow generator mode PCF: Percentage Closer Filtering
  16921. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16922. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16923. */
  16924. static readonly FILTER_PCF: number;
  16925. /**
  16926. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16927. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16928. * Contact Hardening
  16929. */
  16930. static readonly FILTER_PCSS: number;
  16931. /**
  16932. * Reserved for PCF and PCSS
  16933. * Highest Quality.
  16934. *
  16935. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16936. *
  16937. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16938. */
  16939. static readonly QUALITY_HIGH: number;
  16940. /**
  16941. * Reserved for PCF and PCSS
  16942. * Good tradeoff for quality/perf cross devices
  16943. *
  16944. * Execute PCF on a 3*3 kernel.
  16945. *
  16946. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16947. */
  16948. static readonly QUALITY_MEDIUM: number;
  16949. /**
  16950. * Reserved for PCF and PCSS
  16951. * The lowest quality but the fastest.
  16952. *
  16953. * Execute PCF on a 1*1 kernel.
  16954. *
  16955. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16956. */
  16957. static readonly QUALITY_LOW: number;
  16958. /** Gets or sets the custom shader name to use */
  16959. customShaderOptions: ICustomShaderOptions;
  16960. /**
  16961. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16962. */
  16963. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16964. /**
  16965. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16966. */
  16967. onAfterShadowMapRenderObservable: Observable<Effect>;
  16968. /**
  16969. * Observable triggered before a mesh is rendered in the shadow map.
  16970. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16971. */
  16972. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16973. /**
  16974. * Observable triggered after a mesh is rendered in the shadow map.
  16975. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16976. */
  16977. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16978. protected _bias: number;
  16979. /**
  16980. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16981. */
  16982. get bias(): number;
  16983. /**
  16984. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16985. */
  16986. set bias(bias: number);
  16987. protected _normalBias: number;
  16988. /**
  16989. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16990. */
  16991. get normalBias(): number;
  16992. /**
  16993. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16994. */
  16995. set normalBias(normalBias: number);
  16996. protected _blurBoxOffset: number;
  16997. /**
  16998. * Gets the blur box offset: offset applied during the blur pass.
  16999. * Only useful if useKernelBlur = false
  17000. */
  17001. get blurBoxOffset(): number;
  17002. /**
  17003. * Sets the blur box offset: offset applied during the blur pass.
  17004. * Only useful if useKernelBlur = false
  17005. */
  17006. set blurBoxOffset(value: number);
  17007. protected _blurScale: number;
  17008. /**
  17009. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17010. * 2 means half of the size.
  17011. */
  17012. get blurScale(): number;
  17013. /**
  17014. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17015. * 2 means half of the size.
  17016. */
  17017. set blurScale(value: number);
  17018. protected _blurKernel: number;
  17019. /**
  17020. * Gets the blur kernel: kernel size of the blur pass.
  17021. * Only useful if useKernelBlur = true
  17022. */
  17023. get blurKernel(): number;
  17024. /**
  17025. * Sets the blur kernel: kernel size of the blur pass.
  17026. * Only useful if useKernelBlur = true
  17027. */
  17028. set blurKernel(value: number);
  17029. protected _useKernelBlur: boolean;
  17030. /**
  17031. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17032. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17033. */
  17034. get useKernelBlur(): boolean;
  17035. /**
  17036. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17037. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17038. */
  17039. set useKernelBlur(value: boolean);
  17040. protected _depthScale: number;
  17041. /**
  17042. * Gets the depth scale used in ESM mode.
  17043. */
  17044. get depthScale(): number;
  17045. /**
  17046. * Sets the depth scale used in ESM mode.
  17047. * This can override the scale stored on the light.
  17048. */
  17049. set depthScale(value: number);
  17050. protected _validateFilter(filter: number): number;
  17051. protected _filter: number;
  17052. /**
  17053. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17054. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17055. */
  17056. get filter(): number;
  17057. /**
  17058. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17059. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17060. */
  17061. set filter(value: number);
  17062. /**
  17063. * Gets if the current filter is set to Poisson Sampling.
  17064. */
  17065. get usePoissonSampling(): boolean;
  17066. /**
  17067. * Sets the current filter to Poisson Sampling.
  17068. */
  17069. set usePoissonSampling(value: boolean);
  17070. /**
  17071. * Gets if the current filter is set to ESM.
  17072. */
  17073. get useExponentialShadowMap(): boolean;
  17074. /**
  17075. * Sets the current filter is to ESM.
  17076. */
  17077. set useExponentialShadowMap(value: boolean);
  17078. /**
  17079. * Gets if the current filter is set to filtered ESM.
  17080. */
  17081. get useBlurExponentialShadowMap(): boolean;
  17082. /**
  17083. * Gets if the current filter is set to filtered ESM.
  17084. */
  17085. set useBlurExponentialShadowMap(value: boolean);
  17086. /**
  17087. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17088. * exponential to prevent steep falloff artifacts).
  17089. */
  17090. get useCloseExponentialShadowMap(): boolean;
  17091. /**
  17092. * Sets the current filter to "close ESM" (using the inverse of the
  17093. * exponential to prevent steep falloff artifacts).
  17094. */
  17095. set useCloseExponentialShadowMap(value: boolean);
  17096. /**
  17097. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17098. * exponential to prevent steep falloff artifacts).
  17099. */
  17100. get useBlurCloseExponentialShadowMap(): boolean;
  17101. /**
  17102. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17103. * exponential to prevent steep falloff artifacts).
  17104. */
  17105. set useBlurCloseExponentialShadowMap(value: boolean);
  17106. /**
  17107. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17108. */
  17109. get usePercentageCloserFiltering(): boolean;
  17110. /**
  17111. * Sets the current filter to "PCF" (percentage closer filtering).
  17112. */
  17113. set usePercentageCloserFiltering(value: boolean);
  17114. protected _filteringQuality: number;
  17115. /**
  17116. * Gets the PCF or PCSS Quality.
  17117. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17118. */
  17119. get filteringQuality(): number;
  17120. /**
  17121. * Sets the PCF or PCSS Quality.
  17122. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17123. */
  17124. set filteringQuality(filteringQuality: number);
  17125. /**
  17126. * Gets if the current filter is set to "PCSS" (contact hardening).
  17127. */
  17128. get useContactHardeningShadow(): boolean;
  17129. /**
  17130. * Sets the current filter to "PCSS" (contact hardening).
  17131. */
  17132. set useContactHardeningShadow(value: boolean);
  17133. protected _contactHardeningLightSizeUVRatio: number;
  17134. /**
  17135. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17136. * Using a ratio helps keeping shape stability independently of the map size.
  17137. *
  17138. * It does not account for the light projection as it was having too much
  17139. * instability during the light setup or during light position changes.
  17140. *
  17141. * Only valid if useContactHardeningShadow is true.
  17142. */
  17143. get contactHardeningLightSizeUVRatio(): number;
  17144. /**
  17145. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17146. * Using a ratio helps keeping shape stability independently of the map size.
  17147. *
  17148. * It does not account for the light projection as it was having too much
  17149. * instability during the light setup or during light position changes.
  17150. *
  17151. * Only valid if useContactHardeningShadow is true.
  17152. */
  17153. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17154. protected _darkness: number;
  17155. /** Gets or sets the actual darkness of a shadow */
  17156. get darkness(): number;
  17157. set darkness(value: number);
  17158. /**
  17159. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17160. * 0 means strongest and 1 would means no shadow.
  17161. * @returns the darkness.
  17162. */
  17163. getDarkness(): number;
  17164. /**
  17165. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17166. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17167. * @returns the shadow generator allowing fluent coding.
  17168. */
  17169. setDarkness(darkness: number): ShadowGenerator;
  17170. protected _transparencyShadow: boolean;
  17171. /** Gets or sets the ability to have transparent shadow */
  17172. get transparencyShadow(): boolean;
  17173. set transparencyShadow(value: boolean);
  17174. /**
  17175. * Sets the ability to have transparent shadow (boolean).
  17176. * @param transparent True if transparent else False
  17177. * @returns the shadow generator allowing fluent coding
  17178. */
  17179. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17180. protected _shadowMap: Nullable<RenderTargetTexture>;
  17181. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17182. /**
  17183. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17184. * @returns The render target texture if present otherwise, null
  17185. */
  17186. getShadowMap(): Nullable<RenderTargetTexture>;
  17187. /**
  17188. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17189. * @returns The render target texture if the shadow map is present otherwise, null
  17190. */
  17191. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17192. /**
  17193. * Gets the class name of that object
  17194. * @returns "ShadowGenerator"
  17195. */
  17196. getClassName(): string;
  17197. /**
  17198. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17199. * @param mesh Mesh to add
  17200. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17201. * @returns the Shadow Generator itself
  17202. */
  17203. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17204. /**
  17205. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17206. * @param mesh Mesh to remove
  17207. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17208. * @returns the Shadow Generator itself
  17209. */
  17210. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17211. /**
  17212. * Controls the extent to which the shadows fade out at the edge of the frustum
  17213. */
  17214. frustumEdgeFalloff: number;
  17215. protected _light: IShadowLight;
  17216. /**
  17217. * Returns the associated light object.
  17218. * @returns the light generating the shadow
  17219. */
  17220. getLight(): IShadowLight;
  17221. /**
  17222. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17223. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17224. * It might on the other hand introduce peter panning.
  17225. */
  17226. forceBackFacesOnly: boolean;
  17227. protected _scene: Scene;
  17228. protected _lightDirection: Vector3;
  17229. protected _effect: Effect;
  17230. protected _viewMatrix: Matrix;
  17231. protected _projectionMatrix: Matrix;
  17232. protected _transformMatrix: Matrix;
  17233. protected _cachedPosition: Vector3;
  17234. protected _cachedDirection: Vector3;
  17235. protected _cachedDefines: string;
  17236. protected _currentRenderID: number;
  17237. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17238. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17239. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17240. protected _blurPostProcesses: PostProcess[];
  17241. protected _mapSize: number;
  17242. protected _currentFaceIndex: number;
  17243. protected _currentFaceIndexCache: number;
  17244. protected _textureType: number;
  17245. protected _defaultTextureMatrix: Matrix;
  17246. protected _storedUniqueId: Nullable<number>;
  17247. /** @hidden */
  17248. static _SceneComponentInitialization: (scene: Scene) => void;
  17249. /**
  17250. * Creates a ShadowGenerator object.
  17251. * A ShadowGenerator is the required tool to use the shadows.
  17252. * Each light casting shadows needs to use its own ShadowGenerator.
  17253. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17254. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17255. * @param light The light object generating the shadows.
  17256. * @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.
  17257. */
  17258. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17259. protected _initializeGenerator(): void;
  17260. protected _createTargetRenderTexture(): void;
  17261. protected _initializeShadowMap(): void;
  17262. protected _initializeBlurRTTAndPostProcesses(): void;
  17263. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17264. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17265. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  17266. protected _applyFilterValues(): void;
  17267. /**
  17268. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17269. * @param onCompiled Callback triggered at the and of the effects compilation
  17270. * @param options Sets of optional options forcing the compilation with different modes
  17271. */
  17272. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17273. useInstances: boolean;
  17274. }>): void;
  17275. /**
  17276. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17277. * @param options Sets of optional options forcing the compilation with different modes
  17278. * @returns A promise that resolves when the compilation completes
  17279. */
  17280. forceCompilationAsync(options?: Partial<{
  17281. useInstances: boolean;
  17282. }>): Promise<void>;
  17283. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17284. private _prepareShadowDefines;
  17285. /**
  17286. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17287. * @param subMesh The submesh we want to render in the shadow map
  17288. * @param useInstances Defines wether will draw in the map using instances
  17289. * @returns true if ready otherwise, false
  17290. */
  17291. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  17292. /**
  17293. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17294. * @param defines Defines of the material we want to update
  17295. * @param lightIndex Index of the light in the enabled light list of the material
  17296. */
  17297. prepareDefines(defines: any, lightIndex: number): void;
  17298. /**
  17299. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17300. * defined in the generator but impacting the effect).
  17301. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17302. * @param effect The effect we are binfing the information for
  17303. */
  17304. bindShadowLight(lightIndex: string, effect: Effect): void;
  17305. /**
  17306. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17307. * (eq to shadow prjection matrix * light transform matrix)
  17308. * @returns The transform matrix used to create the shadow map
  17309. */
  17310. getTransformMatrix(): Matrix;
  17311. /**
  17312. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17313. * Cube and 2D textures for instance.
  17314. */
  17315. recreateShadowMap(): void;
  17316. protected _disposeBlurPostProcesses(): void;
  17317. protected _disposeRTTandPostProcesses(): void;
  17318. /**
  17319. * Disposes the ShadowGenerator.
  17320. * Returns nothing.
  17321. */
  17322. dispose(): void;
  17323. /**
  17324. * Serializes the shadow generator setup to a json object.
  17325. * @returns The serialized JSON object
  17326. */
  17327. serialize(): any;
  17328. /**
  17329. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17330. * @param parsedShadowGenerator The JSON object to parse
  17331. * @param scene The scene to create the shadow map for
  17332. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17333. * @returns The parsed shadow generator
  17334. */
  17335. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17336. }
  17337. }
  17338. declare module "babylonjs/Lights/light" {
  17339. import { Nullable } from "babylonjs/types";
  17340. import { Scene } from "babylonjs/scene";
  17341. import { Vector3 } from "babylonjs/Maths/math.vector";
  17342. import { Color3 } from "babylonjs/Maths/math.color";
  17343. import { Node } from "babylonjs/node";
  17344. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17345. import { Effect } from "babylonjs/Materials/effect";
  17346. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17347. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17348. /**
  17349. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17350. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17351. * 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.
  17352. */
  17353. export abstract class Light extends Node {
  17354. /**
  17355. * Falloff Default: light is falling off following the material specification:
  17356. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17357. */
  17358. static readonly FALLOFF_DEFAULT: number;
  17359. /**
  17360. * Falloff Physical: light is falling off following the inverse squared distance law.
  17361. */
  17362. static readonly FALLOFF_PHYSICAL: number;
  17363. /**
  17364. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17365. * to enhance interoperability with other engines.
  17366. */
  17367. static readonly FALLOFF_GLTF: number;
  17368. /**
  17369. * Falloff Standard: light is falling off like in the standard material
  17370. * to enhance interoperability with other materials.
  17371. */
  17372. static readonly FALLOFF_STANDARD: number;
  17373. /**
  17374. * If every light affecting the material is in this lightmapMode,
  17375. * material.lightmapTexture adds or multiplies
  17376. * (depends on material.useLightmapAsShadowmap)
  17377. * after every other light calculations.
  17378. */
  17379. static readonly LIGHTMAP_DEFAULT: number;
  17380. /**
  17381. * material.lightmapTexture as only diffuse lighting from this light
  17382. * adds only specular lighting from this light
  17383. * adds dynamic shadows
  17384. */
  17385. static readonly LIGHTMAP_SPECULAR: number;
  17386. /**
  17387. * material.lightmapTexture as only lighting
  17388. * no light calculation from this light
  17389. * only adds dynamic shadows from this light
  17390. */
  17391. static readonly LIGHTMAP_SHADOWSONLY: number;
  17392. /**
  17393. * Each light type uses the default quantity according to its type:
  17394. * point/spot lights use luminous intensity
  17395. * directional lights use illuminance
  17396. */
  17397. static readonly INTENSITYMODE_AUTOMATIC: number;
  17398. /**
  17399. * lumen (lm)
  17400. */
  17401. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17402. /**
  17403. * candela (lm/sr)
  17404. */
  17405. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17406. /**
  17407. * lux (lm/m^2)
  17408. */
  17409. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17410. /**
  17411. * nit (cd/m^2)
  17412. */
  17413. static readonly INTENSITYMODE_LUMINANCE: number;
  17414. /**
  17415. * Light type const id of the point light.
  17416. */
  17417. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17418. /**
  17419. * Light type const id of the directional light.
  17420. */
  17421. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17422. /**
  17423. * Light type const id of the spot light.
  17424. */
  17425. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17426. /**
  17427. * Light type const id of the hemispheric light.
  17428. */
  17429. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17430. /**
  17431. * Diffuse gives the basic color to an object.
  17432. */
  17433. diffuse: Color3;
  17434. /**
  17435. * Specular produces a highlight color on an object.
  17436. * Note: This is note affecting PBR materials.
  17437. */
  17438. specular: Color3;
  17439. /**
  17440. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17441. * falling off base on range or angle.
  17442. * This can be set to any values in Light.FALLOFF_x.
  17443. *
  17444. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17445. * other types of materials.
  17446. */
  17447. falloffType: number;
  17448. /**
  17449. * Strength of the light.
  17450. * Note: By default it is define in the framework own unit.
  17451. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17452. */
  17453. intensity: number;
  17454. private _range;
  17455. protected _inverseSquaredRange: number;
  17456. /**
  17457. * Defines how far from the source the light is impacting in scene units.
  17458. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17459. */
  17460. get range(): number;
  17461. /**
  17462. * Defines how far from the source the light is impacting in scene units.
  17463. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17464. */
  17465. set range(value: number);
  17466. /**
  17467. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17468. * of light.
  17469. */
  17470. private _photometricScale;
  17471. private _intensityMode;
  17472. /**
  17473. * Gets the photometric scale used to interpret the intensity.
  17474. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17475. */
  17476. get intensityMode(): number;
  17477. /**
  17478. * Sets the photometric scale used to interpret the intensity.
  17479. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17480. */
  17481. set intensityMode(value: number);
  17482. private _radius;
  17483. /**
  17484. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17485. */
  17486. get radius(): number;
  17487. /**
  17488. * sets the light radius used by PBR Materials to simulate soft area lights.
  17489. */
  17490. set radius(value: number);
  17491. private _renderPriority;
  17492. /**
  17493. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17494. * exceeding the number allowed of the materials.
  17495. */
  17496. renderPriority: number;
  17497. private _shadowEnabled;
  17498. /**
  17499. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17500. * the current shadow generator.
  17501. */
  17502. get shadowEnabled(): boolean;
  17503. /**
  17504. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17505. * the current shadow generator.
  17506. */
  17507. set shadowEnabled(value: boolean);
  17508. private _includedOnlyMeshes;
  17509. /**
  17510. * Gets the only meshes impacted by this light.
  17511. */
  17512. get includedOnlyMeshes(): AbstractMesh[];
  17513. /**
  17514. * Sets the only meshes impacted by this light.
  17515. */
  17516. set includedOnlyMeshes(value: AbstractMesh[]);
  17517. private _excludedMeshes;
  17518. /**
  17519. * Gets the meshes not impacted by this light.
  17520. */
  17521. get excludedMeshes(): AbstractMesh[];
  17522. /**
  17523. * Sets the meshes not impacted by this light.
  17524. */
  17525. set excludedMeshes(value: AbstractMesh[]);
  17526. private _excludeWithLayerMask;
  17527. /**
  17528. * Gets the layer id use to find what meshes are not impacted by the light.
  17529. * Inactive if 0
  17530. */
  17531. get excludeWithLayerMask(): number;
  17532. /**
  17533. * Sets the layer id use to find what meshes are not impacted by the light.
  17534. * Inactive if 0
  17535. */
  17536. set excludeWithLayerMask(value: number);
  17537. private _includeOnlyWithLayerMask;
  17538. /**
  17539. * Gets the layer id use to find what meshes are impacted by the light.
  17540. * Inactive if 0
  17541. */
  17542. get includeOnlyWithLayerMask(): number;
  17543. /**
  17544. * Sets the layer id use to find what meshes are impacted by the light.
  17545. * Inactive if 0
  17546. */
  17547. set includeOnlyWithLayerMask(value: number);
  17548. private _lightmapMode;
  17549. /**
  17550. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17551. */
  17552. get lightmapMode(): number;
  17553. /**
  17554. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17555. */
  17556. set lightmapMode(value: number);
  17557. /**
  17558. * Shadow generator associted to the light.
  17559. * @hidden Internal use only.
  17560. */
  17561. _shadowGenerator: Nullable<IShadowGenerator>;
  17562. /**
  17563. * @hidden Internal use only.
  17564. */
  17565. _excludedMeshesIds: string[];
  17566. /**
  17567. * @hidden Internal use only.
  17568. */
  17569. _includedOnlyMeshesIds: string[];
  17570. /**
  17571. * The current light unifom buffer.
  17572. * @hidden Internal use only.
  17573. */
  17574. _uniformBuffer: UniformBuffer;
  17575. /** @hidden */
  17576. _renderId: number;
  17577. /**
  17578. * Creates a Light object in the scene.
  17579. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17580. * @param name The firendly name of the light
  17581. * @param scene The scene the light belongs too
  17582. */
  17583. constructor(name: string, scene: Scene);
  17584. protected abstract _buildUniformLayout(): void;
  17585. /**
  17586. * Sets the passed Effect "effect" with the Light information.
  17587. * @param effect The effect to update
  17588. * @param lightIndex The index of the light in the effect to update
  17589. * @returns The light
  17590. */
  17591. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17592. /**
  17593. * Sets the passed Effect "effect" with the Light textures.
  17594. * @param effect The effect to update
  17595. * @param lightIndex The index of the light in the effect to update
  17596. * @returns The light
  17597. */
  17598. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17599. /**
  17600. * Binds the lights information from the scene to the effect for the given mesh.
  17601. * @param lightIndex Light index
  17602. * @param scene The scene where the light belongs to
  17603. * @param effect The effect we are binding the data to
  17604. * @param useSpecular Defines if specular is supported
  17605. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17606. */
  17607. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17608. /**
  17609. * Sets the passed Effect "effect" with the Light information.
  17610. * @param effect The effect to update
  17611. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17612. * @returns The light
  17613. */
  17614. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17615. /**
  17616. * Returns the string "Light".
  17617. * @returns the class name
  17618. */
  17619. getClassName(): string;
  17620. /** @hidden */
  17621. readonly _isLight: boolean;
  17622. /**
  17623. * Converts the light information to a readable string for debug purpose.
  17624. * @param fullDetails Supports for multiple levels of logging within scene loading
  17625. * @returns the human readable light info
  17626. */
  17627. toString(fullDetails?: boolean): string;
  17628. /** @hidden */
  17629. protected _syncParentEnabledState(): void;
  17630. /**
  17631. * Set the enabled state of this node.
  17632. * @param value - the new enabled state
  17633. */
  17634. setEnabled(value: boolean): void;
  17635. /**
  17636. * Returns the Light associated shadow generator if any.
  17637. * @return the associated shadow generator.
  17638. */
  17639. getShadowGenerator(): Nullable<IShadowGenerator>;
  17640. /**
  17641. * Returns a Vector3, the absolute light position in the World.
  17642. * @returns the world space position of the light
  17643. */
  17644. getAbsolutePosition(): Vector3;
  17645. /**
  17646. * Specifies if the light will affect the passed mesh.
  17647. * @param mesh The mesh to test against the light
  17648. * @return true the mesh is affected otherwise, false.
  17649. */
  17650. canAffectMesh(mesh: AbstractMesh): boolean;
  17651. /**
  17652. * Sort function to order lights for rendering.
  17653. * @param a First Light object to compare to second.
  17654. * @param b Second Light object to compare first.
  17655. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17656. */
  17657. static CompareLightsPriority(a: Light, b: Light): number;
  17658. /**
  17659. * Releases resources associated with this node.
  17660. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17661. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17662. */
  17663. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17664. /**
  17665. * Returns the light type ID (integer).
  17666. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17667. */
  17668. getTypeID(): number;
  17669. /**
  17670. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17671. * @returns the scaled intensity in intensity mode unit
  17672. */
  17673. getScaledIntensity(): number;
  17674. /**
  17675. * Returns a new Light object, named "name", from the current one.
  17676. * @param name The name of the cloned light
  17677. * @returns the new created light
  17678. */
  17679. clone(name: string): Nullable<Light>;
  17680. /**
  17681. * Serializes the current light into a Serialization object.
  17682. * @returns the serialized object.
  17683. */
  17684. serialize(): any;
  17685. /**
  17686. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17687. * This new light is named "name" and added to the passed scene.
  17688. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17689. * @param name The friendly name of the light
  17690. * @param scene The scene the new light will belong to
  17691. * @returns the constructor function
  17692. */
  17693. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17694. /**
  17695. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17696. * @param parsedLight The JSON representation of the light
  17697. * @param scene The scene to create the parsed light in
  17698. * @returns the created light after parsing
  17699. */
  17700. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17701. private _hookArrayForExcluded;
  17702. private _hookArrayForIncludedOnly;
  17703. private _resyncMeshes;
  17704. /**
  17705. * Forces the meshes to update their light related information in their rendering used effects
  17706. * @hidden Internal Use Only
  17707. */
  17708. _markMeshesAsLightDirty(): void;
  17709. /**
  17710. * Recomputes the cached photometric scale if needed.
  17711. */
  17712. private _computePhotometricScale;
  17713. /**
  17714. * Returns the Photometric Scale according to the light type and intensity mode.
  17715. */
  17716. private _getPhotometricScale;
  17717. /**
  17718. * Reorder the light in the scene according to their defined priority.
  17719. * @hidden Internal Use Only
  17720. */
  17721. _reorderLightsInScene(): void;
  17722. /**
  17723. * Prepares the list of defines specific to the light type.
  17724. * @param defines the list of defines
  17725. * @param lightIndex defines the index of the light for the effect
  17726. */
  17727. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17728. }
  17729. }
  17730. declare module "babylonjs/Actions/action" {
  17731. import { Observable } from "babylonjs/Misc/observable";
  17732. import { Condition } from "babylonjs/Actions/condition";
  17733. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  17734. import { ActionManager } from "babylonjs/Actions/actionManager";
  17735. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17736. /**
  17737. * Interface used to define Action
  17738. */
  17739. export interface IAction {
  17740. /**
  17741. * Trigger for the action
  17742. */
  17743. trigger: number;
  17744. /** Options of the trigger */
  17745. triggerOptions: any;
  17746. /**
  17747. * Gets the trigger parameters
  17748. * @returns the trigger parameters
  17749. */
  17750. getTriggerParameter(): any;
  17751. /**
  17752. * Internal only - executes current action event
  17753. * @hidden
  17754. */
  17755. _executeCurrent(evt?: ActionEvent): void;
  17756. /**
  17757. * Serialize placeholder for child classes
  17758. * @param parent of child
  17759. * @returns the serialized object
  17760. */
  17761. serialize(parent: any): any;
  17762. /**
  17763. * Internal only
  17764. * @hidden
  17765. */
  17766. _prepare(): void;
  17767. /**
  17768. * Internal only - manager for action
  17769. * @hidden
  17770. */
  17771. _actionManager: AbstractActionManager;
  17772. /**
  17773. * Adds action to chain of actions, may be a DoNothingAction
  17774. * @param action defines the next action to execute
  17775. * @returns The action passed in
  17776. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17777. */
  17778. then(action: IAction): IAction;
  17779. }
  17780. /**
  17781. * The action to be carried out following a trigger
  17782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17783. */
  17784. export class Action implements IAction {
  17785. /** the trigger, with or without parameters, for the action */
  17786. triggerOptions: any;
  17787. /**
  17788. * Trigger for the action
  17789. */
  17790. trigger: number;
  17791. /**
  17792. * Internal only - manager for action
  17793. * @hidden
  17794. */
  17795. _actionManager: ActionManager;
  17796. private _nextActiveAction;
  17797. private _child;
  17798. private _condition?;
  17799. private _triggerParameter;
  17800. /**
  17801. * An event triggered prior to action being executed.
  17802. */
  17803. onBeforeExecuteObservable: Observable<Action>;
  17804. /**
  17805. * Creates a new Action
  17806. * @param triggerOptions the trigger, with or without parameters, for the action
  17807. * @param condition an optional determinant of action
  17808. */
  17809. constructor(
  17810. /** the trigger, with or without parameters, for the action */
  17811. triggerOptions: any, condition?: Condition);
  17812. /**
  17813. * Internal only
  17814. * @hidden
  17815. */
  17816. _prepare(): void;
  17817. /**
  17818. * Gets the trigger parameters
  17819. * @returns the trigger parameters
  17820. */
  17821. getTriggerParameter(): any;
  17822. /**
  17823. * Internal only - executes current action event
  17824. * @hidden
  17825. */
  17826. _executeCurrent(evt?: ActionEvent): void;
  17827. /**
  17828. * Execute placeholder for child classes
  17829. * @param evt optional action event
  17830. */
  17831. execute(evt?: ActionEvent): void;
  17832. /**
  17833. * Skips to next active action
  17834. */
  17835. skipToNextActiveAction(): void;
  17836. /**
  17837. * Adds action to chain of actions, may be a DoNothingAction
  17838. * @param action defines the next action to execute
  17839. * @returns The action passed in
  17840. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17841. */
  17842. then(action: Action): Action;
  17843. /**
  17844. * Internal only
  17845. * @hidden
  17846. */
  17847. _getProperty(propertyPath: string): string;
  17848. /**
  17849. * Internal only
  17850. * @hidden
  17851. */
  17852. _getEffectiveTarget(target: any, propertyPath: string): any;
  17853. /**
  17854. * Serialize placeholder for child classes
  17855. * @param parent of child
  17856. * @returns the serialized object
  17857. */
  17858. serialize(parent: any): any;
  17859. /**
  17860. * Internal only called by serialize
  17861. * @hidden
  17862. */
  17863. protected _serialize(serializedAction: any, parent?: any): any;
  17864. /**
  17865. * Internal only
  17866. * @hidden
  17867. */
  17868. static _SerializeValueAsString: (value: any) => string;
  17869. /**
  17870. * Internal only
  17871. * @hidden
  17872. */
  17873. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  17874. name: string;
  17875. targetType: string;
  17876. value: string;
  17877. };
  17878. }
  17879. }
  17880. declare module "babylonjs/Actions/condition" {
  17881. import { ActionManager } from "babylonjs/Actions/actionManager";
  17882. /**
  17883. * A Condition applied to an Action
  17884. */
  17885. export class Condition {
  17886. /**
  17887. * Internal only - manager for action
  17888. * @hidden
  17889. */
  17890. _actionManager: ActionManager;
  17891. /**
  17892. * Internal only
  17893. * @hidden
  17894. */
  17895. _evaluationId: number;
  17896. /**
  17897. * Internal only
  17898. * @hidden
  17899. */
  17900. _currentResult: boolean;
  17901. /**
  17902. * Creates a new Condition
  17903. * @param actionManager the manager of the action the condition is applied to
  17904. */
  17905. constructor(actionManager: ActionManager);
  17906. /**
  17907. * Check if the current condition is valid
  17908. * @returns a boolean
  17909. */
  17910. isValid(): boolean;
  17911. /**
  17912. * Internal only
  17913. * @hidden
  17914. */
  17915. _getProperty(propertyPath: string): string;
  17916. /**
  17917. * Internal only
  17918. * @hidden
  17919. */
  17920. _getEffectiveTarget(target: any, propertyPath: string): any;
  17921. /**
  17922. * Serialize placeholder for child classes
  17923. * @returns the serialized object
  17924. */
  17925. serialize(): any;
  17926. /**
  17927. * Internal only
  17928. * @hidden
  17929. */
  17930. protected _serialize(serializedCondition: any): any;
  17931. }
  17932. /**
  17933. * Defines specific conditional operators as extensions of Condition
  17934. */
  17935. export class ValueCondition extends Condition {
  17936. /** path to specify the property of the target the conditional operator uses */
  17937. propertyPath: string;
  17938. /** the value compared by the conditional operator against the current value of the property */
  17939. value: any;
  17940. /** the conditional operator, default ValueCondition.IsEqual */
  17941. operator: number;
  17942. /**
  17943. * Internal only
  17944. * @hidden
  17945. */
  17946. private static _IsEqual;
  17947. /**
  17948. * Internal only
  17949. * @hidden
  17950. */
  17951. private static _IsDifferent;
  17952. /**
  17953. * Internal only
  17954. * @hidden
  17955. */
  17956. private static _IsGreater;
  17957. /**
  17958. * Internal only
  17959. * @hidden
  17960. */
  17961. private static _IsLesser;
  17962. /**
  17963. * returns the number for IsEqual
  17964. */
  17965. static get IsEqual(): number;
  17966. /**
  17967. * Returns the number for IsDifferent
  17968. */
  17969. static get IsDifferent(): number;
  17970. /**
  17971. * Returns the number for IsGreater
  17972. */
  17973. static get IsGreater(): number;
  17974. /**
  17975. * Returns the number for IsLesser
  17976. */
  17977. static get IsLesser(): number;
  17978. /**
  17979. * Internal only The action manager for the condition
  17980. * @hidden
  17981. */
  17982. _actionManager: ActionManager;
  17983. /**
  17984. * Internal only
  17985. * @hidden
  17986. */
  17987. private _target;
  17988. /**
  17989. * Internal only
  17990. * @hidden
  17991. */
  17992. private _effectiveTarget;
  17993. /**
  17994. * Internal only
  17995. * @hidden
  17996. */
  17997. private _property;
  17998. /**
  17999. * Creates a new ValueCondition
  18000. * @param actionManager manager for the action the condition applies to
  18001. * @param target for the action
  18002. * @param propertyPath path to specify the property of the target the conditional operator uses
  18003. * @param value the value compared by the conditional operator against the current value of the property
  18004. * @param operator the conditional operator, default ValueCondition.IsEqual
  18005. */
  18006. constructor(actionManager: ActionManager, target: any,
  18007. /** path to specify the property of the target the conditional operator uses */
  18008. propertyPath: string,
  18009. /** the value compared by the conditional operator against the current value of the property */
  18010. value: any,
  18011. /** the conditional operator, default ValueCondition.IsEqual */
  18012. operator?: number);
  18013. /**
  18014. * Compares the given value with the property value for the specified conditional operator
  18015. * @returns the result of the comparison
  18016. */
  18017. isValid(): boolean;
  18018. /**
  18019. * Serialize the ValueCondition into a JSON compatible object
  18020. * @returns serialization object
  18021. */
  18022. serialize(): any;
  18023. /**
  18024. * Gets the name of the conditional operator for the ValueCondition
  18025. * @param operator the conditional operator
  18026. * @returns the name
  18027. */
  18028. static GetOperatorName(operator: number): string;
  18029. }
  18030. /**
  18031. * Defines a predicate condition as an extension of Condition
  18032. */
  18033. export class PredicateCondition extends Condition {
  18034. /** defines the predicate function used to validate the condition */
  18035. predicate: () => boolean;
  18036. /**
  18037. * Internal only - manager for action
  18038. * @hidden
  18039. */
  18040. _actionManager: ActionManager;
  18041. /**
  18042. * Creates a new PredicateCondition
  18043. * @param actionManager manager for the action the condition applies to
  18044. * @param predicate defines the predicate function used to validate the condition
  18045. */
  18046. constructor(actionManager: ActionManager,
  18047. /** defines the predicate function used to validate the condition */
  18048. predicate: () => boolean);
  18049. /**
  18050. * @returns the validity of the predicate condition
  18051. */
  18052. isValid(): boolean;
  18053. }
  18054. /**
  18055. * Defines a state condition as an extension of Condition
  18056. */
  18057. export class StateCondition extends Condition {
  18058. /** Value to compare with target state */
  18059. value: string;
  18060. /**
  18061. * Internal only - manager for action
  18062. * @hidden
  18063. */
  18064. _actionManager: ActionManager;
  18065. /**
  18066. * Internal only
  18067. * @hidden
  18068. */
  18069. private _target;
  18070. /**
  18071. * Creates a new StateCondition
  18072. * @param actionManager manager for the action the condition applies to
  18073. * @param target of the condition
  18074. * @param value to compare with target state
  18075. */
  18076. constructor(actionManager: ActionManager, target: any,
  18077. /** Value to compare with target state */
  18078. value: string);
  18079. /**
  18080. * Gets a boolean indicating if the current condition is met
  18081. * @returns the validity of the state
  18082. */
  18083. isValid(): boolean;
  18084. /**
  18085. * Serialize the StateCondition into a JSON compatible object
  18086. * @returns serialization object
  18087. */
  18088. serialize(): any;
  18089. }
  18090. }
  18091. declare module "babylonjs/Actions/directActions" {
  18092. import { Action } from "babylonjs/Actions/action";
  18093. import { Condition } from "babylonjs/Actions/condition";
  18094. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  18095. /**
  18096. * This defines an action responsible to toggle a boolean once triggered.
  18097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18098. */
  18099. export class SwitchBooleanAction extends Action {
  18100. /**
  18101. * The path to the boolean property in the target object
  18102. */
  18103. propertyPath: string;
  18104. private _target;
  18105. private _effectiveTarget;
  18106. private _property;
  18107. /**
  18108. * Instantiate the action
  18109. * @param triggerOptions defines the trigger options
  18110. * @param target defines the object containing the boolean
  18111. * @param propertyPath defines the path to the boolean property in the target object
  18112. * @param condition defines the trigger related conditions
  18113. */
  18114. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  18115. /** @hidden */
  18116. _prepare(): void;
  18117. /**
  18118. * Execute the action toggle the boolean value.
  18119. */
  18120. execute(): void;
  18121. /**
  18122. * Serializes the actions and its related information.
  18123. * @param parent defines the object to serialize in
  18124. * @returns the serialized object
  18125. */
  18126. serialize(parent: any): any;
  18127. }
  18128. /**
  18129. * This defines an action responsible to set a the state field of the target
  18130. * to a desired value once triggered.
  18131. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18132. */
  18133. export class SetStateAction extends Action {
  18134. /**
  18135. * The value to store in the state field.
  18136. */
  18137. value: string;
  18138. private _target;
  18139. /**
  18140. * Instantiate the action
  18141. * @param triggerOptions defines the trigger options
  18142. * @param target defines the object containing the state property
  18143. * @param value defines the value to store in the state field
  18144. * @param condition defines the trigger related conditions
  18145. */
  18146. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  18147. /**
  18148. * Execute the action and store the value on the target state property.
  18149. */
  18150. execute(): void;
  18151. /**
  18152. * Serializes the actions and its related information.
  18153. * @param parent defines the object to serialize in
  18154. * @returns the serialized object
  18155. */
  18156. serialize(parent: any): any;
  18157. }
  18158. /**
  18159. * This defines an action responsible to set a property of the target
  18160. * to a desired value once triggered.
  18161. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18162. */
  18163. export class SetValueAction extends Action {
  18164. /**
  18165. * The path of the property to set in the target.
  18166. */
  18167. propertyPath: string;
  18168. /**
  18169. * The value to set in the property
  18170. */
  18171. value: any;
  18172. private _target;
  18173. private _effectiveTarget;
  18174. private _property;
  18175. /**
  18176. * Instantiate the action
  18177. * @param triggerOptions defines the trigger options
  18178. * @param target defines the object containing the property
  18179. * @param propertyPath defines the path of the property to set in the target
  18180. * @param value defines the value to set in the property
  18181. * @param condition defines the trigger related conditions
  18182. */
  18183. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  18184. /** @hidden */
  18185. _prepare(): void;
  18186. /**
  18187. * Execute the action and set the targetted property to the desired value.
  18188. */
  18189. execute(): void;
  18190. /**
  18191. * Serializes the actions and its related information.
  18192. * @param parent defines the object to serialize in
  18193. * @returns the serialized object
  18194. */
  18195. serialize(parent: any): any;
  18196. }
  18197. /**
  18198. * This defines an action responsible to increment the target value
  18199. * to a desired value once triggered.
  18200. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18201. */
  18202. export class IncrementValueAction extends Action {
  18203. /**
  18204. * The path of the property to increment in the target.
  18205. */
  18206. propertyPath: string;
  18207. /**
  18208. * The value we should increment the property by.
  18209. */
  18210. value: any;
  18211. private _target;
  18212. private _effectiveTarget;
  18213. private _property;
  18214. /**
  18215. * Instantiate the action
  18216. * @param triggerOptions defines the trigger options
  18217. * @param target defines the object containing the property
  18218. * @param propertyPath defines the path of the property to increment in the target
  18219. * @param value defines the value value we should increment the property by
  18220. * @param condition defines the trigger related conditions
  18221. */
  18222. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  18223. /** @hidden */
  18224. _prepare(): void;
  18225. /**
  18226. * Execute the action and increment the target of the value amount.
  18227. */
  18228. execute(): void;
  18229. /**
  18230. * Serializes the actions and its related information.
  18231. * @param parent defines the object to serialize in
  18232. * @returns the serialized object
  18233. */
  18234. serialize(parent: any): any;
  18235. }
  18236. /**
  18237. * This defines an action responsible to start an animation once triggered.
  18238. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18239. */
  18240. export class PlayAnimationAction extends Action {
  18241. /**
  18242. * Where the animation should start (animation frame)
  18243. */
  18244. from: number;
  18245. /**
  18246. * Where the animation should stop (animation frame)
  18247. */
  18248. to: number;
  18249. /**
  18250. * Define if the animation should loop or stop after the first play.
  18251. */
  18252. loop?: boolean;
  18253. private _target;
  18254. /**
  18255. * Instantiate the action
  18256. * @param triggerOptions defines the trigger options
  18257. * @param target defines the target animation or animation name
  18258. * @param from defines from where the animation should start (animation frame)
  18259. * @param end defines where the animation should stop (animation frame)
  18260. * @param loop defines if the animation should loop or stop after the first play
  18261. * @param condition defines the trigger related conditions
  18262. */
  18263. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  18264. /** @hidden */
  18265. _prepare(): void;
  18266. /**
  18267. * Execute the action and play the animation.
  18268. */
  18269. execute(): void;
  18270. /**
  18271. * Serializes the actions and its related information.
  18272. * @param parent defines the object to serialize in
  18273. * @returns the serialized object
  18274. */
  18275. serialize(parent: any): any;
  18276. }
  18277. /**
  18278. * This defines an action responsible to stop an animation once triggered.
  18279. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18280. */
  18281. export class StopAnimationAction extends Action {
  18282. private _target;
  18283. /**
  18284. * Instantiate the action
  18285. * @param triggerOptions defines the trigger options
  18286. * @param target defines the target animation or animation name
  18287. * @param condition defines the trigger related conditions
  18288. */
  18289. constructor(triggerOptions: any, target: any, condition?: Condition);
  18290. /** @hidden */
  18291. _prepare(): void;
  18292. /**
  18293. * Execute the action and stop the animation.
  18294. */
  18295. execute(): void;
  18296. /**
  18297. * Serializes the actions and its related information.
  18298. * @param parent defines the object to serialize in
  18299. * @returns the serialized object
  18300. */
  18301. serialize(parent: any): any;
  18302. }
  18303. /**
  18304. * This defines an action responsible that does nothing once triggered.
  18305. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18306. */
  18307. export class DoNothingAction extends Action {
  18308. /**
  18309. * Instantiate the action
  18310. * @param triggerOptions defines the trigger options
  18311. * @param condition defines the trigger related conditions
  18312. */
  18313. constructor(triggerOptions?: any, condition?: Condition);
  18314. /**
  18315. * Execute the action and do nothing.
  18316. */
  18317. execute(): void;
  18318. /**
  18319. * Serializes the actions and its related information.
  18320. * @param parent defines the object to serialize in
  18321. * @returns the serialized object
  18322. */
  18323. serialize(parent: any): any;
  18324. }
  18325. /**
  18326. * This defines an action responsible to trigger several actions once triggered.
  18327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18328. */
  18329. export class CombineAction extends Action {
  18330. /**
  18331. * The list of aggregated animations to run.
  18332. */
  18333. children: Action[];
  18334. /**
  18335. * Instantiate the action
  18336. * @param triggerOptions defines the trigger options
  18337. * @param children defines the list of aggregated animations to run
  18338. * @param condition defines the trigger related conditions
  18339. */
  18340. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  18341. /** @hidden */
  18342. _prepare(): void;
  18343. /**
  18344. * Execute the action and executes all the aggregated actions.
  18345. */
  18346. execute(evt: ActionEvent): void;
  18347. /**
  18348. * Serializes the actions and its related information.
  18349. * @param parent defines the object to serialize in
  18350. * @returns the serialized object
  18351. */
  18352. serialize(parent: any): any;
  18353. }
  18354. /**
  18355. * This defines an action responsible to run code (external event) once triggered.
  18356. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18357. */
  18358. export class ExecuteCodeAction extends Action {
  18359. /**
  18360. * The callback function to run.
  18361. */
  18362. func: (evt: ActionEvent) => void;
  18363. /**
  18364. * Instantiate the action
  18365. * @param triggerOptions defines the trigger options
  18366. * @param func defines the callback function to run
  18367. * @param condition defines the trigger related conditions
  18368. */
  18369. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  18370. /**
  18371. * Execute the action and run the attached code.
  18372. */
  18373. execute(evt: ActionEvent): void;
  18374. }
  18375. /**
  18376. * This defines an action responsible to set the parent property of the target once triggered.
  18377. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18378. */
  18379. export class SetParentAction extends Action {
  18380. private _parent;
  18381. private _target;
  18382. /**
  18383. * Instantiate the action
  18384. * @param triggerOptions defines the trigger options
  18385. * @param target defines the target containing the parent property
  18386. * @param parent defines from where the animation should start (animation frame)
  18387. * @param condition defines the trigger related conditions
  18388. */
  18389. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  18390. /** @hidden */
  18391. _prepare(): void;
  18392. /**
  18393. * Execute the action and set the parent property.
  18394. */
  18395. execute(): void;
  18396. /**
  18397. * Serializes the actions and its related information.
  18398. * @param parent defines the object to serialize in
  18399. * @returns the serialized object
  18400. */
  18401. serialize(parent: any): any;
  18402. }
  18403. }
  18404. declare module "babylonjs/Actions/actionManager" {
  18405. import { Nullable } from "babylonjs/types";
  18406. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18407. import { Scene } from "babylonjs/scene";
  18408. import { IAction } from "babylonjs/Actions/action";
  18409. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  18410. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  18411. /**
  18412. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  18413. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  18414. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18415. */
  18416. export class ActionManager extends AbstractActionManager {
  18417. /**
  18418. * Nothing
  18419. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18420. */
  18421. static readonly NothingTrigger: number;
  18422. /**
  18423. * On pick
  18424. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18425. */
  18426. static readonly OnPickTrigger: number;
  18427. /**
  18428. * On left pick
  18429. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18430. */
  18431. static readonly OnLeftPickTrigger: number;
  18432. /**
  18433. * On right pick
  18434. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18435. */
  18436. static readonly OnRightPickTrigger: number;
  18437. /**
  18438. * On center pick
  18439. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18440. */
  18441. static readonly OnCenterPickTrigger: number;
  18442. /**
  18443. * On pick down
  18444. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18445. */
  18446. static readonly OnPickDownTrigger: number;
  18447. /**
  18448. * On double pick
  18449. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18450. */
  18451. static readonly OnDoublePickTrigger: number;
  18452. /**
  18453. * On pick up
  18454. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18455. */
  18456. static readonly OnPickUpTrigger: number;
  18457. /**
  18458. * On pick out.
  18459. * This trigger will only be raised if you also declared a OnPickDown
  18460. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18461. */
  18462. static readonly OnPickOutTrigger: number;
  18463. /**
  18464. * On long press
  18465. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18466. */
  18467. static readonly OnLongPressTrigger: number;
  18468. /**
  18469. * On pointer over
  18470. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18471. */
  18472. static readonly OnPointerOverTrigger: number;
  18473. /**
  18474. * On pointer out
  18475. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18476. */
  18477. static readonly OnPointerOutTrigger: number;
  18478. /**
  18479. * On every frame
  18480. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18481. */
  18482. static readonly OnEveryFrameTrigger: number;
  18483. /**
  18484. * On intersection enter
  18485. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18486. */
  18487. static readonly OnIntersectionEnterTrigger: number;
  18488. /**
  18489. * On intersection exit
  18490. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18491. */
  18492. static readonly OnIntersectionExitTrigger: number;
  18493. /**
  18494. * On key down
  18495. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18496. */
  18497. static readonly OnKeyDownTrigger: number;
  18498. /**
  18499. * On key up
  18500. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18501. */
  18502. static readonly OnKeyUpTrigger: number;
  18503. private _scene;
  18504. /**
  18505. * Creates a new action manager
  18506. * @param scene defines the hosting scene
  18507. */
  18508. constructor(scene: Scene);
  18509. /**
  18510. * Releases all associated resources
  18511. */
  18512. dispose(): void;
  18513. /**
  18514. * Gets hosting scene
  18515. * @returns the hosting scene
  18516. */
  18517. getScene(): Scene;
  18518. /**
  18519. * Does this action manager handles actions of any of the given triggers
  18520. * @param triggers defines the triggers to be tested
  18521. * @return a boolean indicating whether one (or more) of the triggers is handled
  18522. */
  18523. hasSpecificTriggers(triggers: number[]): boolean;
  18524. /**
  18525. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18526. * speed.
  18527. * @param triggerA defines the trigger to be tested
  18528. * @param triggerB defines the trigger to be tested
  18529. * @return a boolean indicating whether one (or more) of the triggers is handled
  18530. */
  18531. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18532. /**
  18533. * Does this action manager handles actions of a given trigger
  18534. * @param trigger defines the trigger to be tested
  18535. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18536. * @return whether the trigger is handled
  18537. */
  18538. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18539. /**
  18540. * Does this action manager has pointer triggers
  18541. */
  18542. get hasPointerTriggers(): boolean;
  18543. /**
  18544. * Does this action manager has pick triggers
  18545. */
  18546. get hasPickTriggers(): boolean;
  18547. /**
  18548. * Registers an action to this action manager
  18549. * @param action defines the action to be registered
  18550. * @return the action amended (prepared) after registration
  18551. */
  18552. registerAction(action: IAction): Nullable<IAction>;
  18553. /**
  18554. * Unregisters an action to this action manager
  18555. * @param action defines the action to be unregistered
  18556. * @return a boolean indicating whether the action has been unregistered
  18557. */
  18558. unregisterAction(action: IAction): Boolean;
  18559. /**
  18560. * Process a specific trigger
  18561. * @param trigger defines the trigger to process
  18562. * @param evt defines the event details to be processed
  18563. */
  18564. processTrigger(trigger: number, evt?: IActionEvent): void;
  18565. /** @hidden */
  18566. _getEffectiveTarget(target: any, propertyPath: string): any;
  18567. /** @hidden */
  18568. _getProperty(propertyPath: string): string;
  18569. /**
  18570. * Serialize this manager to a JSON object
  18571. * @param name defines the property name to store this manager
  18572. * @returns a JSON representation of this manager
  18573. */
  18574. serialize(name: string): any;
  18575. /**
  18576. * Creates a new ActionManager from a JSON data
  18577. * @param parsedActions defines the JSON data to read from
  18578. * @param object defines the hosting mesh
  18579. * @param scene defines the hosting scene
  18580. */
  18581. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18582. /**
  18583. * Get a trigger name by index
  18584. * @param trigger defines the trigger index
  18585. * @returns a trigger name
  18586. */
  18587. static GetTriggerName(trigger: number): string;
  18588. }
  18589. }
  18590. declare module "babylonjs/Sprites/sprite" {
  18591. import { Vector3 } from "babylonjs/Maths/math.vector";
  18592. import { Nullable } from "babylonjs/types";
  18593. import { ActionManager } from "babylonjs/Actions/actionManager";
  18594. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18595. import { Color4 } from "babylonjs/Maths/math.color";
  18596. /**
  18597. * Class used to represent a sprite
  18598. * @see http://doc.babylonjs.com/babylon101/sprites
  18599. */
  18600. export class Sprite {
  18601. /** defines the name */
  18602. name: string;
  18603. /** Gets or sets the current world position */
  18604. position: Vector3;
  18605. /** Gets or sets the main color */
  18606. color: Color4;
  18607. /** Gets or sets the width */
  18608. width: number;
  18609. /** Gets or sets the height */
  18610. height: number;
  18611. /** Gets or sets rotation angle */
  18612. angle: number;
  18613. /** Gets or sets the cell index in the sprite sheet */
  18614. cellIndex: number;
  18615. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18616. cellRef: string;
  18617. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18618. invertU: number;
  18619. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18620. invertV: number;
  18621. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18622. disposeWhenFinishedAnimating: boolean;
  18623. /** Gets the list of attached animations */
  18624. animations: Animation[];
  18625. /** Gets or sets a boolean indicating if the sprite can be picked */
  18626. isPickable: boolean;
  18627. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  18628. useAlphaForPicking: boolean;
  18629. /** @hidden */
  18630. _xOffset: number;
  18631. /** @hidden */
  18632. _yOffset: number;
  18633. /** @hidden */
  18634. _xSize: number;
  18635. /** @hidden */
  18636. _ySize: number;
  18637. /**
  18638. * Gets or sets the associated action manager
  18639. */
  18640. actionManager: Nullable<ActionManager>;
  18641. private _animationStarted;
  18642. private _loopAnimation;
  18643. private _fromIndex;
  18644. private _toIndex;
  18645. private _delay;
  18646. private _direction;
  18647. private _manager;
  18648. private _time;
  18649. private _onAnimationEnd;
  18650. /**
  18651. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18652. */
  18653. isVisible: boolean;
  18654. /**
  18655. * Gets or sets the sprite size
  18656. */
  18657. get size(): number;
  18658. set size(value: number);
  18659. /**
  18660. * Creates a new Sprite
  18661. * @param name defines the name
  18662. * @param manager defines the manager
  18663. */
  18664. constructor(
  18665. /** defines the name */
  18666. name: string, manager: ISpriteManager);
  18667. /**
  18668. * Starts an animation
  18669. * @param from defines the initial key
  18670. * @param to defines the end key
  18671. * @param loop defines if the animation must loop
  18672. * @param delay defines the start delay (in ms)
  18673. * @param onAnimationEnd defines a callback to call when animation ends
  18674. */
  18675. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18676. /** Stops current animation (if any) */
  18677. stopAnimation(): void;
  18678. /** @hidden */
  18679. _animate(deltaTime: number): void;
  18680. /** Release associated resources */
  18681. dispose(): void;
  18682. }
  18683. }
  18684. declare module "babylonjs/Collisions/pickingInfo" {
  18685. import { Nullable } from "babylonjs/types";
  18686. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18687. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18688. import { Sprite } from "babylonjs/Sprites/sprite";
  18689. import { Ray } from "babylonjs/Culling/ray";
  18690. /**
  18691. * Information about the result of picking within a scene
  18692. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18693. */
  18694. export class PickingInfo {
  18695. /** @hidden */
  18696. _pickingUnavailable: boolean;
  18697. /**
  18698. * If the pick collided with an object
  18699. */
  18700. hit: boolean;
  18701. /**
  18702. * Distance away where the pick collided
  18703. */
  18704. distance: number;
  18705. /**
  18706. * The location of pick collision
  18707. */
  18708. pickedPoint: Nullable<Vector3>;
  18709. /**
  18710. * The mesh corresponding the the pick collision
  18711. */
  18712. pickedMesh: Nullable<AbstractMesh>;
  18713. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18714. bu: number;
  18715. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18716. bv: number;
  18717. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18718. faceId: number;
  18719. /** Id of the the submesh that was picked */
  18720. subMeshId: number;
  18721. /** If a sprite was picked, this will be the sprite the pick collided with */
  18722. pickedSprite: Nullable<Sprite>;
  18723. /**
  18724. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18725. */
  18726. originMesh: Nullable<AbstractMesh>;
  18727. /**
  18728. * The ray that was used to perform the picking.
  18729. */
  18730. ray: Nullable<Ray>;
  18731. /**
  18732. * Gets the normal correspodning to the face the pick collided with
  18733. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18734. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18735. * @returns The normal correspodning to the face the pick collided with
  18736. */
  18737. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18738. /**
  18739. * Gets the texture coordinates of where the pick occured
  18740. * @returns the vector containing the coordnates of the texture
  18741. */
  18742. getTextureCoordinates(): Nullable<Vector2>;
  18743. }
  18744. }
  18745. declare module "babylonjs/Events/pointerEvents" {
  18746. import { Nullable } from "babylonjs/types";
  18747. import { Vector2 } from "babylonjs/Maths/math.vector";
  18748. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18749. import { Ray } from "babylonjs/Culling/ray";
  18750. /**
  18751. * Gather the list of pointer event types as constants.
  18752. */
  18753. export class PointerEventTypes {
  18754. /**
  18755. * 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.
  18756. */
  18757. static readonly POINTERDOWN: number;
  18758. /**
  18759. * The pointerup event is fired when a pointer is no longer active.
  18760. */
  18761. static readonly POINTERUP: number;
  18762. /**
  18763. * The pointermove event is fired when a pointer changes coordinates.
  18764. */
  18765. static readonly POINTERMOVE: number;
  18766. /**
  18767. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18768. */
  18769. static readonly POINTERWHEEL: number;
  18770. /**
  18771. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18772. */
  18773. static readonly POINTERPICK: number;
  18774. /**
  18775. * The pointertap event is fired when a the object has been touched and released without drag.
  18776. */
  18777. static readonly POINTERTAP: number;
  18778. /**
  18779. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18780. */
  18781. static readonly POINTERDOUBLETAP: number;
  18782. }
  18783. /**
  18784. * Base class of pointer info types.
  18785. */
  18786. export class PointerInfoBase {
  18787. /**
  18788. * Defines the type of event (PointerEventTypes)
  18789. */
  18790. type: number;
  18791. /**
  18792. * Defines the related dom event
  18793. */
  18794. event: PointerEvent | MouseWheelEvent;
  18795. /**
  18796. * Instantiates the base class of pointers info.
  18797. * @param type Defines the type of event (PointerEventTypes)
  18798. * @param event Defines the related dom event
  18799. */
  18800. constructor(
  18801. /**
  18802. * Defines the type of event (PointerEventTypes)
  18803. */
  18804. type: number,
  18805. /**
  18806. * Defines the related dom event
  18807. */
  18808. event: PointerEvent | MouseWheelEvent);
  18809. }
  18810. /**
  18811. * This class is used to store pointer related info for the onPrePointerObservable event.
  18812. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18813. */
  18814. export class PointerInfoPre extends PointerInfoBase {
  18815. /**
  18816. * Ray from a pointer if availible (eg. 6dof controller)
  18817. */
  18818. ray: Nullable<Ray>;
  18819. /**
  18820. * Defines the local position of the pointer on the canvas.
  18821. */
  18822. localPosition: Vector2;
  18823. /**
  18824. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18825. */
  18826. skipOnPointerObservable: boolean;
  18827. /**
  18828. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18829. * @param type Defines the type of event (PointerEventTypes)
  18830. * @param event Defines the related dom event
  18831. * @param localX Defines the local x coordinates of the pointer when the event occured
  18832. * @param localY Defines the local y coordinates of the pointer when the event occured
  18833. */
  18834. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18835. }
  18836. /**
  18837. * This type contains all the data related to a pointer event in Babylon.js.
  18838. * 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.
  18839. */
  18840. export class PointerInfo extends PointerInfoBase {
  18841. /**
  18842. * Defines the picking info associated to the info (if any)\
  18843. */
  18844. pickInfo: Nullable<PickingInfo>;
  18845. /**
  18846. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18847. * @param type Defines the type of event (PointerEventTypes)
  18848. * @param event Defines the related dom event
  18849. * @param pickInfo Defines the picking info associated to the info (if any)\
  18850. */
  18851. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18852. /**
  18853. * Defines the picking info associated to the info (if any)\
  18854. */
  18855. pickInfo: Nullable<PickingInfo>);
  18856. }
  18857. /**
  18858. * Data relating to a touch event on the screen.
  18859. */
  18860. export interface PointerTouch {
  18861. /**
  18862. * X coordinate of touch.
  18863. */
  18864. x: number;
  18865. /**
  18866. * Y coordinate of touch.
  18867. */
  18868. y: number;
  18869. /**
  18870. * Id of touch. Unique for each finger.
  18871. */
  18872. pointerId: number;
  18873. /**
  18874. * Event type passed from DOM.
  18875. */
  18876. type: any;
  18877. }
  18878. }
  18879. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  18880. import { Observable } from "babylonjs/Misc/observable";
  18881. import { Nullable } from "babylonjs/types";
  18882. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18883. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18884. /**
  18885. * Manage the mouse inputs to control the movement of a free camera.
  18886. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18887. */
  18888. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18889. /**
  18890. * Define if touch is enabled in the mouse input
  18891. */
  18892. touchEnabled: boolean;
  18893. /**
  18894. * Defines the camera the input is attached to.
  18895. */
  18896. camera: FreeCamera;
  18897. /**
  18898. * Defines the buttons associated with the input to handle camera move.
  18899. */
  18900. buttons: number[];
  18901. /**
  18902. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18903. */
  18904. angularSensibility: number;
  18905. private _pointerInput;
  18906. private _onMouseMove;
  18907. private _observer;
  18908. private previousPosition;
  18909. /**
  18910. * Observable for when a pointer move event occurs containing the move offset
  18911. */
  18912. onPointerMovedObservable: Observable<{
  18913. offsetX: number;
  18914. offsetY: number;
  18915. }>;
  18916. /**
  18917. * @hidden
  18918. * If the camera should be rotated automatically based on pointer movement
  18919. */
  18920. _allowCameraRotation: boolean;
  18921. /**
  18922. * Manage the mouse inputs to control the movement of a free camera.
  18923. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18924. * @param touchEnabled Defines if touch is enabled or not
  18925. */
  18926. constructor(
  18927. /**
  18928. * Define if touch is enabled in the mouse input
  18929. */
  18930. touchEnabled?: boolean);
  18931. /**
  18932. * Attach the input controls to a specific dom element to get the input from.
  18933. * @param element Defines the element the controls should be listened from
  18934. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18935. */
  18936. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18937. /**
  18938. * Called on JS contextmenu event.
  18939. * Override this method to provide functionality.
  18940. */
  18941. protected onContextMenu(evt: PointerEvent): void;
  18942. /**
  18943. * Detach the current controls from the specified dom element.
  18944. * @param element Defines the element to stop listening the inputs from
  18945. */
  18946. detachControl(element: Nullable<HTMLElement>): void;
  18947. /**
  18948. * Gets the class name of the current intput.
  18949. * @returns the class name
  18950. */
  18951. getClassName(): string;
  18952. /**
  18953. * Get the friendly name associated with the input class.
  18954. * @returns the input friendly name
  18955. */
  18956. getSimpleName(): string;
  18957. }
  18958. }
  18959. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  18960. import { Nullable } from "babylonjs/types";
  18961. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18962. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18963. /**
  18964. * Manage the touch inputs to control the movement of a free camera.
  18965. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18966. */
  18967. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18968. /**
  18969. * Defines the camera the input is attached to.
  18970. */
  18971. camera: FreeCamera;
  18972. /**
  18973. * Defines the touch sensibility for rotation.
  18974. * The higher the faster.
  18975. */
  18976. touchAngularSensibility: number;
  18977. /**
  18978. * Defines the touch sensibility for move.
  18979. * The higher the faster.
  18980. */
  18981. touchMoveSensibility: number;
  18982. private _offsetX;
  18983. private _offsetY;
  18984. private _pointerPressed;
  18985. private _pointerInput;
  18986. private _observer;
  18987. private _onLostFocus;
  18988. /**
  18989. * Attach the input controls to a specific dom element to get the input from.
  18990. * @param element Defines the element the controls should be listened from
  18991. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18992. */
  18993. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18994. /**
  18995. * Detach the current controls from the specified dom element.
  18996. * @param element Defines the element to stop listening the inputs from
  18997. */
  18998. detachControl(element: Nullable<HTMLElement>): void;
  18999. /**
  19000. * Update the current camera state depending on the inputs that have been used this frame.
  19001. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19002. */
  19003. checkInputs(): void;
  19004. /**
  19005. * Gets the class name of the current intput.
  19006. * @returns the class name
  19007. */
  19008. getClassName(): string;
  19009. /**
  19010. * Get the friendly name associated with the input class.
  19011. * @returns the input friendly name
  19012. */
  19013. getSimpleName(): string;
  19014. }
  19015. }
  19016. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19017. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19018. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19019. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19020. import { Nullable } from "babylonjs/types";
  19021. /**
  19022. * Default Inputs manager for the FreeCamera.
  19023. * It groups all the default supported inputs for ease of use.
  19024. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19025. */
  19026. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19027. /**
  19028. * @hidden
  19029. */
  19030. _mouseInput: Nullable<FreeCameraMouseInput>;
  19031. /**
  19032. * Instantiates a new FreeCameraInputsManager.
  19033. * @param camera Defines the camera the inputs belong to
  19034. */
  19035. constructor(camera: FreeCamera);
  19036. /**
  19037. * Add keyboard input support to the input manager.
  19038. * @returns the current input manager
  19039. */
  19040. addKeyboard(): FreeCameraInputsManager;
  19041. /**
  19042. * Add mouse input support to the input manager.
  19043. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19044. * @returns the current input manager
  19045. */
  19046. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19047. /**
  19048. * Removes the mouse input support from the manager
  19049. * @returns the current input manager
  19050. */
  19051. removeMouse(): FreeCameraInputsManager;
  19052. /**
  19053. * Add touch input support to the input manager.
  19054. * @returns the current input manager
  19055. */
  19056. addTouch(): FreeCameraInputsManager;
  19057. /**
  19058. * Remove all attached input methods from a camera
  19059. */
  19060. clear(): void;
  19061. }
  19062. }
  19063. declare module "babylonjs/Cameras/freeCamera" {
  19064. import { Vector3 } from "babylonjs/Maths/math.vector";
  19065. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19066. import { Scene } from "babylonjs/scene";
  19067. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19068. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19069. /**
  19070. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19071. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19072. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19073. */
  19074. export class FreeCamera extends TargetCamera {
  19075. /**
  19076. * Define the collision ellipsoid of the camera.
  19077. * This is helpful to simulate a camera body like the player body around the camera
  19078. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19079. */
  19080. ellipsoid: Vector3;
  19081. /**
  19082. * Define an offset for the position of the ellipsoid around the camera.
  19083. * This can be helpful to determine the center of the body near the gravity center of the body
  19084. * instead of its head.
  19085. */
  19086. ellipsoidOffset: Vector3;
  19087. /**
  19088. * Enable or disable collisions of the camera with the rest of the scene objects.
  19089. */
  19090. checkCollisions: boolean;
  19091. /**
  19092. * Enable or disable gravity on the camera.
  19093. */
  19094. applyGravity: boolean;
  19095. /**
  19096. * Define the input manager associated to the camera.
  19097. */
  19098. inputs: FreeCameraInputsManager;
  19099. /**
  19100. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19101. * Higher values reduce sensitivity.
  19102. */
  19103. get angularSensibility(): number;
  19104. /**
  19105. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19106. * Higher values reduce sensitivity.
  19107. */
  19108. set angularSensibility(value: number);
  19109. /**
  19110. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19111. */
  19112. get keysUp(): number[];
  19113. set keysUp(value: number[]);
  19114. /**
  19115. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19116. */
  19117. get keysUpward(): number[];
  19118. set keysUpward(value: number[]);
  19119. /**
  19120. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19121. */
  19122. get keysDown(): number[];
  19123. set keysDown(value: number[]);
  19124. /**
  19125. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19126. */
  19127. get keysDownward(): number[];
  19128. set keysDownward(value: number[]);
  19129. /**
  19130. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19131. */
  19132. get keysLeft(): number[];
  19133. set keysLeft(value: number[]);
  19134. /**
  19135. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19136. */
  19137. get keysRight(): number[];
  19138. set keysRight(value: number[]);
  19139. /**
  19140. * Event raised when the camera collide with a mesh in the scene.
  19141. */
  19142. onCollide: (collidedMesh: AbstractMesh) => void;
  19143. private _collider;
  19144. private _needMoveForGravity;
  19145. private _oldPosition;
  19146. private _diffPosition;
  19147. private _newPosition;
  19148. /** @hidden */
  19149. _localDirection: Vector3;
  19150. /** @hidden */
  19151. _transformedDirection: Vector3;
  19152. /**
  19153. * Instantiates a Free Camera.
  19154. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19155. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19156. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19157. * @param name Define the name of the camera in the scene
  19158. * @param position Define the start position of the camera in the scene
  19159. * @param scene Define the scene the camera belongs to
  19160. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19161. */
  19162. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19163. /**
  19164. * Attached controls to the current camera.
  19165. * @param element Defines the element the controls should be listened from
  19166. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19167. */
  19168. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19169. /**
  19170. * Detach the current controls from the camera.
  19171. * The camera will stop reacting to inputs.
  19172. * @param element Defines the element to stop listening the inputs from
  19173. */
  19174. detachControl(element: HTMLElement): void;
  19175. private _collisionMask;
  19176. /**
  19177. * Define a collision mask to limit the list of object the camera can collide with
  19178. */
  19179. get collisionMask(): number;
  19180. set collisionMask(mask: number);
  19181. /** @hidden */
  19182. _collideWithWorld(displacement: Vector3): void;
  19183. private _onCollisionPositionChange;
  19184. /** @hidden */
  19185. _checkInputs(): void;
  19186. /** @hidden */
  19187. _decideIfNeedsToMove(): boolean;
  19188. /** @hidden */
  19189. _updatePosition(): void;
  19190. /**
  19191. * Destroy the camera and release the current resources hold by it.
  19192. */
  19193. dispose(): void;
  19194. /**
  19195. * Gets the current object class name.
  19196. * @return the class name
  19197. */
  19198. getClassName(): string;
  19199. }
  19200. }
  19201. declare module "babylonjs/Gamepads/gamepad" {
  19202. import { Observable } from "babylonjs/Misc/observable";
  19203. /**
  19204. * Represents a gamepad control stick position
  19205. */
  19206. export class StickValues {
  19207. /**
  19208. * The x component of the control stick
  19209. */
  19210. x: number;
  19211. /**
  19212. * The y component of the control stick
  19213. */
  19214. y: number;
  19215. /**
  19216. * Initializes the gamepad x and y control stick values
  19217. * @param x The x component of the gamepad control stick value
  19218. * @param y The y component of the gamepad control stick value
  19219. */
  19220. constructor(
  19221. /**
  19222. * The x component of the control stick
  19223. */
  19224. x: number,
  19225. /**
  19226. * The y component of the control stick
  19227. */
  19228. y: number);
  19229. }
  19230. /**
  19231. * An interface which manages callbacks for gamepad button changes
  19232. */
  19233. export interface GamepadButtonChanges {
  19234. /**
  19235. * Called when a gamepad has been changed
  19236. */
  19237. changed: boolean;
  19238. /**
  19239. * Called when a gamepad press event has been triggered
  19240. */
  19241. pressChanged: boolean;
  19242. /**
  19243. * Called when a touch event has been triggered
  19244. */
  19245. touchChanged: boolean;
  19246. /**
  19247. * Called when a value has changed
  19248. */
  19249. valueChanged: boolean;
  19250. }
  19251. /**
  19252. * Represents a gamepad
  19253. */
  19254. export class Gamepad {
  19255. /**
  19256. * The id of the gamepad
  19257. */
  19258. id: string;
  19259. /**
  19260. * The index of the gamepad
  19261. */
  19262. index: number;
  19263. /**
  19264. * The browser gamepad
  19265. */
  19266. browserGamepad: any;
  19267. /**
  19268. * Specifies what type of gamepad this represents
  19269. */
  19270. type: number;
  19271. private _leftStick;
  19272. private _rightStick;
  19273. /** @hidden */
  19274. _isConnected: boolean;
  19275. private _leftStickAxisX;
  19276. private _leftStickAxisY;
  19277. private _rightStickAxisX;
  19278. private _rightStickAxisY;
  19279. /**
  19280. * Triggered when the left control stick has been changed
  19281. */
  19282. private _onleftstickchanged;
  19283. /**
  19284. * Triggered when the right control stick has been changed
  19285. */
  19286. private _onrightstickchanged;
  19287. /**
  19288. * Represents a gamepad controller
  19289. */
  19290. static GAMEPAD: number;
  19291. /**
  19292. * Represents a generic controller
  19293. */
  19294. static GENERIC: number;
  19295. /**
  19296. * Represents an XBox controller
  19297. */
  19298. static XBOX: number;
  19299. /**
  19300. * Represents a pose-enabled controller
  19301. */
  19302. static POSE_ENABLED: number;
  19303. /**
  19304. * Represents an Dual Shock controller
  19305. */
  19306. static DUALSHOCK: number;
  19307. /**
  19308. * Specifies whether the left control stick should be Y-inverted
  19309. */
  19310. protected _invertLeftStickY: boolean;
  19311. /**
  19312. * Specifies if the gamepad has been connected
  19313. */
  19314. get isConnected(): boolean;
  19315. /**
  19316. * Initializes the gamepad
  19317. * @param id The id of the gamepad
  19318. * @param index The index of the gamepad
  19319. * @param browserGamepad The browser gamepad
  19320. * @param leftStickX The x component of the left joystick
  19321. * @param leftStickY The y component of the left joystick
  19322. * @param rightStickX The x component of the right joystick
  19323. * @param rightStickY The y component of the right joystick
  19324. */
  19325. constructor(
  19326. /**
  19327. * The id of the gamepad
  19328. */
  19329. id: string,
  19330. /**
  19331. * The index of the gamepad
  19332. */
  19333. index: number,
  19334. /**
  19335. * The browser gamepad
  19336. */
  19337. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19338. /**
  19339. * Callback triggered when the left joystick has changed
  19340. * @param callback
  19341. */
  19342. onleftstickchanged(callback: (values: StickValues) => void): void;
  19343. /**
  19344. * Callback triggered when the right joystick has changed
  19345. * @param callback
  19346. */
  19347. onrightstickchanged(callback: (values: StickValues) => void): void;
  19348. /**
  19349. * Gets the left joystick
  19350. */
  19351. get leftStick(): StickValues;
  19352. /**
  19353. * Sets the left joystick values
  19354. */
  19355. set leftStick(newValues: StickValues);
  19356. /**
  19357. * Gets the right joystick
  19358. */
  19359. get rightStick(): StickValues;
  19360. /**
  19361. * Sets the right joystick value
  19362. */
  19363. set rightStick(newValues: StickValues);
  19364. /**
  19365. * Updates the gamepad joystick positions
  19366. */
  19367. update(): void;
  19368. /**
  19369. * Disposes the gamepad
  19370. */
  19371. dispose(): void;
  19372. }
  19373. /**
  19374. * Represents a generic gamepad
  19375. */
  19376. export class GenericPad extends Gamepad {
  19377. private _buttons;
  19378. private _onbuttondown;
  19379. private _onbuttonup;
  19380. /**
  19381. * Observable triggered when a button has been pressed
  19382. */
  19383. onButtonDownObservable: Observable<number>;
  19384. /**
  19385. * Observable triggered when a button has been released
  19386. */
  19387. onButtonUpObservable: Observable<number>;
  19388. /**
  19389. * Callback triggered when a button has been pressed
  19390. * @param callback Called when a button has been pressed
  19391. */
  19392. onbuttondown(callback: (buttonPressed: number) => void): void;
  19393. /**
  19394. * Callback triggered when a button has been released
  19395. * @param callback Called when a button has been released
  19396. */
  19397. onbuttonup(callback: (buttonReleased: number) => void): void;
  19398. /**
  19399. * Initializes the generic gamepad
  19400. * @param id The id of the generic gamepad
  19401. * @param index The index of the generic gamepad
  19402. * @param browserGamepad The browser gamepad
  19403. */
  19404. constructor(id: string, index: number, browserGamepad: any);
  19405. private _setButtonValue;
  19406. /**
  19407. * Updates the generic gamepad
  19408. */
  19409. update(): void;
  19410. /**
  19411. * Disposes the generic gamepad
  19412. */
  19413. dispose(): void;
  19414. }
  19415. }
  19416. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19417. import { Observable } from "babylonjs/Misc/observable";
  19418. import { Nullable } from "babylonjs/types";
  19419. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19420. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19422. import { Ray } from "babylonjs/Culling/ray";
  19423. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19424. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19425. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19426. /**
  19427. * Defines the types of pose enabled controllers that are supported
  19428. */
  19429. export enum PoseEnabledControllerType {
  19430. /**
  19431. * HTC Vive
  19432. */
  19433. VIVE = 0,
  19434. /**
  19435. * Oculus Rift
  19436. */
  19437. OCULUS = 1,
  19438. /**
  19439. * Windows mixed reality
  19440. */
  19441. WINDOWS = 2,
  19442. /**
  19443. * Samsung gear VR
  19444. */
  19445. GEAR_VR = 3,
  19446. /**
  19447. * Google Daydream
  19448. */
  19449. DAYDREAM = 4,
  19450. /**
  19451. * Generic
  19452. */
  19453. GENERIC = 5
  19454. }
  19455. /**
  19456. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19457. */
  19458. export interface MutableGamepadButton {
  19459. /**
  19460. * Value of the button/trigger
  19461. */
  19462. value: number;
  19463. /**
  19464. * If the button/trigger is currently touched
  19465. */
  19466. touched: boolean;
  19467. /**
  19468. * If the button/trigger is currently pressed
  19469. */
  19470. pressed: boolean;
  19471. }
  19472. /**
  19473. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19474. * @hidden
  19475. */
  19476. export interface ExtendedGamepadButton extends GamepadButton {
  19477. /**
  19478. * If the button/trigger is currently pressed
  19479. */
  19480. readonly pressed: boolean;
  19481. /**
  19482. * If the button/trigger is currently touched
  19483. */
  19484. readonly touched: boolean;
  19485. /**
  19486. * Value of the button/trigger
  19487. */
  19488. readonly value: number;
  19489. }
  19490. /** @hidden */
  19491. export interface _GamePadFactory {
  19492. /**
  19493. * Returns whether or not the current gamepad can be created for this type of controller.
  19494. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19495. * @returns true if it can be created, otherwise false
  19496. */
  19497. canCreate(gamepadInfo: any): boolean;
  19498. /**
  19499. * Creates a new instance of the Gamepad.
  19500. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19501. * @returns the new gamepad instance
  19502. */
  19503. create(gamepadInfo: any): Gamepad;
  19504. }
  19505. /**
  19506. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19507. */
  19508. export class PoseEnabledControllerHelper {
  19509. /** @hidden */
  19510. static _ControllerFactories: _GamePadFactory[];
  19511. /** @hidden */
  19512. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19513. /**
  19514. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19515. * @param vrGamepad the gamepad to initialized
  19516. * @returns a vr controller of the type the gamepad identified as
  19517. */
  19518. static InitiateController(vrGamepad: any): Gamepad;
  19519. }
  19520. /**
  19521. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19522. */
  19523. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19524. /**
  19525. * If the controller is used in a webXR session
  19526. */
  19527. isXR: boolean;
  19528. private _deviceRoomPosition;
  19529. private _deviceRoomRotationQuaternion;
  19530. /**
  19531. * The device position in babylon space
  19532. */
  19533. devicePosition: Vector3;
  19534. /**
  19535. * The device rotation in babylon space
  19536. */
  19537. deviceRotationQuaternion: Quaternion;
  19538. /**
  19539. * The scale factor of the device in babylon space
  19540. */
  19541. deviceScaleFactor: number;
  19542. /**
  19543. * (Likely devicePosition should be used instead) The device position in its room space
  19544. */
  19545. position: Vector3;
  19546. /**
  19547. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19548. */
  19549. rotationQuaternion: Quaternion;
  19550. /**
  19551. * The type of controller (Eg. Windows mixed reality)
  19552. */
  19553. controllerType: PoseEnabledControllerType;
  19554. protected _calculatedPosition: Vector3;
  19555. private _calculatedRotation;
  19556. /**
  19557. * The raw pose from the device
  19558. */
  19559. rawPose: DevicePose;
  19560. private _trackPosition;
  19561. private _maxRotationDistFromHeadset;
  19562. private _draggedRoomRotation;
  19563. /**
  19564. * @hidden
  19565. */
  19566. _disableTrackPosition(fixedPosition: Vector3): void;
  19567. /**
  19568. * Internal, the mesh attached to the controller
  19569. * @hidden
  19570. */
  19571. _mesh: Nullable<AbstractMesh>;
  19572. private _poseControlledCamera;
  19573. private _leftHandSystemQuaternion;
  19574. /**
  19575. * Internal, matrix used to convert room space to babylon space
  19576. * @hidden
  19577. */
  19578. _deviceToWorld: Matrix;
  19579. /**
  19580. * Node to be used when casting a ray from the controller
  19581. * @hidden
  19582. */
  19583. _pointingPoseNode: Nullable<TransformNode>;
  19584. /**
  19585. * Name of the child mesh that can be used to cast a ray from the controller
  19586. */
  19587. static readonly POINTING_POSE: string;
  19588. /**
  19589. * Creates a new PoseEnabledController from a gamepad
  19590. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19591. */
  19592. constructor(browserGamepad: any);
  19593. private _workingMatrix;
  19594. /**
  19595. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19596. */
  19597. update(): void;
  19598. /**
  19599. * Updates only the pose device and mesh without doing any button event checking
  19600. */
  19601. protected _updatePoseAndMesh(): void;
  19602. /**
  19603. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19604. * @param poseData raw pose fromthe device
  19605. */
  19606. updateFromDevice(poseData: DevicePose): void;
  19607. /**
  19608. * @hidden
  19609. */
  19610. _meshAttachedObservable: Observable<AbstractMesh>;
  19611. /**
  19612. * Attaches a mesh to the controller
  19613. * @param mesh the mesh to be attached
  19614. */
  19615. attachToMesh(mesh: AbstractMesh): void;
  19616. /**
  19617. * Attaches the controllers mesh to a camera
  19618. * @param camera the camera the mesh should be attached to
  19619. */
  19620. attachToPoseControlledCamera(camera: TargetCamera): void;
  19621. /**
  19622. * Disposes of the controller
  19623. */
  19624. dispose(): void;
  19625. /**
  19626. * The mesh that is attached to the controller
  19627. */
  19628. get mesh(): Nullable<AbstractMesh>;
  19629. /**
  19630. * Gets the ray of the controller in the direction the controller is pointing
  19631. * @param length the length the resulting ray should be
  19632. * @returns a ray in the direction the controller is pointing
  19633. */
  19634. getForwardRay(length?: number): Ray;
  19635. }
  19636. }
  19637. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19638. import { Observable } from "babylonjs/Misc/observable";
  19639. import { Scene } from "babylonjs/scene";
  19640. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19641. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19642. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19643. import { Nullable } from "babylonjs/types";
  19644. /**
  19645. * Defines the WebVRController object that represents controllers tracked in 3D space
  19646. */
  19647. export abstract class WebVRController extends PoseEnabledController {
  19648. /**
  19649. * Internal, the default controller model for the controller
  19650. */
  19651. protected _defaultModel: Nullable<AbstractMesh>;
  19652. /**
  19653. * Fired when the trigger state has changed
  19654. */
  19655. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19656. /**
  19657. * Fired when the main button state has changed
  19658. */
  19659. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19660. /**
  19661. * Fired when the secondary button state has changed
  19662. */
  19663. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19664. /**
  19665. * Fired when the pad state has changed
  19666. */
  19667. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19668. /**
  19669. * Fired when controllers stick values have changed
  19670. */
  19671. onPadValuesChangedObservable: Observable<StickValues>;
  19672. /**
  19673. * Array of button availible on the controller
  19674. */
  19675. protected _buttons: Array<MutableGamepadButton>;
  19676. private _onButtonStateChange;
  19677. /**
  19678. * Fired when a controller button's state has changed
  19679. * @param callback the callback containing the button that was modified
  19680. */
  19681. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19682. /**
  19683. * X and Y axis corresponding to the controllers joystick
  19684. */
  19685. pad: StickValues;
  19686. /**
  19687. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19688. */
  19689. hand: string;
  19690. /**
  19691. * The default controller model for the controller
  19692. */
  19693. get defaultModel(): Nullable<AbstractMesh>;
  19694. /**
  19695. * Creates a new WebVRController from a gamepad
  19696. * @param vrGamepad the gamepad that the WebVRController should be created from
  19697. */
  19698. constructor(vrGamepad: any);
  19699. /**
  19700. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19701. */
  19702. update(): void;
  19703. /**
  19704. * Function to be called when a button is modified
  19705. */
  19706. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19707. /**
  19708. * Loads a mesh and attaches it to the controller
  19709. * @param scene the scene the mesh should be added to
  19710. * @param meshLoaded callback for when the mesh has been loaded
  19711. */
  19712. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19713. private _setButtonValue;
  19714. private _changes;
  19715. private _checkChanges;
  19716. /**
  19717. * Disposes of th webVRCOntroller
  19718. */
  19719. dispose(): void;
  19720. }
  19721. }
  19722. declare module "babylonjs/Lights/hemisphericLight" {
  19723. import { Nullable } from "babylonjs/types";
  19724. import { Scene } from "babylonjs/scene";
  19725. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19726. import { Color3 } from "babylonjs/Maths/math.color";
  19727. import { Effect } from "babylonjs/Materials/effect";
  19728. import { Light } from "babylonjs/Lights/light";
  19729. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19730. /**
  19731. * The HemisphericLight simulates the ambient environment light,
  19732. * so the passed direction is the light reflection direction, not the incoming direction.
  19733. */
  19734. export class HemisphericLight extends Light {
  19735. /**
  19736. * The groundColor is the light in the opposite direction to the one specified during creation.
  19737. * 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.
  19738. */
  19739. groundColor: Color3;
  19740. /**
  19741. * The light reflection direction, not the incoming direction.
  19742. */
  19743. direction: Vector3;
  19744. /**
  19745. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19746. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19747. * The HemisphericLight can't cast shadows.
  19748. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19749. * @param name The friendly name of the light
  19750. * @param direction The direction of the light reflection
  19751. * @param scene The scene the light belongs to
  19752. */
  19753. constructor(name: string, direction: Vector3, scene: Scene);
  19754. protected _buildUniformLayout(): void;
  19755. /**
  19756. * Returns the string "HemisphericLight".
  19757. * @return The class name
  19758. */
  19759. getClassName(): string;
  19760. /**
  19761. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19762. * Returns the updated direction.
  19763. * @param target The target the direction should point to
  19764. * @return The computed direction
  19765. */
  19766. setDirectionToTarget(target: Vector3): Vector3;
  19767. /**
  19768. * Returns the shadow generator associated to the light.
  19769. * @returns Always null for hemispheric lights because it does not support shadows.
  19770. */
  19771. getShadowGenerator(): Nullable<IShadowGenerator>;
  19772. /**
  19773. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19774. * @param effect The effect to update
  19775. * @param lightIndex The index of the light in the effect to update
  19776. * @returns The hemispheric light
  19777. */
  19778. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19779. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19780. /**
  19781. * Computes the world matrix of the node
  19782. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19783. * @param useWasUpdatedFlag defines a reserved property
  19784. * @returns the world matrix
  19785. */
  19786. computeWorldMatrix(): Matrix;
  19787. /**
  19788. * Returns the integer 3.
  19789. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19790. */
  19791. getTypeID(): number;
  19792. /**
  19793. * Prepares the list of defines specific to the light type.
  19794. * @param defines the list of defines
  19795. * @param lightIndex defines the index of the light for the effect
  19796. */
  19797. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19798. }
  19799. }
  19800. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19801. /** @hidden */
  19802. export var vrMultiviewToSingleviewPixelShader: {
  19803. name: string;
  19804. shader: string;
  19805. };
  19806. }
  19807. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19808. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19809. import { Scene } from "babylonjs/scene";
  19810. /**
  19811. * Renders to multiple views with a single draw call
  19812. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19813. */
  19814. export class MultiviewRenderTarget extends RenderTargetTexture {
  19815. /**
  19816. * Creates a multiview render target
  19817. * @param scene scene used with the render target
  19818. * @param size the size of the render target (used for each view)
  19819. */
  19820. constructor(scene: Scene, size?: number | {
  19821. width: number;
  19822. height: number;
  19823. } | {
  19824. ratio: number;
  19825. });
  19826. /**
  19827. * @hidden
  19828. * @param faceIndex the face index, if its a cube texture
  19829. */
  19830. _bindFrameBuffer(faceIndex?: number): void;
  19831. /**
  19832. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19833. * @returns the view count
  19834. */
  19835. getViewCount(): number;
  19836. }
  19837. }
  19838. declare module "babylonjs/Maths/math.frustum" {
  19839. import { Matrix } from "babylonjs/Maths/math.vector";
  19840. import { DeepImmutable } from "babylonjs/types";
  19841. import { Plane } from "babylonjs/Maths/math.plane";
  19842. /**
  19843. * Represents a camera frustum
  19844. */
  19845. export class Frustum {
  19846. /**
  19847. * Gets the planes representing the frustum
  19848. * @param transform matrix to be applied to the returned planes
  19849. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19850. */
  19851. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19852. /**
  19853. * Gets the near frustum plane transformed by the transform matrix
  19854. * @param transform transformation matrix to be applied to the resulting frustum plane
  19855. * @param frustumPlane the resuling frustum plane
  19856. */
  19857. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19858. /**
  19859. * Gets the far frustum plane transformed by the transform matrix
  19860. * @param transform transformation matrix to be applied to the resulting frustum plane
  19861. * @param frustumPlane the resuling frustum plane
  19862. */
  19863. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19864. /**
  19865. * Gets the left frustum plane transformed by the transform matrix
  19866. * @param transform transformation matrix to be applied to the resulting frustum plane
  19867. * @param frustumPlane the resuling frustum plane
  19868. */
  19869. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19870. /**
  19871. * Gets the right frustum plane transformed by the transform matrix
  19872. * @param transform transformation matrix to be applied to the resulting frustum plane
  19873. * @param frustumPlane the resuling frustum plane
  19874. */
  19875. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19876. /**
  19877. * Gets the top frustum plane transformed by the transform matrix
  19878. * @param transform transformation matrix to be applied to the resulting frustum plane
  19879. * @param frustumPlane the resuling frustum plane
  19880. */
  19881. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19882. /**
  19883. * Gets the bottom frustum plane transformed by the transform matrix
  19884. * @param transform transformation matrix to be applied to the resulting frustum plane
  19885. * @param frustumPlane the resuling frustum plane
  19886. */
  19887. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19888. /**
  19889. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19890. * @param transform transformation matrix to be applied to the resulting frustum planes
  19891. * @param frustumPlanes the resuling frustum planes
  19892. */
  19893. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19894. }
  19895. }
  19896. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  19897. import { Camera } from "babylonjs/Cameras/camera";
  19898. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19899. import { Nullable } from "babylonjs/types";
  19900. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19901. import { Matrix } from "babylonjs/Maths/math.vector";
  19902. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19903. module "babylonjs/Engines/engine" {
  19904. interface Engine {
  19905. /**
  19906. * Creates a new multiview render target
  19907. * @param width defines the width of the texture
  19908. * @param height defines the height of the texture
  19909. * @returns the created multiview texture
  19910. */
  19911. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19912. /**
  19913. * Binds a multiview framebuffer to be drawn to
  19914. * @param multiviewTexture texture to bind
  19915. */
  19916. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19917. }
  19918. }
  19919. module "babylonjs/Cameras/camera" {
  19920. interface Camera {
  19921. /**
  19922. * @hidden
  19923. * 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)
  19924. */
  19925. _useMultiviewToSingleView: boolean;
  19926. /**
  19927. * @hidden
  19928. * 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)
  19929. */
  19930. _multiviewTexture: Nullable<RenderTargetTexture>;
  19931. /**
  19932. * @hidden
  19933. * ensures the multiview texture of the camera exists and has the specified width/height
  19934. * @param width height to set on the multiview texture
  19935. * @param height width to set on the multiview texture
  19936. */
  19937. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19938. }
  19939. }
  19940. module "babylonjs/scene" {
  19941. interface Scene {
  19942. /** @hidden */
  19943. _transformMatrixR: Matrix;
  19944. /** @hidden */
  19945. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19946. /** @hidden */
  19947. _createMultiviewUbo(): void;
  19948. /** @hidden */
  19949. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19950. /** @hidden */
  19951. _renderMultiviewToSingleView(camera: Camera): void;
  19952. }
  19953. }
  19954. }
  19955. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  19956. import { Camera } from "babylonjs/Cameras/camera";
  19957. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19958. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  19959. import "babylonjs/Engines/Extensions/engine.multiview";
  19960. /**
  19961. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19962. * This will not be used for webXR as it supports displaying texture arrays directly
  19963. */
  19964. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19965. /**
  19966. * Initializes a VRMultiviewToSingleview
  19967. * @param name name of the post process
  19968. * @param camera camera to be applied to
  19969. * @param scaleFactor scaling factor to the size of the output texture
  19970. */
  19971. constructor(name: string, camera: Camera, scaleFactor: number);
  19972. }
  19973. }
  19974. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  19975. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  19976. import { Nullable } from "babylonjs/types";
  19977. import { Size } from "babylonjs/Maths/math.size";
  19978. import { Observable } from "babylonjs/Misc/observable";
  19979. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  19980. /**
  19981. * Interface used to define additional presentation attributes
  19982. */
  19983. export interface IVRPresentationAttributes {
  19984. /**
  19985. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19986. */
  19987. highRefreshRate: boolean;
  19988. /**
  19989. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19990. */
  19991. foveationLevel: number;
  19992. }
  19993. module "babylonjs/Engines/engine" {
  19994. interface Engine {
  19995. /** @hidden */
  19996. _vrDisplay: any;
  19997. /** @hidden */
  19998. _vrSupported: boolean;
  19999. /** @hidden */
  20000. _oldSize: Size;
  20001. /** @hidden */
  20002. _oldHardwareScaleFactor: number;
  20003. /** @hidden */
  20004. _vrExclusivePointerMode: boolean;
  20005. /** @hidden */
  20006. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20007. /** @hidden */
  20008. _onVRDisplayPointerRestricted: () => void;
  20009. /** @hidden */
  20010. _onVRDisplayPointerUnrestricted: () => void;
  20011. /** @hidden */
  20012. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20013. /** @hidden */
  20014. _onVrDisplayDisconnect: Nullable<() => void>;
  20015. /** @hidden */
  20016. _onVrDisplayPresentChange: Nullable<() => void>;
  20017. /**
  20018. * Observable signaled when VR display mode changes
  20019. */
  20020. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20021. /**
  20022. * Observable signaled when VR request present is complete
  20023. */
  20024. onVRRequestPresentComplete: Observable<boolean>;
  20025. /**
  20026. * Observable signaled when VR request present starts
  20027. */
  20028. onVRRequestPresentStart: Observable<Engine>;
  20029. /**
  20030. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20031. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20032. */
  20033. isInVRExclusivePointerMode: boolean;
  20034. /**
  20035. * Gets a boolean indicating if a webVR device was detected
  20036. * @returns true if a webVR device was detected
  20037. */
  20038. isVRDevicePresent(): boolean;
  20039. /**
  20040. * Gets the current webVR device
  20041. * @returns the current webVR device (or null)
  20042. */
  20043. getVRDevice(): any;
  20044. /**
  20045. * Initializes a webVR display and starts listening to display change events
  20046. * The onVRDisplayChangedObservable will be notified upon these changes
  20047. * @returns A promise containing a VRDisplay and if vr is supported
  20048. */
  20049. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20050. /** @hidden */
  20051. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20052. /**
  20053. * Gets or sets the presentation attributes used to configure VR rendering
  20054. */
  20055. vrPresentationAttributes?: IVRPresentationAttributes;
  20056. /**
  20057. * Call this function to switch to webVR mode
  20058. * Will do nothing if webVR is not supported or if there is no webVR device
  20059. * @param options the webvr options provided to the camera. mainly used for multiview
  20060. * @see http://doc.babylonjs.com/how_to/webvr_camera
  20061. */
  20062. enableVR(options: WebVROptions): void;
  20063. /** @hidden */
  20064. _onVRFullScreenTriggered(): void;
  20065. }
  20066. }
  20067. }
  20068. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20069. import { Nullable } from "babylonjs/types";
  20070. import { Observable } from "babylonjs/Misc/observable";
  20071. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20072. import { Scene } from "babylonjs/scene";
  20073. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20074. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20075. import { Node } from "babylonjs/node";
  20076. import { Ray } from "babylonjs/Culling/ray";
  20077. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20078. import "babylonjs/Engines/Extensions/engine.webVR";
  20079. /**
  20080. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20081. * IMPORTANT!! The data is right-hand data.
  20082. * @export
  20083. * @interface DevicePose
  20084. */
  20085. export interface DevicePose {
  20086. /**
  20087. * The position of the device, values in array are [x,y,z].
  20088. */
  20089. readonly position: Nullable<Float32Array>;
  20090. /**
  20091. * The linearVelocity of the device, values in array are [x,y,z].
  20092. */
  20093. readonly linearVelocity: Nullable<Float32Array>;
  20094. /**
  20095. * The linearAcceleration of the device, values in array are [x,y,z].
  20096. */
  20097. readonly linearAcceleration: Nullable<Float32Array>;
  20098. /**
  20099. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20100. */
  20101. readonly orientation: Nullable<Float32Array>;
  20102. /**
  20103. * The angularVelocity of the device, values in array are [x,y,z].
  20104. */
  20105. readonly angularVelocity: Nullable<Float32Array>;
  20106. /**
  20107. * The angularAcceleration of the device, values in array are [x,y,z].
  20108. */
  20109. readonly angularAcceleration: Nullable<Float32Array>;
  20110. }
  20111. /**
  20112. * Interface representing a pose controlled object in Babylon.
  20113. * A pose controlled object has both regular pose values as well as pose values
  20114. * from an external device such as a VR head mounted display
  20115. */
  20116. export interface PoseControlled {
  20117. /**
  20118. * The position of the object in babylon space.
  20119. */
  20120. position: Vector3;
  20121. /**
  20122. * The rotation quaternion of the object in babylon space.
  20123. */
  20124. rotationQuaternion: Quaternion;
  20125. /**
  20126. * The position of the device in babylon space.
  20127. */
  20128. devicePosition?: Vector3;
  20129. /**
  20130. * The rotation quaternion of the device in babylon space.
  20131. */
  20132. deviceRotationQuaternion: Quaternion;
  20133. /**
  20134. * The raw pose coming from the device.
  20135. */
  20136. rawPose: Nullable<DevicePose>;
  20137. /**
  20138. * The scale of the device to be used when translating from device space to babylon space.
  20139. */
  20140. deviceScaleFactor: number;
  20141. /**
  20142. * Updates the poseControlled values based on the input device pose.
  20143. * @param poseData the pose data to update the object with
  20144. */
  20145. updateFromDevice(poseData: DevicePose): void;
  20146. }
  20147. /**
  20148. * Set of options to customize the webVRCamera
  20149. */
  20150. export interface WebVROptions {
  20151. /**
  20152. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20153. */
  20154. trackPosition?: boolean;
  20155. /**
  20156. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20157. */
  20158. positionScale?: number;
  20159. /**
  20160. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20161. */
  20162. displayName?: string;
  20163. /**
  20164. * Should the native controller meshes be initialized. (default: true)
  20165. */
  20166. controllerMeshes?: boolean;
  20167. /**
  20168. * Creating a default HemiLight only on controllers. (default: true)
  20169. */
  20170. defaultLightingOnControllers?: boolean;
  20171. /**
  20172. * If you don't want to use the default VR button of the helper. (default: false)
  20173. */
  20174. useCustomVRButton?: boolean;
  20175. /**
  20176. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20177. */
  20178. customVRButton?: HTMLButtonElement;
  20179. /**
  20180. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20181. */
  20182. rayLength?: number;
  20183. /**
  20184. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20185. */
  20186. defaultHeight?: number;
  20187. /**
  20188. * If multiview should be used if availible (default: false)
  20189. */
  20190. useMultiview?: boolean;
  20191. }
  20192. /**
  20193. * This represents a WebVR camera.
  20194. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20195. * @example http://doc.babylonjs.com/how_to/webvr_camera
  20196. */
  20197. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20198. private webVROptions;
  20199. /**
  20200. * @hidden
  20201. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20202. */
  20203. _vrDevice: any;
  20204. /**
  20205. * The rawPose of the vrDevice.
  20206. */
  20207. rawPose: Nullable<DevicePose>;
  20208. private _onVREnabled;
  20209. private _specsVersion;
  20210. private _attached;
  20211. private _frameData;
  20212. protected _descendants: Array<Node>;
  20213. private _deviceRoomPosition;
  20214. /** @hidden */
  20215. _deviceRoomRotationQuaternion: Quaternion;
  20216. private _standingMatrix;
  20217. /**
  20218. * Represents device position in babylon space.
  20219. */
  20220. devicePosition: Vector3;
  20221. /**
  20222. * Represents device rotation in babylon space.
  20223. */
  20224. deviceRotationQuaternion: Quaternion;
  20225. /**
  20226. * The scale of the device to be used when translating from device space to babylon space.
  20227. */
  20228. deviceScaleFactor: number;
  20229. private _deviceToWorld;
  20230. private _worldToDevice;
  20231. /**
  20232. * References to the webVR controllers for the vrDevice.
  20233. */
  20234. controllers: Array<WebVRController>;
  20235. /**
  20236. * Emits an event when a controller is attached.
  20237. */
  20238. onControllersAttachedObservable: Observable<WebVRController[]>;
  20239. /**
  20240. * Emits an event when a controller's mesh has been loaded;
  20241. */
  20242. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20243. /**
  20244. * Emits an event when the HMD's pose has been updated.
  20245. */
  20246. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20247. private _poseSet;
  20248. /**
  20249. * If the rig cameras be used as parent instead of this camera.
  20250. */
  20251. rigParenting: boolean;
  20252. private _lightOnControllers;
  20253. private _defaultHeight?;
  20254. /**
  20255. * Instantiates a WebVRFreeCamera.
  20256. * @param name The name of the WebVRFreeCamera
  20257. * @param position The starting anchor position for the camera
  20258. * @param scene The scene the camera belongs to
  20259. * @param webVROptions a set of customizable options for the webVRCamera
  20260. */
  20261. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20262. /**
  20263. * Gets the device distance from the ground in meters.
  20264. * @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.
  20265. */
  20266. deviceDistanceToRoomGround(): number;
  20267. /**
  20268. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20269. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20270. */
  20271. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20272. /**
  20273. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20274. * @returns A promise with a boolean set to if the standing matrix is supported.
  20275. */
  20276. useStandingMatrixAsync(): Promise<boolean>;
  20277. /**
  20278. * Disposes the camera
  20279. */
  20280. dispose(): void;
  20281. /**
  20282. * Gets a vrController by name.
  20283. * @param name The name of the controller to retreive
  20284. * @returns the controller matching the name specified or null if not found
  20285. */
  20286. getControllerByName(name: string): Nullable<WebVRController>;
  20287. private _leftController;
  20288. /**
  20289. * The controller corresponding to the users left hand.
  20290. */
  20291. get leftController(): Nullable<WebVRController>;
  20292. private _rightController;
  20293. /**
  20294. * The controller corresponding to the users right hand.
  20295. */
  20296. get rightController(): Nullable<WebVRController>;
  20297. /**
  20298. * Casts a ray forward from the vrCamera's gaze.
  20299. * @param length Length of the ray (default: 100)
  20300. * @returns the ray corresponding to the gaze
  20301. */
  20302. getForwardRay(length?: number): Ray;
  20303. /**
  20304. * @hidden
  20305. * Updates the camera based on device's frame data
  20306. */
  20307. _checkInputs(): void;
  20308. /**
  20309. * Updates the poseControlled values based on the input device pose.
  20310. * @param poseData Pose coming from the device
  20311. */
  20312. updateFromDevice(poseData: DevicePose): void;
  20313. private _htmlElementAttached;
  20314. private _detachIfAttached;
  20315. /**
  20316. * WebVR's attach control will start broadcasting frames to the device.
  20317. * Note that in certain browsers (chrome for example) this function must be called
  20318. * within a user-interaction callback. Example:
  20319. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20320. *
  20321. * @param element html element to attach the vrDevice to
  20322. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20323. */
  20324. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20325. /**
  20326. * Detaches the camera from the html element and disables VR
  20327. *
  20328. * @param element html element to detach from
  20329. */
  20330. detachControl(element: HTMLElement): void;
  20331. /**
  20332. * @returns the name of this class
  20333. */
  20334. getClassName(): string;
  20335. /**
  20336. * Calls resetPose on the vrDisplay
  20337. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20338. */
  20339. resetToCurrentRotation(): void;
  20340. /**
  20341. * @hidden
  20342. * Updates the rig cameras (left and right eye)
  20343. */
  20344. _updateRigCameras(): void;
  20345. private _workingVector;
  20346. private _oneVector;
  20347. private _workingMatrix;
  20348. private updateCacheCalled;
  20349. private _correctPositionIfNotTrackPosition;
  20350. /**
  20351. * @hidden
  20352. * Updates the cached values of the camera
  20353. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20354. */
  20355. _updateCache(ignoreParentClass?: boolean): void;
  20356. /**
  20357. * @hidden
  20358. * Get current device position in babylon world
  20359. */
  20360. _computeDevicePosition(): void;
  20361. /**
  20362. * Updates the current device position and rotation in the babylon world
  20363. */
  20364. update(): void;
  20365. /**
  20366. * @hidden
  20367. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20368. * @returns an identity matrix
  20369. */
  20370. _getViewMatrix(): Matrix;
  20371. private _tmpMatrix;
  20372. /**
  20373. * This function is called by the two RIG cameras.
  20374. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20375. * @hidden
  20376. */
  20377. _getWebVRViewMatrix(): Matrix;
  20378. /** @hidden */
  20379. _getWebVRProjectionMatrix(): Matrix;
  20380. private _onGamepadConnectedObserver;
  20381. private _onGamepadDisconnectedObserver;
  20382. private _updateCacheWhenTrackingDisabledObserver;
  20383. /**
  20384. * Initializes the controllers and their meshes
  20385. */
  20386. initControllers(): void;
  20387. }
  20388. }
  20389. declare module "babylonjs/PostProcesses/postProcess" {
  20390. import { Nullable } from "babylonjs/types";
  20391. import { SmartArray } from "babylonjs/Misc/smartArray";
  20392. import { Observable } from "babylonjs/Misc/observable";
  20393. import { Vector2 } from "babylonjs/Maths/math.vector";
  20394. import { Camera } from "babylonjs/Cameras/camera";
  20395. import { Effect } from "babylonjs/Materials/effect";
  20396. import "babylonjs/Shaders/postprocess.vertex";
  20397. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20398. import { Engine } from "babylonjs/Engines/engine";
  20399. import { Color4 } from "babylonjs/Maths/math.color";
  20400. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20401. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20402. /**
  20403. * Size options for a post process
  20404. */
  20405. export type PostProcessOptions = {
  20406. width: number;
  20407. height: number;
  20408. };
  20409. /**
  20410. * PostProcess can be used to apply a shader to a texture after it has been rendered
  20411. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20412. */
  20413. export class PostProcess {
  20414. /** Name of the PostProcess. */
  20415. name: string;
  20416. /**
  20417. * Gets or sets the unique id of the post process
  20418. */
  20419. uniqueId: number;
  20420. /**
  20421. * Width of the texture to apply the post process on
  20422. */
  20423. width: number;
  20424. /**
  20425. * Height of the texture to apply the post process on
  20426. */
  20427. height: number;
  20428. /**
  20429. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  20430. * @hidden
  20431. */
  20432. _outputTexture: Nullable<InternalTexture>;
  20433. /**
  20434. * Sampling mode used by the shader
  20435. * See https://doc.babylonjs.com/classes/3.1/texture
  20436. */
  20437. renderTargetSamplingMode: number;
  20438. /**
  20439. * Clear color to use when screen clearing
  20440. */
  20441. clearColor: Color4;
  20442. /**
  20443. * If the buffer needs to be cleared before applying the post process. (default: true)
  20444. * Should be set to false if shader will overwrite all previous pixels.
  20445. */
  20446. autoClear: boolean;
  20447. /**
  20448. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  20449. */
  20450. alphaMode: number;
  20451. /**
  20452. * Sets the setAlphaBlendConstants of the babylon engine
  20453. */
  20454. alphaConstants: Color4;
  20455. /**
  20456. * Animations to be used for the post processing
  20457. */
  20458. animations: import("babylonjs/Animations/animation").Animation[];
  20459. /**
  20460. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  20461. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  20462. */
  20463. enablePixelPerfectMode: boolean;
  20464. /**
  20465. * Force the postprocess to be applied without taking in account viewport
  20466. */
  20467. forceFullscreenViewport: boolean;
  20468. /**
  20469. * List of inspectable custom properties (used by the Inspector)
  20470. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20471. */
  20472. inspectableCustomProperties: IInspectable[];
  20473. /**
  20474. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  20475. *
  20476. * | Value | Type | Description |
  20477. * | ----- | ----------------------------------- | ----------- |
  20478. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  20479. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  20480. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  20481. *
  20482. */
  20483. scaleMode: number;
  20484. /**
  20485. * Force textures to be a power of two (default: false)
  20486. */
  20487. alwaysForcePOT: boolean;
  20488. private _samples;
  20489. /**
  20490. * Number of sample textures (default: 1)
  20491. */
  20492. get samples(): number;
  20493. set samples(n: number);
  20494. /**
  20495. * Modify the scale of the post process to be the same as the viewport (default: false)
  20496. */
  20497. adaptScaleToCurrentViewport: boolean;
  20498. private _camera;
  20499. private _scene;
  20500. private _engine;
  20501. private _options;
  20502. private _reusable;
  20503. private _textureType;
  20504. private _textureFormat;
  20505. /**
  20506. * Smart array of input and output textures for the post process.
  20507. * @hidden
  20508. */
  20509. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  20510. /**
  20511. * The index in _textures that corresponds to the output texture.
  20512. * @hidden
  20513. */
  20514. _currentRenderTextureInd: number;
  20515. private _effect;
  20516. private _samplers;
  20517. private _fragmentUrl;
  20518. private _vertexUrl;
  20519. private _parameters;
  20520. private _scaleRatio;
  20521. protected _indexParameters: any;
  20522. private _shareOutputWithPostProcess;
  20523. private _texelSize;
  20524. private _forcedOutputTexture;
  20525. /**
  20526. * Returns the fragment url or shader name used in the post process.
  20527. * @returns the fragment url or name in the shader store.
  20528. */
  20529. getEffectName(): string;
  20530. /**
  20531. * An event triggered when the postprocess is activated.
  20532. */
  20533. onActivateObservable: Observable<Camera>;
  20534. private _onActivateObserver;
  20535. /**
  20536. * A function that is added to the onActivateObservable
  20537. */
  20538. set onActivate(callback: Nullable<(camera: Camera) => void>);
  20539. /**
  20540. * An event triggered when the postprocess changes its size.
  20541. */
  20542. onSizeChangedObservable: Observable<PostProcess>;
  20543. private _onSizeChangedObserver;
  20544. /**
  20545. * A function that is added to the onSizeChangedObservable
  20546. */
  20547. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  20548. /**
  20549. * An event triggered when the postprocess applies its effect.
  20550. */
  20551. onApplyObservable: Observable<Effect>;
  20552. private _onApplyObserver;
  20553. /**
  20554. * A function that is added to the onApplyObservable
  20555. */
  20556. set onApply(callback: (effect: Effect) => void);
  20557. /**
  20558. * An event triggered before rendering the postprocess
  20559. */
  20560. onBeforeRenderObservable: Observable<Effect>;
  20561. private _onBeforeRenderObserver;
  20562. /**
  20563. * A function that is added to the onBeforeRenderObservable
  20564. */
  20565. set onBeforeRender(callback: (effect: Effect) => void);
  20566. /**
  20567. * An event triggered after rendering the postprocess
  20568. */
  20569. onAfterRenderObservable: Observable<Effect>;
  20570. private _onAfterRenderObserver;
  20571. /**
  20572. * A function that is added to the onAfterRenderObservable
  20573. */
  20574. set onAfterRender(callback: (efect: Effect) => void);
  20575. /**
  20576. * 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
  20577. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20578. */
  20579. get inputTexture(): InternalTexture;
  20580. set inputTexture(value: InternalTexture);
  20581. /**
  20582. * Gets the camera which post process is applied to.
  20583. * @returns The camera the post process is applied to.
  20584. */
  20585. getCamera(): Camera;
  20586. /**
  20587. * Gets the texel size of the postprocess.
  20588. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20589. */
  20590. get texelSize(): Vector2;
  20591. /**
  20592. * Creates a new instance PostProcess
  20593. * @param name The name of the PostProcess.
  20594. * @param fragmentUrl The url of the fragment shader to be used.
  20595. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20596. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20597. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20598. * @param camera The camera to apply the render pass to.
  20599. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20600. * @param engine The engine which the post process will be applied. (default: current engine)
  20601. * @param reusable If the post process can be reused on the same frame. (default: false)
  20602. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20603. * @param textureType Type of textures used when performing the post process. (default: 0)
  20604. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20605. * @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
  20606. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20607. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20608. */
  20609. constructor(
  20610. /** Name of the PostProcess. */
  20611. 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, textureFormat?: number);
  20612. /**
  20613. * Gets a string idenfifying the name of the class
  20614. * @returns "PostProcess" string
  20615. */
  20616. getClassName(): string;
  20617. /**
  20618. * Gets the engine which this post process belongs to.
  20619. * @returns The engine the post process was enabled with.
  20620. */
  20621. getEngine(): Engine;
  20622. /**
  20623. * The effect that is created when initializing the post process.
  20624. * @returns The created effect corresponding the the postprocess.
  20625. */
  20626. getEffect(): Effect;
  20627. /**
  20628. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20629. * @param postProcess The post process to share the output with.
  20630. * @returns This post process.
  20631. */
  20632. shareOutputWith(postProcess: PostProcess): PostProcess;
  20633. /**
  20634. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20635. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20636. */
  20637. useOwnOutput(): void;
  20638. /**
  20639. * Updates the effect with the current post process compile time values and recompiles the shader.
  20640. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20641. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20642. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20643. * @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
  20644. * @param onCompiled Called when the shader has been compiled.
  20645. * @param onError Called if there is an error when compiling a shader.
  20646. */
  20647. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20648. /**
  20649. * The post process is reusable if it can be used multiple times within one frame.
  20650. * @returns If the post process is reusable
  20651. */
  20652. isReusable(): boolean;
  20653. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20654. markTextureDirty(): void;
  20655. /**
  20656. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20657. * 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.
  20658. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20659. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20660. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20661. * @returns The target texture that was bound to be written to.
  20662. */
  20663. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20664. /**
  20665. * If the post process is supported.
  20666. */
  20667. get isSupported(): boolean;
  20668. /**
  20669. * The aspect ratio of the output texture.
  20670. */
  20671. get aspectRatio(): number;
  20672. /**
  20673. * Get a value indicating if the post-process is ready to be used
  20674. * @returns true if the post-process is ready (shader is compiled)
  20675. */
  20676. isReady(): boolean;
  20677. /**
  20678. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20679. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20680. */
  20681. apply(): Nullable<Effect>;
  20682. private _disposeTextures;
  20683. /**
  20684. * Disposes the post process.
  20685. * @param camera The camera to dispose the post process on.
  20686. */
  20687. dispose(camera?: Camera): void;
  20688. }
  20689. }
  20690. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  20691. /** @hidden */
  20692. export var kernelBlurVaryingDeclaration: {
  20693. name: string;
  20694. shader: string;
  20695. };
  20696. }
  20697. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  20698. /** @hidden */
  20699. export var kernelBlurFragment: {
  20700. name: string;
  20701. shader: string;
  20702. };
  20703. }
  20704. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  20705. /** @hidden */
  20706. export var kernelBlurFragment2: {
  20707. name: string;
  20708. shader: string;
  20709. };
  20710. }
  20711. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  20712. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20713. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  20714. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  20715. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  20716. /** @hidden */
  20717. export var kernelBlurPixelShader: {
  20718. name: string;
  20719. shader: string;
  20720. };
  20721. }
  20722. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  20723. /** @hidden */
  20724. export var kernelBlurVertex: {
  20725. name: string;
  20726. shader: string;
  20727. };
  20728. }
  20729. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  20730. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20731. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  20732. /** @hidden */
  20733. export var kernelBlurVertexShader: {
  20734. name: string;
  20735. shader: string;
  20736. };
  20737. }
  20738. declare module "babylonjs/PostProcesses/blurPostProcess" {
  20739. import { Vector2 } from "babylonjs/Maths/math.vector";
  20740. import { Nullable } from "babylonjs/types";
  20741. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  20742. import { Camera } from "babylonjs/Cameras/camera";
  20743. import { Effect } from "babylonjs/Materials/effect";
  20744. import { Engine } from "babylonjs/Engines/engine";
  20745. import "babylonjs/Shaders/kernelBlur.fragment";
  20746. import "babylonjs/Shaders/kernelBlur.vertex";
  20747. /**
  20748. * The Blur Post Process which blurs an image based on a kernel and direction.
  20749. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20750. */
  20751. export class BlurPostProcess extends PostProcess {
  20752. /** The direction in which to blur the image. */
  20753. direction: Vector2;
  20754. private blockCompilation;
  20755. protected _kernel: number;
  20756. protected _idealKernel: number;
  20757. protected _packedFloat: boolean;
  20758. private _staticDefines;
  20759. /**
  20760. * Sets the length in pixels of the blur sample region
  20761. */
  20762. set kernel(v: number);
  20763. /**
  20764. * Gets the length in pixels of the blur sample region
  20765. */
  20766. get kernel(): number;
  20767. /**
  20768. * Sets wether or not the blur needs to unpack/repack floats
  20769. */
  20770. set packedFloat(v: boolean);
  20771. /**
  20772. * Gets wether or not the blur is unpacking/repacking floats
  20773. */
  20774. get packedFloat(): boolean;
  20775. /**
  20776. * Creates a new instance BlurPostProcess
  20777. * @param name The name of the effect.
  20778. * @param direction The direction in which to blur the image.
  20779. * @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.
  20780. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20781. * @param camera The camera to apply the render pass to.
  20782. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20783. * @param engine The engine which the post process will be applied. (default: current engine)
  20784. * @param reusable If the post process can be reused on the same frame. (default: false)
  20785. * @param textureType Type of textures used when performing the post process. (default: 0)
  20786. * @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)
  20787. */
  20788. constructor(name: string,
  20789. /** The direction in which to blur the image. */
  20790. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20791. /**
  20792. * Updates the effect with the current post process compile time values and recompiles the shader.
  20793. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20794. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20795. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20796. * @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
  20797. * @param onCompiled Called when the shader has been compiled.
  20798. * @param onError Called if there is an error when compiling a shader.
  20799. */
  20800. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20801. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20802. /**
  20803. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20804. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20805. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20806. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20807. * The gaps between physical kernels are compensated for in the weighting of the samples
  20808. * @param idealKernel Ideal blur kernel.
  20809. * @return Nearest best kernel.
  20810. */
  20811. protected _nearestBestKernel(idealKernel: number): number;
  20812. /**
  20813. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20814. * @param x The point on the Gaussian distribution to sample.
  20815. * @return the value of the Gaussian function at x.
  20816. */
  20817. protected _gaussianWeight(x: number): number;
  20818. /**
  20819. * Generates a string that can be used as a floating point number in GLSL.
  20820. * @param x Value to print.
  20821. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20822. * @return GLSL float string.
  20823. */
  20824. protected _glslFloat(x: number, decimalFigures?: number): string;
  20825. }
  20826. }
  20827. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  20828. import { Scene } from "babylonjs/scene";
  20829. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20830. import { Plane } from "babylonjs/Maths/math.plane";
  20831. /**
  20832. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20833. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20834. * You can then easily use it as a reflectionTexture on a flat surface.
  20835. * In case the surface is not a plane, please consider relying on reflection probes.
  20836. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20837. */
  20838. export class MirrorTexture extends RenderTargetTexture {
  20839. private scene;
  20840. /**
  20841. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20842. * 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.
  20843. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20844. */
  20845. mirrorPlane: Plane;
  20846. /**
  20847. * Define the blur ratio used to blur the reflection if needed.
  20848. */
  20849. set blurRatio(value: number);
  20850. get blurRatio(): number;
  20851. /**
  20852. * Define the adaptive blur kernel used to blur the reflection if needed.
  20853. * This will autocompute the closest best match for the `blurKernel`
  20854. */
  20855. set adaptiveBlurKernel(value: number);
  20856. /**
  20857. * Define the blur kernel used to blur the reflection if needed.
  20858. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20859. */
  20860. set blurKernel(value: number);
  20861. /**
  20862. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20863. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20864. */
  20865. set blurKernelX(value: number);
  20866. get blurKernelX(): number;
  20867. /**
  20868. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20869. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20870. */
  20871. set blurKernelY(value: number);
  20872. get blurKernelY(): number;
  20873. private _autoComputeBlurKernel;
  20874. protected _onRatioRescale(): void;
  20875. private _updateGammaSpace;
  20876. private _imageProcessingConfigChangeObserver;
  20877. private _transformMatrix;
  20878. private _mirrorMatrix;
  20879. private _savedViewMatrix;
  20880. private _blurX;
  20881. private _blurY;
  20882. private _adaptiveBlurKernel;
  20883. private _blurKernelX;
  20884. private _blurKernelY;
  20885. private _blurRatio;
  20886. /**
  20887. * Instantiates a Mirror Texture.
  20888. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20889. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20890. * You can then easily use it as a reflectionTexture on a flat surface.
  20891. * In case the surface is not a plane, please consider relying on reflection probes.
  20892. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20893. * @param name
  20894. * @param size
  20895. * @param scene
  20896. * @param generateMipMaps
  20897. * @param type
  20898. * @param samplingMode
  20899. * @param generateDepthBuffer
  20900. */
  20901. constructor(name: string, size: number | {
  20902. width: number;
  20903. height: number;
  20904. } | {
  20905. ratio: number;
  20906. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20907. private _preparePostProcesses;
  20908. /**
  20909. * Clone the mirror texture.
  20910. * @returns the cloned texture
  20911. */
  20912. clone(): MirrorTexture;
  20913. /**
  20914. * Serialize the texture to a JSON representation you could use in Parse later on
  20915. * @returns the serialized JSON representation
  20916. */
  20917. serialize(): any;
  20918. /**
  20919. * Dispose the texture and release its associated resources.
  20920. */
  20921. dispose(): void;
  20922. }
  20923. }
  20924. declare module "babylonjs/Materials/Textures/texture" {
  20925. import { Observable } from "babylonjs/Misc/observable";
  20926. import { Nullable } from "babylonjs/types";
  20927. import { Matrix } from "babylonjs/Maths/math.vector";
  20928. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20929. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20930. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  20931. import { Scene } from "babylonjs/scene";
  20932. /**
  20933. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20934. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20935. */
  20936. export class Texture extends BaseTexture {
  20937. /**
  20938. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20939. */
  20940. static SerializeBuffers: boolean;
  20941. /** @hidden */
  20942. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  20943. /** @hidden */
  20944. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  20945. /** @hidden */
  20946. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  20947. /** nearest is mag = nearest and min = nearest and mip = linear */
  20948. static readonly NEAREST_SAMPLINGMODE: number;
  20949. /** nearest is mag = nearest and min = nearest and mip = linear */
  20950. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20951. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20952. static readonly BILINEAR_SAMPLINGMODE: number;
  20953. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20954. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20955. /** Trilinear is mag = linear and min = linear and mip = linear */
  20956. static readonly TRILINEAR_SAMPLINGMODE: number;
  20957. /** Trilinear is mag = linear and min = linear and mip = linear */
  20958. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20959. /** mag = nearest and min = nearest and mip = nearest */
  20960. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20961. /** mag = nearest and min = linear and mip = nearest */
  20962. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20963. /** mag = nearest and min = linear and mip = linear */
  20964. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20965. /** mag = nearest and min = linear and mip = none */
  20966. static readonly NEAREST_LINEAR: number;
  20967. /** mag = nearest and min = nearest and mip = none */
  20968. static readonly NEAREST_NEAREST: number;
  20969. /** mag = linear and min = nearest and mip = nearest */
  20970. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20971. /** mag = linear and min = nearest and mip = linear */
  20972. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20973. /** mag = linear and min = linear and mip = none */
  20974. static readonly LINEAR_LINEAR: number;
  20975. /** mag = linear and min = nearest and mip = none */
  20976. static readonly LINEAR_NEAREST: number;
  20977. /** Explicit coordinates mode */
  20978. static readonly EXPLICIT_MODE: number;
  20979. /** Spherical coordinates mode */
  20980. static readonly SPHERICAL_MODE: number;
  20981. /** Planar coordinates mode */
  20982. static readonly PLANAR_MODE: number;
  20983. /** Cubic coordinates mode */
  20984. static readonly CUBIC_MODE: number;
  20985. /** Projection coordinates mode */
  20986. static readonly PROJECTION_MODE: number;
  20987. /** Inverse Cubic coordinates mode */
  20988. static readonly SKYBOX_MODE: number;
  20989. /** Inverse Cubic coordinates mode */
  20990. static readonly INVCUBIC_MODE: number;
  20991. /** Equirectangular coordinates mode */
  20992. static readonly EQUIRECTANGULAR_MODE: number;
  20993. /** Equirectangular Fixed coordinates mode */
  20994. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20995. /** Equirectangular Fixed Mirrored coordinates mode */
  20996. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20997. /** Texture is not repeating outside of 0..1 UVs */
  20998. static readonly CLAMP_ADDRESSMODE: number;
  20999. /** Texture is repeating outside of 0..1 UVs */
  21000. static readonly WRAP_ADDRESSMODE: number;
  21001. /** Texture is repeating and mirrored */
  21002. static readonly MIRROR_ADDRESSMODE: number;
  21003. /**
  21004. * 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
  21005. */
  21006. static UseSerializedUrlIfAny: boolean;
  21007. /**
  21008. * Define the url of the texture.
  21009. */
  21010. url: Nullable<string>;
  21011. /**
  21012. * Define an offset on the texture to offset the u coordinates of the UVs
  21013. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  21014. */
  21015. uOffset: number;
  21016. /**
  21017. * Define an offset on the texture to offset the v coordinates of the UVs
  21018. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  21019. */
  21020. vOffset: number;
  21021. /**
  21022. * Define an offset on the texture to scale the u coordinates of the UVs
  21023. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  21024. */
  21025. uScale: number;
  21026. /**
  21027. * Define an offset on the texture to scale the v coordinates of the UVs
  21028. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  21029. */
  21030. vScale: number;
  21031. /**
  21032. * Define an offset on the texture to rotate around the u coordinates of the UVs
  21033. * @see http://doc.babylonjs.com/how_to/more_materials
  21034. */
  21035. uAng: number;
  21036. /**
  21037. * Define an offset on the texture to rotate around the v coordinates of the UVs
  21038. * @see http://doc.babylonjs.com/how_to/more_materials
  21039. */
  21040. vAng: number;
  21041. /**
  21042. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  21043. * @see http://doc.babylonjs.com/how_to/more_materials
  21044. */
  21045. wAng: number;
  21046. /**
  21047. * Defines the center of rotation (U)
  21048. */
  21049. uRotationCenter: number;
  21050. /**
  21051. * Defines the center of rotation (V)
  21052. */
  21053. vRotationCenter: number;
  21054. /**
  21055. * Defines the center of rotation (W)
  21056. */
  21057. wRotationCenter: number;
  21058. /**
  21059. * Are mip maps generated for this texture or not.
  21060. */
  21061. get noMipmap(): boolean;
  21062. /**
  21063. * List of inspectable custom properties (used by the Inspector)
  21064. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21065. */
  21066. inspectableCustomProperties: Nullable<IInspectable[]>;
  21067. private _noMipmap;
  21068. /** @hidden */
  21069. _invertY: boolean;
  21070. private _rowGenerationMatrix;
  21071. private _cachedTextureMatrix;
  21072. private _projectionModeMatrix;
  21073. private _t0;
  21074. private _t1;
  21075. private _t2;
  21076. private _cachedUOffset;
  21077. private _cachedVOffset;
  21078. private _cachedUScale;
  21079. private _cachedVScale;
  21080. private _cachedUAng;
  21081. private _cachedVAng;
  21082. private _cachedWAng;
  21083. private _cachedProjectionMatrixId;
  21084. private _cachedCoordinatesMode;
  21085. /** @hidden */
  21086. protected _initialSamplingMode: number;
  21087. /** @hidden */
  21088. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  21089. private _deleteBuffer;
  21090. protected _format: Nullable<number>;
  21091. private _delayedOnLoad;
  21092. private _delayedOnError;
  21093. private _mimeType?;
  21094. /**
  21095. * Observable triggered once the texture has been loaded.
  21096. */
  21097. onLoadObservable: Observable<Texture>;
  21098. protected _isBlocking: boolean;
  21099. /**
  21100. * Is the texture preventing material to render while loading.
  21101. * If false, a default texture will be used instead of the loading one during the preparation step.
  21102. */
  21103. set isBlocking(value: boolean);
  21104. get isBlocking(): boolean;
  21105. /**
  21106. * Get the current sampling mode associated with the texture.
  21107. */
  21108. get samplingMode(): number;
  21109. /**
  21110. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  21111. */
  21112. get invertY(): boolean;
  21113. /**
  21114. * Instantiates a new texture.
  21115. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  21116. * @see http://doc.babylonjs.com/babylon101/materials#texture
  21117. * @param url defines the url of the picture to load as a texture
  21118. * @param scene defines the scene or engine the texture will belong to
  21119. * @param noMipmap defines if the texture will require mip maps or not
  21120. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  21121. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21122. * @param onLoad defines a callback triggered when the texture has been loaded
  21123. * @param onError defines a callback triggered when an error occurred during the loading session
  21124. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  21125. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  21126. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21127. * @param mimeType defines an optional mime type information
  21128. */
  21129. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  21130. /**
  21131. * Update the url (and optional buffer) of this texture if url was null during construction.
  21132. * @param url the url of the texture
  21133. * @param buffer the buffer of the texture (defaults to null)
  21134. * @param onLoad callback called when the texture is loaded (defaults to null)
  21135. */
  21136. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  21137. /**
  21138. * Finish the loading sequence of a texture flagged as delayed load.
  21139. * @hidden
  21140. */
  21141. delayLoad(): void;
  21142. private _prepareRowForTextureGeneration;
  21143. /**
  21144. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  21145. * @returns the transform matrix of the texture.
  21146. */
  21147. getTextureMatrix(uBase?: number): Matrix;
  21148. /**
  21149. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  21150. * @returns The reflection texture transform
  21151. */
  21152. getReflectionTextureMatrix(): Matrix;
  21153. /**
  21154. * Clones the texture.
  21155. * @returns the cloned texture
  21156. */
  21157. clone(): Texture;
  21158. /**
  21159. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21160. * @returns The JSON representation of the texture
  21161. */
  21162. serialize(): any;
  21163. /**
  21164. * Get the current class name of the texture useful for serialization or dynamic coding.
  21165. * @returns "Texture"
  21166. */
  21167. getClassName(): string;
  21168. /**
  21169. * Dispose the texture and release its associated resources.
  21170. */
  21171. dispose(): void;
  21172. /**
  21173. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  21174. * @param parsedTexture Define the JSON representation of the texture
  21175. * @param scene Define the scene the parsed texture should be instantiated in
  21176. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  21177. * @returns The parsed texture if successful
  21178. */
  21179. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  21180. /**
  21181. * Creates a texture from its base 64 representation.
  21182. * @param data Define the base64 payload without the data: prefix
  21183. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  21184. * @param scene Define the scene the texture should belong to
  21185. * @param noMipmap Forces the texture to not create mip map information if true
  21186. * @param invertY define if the texture needs to be inverted on the y axis during loading
  21187. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21188. * @param onLoad define a callback triggered when the texture has been loaded
  21189. * @param onError define a callback triggered when an error occurred during the loading session
  21190. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21191. * @returns the created texture
  21192. */
  21193. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  21194. /**
  21195. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  21196. * @param data Define the base64 payload without the data: prefix
  21197. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  21198. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  21199. * @param scene Define the scene the texture should belong to
  21200. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  21201. * @param noMipmap Forces the texture to not create mip map information if true
  21202. * @param invertY define if the texture needs to be inverted on the y axis during loading
  21203. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21204. * @param onLoad define a callback triggered when the texture has been loaded
  21205. * @param onError define a callback triggered when an error occurred during the loading session
  21206. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21207. * @returns the created texture
  21208. */
  21209. 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;
  21210. }
  21211. }
  21212. declare module "babylonjs/PostProcesses/postProcessManager" {
  21213. import { Nullable } from "babylonjs/types";
  21214. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21215. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21216. import { Scene } from "babylonjs/scene";
  21217. /**
  21218. * PostProcessManager is used to manage one or more post processes or post process pipelines
  21219. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  21220. */
  21221. export class PostProcessManager {
  21222. private _scene;
  21223. private _indexBuffer;
  21224. private _vertexBuffers;
  21225. /**
  21226. * Creates a new instance PostProcess
  21227. * @param scene The scene that the post process is associated with.
  21228. */
  21229. constructor(scene: Scene);
  21230. private _prepareBuffers;
  21231. private _buildIndexBuffer;
  21232. /**
  21233. * Rebuilds the vertex buffers of the manager.
  21234. * @hidden
  21235. */
  21236. _rebuild(): void;
  21237. /**
  21238. * Prepares a frame to be run through a post process.
  21239. * @param sourceTexture The input texture to the post procesess. (default: null)
  21240. * @param postProcesses An array of post processes to be run. (default: null)
  21241. * @returns True if the post processes were able to be run.
  21242. * @hidden
  21243. */
  21244. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  21245. /**
  21246. * Manually render a set of post processes to a texture.
  21247. * @param postProcesses An array of post processes to be run.
  21248. * @param targetTexture The target texture to render to.
  21249. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  21250. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  21251. * @param lodLevel defines which lod of the texture to render to
  21252. */
  21253. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  21254. /**
  21255. * Finalize the result of the output of the postprocesses.
  21256. * @param doNotPresent If true the result will not be displayed to the screen.
  21257. * @param targetTexture The target texture to render to.
  21258. * @param faceIndex The index of the face to bind the target texture to.
  21259. * @param postProcesses The array of post processes to render.
  21260. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  21261. * @hidden
  21262. */
  21263. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  21264. /**
  21265. * Disposes of the post process manager.
  21266. */
  21267. dispose(): void;
  21268. }
  21269. }
  21270. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  21271. import { Observable } from "babylonjs/Misc/observable";
  21272. import { SmartArray } from "babylonjs/Misc/smartArray";
  21273. import { Nullable, Immutable } from "babylonjs/types";
  21274. import { Camera } from "babylonjs/Cameras/camera";
  21275. import { Scene } from "babylonjs/scene";
  21276. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21277. import { Color4 } from "babylonjs/Maths/math.color";
  21278. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  21279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21280. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21281. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21282. import { Texture } from "babylonjs/Materials/Textures/texture";
  21283. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21284. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  21285. import "babylonjs/Engines/Extensions/engine.renderTarget";
  21286. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  21287. import { Engine } from "babylonjs/Engines/engine";
  21288. /**
  21289. * This Helps creating a texture that will be created from a camera in your scene.
  21290. * It is basically a dynamic texture that could be used to create special effects for instance.
  21291. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21292. */
  21293. export class RenderTargetTexture extends Texture {
  21294. isCube: boolean;
  21295. /**
  21296. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21297. */
  21298. static readonly REFRESHRATE_RENDER_ONCE: number;
  21299. /**
  21300. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21301. */
  21302. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21303. /**
  21304. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21305. * the central point of your effect and can save a lot of performances.
  21306. */
  21307. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21308. /**
  21309. * Use this predicate to dynamically define the list of mesh you want to render.
  21310. * If set, the renderList property will be overwritten.
  21311. */
  21312. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21313. private _renderList;
  21314. /**
  21315. * Use this list to define the list of mesh you want to render.
  21316. */
  21317. get renderList(): Nullable<Array<AbstractMesh>>;
  21318. set renderList(value: Nullable<Array<AbstractMesh>>);
  21319. /**
  21320. * Use this function to overload the renderList array at rendering time.
  21321. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  21322. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  21323. * the cube (if the RTT is a cube, else layerOrFace=0).
  21324. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  21325. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  21326. * hold dummy elements!
  21327. */
  21328. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  21329. private _hookArray;
  21330. /**
  21331. * Define if particles should be rendered in your texture.
  21332. */
  21333. renderParticles: boolean;
  21334. /**
  21335. * Define if sprites should be rendered in your texture.
  21336. */
  21337. renderSprites: boolean;
  21338. /**
  21339. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21340. */
  21341. coordinatesMode: number;
  21342. /**
  21343. * Define the camera used to render the texture.
  21344. */
  21345. activeCamera: Nullable<Camera>;
  21346. /**
  21347. * Override the mesh isReady function with your own one.
  21348. */
  21349. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  21350. /**
  21351. * Override the render function of the texture with your own one.
  21352. */
  21353. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21354. /**
  21355. * Define if camera post processes should be use while rendering the texture.
  21356. */
  21357. useCameraPostProcesses: boolean;
  21358. /**
  21359. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21360. */
  21361. ignoreCameraViewport: boolean;
  21362. private _postProcessManager;
  21363. private _postProcesses;
  21364. private _resizeObserver;
  21365. /**
  21366. * An event triggered when the texture is unbind.
  21367. */
  21368. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21369. /**
  21370. * An event triggered when the texture is unbind.
  21371. */
  21372. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21373. private _onAfterUnbindObserver;
  21374. /**
  21375. * Set a after unbind callback in the texture.
  21376. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21377. */
  21378. set onAfterUnbind(callback: () => void);
  21379. /**
  21380. * An event triggered before rendering the texture
  21381. */
  21382. onBeforeRenderObservable: Observable<number>;
  21383. private _onBeforeRenderObserver;
  21384. /**
  21385. * Set a before render callback in the texture.
  21386. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21387. */
  21388. set onBeforeRender(callback: (faceIndex: number) => void);
  21389. /**
  21390. * An event triggered after rendering the texture
  21391. */
  21392. onAfterRenderObservable: Observable<number>;
  21393. private _onAfterRenderObserver;
  21394. /**
  21395. * Set a after render callback in the texture.
  21396. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21397. */
  21398. set onAfterRender(callback: (faceIndex: number) => void);
  21399. /**
  21400. * An event triggered after the texture clear
  21401. */
  21402. onClearObservable: Observable<Engine>;
  21403. private _onClearObserver;
  21404. /**
  21405. * Set a clear callback in the texture.
  21406. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21407. */
  21408. set onClear(callback: (Engine: Engine) => void);
  21409. /**
  21410. * An event triggered when the texture is resized.
  21411. */
  21412. onResizeObservable: Observable<RenderTargetTexture>;
  21413. /**
  21414. * Define the clear color of the Render Target if it should be different from the scene.
  21415. */
  21416. clearColor: Color4;
  21417. protected _size: number | {
  21418. width: number;
  21419. height: number;
  21420. layers?: number;
  21421. };
  21422. protected _initialSizeParameter: number | {
  21423. width: number;
  21424. height: number;
  21425. } | {
  21426. ratio: number;
  21427. };
  21428. protected _sizeRatio: Nullable<number>;
  21429. /** @hidden */
  21430. _generateMipMaps: boolean;
  21431. protected _renderingManager: RenderingManager;
  21432. /** @hidden */
  21433. _waitingRenderList: string[];
  21434. protected _doNotChangeAspectRatio: boolean;
  21435. protected _currentRefreshId: number;
  21436. protected _refreshRate: number;
  21437. protected _textureMatrix: Matrix;
  21438. protected _samples: number;
  21439. protected _renderTargetOptions: RenderTargetCreationOptions;
  21440. /**
  21441. * Gets render target creation options that were used.
  21442. */
  21443. get renderTargetOptions(): RenderTargetCreationOptions;
  21444. protected _engine: Engine;
  21445. protected _onRatioRescale(): void;
  21446. /**
  21447. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21448. * It must define where the camera used to render the texture is set
  21449. */
  21450. boundingBoxPosition: Vector3;
  21451. private _boundingBoxSize;
  21452. /**
  21453. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21454. * When defined, the cubemap will switch to local mode
  21455. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21456. * @example https://www.babylonjs-playground.com/#RNASML
  21457. */
  21458. set boundingBoxSize(value: Vector3);
  21459. get boundingBoxSize(): Vector3;
  21460. /**
  21461. * In case the RTT has been created with a depth texture, get the associated
  21462. * depth texture.
  21463. * Otherwise, return null.
  21464. */
  21465. get depthStencilTexture(): Nullable<InternalTexture>;
  21466. /**
  21467. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21468. * or used a shadow, depth texture...
  21469. * @param name The friendly name of the texture
  21470. * @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)
  21471. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21472. * @param generateMipMaps True if mip maps need to be generated after render.
  21473. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21474. * @param type The type of the buffer in the RTT (int, half float, float...)
  21475. * @param isCube True if a cube texture needs to be created
  21476. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21477. * @param generateDepthBuffer True to generate a depth buffer
  21478. * @param generateStencilBuffer True to generate a stencil buffer
  21479. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21480. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21481. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21482. */
  21483. constructor(name: string, size: number | {
  21484. width: number;
  21485. height: number;
  21486. layers?: number;
  21487. } | {
  21488. ratio: number;
  21489. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21490. /**
  21491. * Creates a depth stencil texture.
  21492. * This is only available in WebGL 2 or with the depth texture extension available.
  21493. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21494. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21495. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21496. */
  21497. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21498. private _processSizeParameter;
  21499. /**
  21500. * Define the number of samples to use in case of MSAA.
  21501. * It defaults to one meaning no MSAA has been enabled.
  21502. */
  21503. get samples(): number;
  21504. set samples(value: number);
  21505. /**
  21506. * Resets the refresh counter of the texture and start bak from scratch.
  21507. * Could be useful to regenerate the texture if it is setup to render only once.
  21508. */
  21509. resetRefreshCounter(): void;
  21510. /**
  21511. * Define the refresh rate of the texture or the rendering frequency.
  21512. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21513. */
  21514. get refreshRate(): number;
  21515. set refreshRate(value: number);
  21516. /**
  21517. * Adds a post process to the render target rendering passes.
  21518. * @param postProcess define the post process to add
  21519. */
  21520. addPostProcess(postProcess: PostProcess): void;
  21521. /**
  21522. * Clear all the post processes attached to the render target
  21523. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21524. */
  21525. clearPostProcesses(dispose?: boolean): void;
  21526. /**
  21527. * Remove one of the post process from the list of attached post processes to the texture
  21528. * @param postProcess define the post process to remove from the list
  21529. */
  21530. removePostProcess(postProcess: PostProcess): void;
  21531. /** @hidden */
  21532. _shouldRender(): boolean;
  21533. /**
  21534. * Gets the actual render size of the texture.
  21535. * @returns the width of the render size
  21536. */
  21537. getRenderSize(): number;
  21538. /**
  21539. * Gets the actual render width of the texture.
  21540. * @returns the width of the render size
  21541. */
  21542. getRenderWidth(): number;
  21543. /**
  21544. * Gets the actual render height of the texture.
  21545. * @returns the height of the render size
  21546. */
  21547. getRenderHeight(): number;
  21548. /**
  21549. * Gets the actual number of layers of the texture.
  21550. * @returns the number of layers
  21551. */
  21552. getRenderLayers(): number;
  21553. /**
  21554. * Get if the texture can be rescaled or not.
  21555. */
  21556. get canRescale(): boolean;
  21557. /**
  21558. * Resize the texture using a ratio.
  21559. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21560. */
  21561. scale(ratio: number): void;
  21562. /**
  21563. * Get the texture reflection matrix used to rotate/transform the reflection.
  21564. * @returns the reflection matrix
  21565. */
  21566. getReflectionTextureMatrix(): Matrix;
  21567. /**
  21568. * Resize the texture to a new desired size.
  21569. * Be carrefull as it will recreate all the data in the new texture.
  21570. * @param size Define the new size. It can be:
  21571. * - a number for squared texture,
  21572. * - an object containing { width: number, height: number }
  21573. * - or an object containing a ratio { ratio: number }
  21574. */
  21575. resize(size: number | {
  21576. width: number;
  21577. height: number;
  21578. } | {
  21579. ratio: number;
  21580. }): void;
  21581. private _defaultRenderListPrepared;
  21582. /**
  21583. * Renders all the objects from the render list into the texture.
  21584. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21585. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21586. */
  21587. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21588. private _bestReflectionRenderTargetDimension;
  21589. private _prepareRenderingManager;
  21590. /**
  21591. * @hidden
  21592. * @param faceIndex face index to bind to if this is a cubetexture
  21593. * @param layer defines the index of the texture to bind in the array
  21594. */
  21595. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21596. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21597. private renderToTarget;
  21598. /**
  21599. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21600. * This allowed control for front to back rendering or reversly depending of the special needs.
  21601. *
  21602. * @param renderingGroupId The rendering group id corresponding to its index
  21603. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21604. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21605. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21606. */
  21607. 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;
  21608. /**
  21609. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21610. *
  21611. * @param renderingGroupId The rendering group id corresponding to its index
  21612. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21613. */
  21614. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21615. /**
  21616. * Clones the texture.
  21617. * @returns the cloned texture
  21618. */
  21619. clone(): RenderTargetTexture;
  21620. /**
  21621. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21622. * @returns The JSON representation of the texture
  21623. */
  21624. serialize(): any;
  21625. /**
  21626. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21627. */
  21628. disposeFramebufferObjects(): void;
  21629. /**
  21630. * Dispose the texture and release its associated resources.
  21631. */
  21632. dispose(): void;
  21633. /** @hidden */
  21634. _rebuild(): void;
  21635. /**
  21636. * Clear the info related to rendering groups preventing retention point in material dispose.
  21637. */
  21638. freeRenderingGroups(): void;
  21639. /**
  21640. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21641. * @returns the view count
  21642. */
  21643. getViewCount(): number;
  21644. }
  21645. }
  21646. declare module "babylonjs/Misc/guid" {
  21647. /**
  21648. * Class used to manipulate GUIDs
  21649. */
  21650. export class GUID {
  21651. /**
  21652. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21653. * Be aware Math.random() could cause collisions, but:
  21654. * "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"
  21655. * @returns a pseudo random id
  21656. */
  21657. static RandomId(): string;
  21658. }
  21659. }
  21660. declare module "babylonjs/Materials/shadowDepthWrapper" {
  21661. import { Nullable } from "babylonjs/types";
  21662. import { Scene } from "babylonjs/scene";
  21663. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21664. import { Material } from "babylonjs/Materials/material";
  21665. import { Effect } from "babylonjs/Materials/effect";
  21666. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  21667. /**
  21668. * Options to be used when creating a shadow depth material
  21669. */
  21670. export interface IIOptionShadowDepthMaterial {
  21671. /** Variables in the vertex shader code that need to have their names remapped.
  21672. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  21673. * "var_name" should be either: worldPos or vNormalW
  21674. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  21675. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  21676. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  21677. */
  21678. remappedVariables?: string[];
  21679. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  21680. standalone?: boolean;
  21681. }
  21682. /**
  21683. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  21684. */
  21685. export class ShadowDepthWrapper {
  21686. private _scene;
  21687. private _options?;
  21688. private _baseMaterial;
  21689. private _onEffectCreatedObserver;
  21690. private _subMeshToEffect;
  21691. private _subMeshToDepthEffect;
  21692. private _meshes;
  21693. /** @hidden */
  21694. _matriceNames: any;
  21695. /** Gets the standalone status of the wrapper */
  21696. get standalone(): boolean;
  21697. /** Gets the base material the wrapper is built upon */
  21698. get baseMaterial(): Material;
  21699. /**
  21700. * Instantiate a new shadow depth wrapper.
  21701. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  21702. * generate the shadow depth map. For more information, please refer to the documentation:
  21703. * https://doc.babylonjs.com/babylon101/shadows
  21704. * @param baseMaterial Material to wrap
  21705. * @param scene Define the scene the material belongs to
  21706. * @param options Options used to create the wrapper
  21707. */
  21708. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  21709. /**
  21710. * Gets the effect to use to generate the depth map
  21711. * @param subMesh subMesh to get the effect for
  21712. * @param shadowGenerator shadow generator to get the effect for
  21713. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  21714. */
  21715. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  21716. /**
  21717. * Specifies that the submesh is ready to be used for depth rendering
  21718. * @param subMesh submesh to check
  21719. * @param defines the list of defines to take into account when checking the effect
  21720. * @param shadowGenerator combined with subMesh, it defines the effect to check
  21721. * @param useInstances specifies that instances should be used
  21722. * @returns a boolean indicating that the submesh is ready or not
  21723. */
  21724. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  21725. /**
  21726. * Disposes the resources
  21727. */
  21728. dispose(): void;
  21729. private _makeEffect;
  21730. }
  21731. }
  21732. declare module "babylonjs/Materials/material" {
  21733. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21734. import { SmartArray } from "babylonjs/Misc/smartArray";
  21735. import { Observable } from "babylonjs/Misc/observable";
  21736. import { Nullable } from "babylonjs/types";
  21737. import { Scene } from "babylonjs/scene";
  21738. import { Matrix } from "babylonjs/Maths/math.vector";
  21739. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21740. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21741. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21742. import { Effect } from "babylonjs/Materials/effect";
  21743. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21744. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21745. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21746. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21747. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  21748. import { Mesh } from "babylonjs/Meshes/mesh";
  21749. import { Animation } from "babylonjs/Animations/animation";
  21750. /**
  21751. * Options for compiling materials.
  21752. */
  21753. export interface IMaterialCompilationOptions {
  21754. /**
  21755. * Defines whether clip planes are enabled.
  21756. */
  21757. clipPlane: boolean;
  21758. /**
  21759. * Defines whether instances are enabled.
  21760. */
  21761. useInstances: boolean;
  21762. }
  21763. /**
  21764. * Base class for the main features of a material in Babylon.js
  21765. */
  21766. export class Material implements IAnimatable {
  21767. /**
  21768. * Returns the triangle fill mode
  21769. */
  21770. static readonly TriangleFillMode: number;
  21771. /**
  21772. * Returns the wireframe mode
  21773. */
  21774. static readonly WireFrameFillMode: number;
  21775. /**
  21776. * Returns the point fill mode
  21777. */
  21778. static readonly PointFillMode: number;
  21779. /**
  21780. * Returns the point list draw mode
  21781. */
  21782. static readonly PointListDrawMode: number;
  21783. /**
  21784. * Returns the line list draw mode
  21785. */
  21786. static readonly LineListDrawMode: number;
  21787. /**
  21788. * Returns the line loop draw mode
  21789. */
  21790. static readonly LineLoopDrawMode: number;
  21791. /**
  21792. * Returns the line strip draw mode
  21793. */
  21794. static readonly LineStripDrawMode: number;
  21795. /**
  21796. * Returns the triangle strip draw mode
  21797. */
  21798. static readonly TriangleStripDrawMode: number;
  21799. /**
  21800. * Returns the triangle fan draw mode
  21801. */
  21802. static readonly TriangleFanDrawMode: number;
  21803. /**
  21804. * Stores the clock-wise side orientation
  21805. */
  21806. static readonly ClockWiseSideOrientation: number;
  21807. /**
  21808. * Stores the counter clock-wise side orientation
  21809. */
  21810. static readonly CounterClockWiseSideOrientation: number;
  21811. /**
  21812. * The dirty texture flag value
  21813. */
  21814. static readonly TextureDirtyFlag: number;
  21815. /**
  21816. * The dirty light flag value
  21817. */
  21818. static readonly LightDirtyFlag: number;
  21819. /**
  21820. * The dirty fresnel flag value
  21821. */
  21822. static readonly FresnelDirtyFlag: number;
  21823. /**
  21824. * The dirty attribute flag value
  21825. */
  21826. static readonly AttributesDirtyFlag: number;
  21827. /**
  21828. * The dirty misc flag value
  21829. */
  21830. static readonly MiscDirtyFlag: number;
  21831. /**
  21832. * The all dirty flag value
  21833. */
  21834. static readonly AllDirtyFlag: number;
  21835. /**
  21836. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21837. */
  21838. static readonly MATERIAL_OPAQUE: number;
  21839. /**
  21840. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21841. */
  21842. static readonly MATERIAL_ALPHATEST: number;
  21843. /**
  21844. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21845. */
  21846. static readonly MATERIAL_ALPHABLEND: number;
  21847. /**
  21848. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21849. * They are also discarded below the alpha cutoff threshold to improve performances.
  21850. */
  21851. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21852. /**
  21853. * Custom callback helping to override the default shader used in the material.
  21854. */
  21855. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  21856. /**
  21857. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  21858. */
  21859. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  21860. /**
  21861. * The ID of the material
  21862. */
  21863. id: string;
  21864. /**
  21865. * Gets or sets the unique id of the material
  21866. */
  21867. uniqueId: number;
  21868. /**
  21869. * The name of the material
  21870. */
  21871. name: string;
  21872. /**
  21873. * Gets or sets user defined metadata
  21874. */
  21875. metadata: any;
  21876. /**
  21877. * For internal use only. Please do not use.
  21878. */
  21879. reservedDataStore: any;
  21880. /**
  21881. * Specifies if the ready state should be checked on each call
  21882. */
  21883. checkReadyOnEveryCall: boolean;
  21884. /**
  21885. * Specifies if the ready state should be checked once
  21886. */
  21887. checkReadyOnlyOnce: boolean;
  21888. /**
  21889. * The state of the material
  21890. */
  21891. state: string;
  21892. /**
  21893. * The alpha value of the material
  21894. */
  21895. protected _alpha: number;
  21896. /**
  21897. * List of inspectable custom properties (used by the Inspector)
  21898. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21899. */
  21900. inspectableCustomProperties: IInspectable[];
  21901. /**
  21902. * Sets the alpha value of the material
  21903. */
  21904. set alpha(value: number);
  21905. /**
  21906. * Gets the alpha value of the material
  21907. */
  21908. get alpha(): number;
  21909. /**
  21910. * Specifies if back face culling is enabled
  21911. */
  21912. protected _backFaceCulling: boolean;
  21913. /**
  21914. * Sets the back-face culling state
  21915. */
  21916. set backFaceCulling(value: boolean);
  21917. /**
  21918. * Gets the back-face culling state
  21919. */
  21920. get backFaceCulling(): boolean;
  21921. /**
  21922. * Stores the value for side orientation
  21923. */
  21924. sideOrientation: number;
  21925. /**
  21926. * Callback triggered when the material is compiled
  21927. */
  21928. onCompiled: Nullable<(effect: Effect) => void>;
  21929. /**
  21930. * Callback triggered when an error occurs
  21931. */
  21932. onError: Nullable<(effect: Effect, errors: string) => void>;
  21933. /**
  21934. * Callback triggered to get the render target textures
  21935. */
  21936. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21937. /**
  21938. * Gets a boolean indicating that current material needs to register RTT
  21939. */
  21940. get hasRenderTargetTextures(): boolean;
  21941. /**
  21942. * Specifies if the material should be serialized
  21943. */
  21944. doNotSerialize: boolean;
  21945. /**
  21946. * @hidden
  21947. */
  21948. _storeEffectOnSubMeshes: boolean;
  21949. /**
  21950. * Stores the animations for the material
  21951. */
  21952. animations: Nullable<Array<Animation>>;
  21953. /**
  21954. * An event triggered when the material is disposed
  21955. */
  21956. onDisposeObservable: Observable<Material>;
  21957. /**
  21958. * An observer which watches for dispose events
  21959. */
  21960. private _onDisposeObserver;
  21961. private _onUnBindObservable;
  21962. /**
  21963. * Called during a dispose event
  21964. */
  21965. set onDispose(callback: () => void);
  21966. private _onBindObservable;
  21967. /**
  21968. * An event triggered when the material is bound
  21969. */
  21970. get onBindObservable(): Observable<AbstractMesh>;
  21971. /**
  21972. * An observer which watches for bind events
  21973. */
  21974. private _onBindObserver;
  21975. /**
  21976. * Called during a bind event
  21977. */
  21978. set onBind(callback: (Mesh: AbstractMesh) => void);
  21979. /**
  21980. * An event triggered when the material is unbound
  21981. */
  21982. get onUnBindObservable(): Observable<Material>;
  21983. protected _onEffectCreatedObservable: Nullable<Observable<{
  21984. effect: Effect;
  21985. subMesh: Nullable<SubMesh>;
  21986. }>>;
  21987. /**
  21988. * An event triggered when the effect is (re)created
  21989. */
  21990. get onEffectCreatedObservable(): Observable<{
  21991. effect: Effect;
  21992. subMesh: Nullable<SubMesh>;
  21993. }>;
  21994. /**
  21995. * Stores the value of the alpha mode
  21996. */
  21997. private _alphaMode;
  21998. /**
  21999. * Sets the value of the alpha mode.
  22000. *
  22001. * | Value | Type | Description |
  22002. * | --- | --- | --- |
  22003. * | 0 | ALPHA_DISABLE | |
  22004. * | 1 | ALPHA_ADD | |
  22005. * | 2 | ALPHA_COMBINE | |
  22006. * | 3 | ALPHA_SUBTRACT | |
  22007. * | 4 | ALPHA_MULTIPLY | |
  22008. * | 5 | ALPHA_MAXIMIZED | |
  22009. * | 6 | ALPHA_ONEONE | |
  22010. * | 7 | ALPHA_PREMULTIPLIED | |
  22011. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22012. * | 9 | ALPHA_INTERPOLATE | |
  22013. * | 10 | ALPHA_SCREENMODE | |
  22014. *
  22015. */
  22016. set alphaMode(value: number);
  22017. /**
  22018. * Gets the value of the alpha mode
  22019. */
  22020. get alphaMode(): number;
  22021. /**
  22022. * Stores the state of the need depth pre-pass value
  22023. */
  22024. private _needDepthPrePass;
  22025. /**
  22026. * Sets the need depth pre-pass value
  22027. */
  22028. set needDepthPrePass(value: boolean);
  22029. /**
  22030. * Gets the depth pre-pass value
  22031. */
  22032. get needDepthPrePass(): boolean;
  22033. /**
  22034. * Specifies if depth writing should be disabled
  22035. */
  22036. disableDepthWrite: boolean;
  22037. /**
  22038. * Specifies if color writing should be disabled
  22039. */
  22040. disableColorWrite: boolean;
  22041. /**
  22042. * Specifies if depth writing should be forced
  22043. */
  22044. forceDepthWrite: boolean;
  22045. /**
  22046. * Specifies the depth function that should be used. 0 means the default engine function
  22047. */
  22048. depthFunction: number;
  22049. /**
  22050. * Specifies if there should be a separate pass for culling
  22051. */
  22052. separateCullingPass: boolean;
  22053. /**
  22054. * Stores the state specifing if fog should be enabled
  22055. */
  22056. private _fogEnabled;
  22057. /**
  22058. * Sets the state for enabling fog
  22059. */
  22060. set fogEnabled(value: boolean);
  22061. /**
  22062. * Gets the value of the fog enabled state
  22063. */
  22064. get fogEnabled(): boolean;
  22065. /**
  22066. * Stores the size of points
  22067. */
  22068. pointSize: number;
  22069. /**
  22070. * Stores the z offset value
  22071. */
  22072. zOffset: number;
  22073. /**
  22074. * Gets a value specifying if wireframe mode is enabled
  22075. */
  22076. get wireframe(): boolean;
  22077. /**
  22078. * Sets the state of wireframe mode
  22079. */
  22080. set wireframe(value: boolean);
  22081. /**
  22082. * Gets the value specifying if point clouds are enabled
  22083. */
  22084. get pointsCloud(): boolean;
  22085. /**
  22086. * Sets the state of point cloud mode
  22087. */
  22088. set pointsCloud(value: boolean);
  22089. /**
  22090. * Gets the material fill mode
  22091. */
  22092. get fillMode(): number;
  22093. /**
  22094. * Sets the material fill mode
  22095. */
  22096. set fillMode(value: number);
  22097. /**
  22098. * @hidden
  22099. * Stores the effects for the material
  22100. */
  22101. _effect: Nullable<Effect>;
  22102. /**
  22103. * Specifies if uniform buffers should be used
  22104. */
  22105. private _useUBO;
  22106. /**
  22107. * Stores a reference to the scene
  22108. */
  22109. private _scene;
  22110. /**
  22111. * Stores the fill mode state
  22112. */
  22113. private _fillMode;
  22114. /**
  22115. * Specifies if the depth write state should be cached
  22116. */
  22117. private _cachedDepthWriteState;
  22118. /**
  22119. * Specifies if the color write state should be cached
  22120. */
  22121. private _cachedColorWriteState;
  22122. /**
  22123. * Specifies if the depth function state should be cached
  22124. */
  22125. private _cachedDepthFunctionState;
  22126. /**
  22127. * Stores the uniform buffer
  22128. */
  22129. protected _uniformBuffer: UniformBuffer;
  22130. /** @hidden */
  22131. _indexInSceneMaterialArray: number;
  22132. /** @hidden */
  22133. meshMap: Nullable<{
  22134. [id: string]: AbstractMesh | undefined;
  22135. }>;
  22136. /**
  22137. * Creates a material instance
  22138. * @param name defines the name of the material
  22139. * @param scene defines the scene to reference
  22140. * @param doNotAdd specifies if the material should be added to the scene
  22141. */
  22142. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22143. /**
  22144. * Returns a string representation of the current material
  22145. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22146. * @returns a string with material information
  22147. */
  22148. toString(fullDetails?: boolean): string;
  22149. /**
  22150. * Gets the class name of the material
  22151. * @returns a string with the class name of the material
  22152. */
  22153. getClassName(): string;
  22154. /**
  22155. * Specifies if updates for the material been locked
  22156. */
  22157. get isFrozen(): boolean;
  22158. /**
  22159. * Locks updates for the material
  22160. */
  22161. freeze(): void;
  22162. /**
  22163. * Unlocks updates for the material
  22164. */
  22165. unfreeze(): void;
  22166. /**
  22167. * Specifies if the material is ready to be used
  22168. * @param mesh defines the mesh to check
  22169. * @param useInstances specifies if instances should be used
  22170. * @returns a boolean indicating if the material is ready to be used
  22171. */
  22172. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22173. /**
  22174. * Specifies that the submesh is ready to be used
  22175. * @param mesh defines the mesh to check
  22176. * @param subMesh defines which submesh to check
  22177. * @param useInstances specifies that instances should be used
  22178. * @returns a boolean indicating that the submesh is ready or not
  22179. */
  22180. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22181. /**
  22182. * Returns the material effect
  22183. * @returns the effect associated with the material
  22184. */
  22185. getEffect(): Nullable<Effect>;
  22186. /**
  22187. * Returns the current scene
  22188. * @returns a Scene
  22189. */
  22190. getScene(): Scene;
  22191. /**
  22192. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22193. */
  22194. protected _forceAlphaTest: boolean;
  22195. /**
  22196. * The transparency mode of the material.
  22197. */
  22198. protected _transparencyMode: Nullable<number>;
  22199. /**
  22200. * Gets the current transparency mode.
  22201. */
  22202. get transparencyMode(): Nullable<number>;
  22203. /**
  22204. * Sets the transparency mode of the material.
  22205. *
  22206. * | Value | Type | Description |
  22207. * | ----- | ----------------------------------- | ----------- |
  22208. * | 0 | OPAQUE | |
  22209. * | 1 | ALPHATEST | |
  22210. * | 2 | ALPHABLEND | |
  22211. * | 3 | ALPHATESTANDBLEND | |
  22212. *
  22213. */
  22214. set transparencyMode(value: Nullable<number>);
  22215. /**
  22216. * Returns true if alpha blending should be disabled.
  22217. */
  22218. protected get _disableAlphaBlending(): boolean;
  22219. /**
  22220. * Specifies whether or not this material should be rendered in alpha blend mode.
  22221. * @returns a boolean specifying if alpha blending is needed
  22222. */
  22223. needAlphaBlending(): boolean;
  22224. /**
  22225. * Specifies if the mesh will require alpha blending
  22226. * @param mesh defines the mesh to check
  22227. * @returns a boolean specifying if alpha blending is needed for the mesh
  22228. */
  22229. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22230. /**
  22231. * Specifies whether or not this material should be rendered in alpha test mode.
  22232. * @returns a boolean specifying if an alpha test is needed.
  22233. */
  22234. needAlphaTesting(): boolean;
  22235. /**
  22236. * Specifies if material alpha testing should be turned on for the mesh
  22237. * @param mesh defines the mesh to check
  22238. */
  22239. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22240. /**
  22241. * Gets the texture used for the alpha test
  22242. * @returns the texture to use for alpha testing
  22243. */
  22244. getAlphaTestTexture(): Nullable<BaseTexture>;
  22245. /**
  22246. * Marks the material to indicate that it needs to be re-calculated
  22247. */
  22248. markDirty(): void;
  22249. /** @hidden */
  22250. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22251. /**
  22252. * Binds the material to the mesh
  22253. * @param world defines the world transformation matrix
  22254. * @param mesh defines the mesh to bind the material to
  22255. */
  22256. bind(world: Matrix, mesh?: Mesh): void;
  22257. /**
  22258. * Binds the submesh to the material
  22259. * @param world defines the world transformation matrix
  22260. * @param mesh defines the mesh containing the submesh
  22261. * @param subMesh defines the submesh to bind the material to
  22262. */
  22263. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22264. /**
  22265. * Binds the world matrix to the material
  22266. * @param world defines the world transformation matrix
  22267. */
  22268. bindOnlyWorldMatrix(world: Matrix): void;
  22269. /**
  22270. * Binds the scene's uniform buffer to the effect.
  22271. * @param effect defines the effect to bind to the scene uniform buffer
  22272. * @param sceneUbo defines the uniform buffer storing scene data
  22273. */
  22274. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22275. /**
  22276. * Binds the view matrix to the effect
  22277. * @param effect defines the effect to bind the view matrix to
  22278. */
  22279. bindView(effect: Effect): void;
  22280. /**
  22281. * Binds the view projection matrix to the effect
  22282. * @param effect defines the effect to bind the view projection matrix to
  22283. */
  22284. bindViewProjection(effect: Effect): void;
  22285. /**
  22286. * Processes to execute after binding the material to a mesh
  22287. * @param mesh defines the rendered mesh
  22288. */
  22289. protected _afterBind(mesh?: Mesh): void;
  22290. /**
  22291. * Unbinds the material from the mesh
  22292. */
  22293. unbind(): void;
  22294. /**
  22295. * Gets the active textures from the material
  22296. * @returns an array of textures
  22297. */
  22298. getActiveTextures(): BaseTexture[];
  22299. /**
  22300. * Specifies if the material uses a texture
  22301. * @param texture defines the texture to check against the material
  22302. * @returns a boolean specifying if the material uses the texture
  22303. */
  22304. hasTexture(texture: BaseTexture): boolean;
  22305. /**
  22306. * Makes a duplicate of the material, and gives it a new name
  22307. * @param name defines the new name for the duplicated material
  22308. * @returns the cloned material
  22309. */
  22310. clone(name: string): Nullable<Material>;
  22311. /**
  22312. * Gets the meshes bound to the material
  22313. * @returns an array of meshes bound to the material
  22314. */
  22315. getBindedMeshes(): AbstractMesh[];
  22316. /**
  22317. * Force shader compilation
  22318. * @param mesh defines the mesh associated with this material
  22319. * @param onCompiled defines a function to execute once the material is compiled
  22320. * @param options defines the options to configure the compilation
  22321. * @param onError defines a function to execute if the material fails compiling
  22322. */
  22323. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  22324. /**
  22325. * Force shader compilation
  22326. * @param mesh defines the mesh that will use this material
  22327. * @param options defines additional options for compiling the shaders
  22328. * @returns a promise that resolves when the compilation completes
  22329. */
  22330. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  22331. private static readonly _AllDirtyCallBack;
  22332. private static readonly _ImageProcessingDirtyCallBack;
  22333. private static readonly _TextureDirtyCallBack;
  22334. private static readonly _FresnelDirtyCallBack;
  22335. private static readonly _MiscDirtyCallBack;
  22336. private static readonly _LightsDirtyCallBack;
  22337. private static readonly _AttributeDirtyCallBack;
  22338. private static _FresnelAndMiscDirtyCallBack;
  22339. private static _TextureAndMiscDirtyCallBack;
  22340. private static readonly _DirtyCallbackArray;
  22341. private static readonly _RunDirtyCallBacks;
  22342. /**
  22343. * Marks a define in the material to indicate that it needs to be re-computed
  22344. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22345. */
  22346. markAsDirty(flag: number): void;
  22347. /**
  22348. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22349. * @param func defines a function which checks material defines against the submeshes
  22350. */
  22351. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22352. /**
  22353. * Indicates that we need to re-calculated for all submeshes
  22354. */
  22355. protected _markAllSubMeshesAsAllDirty(): void;
  22356. /**
  22357. * Indicates that image processing needs to be re-calculated for all submeshes
  22358. */
  22359. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22360. /**
  22361. * Indicates that textures need to be re-calculated for all submeshes
  22362. */
  22363. protected _markAllSubMeshesAsTexturesDirty(): void;
  22364. /**
  22365. * Indicates that fresnel needs to be re-calculated for all submeshes
  22366. */
  22367. protected _markAllSubMeshesAsFresnelDirty(): void;
  22368. /**
  22369. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22370. */
  22371. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22372. /**
  22373. * Indicates that lights need to be re-calculated for all submeshes
  22374. */
  22375. protected _markAllSubMeshesAsLightsDirty(): void;
  22376. /**
  22377. * Indicates that attributes need to be re-calculated for all submeshes
  22378. */
  22379. protected _markAllSubMeshesAsAttributesDirty(): void;
  22380. /**
  22381. * Indicates that misc needs to be re-calculated for all submeshes
  22382. */
  22383. protected _markAllSubMeshesAsMiscDirty(): void;
  22384. /**
  22385. * Indicates that textures and misc need to be re-calculated for all submeshes
  22386. */
  22387. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22388. /**
  22389. * Disposes the material
  22390. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22391. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22392. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22393. */
  22394. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22395. /** @hidden */
  22396. private releaseVertexArrayObject;
  22397. /**
  22398. * Serializes this material
  22399. * @returns the serialized material object
  22400. */
  22401. serialize(): any;
  22402. /**
  22403. * Creates a material from parsed material data
  22404. * @param parsedMaterial defines parsed material data
  22405. * @param scene defines the hosting scene
  22406. * @param rootUrl defines the root URL to use to load textures
  22407. * @returns a new material
  22408. */
  22409. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22410. }
  22411. }
  22412. declare module "babylonjs/Materials/multiMaterial" {
  22413. import { Nullable } from "babylonjs/types";
  22414. import { Scene } from "babylonjs/scene";
  22415. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22416. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  22417. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22418. import { Material } from "babylonjs/Materials/material";
  22419. /**
  22420. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22421. * separate meshes. This can be use to improve performances.
  22422. * @see http://doc.babylonjs.com/how_to/multi_materials
  22423. */
  22424. export class MultiMaterial extends Material {
  22425. private _subMaterials;
  22426. /**
  22427. * Gets or Sets the list of Materials used within the multi material.
  22428. * They need to be ordered according to the submeshes order in the associated mesh
  22429. */
  22430. get subMaterials(): Nullable<Material>[];
  22431. set subMaterials(value: Nullable<Material>[]);
  22432. /**
  22433. * Function used to align with Node.getChildren()
  22434. * @returns the list of Materials used within the multi material
  22435. */
  22436. getChildren(): Nullable<Material>[];
  22437. /**
  22438. * Instantiates a new Multi Material
  22439. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22440. * separate meshes. This can be use to improve performances.
  22441. * @see http://doc.babylonjs.com/how_to/multi_materials
  22442. * @param name Define the name in the scene
  22443. * @param scene Define the scene the material belongs to
  22444. */
  22445. constructor(name: string, scene: Scene);
  22446. private _hookArray;
  22447. /**
  22448. * Get one of the submaterial by its index in the submaterials array
  22449. * @param index The index to look the sub material at
  22450. * @returns The Material if the index has been defined
  22451. */
  22452. getSubMaterial(index: number): Nullable<Material>;
  22453. /**
  22454. * Get the list of active textures for the whole sub materials list.
  22455. * @returns All the textures that will be used during the rendering
  22456. */
  22457. getActiveTextures(): BaseTexture[];
  22458. /**
  22459. * Gets the current class name of the material e.g. "MultiMaterial"
  22460. * Mainly use in serialization.
  22461. * @returns the class name
  22462. */
  22463. getClassName(): string;
  22464. /**
  22465. * Checks if the material is ready to render the requested sub mesh
  22466. * @param mesh Define the mesh the submesh belongs to
  22467. * @param subMesh Define the sub mesh to look readyness for
  22468. * @param useInstances Define whether or not the material is used with instances
  22469. * @returns true if ready, otherwise false
  22470. */
  22471. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22472. /**
  22473. * Clones the current material and its related sub materials
  22474. * @param name Define the name of the newly cloned material
  22475. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  22476. * @returns the cloned material
  22477. */
  22478. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  22479. /**
  22480. * Serializes the materials into a JSON representation.
  22481. * @returns the JSON representation
  22482. */
  22483. serialize(): any;
  22484. /**
  22485. * Dispose the material and release its associated resources
  22486. * @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)
  22487. * @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)
  22488. * @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)
  22489. */
  22490. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  22491. /**
  22492. * Creates a MultiMaterial from parsed MultiMaterial data.
  22493. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22494. * @param scene defines the hosting scene
  22495. * @returns a new MultiMaterial
  22496. */
  22497. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22498. }
  22499. }
  22500. declare module "babylonjs/Meshes/subMesh" {
  22501. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  22502. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  22503. import { Engine } from "babylonjs/Engines/engine";
  22504. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22505. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22506. import { Effect } from "babylonjs/Materials/effect";
  22507. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22508. import { Plane } from "babylonjs/Maths/math.plane";
  22509. import { Collider } from "babylonjs/Collisions/collider";
  22510. import { Material } from "babylonjs/Materials/material";
  22511. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22512. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22513. import { Mesh } from "babylonjs/Meshes/mesh";
  22514. import { Ray } from "babylonjs/Culling/ray";
  22515. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22516. /**
  22517. * Base class for submeshes
  22518. */
  22519. export class BaseSubMesh {
  22520. /** @hidden */
  22521. _materialDefines: Nullable<MaterialDefines>;
  22522. /** @hidden */
  22523. _materialEffect: Nullable<Effect>;
  22524. /** @hidden */
  22525. _effectOverride: Nullable<Effect>;
  22526. /**
  22527. * Gets material defines used by the effect associated to the sub mesh
  22528. */
  22529. get materialDefines(): Nullable<MaterialDefines>;
  22530. /**
  22531. * Sets material defines used by the effect associated to the sub mesh
  22532. */
  22533. set materialDefines(defines: Nullable<MaterialDefines>);
  22534. /**
  22535. * Gets associated effect
  22536. */
  22537. get effect(): Nullable<Effect>;
  22538. /**
  22539. * Sets associated effect (effect used to render this submesh)
  22540. * @param effect defines the effect to associate with
  22541. * @param defines defines the set of defines used to compile this effect
  22542. */
  22543. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22544. }
  22545. /**
  22546. * Defines a subdivision inside a mesh
  22547. */
  22548. export class SubMesh extends BaseSubMesh implements ICullable {
  22549. /** the material index to use */
  22550. materialIndex: number;
  22551. /** vertex index start */
  22552. verticesStart: number;
  22553. /** vertices count */
  22554. verticesCount: number;
  22555. /** index start */
  22556. indexStart: number;
  22557. /** indices count */
  22558. indexCount: number;
  22559. /** @hidden */
  22560. _linesIndexCount: number;
  22561. private _mesh;
  22562. private _renderingMesh;
  22563. private _boundingInfo;
  22564. private _linesIndexBuffer;
  22565. /** @hidden */
  22566. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22567. /** @hidden */
  22568. _trianglePlanes: Plane[];
  22569. /** @hidden */
  22570. _lastColliderTransformMatrix: Nullable<Matrix>;
  22571. /** @hidden */
  22572. _renderId: number;
  22573. /** @hidden */
  22574. _alphaIndex: number;
  22575. /** @hidden */
  22576. _distanceToCamera: number;
  22577. /** @hidden */
  22578. _id: number;
  22579. private _currentMaterial;
  22580. /**
  22581. * Add a new submesh to a mesh
  22582. * @param materialIndex defines the material index to use
  22583. * @param verticesStart defines vertex index start
  22584. * @param verticesCount defines vertices count
  22585. * @param indexStart defines index start
  22586. * @param indexCount defines indices count
  22587. * @param mesh defines the parent mesh
  22588. * @param renderingMesh defines an optional rendering mesh
  22589. * @param createBoundingBox defines if bounding box should be created for this submesh
  22590. * @returns the new submesh
  22591. */
  22592. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22593. /**
  22594. * Creates a new submesh
  22595. * @param materialIndex defines the material index to use
  22596. * @param verticesStart defines vertex index start
  22597. * @param verticesCount defines vertices count
  22598. * @param indexStart defines index start
  22599. * @param indexCount defines indices count
  22600. * @param mesh defines the parent mesh
  22601. * @param renderingMesh defines an optional rendering mesh
  22602. * @param createBoundingBox defines if bounding box should be created for this submesh
  22603. */
  22604. constructor(
  22605. /** the material index to use */
  22606. materialIndex: number,
  22607. /** vertex index start */
  22608. verticesStart: number,
  22609. /** vertices count */
  22610. verticesCount: number,
  22611. /** index start */
  22612. indexStart: number,
  22613. /** indices count */
  22614. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22615. /**
  22616. * Returns true if this submesh covers the entire parent mesh
  22617. * @ignorenaming
  22618. */
  22619. get IsGlobal(): boolean;
  22620. /**
  22621. * Returns the submesh BoudingInfo object
  22622. * @returns current bounding info (or mesh's one if the submesh is global)
  22623. */
  22624. getBoundingInfo(): BoundingInfo;
  22625. /**
  22626. * Sets the submesh BoundingInfo
  22627. * @param boundingInfo defines the new bounding info to use
  22628. * @returns the SubMesh
  22629. */
  22630. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22631. /**
  22632. * Returns the mesh of the current submesh
  22633. * @return the parent mesh
  22634. */
  22635. getMesh(): AbstractMesh;
  22636. /**
  22637. * Returns the rendering mesh of the submesh
  22638. * @returns the rendering mesh (could be different from parent mesh)
  22639. */
  22640. getRenderingMesh(): Mesh;
  22641. /**
  22642. * Returns the submesh material
  22643. * @returns null or the current material
  22644. */
  22645. getMaterial(): Nullable<Material>;
  22646. /**
  22647. * Sets a new updated BoundingInfo object to the submesh
  22648. * @param data defines an optional position array to use to determine the bounding info
  22649. * @returns the SubMesh
  22650. */
  22651. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22652. /** @hidden */
  22653. _checkCollision(collider: Collider): boolean;
  22654. /**
  22655. * Updates the submesh BoundingInfo
  22656. * @param world defines the world matrix to use to update the bounding info
  22657. * @returns the submesh
  22658. */
  22659. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22660. /**
  22661. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22662. * @param frustumPlanes defines the frustum planes
  22663. * @returns true if the submesh is intersecting with the frustum
  22664. */
  22665. isInFrustum(frustumPlanes: Plane[]): boolean;
  22666. /**
  22667. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22668. * @param frustumPlanes defines the frustum planes
  22669. * @returns true if the submesh is inside the frustum
  22670. */
  22671. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22672. /**
  22673. * Renders the submesh
  22674. * @param enableAlphaMode defines if alpha needs to be used
  22675. * @returns the submesh
  22676. */
  22677. render(enableAlphaMode: boolean): SubMesh;
  22678. /**
  22679. * @hidden
  22680. */
  22681. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22682. /**
  22683. * Checks if the submesh intersects with a ray
  22684. * @param ray defines the ray to test
  22685. * @returns true is the passed ray intersects the submesh bounding box
  22686. */
  22687. canIntersects(ray: Ray): boolean;
  22688. /**
  22689. * Intersects current submesh with a ray
  22690. * @param ray defines the ray to test
  22691. * @param positions defines mesh's positions array
  22692. * @param indices defines mesh's indices array
  22693. * @param fastCheck defines if the first intersection will be used (and not the closest)
  22694. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22695. * @returns intersection info or null if no intersection
  22696. */
  22697. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22698. /** @hidden */
  22699. private _intersectLines;
  22700. /** @hidden */
  22701. private _intersectUnIndexedLines;
  22702. /** @hidden */
  22703. private _intersectTriangles;
  22704. /** @hidden */
  22705. private _intersectUnIndexedTriangles;
  22706. /** @hidden */
  22707. _rebuild(): void;
  22708. /**
  22709. * Creates a new submesh from the passed mesh
  22710. * @param newMesh defines the new hosting mesh
  22711. * @param newRenderingMesh defines an optional rendering mesh
  22712. * @returns the new submesh
  22713. */
  22714. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22715. /**
  22716. * Release associated resources
  22717. */
  22718. dispose(): void;
  22719. /**
  22720. * Gets the class name
  22721. * @returns the string "SubMesh".
  22722. */
  22723. getClassName(): string;
  22724. /**
  22725. * Creates a new submesh from indices data
  22726. * @param materialIndex the index of the main mesh material
  22727. * @param startIndex the index where to start the copy in the mesh indices array
  22728. * @param indexCount the number of indices to copy then from the startIndex
  22729. * @param mesh the main mesh to create the submesh from
  22730. * @param renderingMesh the optional rendering mesh
  22731. * @returns a new submesh
  22732. */
  22733. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22734. }
  22735. }
  22736. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22737. /**
  22738. * Class used to represent data loading progression
  22739. */
  22740. export class SceneLoaderFlags {
  22741. private static _ForceFullSceneLoadingForIncremental;
  22742. private static _ShowLoadingScreen;
  22743. private static _CleanBoneMatrixWeights;
  22744. private static _loggingLevel;
  22745. /**
  22746. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22747. */
  22748. static get ForceFullSceneLoadingForIncremental(): boolean;
  22749. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22750. /**
  22751. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22752. */
  22753. static get ShowLoadingScreen(): boolean;
  22754. static set ShowLoadingScreen(value: boolean);
  22755. /**
  22756. * Defines the current logging level (while loading the scene)
  22757. * @ignorenaming
  22758. */
  22759. static get loggingLevel(): number;
  22760. static set loggingLevel(value: number);
  22761. /**
  22762. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22763. */
  22764. static get CleanBoneMatrixWeights(): boolean;
  22765. static set CleanBoneMatrixWeights(value: boolean);
  22766. }
  22767. }
  22768. declare module "babylonjs/Meshes/geometry" {
  22769. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22770. import { Scene } from "babylonjs/scene";
  22771. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22772. import { Engine } from "babylonjs/Engines/engine";
  22773. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22774. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22775. import { Effect } from "babylonjs/Materials/effect";
  22776. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22777. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22778. import { Mesh } from "babylonjs/Meshes/mesh";
  22779. /**
  22780. * Class used to store geometry data (vertex buffers + index buffer)
  22781. */
  22782. export class Geometry implements IGetSetVerticesData {
  22783. /**
  22784. * Gets or sets the ID of the geometry
  22785. */
  22786. id: string;
  22787. /**
  22788. * Gets or sets the unique ID of the geometry
  22789. */
  22790. uniqueId: number;
  22791. /**
  22792. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22793. */
  22794. delayLoadState: number;
  22795. /**
  22796. * Gets the file containing the data to load when running in delay load state
  22797. */
  22798. delayLoadingFile: Nullable<string>;
  22799. /**
  22800. * Callback called when the geometry is updated
  22801. */
  22802. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22803. private _scene;
  22804. private _engine;
  22805. private _meshes;
  22806. private _totalVertices;
  22807. /** @hidden */
  22808. _indices: IndicesArray;
  22809. /** @hidden */
  22810. _vertexBuffers: {
  22811. [key: string]: VertexBuffer;
  22812. };
  22813. private _isDisposed;
  22814. private _extend;
  22815. private _boundingBias;
  22816. /** @hidden */
  22817. _delayInfo: Array<string>;
  22818. private _indexBuffer;
  22819. private _indexBufferIsUpdatable;
  22820. /** @hidden */
  22821. _boundingInfo: Nullable<BoundingInfo>;
  22822. /** @hidden */
  22823. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22824. /** @hidden */
  22825. _softwareSkinningFrameId: number;
  22826. private _vertexArrayObjects;
  22827. private _updatable;
  22828. /** @hidden */
  22829. _positions: Nullable<Vector3[]>;
  22830. /**
  22831. * 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
  22832. */
  22833. get boundingBias(): Vector2;
  22834. /**
  22835. * 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
  22836. */
  22837. set boundingBias(value: Vector2);
  22838. /**
  22839. * Static function used to attach a new empty geometry to a mesh
  22840. * @param mesh defines the mesh to attach the geometry to
  22841. * @returns the new Geometry
  22842. */
  22843. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22844. /** Get the list of meshes using this geometry */
  22845. get meshes(): Mesh[];
  22846. /**
  22847. * Creates a new geometry
  22848. * @param id defines the unique ID
  22849. * @param scene defines the hosting scene
  22850. * @param vertexData defines the VertexData used to get geometry data
  22851. * @param updatable defines if geometry must be updatable (false by default)
  22852. * @param mesh defines the mesh that will be associated with the geometry
  22853. */
  22854. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22855. /**
  22856. * Gets the current extend of the geometry
  22857. */
  22858. get extend(): {
  22859. minimum: Vector3;
  22860. maximum: Vector3;
  22861. };
  22862. /**
  22863. * Gets the hosting scene
  22864. * @returns the hosting Scene
  22865. */
  22866. getScene(): Scene;
  22867. /**
  22868. * Gets the hosting engine
  22869. * @returns the hosting Engine
  22870. */
  22871. getEngine(): Engine;
  22872. /**
  22873. * Defines if the geometry is ready to use
  22874. * @returns true if the geometry is ready to be used
  22875. */
  22876. isReady(): boolean;
  22877. /**
  22878. * Gets a value indicating that the geometry should not be serialized
  22879. */
  22880. get doNotSerialize(): boolean;
  22881. /** @hidden */
  22882. _rebuild(): void;
  22883. /**
  22884. * Affects all geometry data in one call
  22885. * @param vertexData defines the geometry data
  22886. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22887. */
  22888. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22889. /**
  22890. * Set specific vertex data
  22891. * @param kind defines the data kind (Position, normal, etc...)
  22892. * @param data defines the vertex data to use
  22893. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22894. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22895. */
  22896. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22897. /**
  22898. * Removes a specific vertex data
  22899. * @param kind defines the data kind (Position, normal, etc...)
  22900. */
  22901. removeVerticesData(kind: string): void;
  22902. /**
  22903. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22904. * @param buffer defines the vertex buffer to use
  22905. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22906. */
  22907. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22908. /**
  22909. * Update a specific vertex buffer
  22910. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22911. * It will do nothing if the buffer is not updatable
  22912. * @param kind defines the data kind (Position, normal, etc...)
  22913. * @param data defines the data to use
  22914. * @param offset defines the offset in the target buffer where to store the data
  22915. * @param useBytes set to true if the offset is in bytes
  22916. */
  22917. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22918. /**
  22919. * Update a specific vertex buffer
  22920. * This function will create a new buffer if the current one is not updatable
  22921. * @param kind defines the data kind (Position, normal, etc...)
  22922. * @param data defines the data to use
  22923. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22924. */
  22925. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22926. private _updateBoundingInfo;
  22927. /** @hidden */
  22928. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22929. /**
  22930. * Gets total number of vertices
  22931. * @returns the total number of vertices
  22932. */
  22933. getTotalVertices(): number;
  22934. /**
  22935. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22936. * @param kind defines the data kind (Position, normal, etc...)
  22937. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22938. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22939. * @returns a float array containing vertex data
  22940. */
  22941. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22942. /**
  22943. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22944. * @param kind defines the data kind (Position, normal, etc...)
  22945. * @returns true if the vertex buffer with the specified kind is updatable
  22946. */
  22947. isVertexBufferUpdatable(kind: string): boolean;
  22948. /**
  22949. * Gets a specific vertex buffer
  22950. * @param kind defines the data kind (Position, normal, etc...)
  22951. * @returns a VertexBuffer
  22952. */
  22953. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22954. /**
  22955. * Returns all vertex buffers
  22956. * @return an object holding all vertex buffers indexed by kind
  22957. */
  22958. getVertexBuffers(): Nullable<{
  22959. [key: string]: VertexBuffer;
  22960. }>;
  22961. /**
  22962. * Gets a boolean indicating if specific vertex buffer is present
  22963. * @param kind defines the data kind (Position, normal, etc...)
  22964. * @returns true if data is present
  22965. */
  22966. isVerticesDataPresent(kind: string): boolean;
  22967. /**
  22968. * Gets a list of all attached data kinds (Position, normal, etc...)
  22969. * @returns a list of string containing all kinds
  22970. */
  22971. getVerticesDataKinds(): string[];
  22972. /**
  22973. * Update index buffer
  22974. * @param indices defines the indices to store in the index buffer
  22975. * @param offset defines the offset in the target buffer where to store the data
  22976. * @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)
  22977. */
  22978. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22979. /**
  22980. * Creates a new index buffer
  22981. * @param indices defines the indices to store in the index buffer
  22982. * @param totalVertices defines the total number of vertices (could be null)
  22983. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22984. */
  22985. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22986. /**
  22987. * Return the total number of indices
  22988. * @returns the total number of indices
  22989. */
  22990. getTotalIndices(): number;
  22991. /**
  22992. * Gets the index buffer array
  22993. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22994. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22995. * @returns the index buffer array
  22996. */
  22997. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22998. /**
  22999. * Gets the index buffer
  23000. * @return the index buffer
  23001. */
  23002. getIndexBuffer(): Nullable<DataBuffer>;
  23003. /** @hidden */
  23004. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23005. /**
  23006. * Release the associated resources for a specific mesh
  23007. * @param mesh defines the source mesh
  23008. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23009. */
  23010. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23011. /**
  23012. * Apply current geometry to a given mesh
  23013. * @param mesh defines the mesh to apply geometry to
  23014. */
  23015. applyToMesh(mesh: Mesh): void;
  23016. private _updateExtend;
  23017. private _applyToMesh;
  23018. private notifyUpdate;
  23019. /**
  23020. * Load the geometry if it was flagged as delay loaded
  23021. * @param scene defines the hosting scene
  23022. * @param onLoaded defines a callback called when the geometry is loaded
  23023. */
  23024. load(scene: Scene, onLoaded?: () => void): void;
  23025. private _queueLoad;
  23026. /**
  23027. * Invert the geometry to move from a right handed system to a left handed one.
  23028. */
  23029. toLeftHanded(): void;
  23030. /** @hidden */
  23031. _resetPointsArrayCache(): void;
  23032. /** @hidden */
  23033. _generatePointsArray(): boolean;
  23034. /**
  23035. * Gets a value indicating if the geometry is disposed
  23036. * @returns true if the geometry was disposed
  23037. */
  23038. isDisposed(): boolean;
  23039. private _disposeVertexArrayObjects;
  23040. /**
  23041. * Free all associated resources
  23042. */
  23043. dispose(): void;
  23044. /**
  23045. * Clone the current geometry into a new geometry
  23046. * @param id defines the unique ID of the new geometry
  23047. * @returns a new geometry object
  23048. */
  23049. copy(id: string): Geometry;
  23050. /**
  23051. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23052. * @return a JSON representation of the current geometry data (without the vertices data)
  23053. */
  23054. serialize(): any;
  23055. private toNumberArray;
  23056. /**
  23057. * Serialize all vertices data into a JSON oject
  23058. * @returns a JSON representation of the current geometry data
  23059. */
  23060. serializeVerticeData(): any;
  23061. /**
  23062. * Extracts a clone of a mesh geometry
  23063. * @param mesh defines the source mesh
  23064. * @param id defines the unique ID of the new geometry object
  23065. * @returns the new geometry object
  23066. */
  23067. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23068. /**
  23069. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23070. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23071. * Be aware Math.random() could cause collisions, but:
  23072. * "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"
  23073. * @returns a string containing a new GUID
  23074. */
  23075. static RandomId(): string;
  23076. /** @hidden */
  23077. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23078. private static _CleanMatricesWeights;
  23079. /**
  23080. * Create a new geometry from persisted data (Using .babylon file format)
  23081. * @param parsedVertexData defines the persisted data
  23082. * @param scene defines the hosting scene
  23083. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23084. * @returns the new geometry object
  23085. */
  23086. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23087. }
  23088. }
  23089. declare module "babylonjs/Meshes/mesh.vertexData" {
  23090. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23091. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  23092. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  23093. import { Geometry } from "babylonjs/Meshes/geometry";
  23094. import { Mesh } from "babylonjs/Meshes/mesh";
  23095. /**
  23096. * Define an interface for all classes that will get and set the data on vertices
  23097. */
  23098. export interface IGetSetVerticesData {
  23099. /**
  23100. * Gets a boolean indicating if specific vertex data is present
  23101. * @param kind defines the vertex data kind to use
  23102. * @returns true is data kind is present
  23103. */
  23104. isVerticesDataPresent(kind: string): boolean;
  23105. /**
  23106. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23107. * @param kind defines the data kind (Position, normal, etc...)
  23108. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23109. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23110. * @returns a float array containing vertex data
  23111. */
  23112. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23113. /**
  23114. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23115. * @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.
  23116. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23117. * @returns the indices array or an empty array if the mesh has no geometry
  23118. */
  23119. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23120. /**
  23121. * Set specific vertex data
  23122. * @param kind defines the data kind (Position, normal, etc...)
  23123. * @param data defines the vertex data to use
  23124. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23125. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23126. */
  23127. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23128. /**
  23129. * Update a specific associated vertex buffer
  23130. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23131. * - VertexBuffer.PositionKind
  23132. * - VertexBuffer.UVKind
  23133. * - VertexBuffer.UV2Kind
  23134. * - VertexBuffer.UV3Kind
  23135. * - VertexBuffer.UV4Kind
  23136. * - VertexBuffer.UV5Kind
  23137. * - VertexBuffer.UV6Kind
  23138. * - VertexBuffer.ColorKind
  23139. * - VertexBuffer.MatricesIndicesKind
  23140. * - VertexBuffer.MatricesIndicesExtraKind
  23141. * - VertexBuffer.MatricesWeightsKind
  23142. * - VertexBuffer.MatricesWeightsExtraKind
  23143. * @param data defines the data source
  23144. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23145. * @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)
  23146. */
  23147. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23148. /**
  23149. * Creates a new index buffer
  23150. * @param indices defines the indices to store in the index buffer
  23151. * @param totalVertices defines the total number of vertices (could be null)
  23152. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23153. */
  23154. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23155. }
  23156. /**
  23157. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23158. */
  23159. export class VertexData {
  23160. /**
  23161. * Mesh side orientation : usually the external or front surface
  23162. */
  23163. static readonly FRONTSIDE: number;
  23164. /**
  23165. * Mesh side orientation : usually the internal or back surface
  23166. */
  23167. static readonly BACKSIDE: number;
  23168. /**
  23169. * Mesh side orientation : both internal and external or front and back surfaces
  23170. */
  23171. static readonly DOUBLESIDE: number;
  23172. /**
  23173. * Mesh side orientation : by default, `FRONTSIDE`
  23174. */
  23175. static readonly DEFAULTSIDE: number;
  23176. /**
  23177. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23178. */
  23179. positions: Nullable<FloatArray>;
  23180. /**
  23181. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23182. */
  23183. normals: Nullable<FloatArray>;
  23184. /**
  23185. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23186. */
  23187. tangents: Nullable<FloatArray>;
  23188. /**
  23189. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23190. */
  23191. uvs: Nullable<FloatArray>;
  23192. /**
  23193. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23194. */
  23195. uvs2: Nullable<FloatArray>;
  23196. /**
  23197. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23198. */
  23199. uvs3: Nullable<FloatArray>;
  23200. /**
  23201. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23202. */
  23203. uvs4: Nullable<FloatArray>;
  23204. /**
  23205. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23206. */
  23207. uvs5: Nullable<FloatArray>;
  23208. /**
  23209. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23210. */
  23211. uvs6: Nullable<FloatArray>;
  23212. /**
  23213. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23214. */
  23215. colors: Nullable<FloatArray>;
  23216. /**
  23217. * 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).
  23218. */
  23219. matricesIndices: Nullable<FloatArray>;
  23220. /**
  23221. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23222. */
  23223. matricesWeights: Nullable<FloatArray>;
  23224. /**
  23225. * An array extending the number of possible indices
  23226. */
  23227. matricesIndicesExtra: Nullable<FloatArray>;
  23228. /**
  23229. * An array extending the number of possible weights when the number of indices is extended
  23230. */
  23231. matricesWeightsExtra: Nullable<FloatArray>;
  23232. /**
  23233. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23234. */
  23235. indices: Nullable<IndicesArray>;
  23236. /**
  23237. * Uses the passed data array to set the set the values for the specified kind of data
  23238. * @param data a linear array of floating numbers
  23239. * @param kind the type of data that is being set, eg positions, colors etc
  23240. */
  23241. set(data: FloatArray, kind: string): void;
  23242. /**
  23243. * Associates the vertexData to the passed Mesh.
  23244. * Sets it as updatable or not (default `false`)
  23245. * @param mesh the mesh the vertexData is applied to
  23246. * @param updatable when used and having the value true allows new data to update the vertexData
  23247. * @returns the VertexData
  23248. */
  23249. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23250. /**
  23251. * Associates the vertexData to the passed Geometry.
  23252. * Sets it as updatable or not (default `false`)
  23253. * @param geometry the geometry the vertexData is applied to
  23254. * @param updatable when used and having the value true allows new data to update the vertexData
  23255. * @returns VertexData
  23256. */
  23257. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23258. /**
  23259. * Updates the associated mesh
  23260. * @param mesh the mesh to be updated
  23261. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23262. * @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
  23263. * @returns VertexData
  23264. */
  23265. updateMesh(mesh: Mesh): VertexData;
  23266. /**
  23267. * Updates the associated geometry
  23268. * @param geometry the geometry to be updated
  23269. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23270. * @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
  23271. * @returns VertexData.
  23272. */
  23273. updateGeometry(geometry: Geometry): VertexData;
  23274. private _applyTo;
  23275. private _update;
  23276. /**
  23277. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23278. * @param matrix the transforming matrix
  23279. * @returns the VertexData
  23280. */
  23281. transform(matrix: Matrix): VertexData;
  23282. /**
  23283. * Merges the passed VertexData into the current one
  23284. * @param other the VertexData to be merged into the current one
  23285. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23286. * @returns the modified VertexData
  23287. */
  23288. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23289. private _mergeElement;
  23290. private _validate;
  23291. /**
  23292. * Serializes the VertexData
  23293. * @returns a serialized object
  23294. */
  23295. serialize(): any;
  23296. /**
  23297. * Extracts the vertexData from a mesh
  23298. * @param mesh the mesh from which to extract the VertexData
  23299. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23300. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23301. * @returns the object VertexData associated to the passed mesh
  23302. */
  23303. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23304. /**
  23305. * Extracts the vertexData from the geometry
  23306. * @param geometry the geometry from which to extract the VertexData
  23307. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23308. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23309. * @returns the object VertexData associated to the passed mesh
  23310. */
  23311. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23312. private static _ExtractFrom;
  23313. /**
  23314. * Creates the VertexData for a Ribbon
  23315. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23316. * * pathArray array of paths, each of which an array of successive Vector3
  23317. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23318. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23319. * * 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
  23320. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23321. * * 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)
  23322. * * 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)
  23323. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23324. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23325. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23326. * @returns the VertexData of the ribbon
  23327. */
  23328. static CreateRibbon(options: {
  23329. pathArray: Vector3[][];
  23330. closeArray?: boolean;
  23331. closePath?: boolean;
  23332. offset?: number;
  23333. sideOrientation?: number;
  23334. frontUVs?: Vector4;
  23335. backUVs?: Vector4;
  23336. invertUV?: boolean;
  23337. uvs?: Vector2[];
  23338. colors?: Color4[];
  23339. }): VertexData;
  23340. /**
  23341. * Creates the VertexData for a box
  23342. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23343. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23344. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23345. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23346. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23347. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23348. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23349. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23350. * * 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)
  23351. * * 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)
  23352. * @returns the VertexData of the box
  23353. */
  23354. static CreateBox(options: {
  23355. size?: number;
  23356. width?: number;
  23357. height?: number;
  23358. depth?: number;
  23359. faceUV?: Vector4[];
  23360. faceColors?: Color4[];
  23361. sideOrientation?: number;
  23362. frontUVs?: Vector4;
  23363. backUVs?: Vector4;
  23364. }): VertexData;
  23365. /**
  23366. * Creates the VertexData for a tiled box
  23367. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23368. * * faceTiles sets the pattern, tile size and number of tiles for a face
  23369. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23370. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23371. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23372. * @returns the VertexData of the box
  23373. */
  23374. static CreateTiledBox(options: {
  23375. pattern?: number;
  23376. width?: number;
  23377. height?: number;
  23378. depth?: number;
  23379. tileSize?: number;
  23380. tileWidth?: number;
  23381. tileHeight?: number;
  23382. alignHorizontal?: number;
  23383. alignVertical?: number;
  23384. faceUV?: Vector4[];
  23385. faceColors?: Color4[];
  23386. sideOrientation?: number;
  23387. }): VertexData;
  23388. /**
  23389. * Creates the VertexData for a tiled plane
  23390. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23391. * * pattern a limited pattern arrangement depending on the number
  23392. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  23393. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  23394. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  23395. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23396. * * 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)
  23397. * * 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)
  23398. * @returns the VertexData of the tiled plane
  23399. */
  23400. static CreateTiledPlane(options: {
  23401. pattern?: number;
  23402. tileSize?: number;
  23403. tileWidth?: number;
  23404. tileHeight?: number;
  23405. size?: number;
  23406. width?: number;
  23407. height?: number;
  23408. alignHorizontal?: number;
  23409. alignVertical?: number;
  23410. sideOrientation?: number;
  23411. frontUVs?: Vector4;
  23412. backUVs?: Vector4;
  23413. }): VertexData;
  23414. /**
  23415. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23416. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23417. * * segments sets the number of horizontal strips optional, default 32
  23418. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23419. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23420. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23421. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23422. * * 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
  23423. * * 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
  23424. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23425. * * 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)
  23426. * * 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)
  23427. * @returns the VertexData of the ellipsoid
  23428. */
  23429. static CreateSphere(options: {
  23430. segments?: number;
  23431. diameter?: number;
  23432. diameterX?: number;
  23433. diameterY?: number;
  23434. diameterZ?: number;
  23435. arc?: number;
  23436. slice?: number;
  23437. sideOrientation?: number;
  23438. frontUVs?: Vector4;
  23439. backUVs?: Vector4;
  23440. }): VertexData;
  23441. /**
  23442. * Creates the VertexData for a cylinder, cone or prism
  23443. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23444. * * height sets the height (y direction) of the cylinder, optional, default 2
  23445. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23446. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23447. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23448. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23449. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23450. * * 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
  23451. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23452. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23453. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23454. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23455. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23456. * * 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)
  23457. * * 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)
  23458. * @returns the VertexData of the cylinder, cone or prism
  23459. */
  23460. static CreateCylinder(options: {
  23461. height?: number;
  23462. diameterTop?: number;
  23463. diameterBottom?: number;
  23464. diameter?: number;
  23465. tessellation?: number;
  23466. subdivisions?: number;
  23467. arc?: number;
  23468. faceColors?: Color4[];
  23469. faceUV?: Vector4[];
  23470. hasRings?: boolean;
  23471. enclose?: boolean;
  23472. sideOrientation?: number;
  23473. frontUVs?: Vector4;
  23474. backUVs?: Vector4;
  23475. }): VertexData;
  23476. /**
  23477. * Creates the VertexData for a torus
  23478. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23479. * * diameter the diameter of the torus, optional default 1
  23480. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23481. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23482. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23483. * * 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)
  23484. * * 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)
  23485. * @returns the VertexData of the torus
  23486. */
  23487. static CreateTorus(options: {
  23488. diameter?: number;
  23489. thickness?: number;
  23490. tessellation?: number;
  23491. sideOrientation?: number;
  23492. frontUVs?: Vector4;
  23493. backUVs?: Vector4;
  23494. }): VertexData;
  23495. /**
  23496. * Creates the VertexData of the LineSystem
  23497. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23498. * - lines an array of lines, each line being an array of successive Vector3
  23499. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23500. * @returns the VertexData of the LineSystem
  23501. */
  23502. static CreateLineSystem(options: {
  23503. lines: Vector3[][];
  23504. colors?: Nullable<Color4[][]>;
  23505. }): VertexData;
  23506. /**
  23507. * Create the VertexData for a DashedLines
  23508. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23509. * - points an array successive Vector3
  23510. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23511. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23512. * - dashNb the intended total number of dashes, optional, default 200
  23513. * @returns the VertexData for the DashedLines
  23514. */
  23515. static CreateDashedLines(options: {
  23516. points: Vector3[];
  23517. dashSize?: number;
  23518. gapSize?: number;
  23519. dashNb?: number;
  23520. }): VertexData;
  23521. /**
  23522. * Creates the VertexData for a Ground
  23523. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23524. * - width the width (x direction) of the ground, optional, default 1
  23525. * - height the height (z direction) of the ground, optional, default 1
  23526. * - subdivisions the number of subdivisions per side, optional, default 1
  23527. * @returns the VertexData of the Ground
  23528. */
  23529. static CreateGround(options: {
  23530. width?: number;
  23531. height?: number;
  23532. subdivisions?: number;
  23533. subdivisionsX?: number;
  23534. subdivisionsY?: number;
  23535. }): VertexData;
  23536. /**
  23537. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23538. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23539. * * xmin the ground minimum X coordinate, optional, default -1
  23540. * * zmin the ground minimum Z coordinate, optional, default -1
  23541. * * xmax the ground maximum X coordinate, optional, default 1
  23542. * * zmax the ground maximum Z coordinate, optional, default 1
  23543. * * 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}
  23544. * * 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}
  23545. * @returns the VertexData of the TiledGround
  23546. */
  23547. static CreateTiledGround(options: {
  23548. xmin: number;
  23549. zmin: number;
  23550. xmax: number;
  23551. zmax: number;
  23552. subdivisions?: {
  23553. w: number;
  23554. h: number;
  23555. };
  23556. precision?: {
  23557. w: number;
  23558. h: number;
  23559. };
  23560. }): VertexData;
  23561. /**
  23562. * Creates the VertexData of the Ground designed from a heightmap
  23563. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23564. * * width the width (x direction) of the ground
  23565. * * height the height (z direction) of the ground
  23566. * * subdivisions the number of subdivisions per side
  23567. * * minHeight the minimum altitude on the ground, optional, default 0
  23568. * * maxHeight the maximum altitude on the ground, optional default 1
  23569. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23570. * * buffer the array holding the image color data
  23571. * * bufferWidth the width of image
  23572. * * bufferHeight the height of image
  23573. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23574. * @returns the VertexData of the Ground designed from a heightmap
  23575. */
  23576. static CreateGroundFromHeightMap(options: {
  23577. width: number;
  23578. height: number;
  23579. subdivisions: number;
  23580. minHeight: number;
  23581. maxHeight: number;
  23582. colorFilter: Color3;
  23583. buffer: Uint8Array;
  23584. bufferWidth: number;
  23585. bufferHeight: number;
  23586. alphaFilter: number;
  23587. }): VertexData;
  23588. /**
  23589. * Creates the VertexData for a Plane
  23590. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23591. * * size sets the width and height of the plane to the value of size, optional default 1
  23592. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23593. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23594. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23595. * * 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)
  23596. * * 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)
  23597. * @returns the VertexData of the box
  23598. */
  23599. static CreatePlane(options: {
  23600. size?: number;
  23601. width?: number;
  23602. height?: number;
  23603. sideOrientation?: number;
  23604. frontUVs?: Vector4;
  23605. backUVs?: Vector4;
  23606. }): VertexData;
  23607. /**
  23608. * Creates the VertexData of the Disc or regular Polygon
  23609. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23610. * * radius the radius of the disc, optional default 0.5
  23611. * * tessellation the number of polygon sides, optional, default 64
  23612. * * 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
  23613. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23614. * * 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)
  23615. * * 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)
  23616. * @returns the VertexData of the box
  23617. */
  23618. static CreateDisc(options: {
  23619. radius?: number;
  23620. tessellation?: number;
  23621. arc?: number;
  23622. sideOrientation?: number;
  23623. frontUVs?: Vector4;
  23624. backUVs?: Vector4;
  23625. }): VertexData;
  23626. /**
  23627. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23628. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23629. * @param polygon a mesh built from polygonTriangulation.build()
  23630. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23631. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23632. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23633. * @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)
  23634. * @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)
  23635. * @returns the VertexData of the Polygon
  23636. */
  23637. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23638. /**
  23639. * Creates the VertexData of the IcoSphere
  23640. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23641. * * radius the radius of the IcoSphere, optional default 1
  23642. * * radiusX allows stretching in the x direction, optional, default radius
  23643. * * radiusY allows stretching in the y direction, optional, default radius
  23644. * * radiusZ allows stretching in the z direction, optional, default radius
  23645. * * flat when true creates a flat shaded mesh, optional, default true
  23646. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23647. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23648. * * 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)
  23649. * * 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)
  23650. * @returns the VertexData of the IcoSphere
  23651. */
  23652. static CreateIcoSphere(options: {
  23653. radius?: number;
  23654. radiusX?: number;
  23655. radiusY?: number;
  23656. radiusZ?: number;
  23657. flat?: boolean;
  23658. subdivisions?: number;
  23659. sideOrientation?: number;
  23660. frontUVs?: Vector4;
  23661. backUVs?: Vector4;
  23662. }): VertexData;
  23663. /**
  23664. * Creates the VertexData for a Polyhedron
  23665. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23666. * * type provided types are:
  23667. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23668. * * 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)
  23669. * * size the size of the IcoSphere, optional default 1
  23670. * * sizeX allows stretching in the x direction, optional, default size
  23671. * * sizeY allows stretching in the y direction, optional, default size
  23672. * * sizeZ allows stretching in the z direction, optional, default size
  23673. * * 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
  23674. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23675. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23676. * * flat when true creates a flat shaded mesh, optional, default true
  23677. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23678. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23679. * * 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)
  23680. * * 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)
  23681. * @returns the VertexData of the Polyhedron
  23682. */
  23683. static CreatePolyhedron(options: {
  23684. type?: number;
  23685. size?: number;
  23686. sizeX?: number;
  23687. sizeY?: number;
  23688. sizeZ?: number;
  23689. custom?: any;
  23690. faceUV?: Vector4[];
  23691. faceColors?: Color4[];
  23692. flat?: boolean;
  23693. sideOrientation?: number;
  23694. frontUVs?: Vector4;
  23695. backUVs?: Vector4;
  23696. }): VertexData;
  23697. /**
  23698. * Creates the VertexData for a TorusKnot
  23699. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23700. * * radius the radius of the torus knot, optional, default 2
  23701. * * tube the thickness of the tube, optional, default 0.5
  23702. * * radialSegments the number of sides on each tube segments, optional, default 32
  23703. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23704. * * p the number of windings around the z axis, optional, default 2
  23705. * * q the number of windings around the x axis, optional, default 3
  23706. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23707. * * 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)
  23708. * * 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)
  23709. * @returns the VertexData of the Torus Knot
  23710. */
  23711. static CreateTorusKnot(options: {
  23712. radius?: number;
  23713. tube?: number;
  23714. radialSegments?: number;
  23715. tubularSegments?: number;
  23716. p?: number;
  23717. q?: number;
  23718. sideOrientation?: number;
  23719. frontUVs?: Vector4;
  23720. backUVs?: Vector4;
  23721. }): VertexData;
  23722. /**
  23723. * Compute normals for given positions and indices
  23724. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23725. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23726. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23727. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23728. * * facetNormals : optional array of facet normals (vector3)
  23729. * * facetPositions : optional array of facet positions (vector3)
  23730. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23731. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23732. * * bInfo : optional bounding info, required for facetPartitioning computation
  23733. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23734. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23735. * * useRightHandedSystem: optional boolean to for right handed system computation
  23736. * * depthSort : optional boolean to enable the facet depth sort computation
  23737. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23738. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23739. */
  23740. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23741. facetNormals?: any;
  23742. facetPositions?: any;
  23743. facetPartitioning?: any;
  23744. ratio?: number;
  23745. bInfo?: any;
  23746. bbSize?: Vector3;
  23747. subDiv?: any;
  23748. useRightHandedSystem?: boolean;
  23749. depthSort?: boolean;
  23750. distanceTo?: Vector3;
  23751. depthSortedFacets?: any;
  23752. }): void;
  23753. /** @hidden */
  23754. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23755. /**
  23756. * Applies VertexData created from the imported parameters to the geometry
  23757. * @param parsedVertexData the parsed data from an imported file
  23758. * @param geometry the geometry to apply the VertexData to
  23759. */
  23760. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23761. }
  23762. }
  23763. declare module "babylonjs/Morph/morphTarget" {
  23764. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23765. import { Observable } from "babylonjs/Misc/observable";
  23766. import { Nullable, FloatArray } from "babylonjs/types";
  23767. import { Scene } from "babylonjs/scene";
  23768. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23769. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23770. /**
  23771. * Defines a target to use with MorphTargetManager
  23772. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23773. */
  23774. export class MorphTarget implements IAnimatable {
  23775. /** defines the name of the target */
  23776. name: string;
  23777. /**
  23778. * Gets or sets the list of animations
  23779. */
  23780. animations: import("babylonjs/Animations/animation").Animation[];
  23781. private _scene;
  23782. private _positions;
  23783. private _normals;
  23784. private _tangents;
  23785. private _uvs;
  23786. private _influence;
  23787. private _uniqueId;
  23788. /**
  23789. * Observable raised when the influence changes
  23790. */
  23791. onInfluenceChanged: Observable<boolean>;
  23792. /** @hidden */
  23793. _onDataLayoutChanged: Observable<void>;
  23794. /**
  23795. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23796. */
  23797. get influence(): number;
  23798. set influence(influence: number);
  23799. /**
  23800. * Gets or sets the id of the morph Target
  23801. */
  23802. id: string;
  23803. private _animationPropertiesOverride;
  23804. /**
  23805. * Gets or sets the animation properties override
  23806. */
  23807. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23808. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23809. /**
  23810. * Creates a new MorphTarget
  23811. * @param name defines the name of the target
  23812. * @param influence defines the influence to use
  23813. * @param scene defines the scene the morphtarget belongs to
  23814. */
  23815. constructor(
  23816. /** defines the name of the target */
  23817. name: string, influence?: number, scene?: Nullable<Scene>);
  23818. /**
  23819. * Gets the unique ID of this manager
  23820. */
  23821. get uniqueId(): number;
  23822. /**
  23823. * Gets a boolean defining if the target contains position data
  23824. */
  23825. get hasPositions(): boolean;
  23826. /**
  23827. * Gets a boolean defining if the target contains normal data
  23828. */
  23829. get hasNormals(): boolean;
  23830. /**
  23831. * Gets a boolean defining if the target contains tangent data
  23832. */
  23833. get hasTangents(): boolean;
  23834. /**
  23835. * Gets a boolean defining if the target contains texture coordinates data
  23836. */
  23837. get hasUVs(): boolean;
  23838. /**
  23839. * Affects position data to this target
  23840. * @param data defines the position data to use
  23841. */
  23842. setPositions(data: Nullable<FloatArray>): void;
  23843. /**
  23844. * Gets the position data stored in this target
  23845. * @returns a FloatArray containing the position data (or null if not present)
  23846. */
  23847. getPositions(): Nullable<FloatArray>;
  23848. /**
  23849. * Affects normal data to this target
  23850. * @param data defines the normal data to use
  23851. */
  23852. setNormals(data: Nullable<FloatArray>): void;
  23853. /**
  23854. * Gets the normal data stored in this target
  23855. * @returns a FloatArray containing the normal data (or null if not present)
  23856. */
  23857. getNormals(): Nullable<FloatArray>;
  23858. /**
  23859. * Affects tangent data to this target
  23860. * @param data defines the tangent data to use
  23861. */
  23862. setTangents(data: Nullable<FloatArray>): void;
  23863. /**
  23864. * Gets the tangent data stored in this target
  23865. * @returns a FloatArray containing the tangent data (or null if not present)
  23866. */
  23867. getTangents(): Nullable<FloatArray>;
  23868. /**
  23869. * Affects texture coordinates data to this target
  23870. * @param data defines the texture coordinates data to use
  23871. */
  23872. setUVs(data: Nullable<FloatArray>): void;
  23873. /**
  23874. * Gets the texture coordinates data stored in this target
  23875. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23876. */
  23877. getUVs(): Nullable<FloatArray>;
  23878. /**
  23879. * Clone the current target
  23880. * @returns a new MorphTarget
  23881. */
  23882. clone(): MorphTarget;
  23883. /**
  23884. * Serializes the current target into a Serialization object
  23885. * @returns the serialized object
  23886. */
  23887. serialize(): any;
  23888. /**
  23889. * Returns the string "MorphTarget"
  23890. * @returns "MorphTarget"
  23891. */
  23892. getClassName(): string;
  23893. /**
  23894. * Creates a new target from serialized data
  23895. * @param serializationObject defines the serialized data to use
  23896. * @returns a new MorphTarget
  23897. */
  23898. static Parse(serializationObject: any): MorphTarget;
  23899. /**
  23900. * Creates a MorphTarget from mesh data
  23901. * @param mesh defines the source mesh
  23902. * @param name defines the name to use for the new target
  23903. * @param influence defines the influence to attach to the target
  23904. * @returns a new MorphTarget
  23905. */
  23906. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23907. }
  23908. }
  23909. declare module "babylonjs/Morph/morphTargetManager" {
  23910. import { Nullable } from "babylonjs/types";
  23911. import { Scene } from "babylonjs/scene";
  23912. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23913. /**
  23914. * This class is used to deform meshes using morphing between different targets
  23915. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23916. */
  23917. export class MorphTargetManager {
  23918. private _targets;
  23919. private _targetInfluenceChangedObservers;
  23920. private _targetDataLayoutChangedObservers;
  23921. private _activeTargets;
  23922. private _scene;
  23923. private _influences;
  23924. private _supportsNormals;
  23925. private _supportsTangents;
  23926. private _supportsUVs;
  23927. private _vertexCount;
  23928. private _uniqueId;
  23929. private _tempInfluences;
  23930. /**
  23931. * Gets or sets a boolean indicating if normals must be morphed
  23932. */
  23933. enableNormalMorphing: boolean;
  23934. /**
  23935. * Gets or sets a boolean indicating if tangents must be morphed
  23936. */
  23937. enableTangentMorphing: boolean;
  23938. /**
  23939. * Gets or sets a boolean indicating if UV must be morphed
  23940. */
  23941. enableUVMorphing: boolean;
  23942. /**
  23943. * Creates a new MorphTargetManager
  23944. * @param scene defines the current scene
  23945. */
  23946. constructor(scene?: Nullable<Scene>);
  23947. /**
  23948. * Gets the unique ID of this manager
  23949. */
  23950. get uniqueId(): number;
  23951. /**
  23952. * Gets the number of vertices handled by this manager
  23953. */
  23954. get vertexCount(): number;
  23955. /**
  23956. * Gets a boolean indicating if this manager supports morphing of normals
  23957. */
  23958. get supportsNormals(): boolean;
  23959. /**
  23960. * Gets a boolean indicating if this manager supports morphing of tangents
  23961. */
  23962. get supportsTangents(): boolean;
  23963. /**
  23964. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23965. */
  23966. get supportsUVs(): boolean;
  23967. /**
  23968. * Gets the number of targets stored in this manager
  23969. */
  23970. get numTargets(): number;
  23971. /**
  23972. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23973. */
  23974. get numInfluencers(): number;
  23975. /**
  23976. * Gets the list of influences (one per target)
  23977. */
  23978. get influences(): Float32Array;
  23979. /**
  23980. * Gets the active target at specified index. An active target is a target with an influence > 0
  23981. * @param index defines the index to check
  23982. * @returns the requested target
  23983. */
  23984. getActiveTarget(index: number): MorphTarget;
  23985. /**
  23986. * Gets the target at specified index
  23987. * @param index defines the index to check
  23988. * @returns the requested target
  23989. */
  23990. getTarget(index: number): MorphTarget;
  23991. /**
  23992. * Add a new target to this manager
  23993. * @param target defines the target to add
  23994. */
  23995. addTarget(target: MorphTarget): void;
  23996. /**
  23997. * Removes a target from the manager
  23998. * @param target defines the target to remove
  23999. */
  24000. removeTarget(target: MorphTarget): void;
  24001. /**
  24002. * Clone the current manager
  24003. * @returns a new MorphTargetManager
  24004. */
  24005. clone(): MorphTargetManager;
  24006. /**
  24007. * Serializes the current manager into a Serialization object
  24008. * @returns the serialized object
  24009. */
  24010. serialize(): any;
  24011. private _syncActiveTargets;
  24012. /**
  24013. * Syncrhonize the targets with all the meshes using this morph target manager
  24014. */
  24015. synchronize(): void;
  24016. /**
  24017. * Creates a new MorphTargetManager from serialized data
  24018. * @param serializationObject defines the serialized data
  24019. * @param scene defines the hosting scene
  24020. * @returns the new MorphTargetManager
  24021. */
  24022. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  24023. }
  24024. }
  24025. declare module "babylonjs/Meshes/meshLODLevel" {
  24026. import { Mesh } from "babylonjs/Meshes/mesh";
  24027. import { Nullable } from "babylonjs/types";
  24028. /**
  24029. * Class used to represent a specific level of detail of a mesh
  24030. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24031. */
  24032. export class MeshLODLevel {
  24033. /** Defines the distance where this level should start being displayed */
  24034. distance: number;
  24035. /** Defines the mesh to use to render this level */
  24036. mesh: Nullable<Mesh>;
  24037. /**
  24038. * Creates a new LOD level
  24039. * @param distance defines the distance where this level should star being displayed
  24040. * @param mesh defines the mesh to use to render this level
  24041. */
  24042. constructor(
  24043. /** Defines the distance where this level should start being displayed */
  24044. distance: number,
  24045. /** Defines the mesh to use to render this level */
  24046. mesh: Nullable<Mesh>);
  24047. }
  24048. }
  24049. declare module "babylonjs/Meshes/groundMesh" {
  24050. import { Scene } from "babylonjs/scene";
  24051. import { Vector3 } from "babylonjs/Maths/math.vector";
  24052. import { Mesh } from "babylonjs/Meshes/mesh";
  24053. /**
  24054. * Mesh representing the gorund
  24055. */
  24056. export class GroundMesh extends Mesh {
  24057. /** If octree should be generated */
  24058. generateOctree: boolean;
  24059. private _heightQuads;
  24060. /** @hidden */
  24061. _subdivisionsX: number;
  24062. /** @hidden */
  24063. _subdivisionsY: number;
  24064. /** @hidden */
  24065. _width: number;
  24066. /** @hidden */
  24067. _height: number;
  24068. /** @hidden */
  24069. _minX: number;
  24070. /** @hidden */
  24071. _maxX: number;
  24072. /** @hidden */
  24073. _minZ: number;
  24074. /** @hidden */
  24075. _maxZ: number;
  24076. constructor(name: string, scene: Scene);
  24077. /**
  24078. * "GroundMesh"
  24079. * @returns "GroundMesh"
  24080. */
  24081. getClassName(): string;
  24082. /**
  24083. * The minimum of x and y subdivisions
  24084. */
  24085. get subdivisions(): number;
  24086. /**
  24087. * X subdivisions
  24088. */
  24089. get subdivisionsX(): number;
  24090. /**
  24091. * Y subdivisions
  24092. */
  24093. get subdivisionsY(): number;
  24094. /**
  24095. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  24096. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  24097. * @param chunksCount the number of subdivisions for x and y
  24098. * @param octreeBlocksSize (Default: 32)
  24099. */
  24100. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  24101. /**
  24102. * Returns a height (y) value in the Worl system :
  24103. * the ground altitude at the coordinates (x, z) expressed in the World system.
  24104. * @param x x coordinate
  24105. * @param z z coordinate
  24106. * @returns the ground y position if (x, z) are outside the ground surface.
  24107. */
  24108. getHeightAtCoordinates(x: number, z: number): number;
  24109. /**
  24110. * Returns a normalized vector (Vector3) orthogonal to the ground
  24111. * at the ground coordinates (x, z) expressed in the World system.
  24112. * @param x x coordinate
  24113. * @param z z coordinate
  24114. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  24115. */
  24116. getNormalAtCoordinates(x: number, z: number): Vector3;
  24117. /**
  24118. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  24119. * at the ground coordinates (x, z) expressed in the World system.
  24120. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  24121. * @param x x coordinate
  24122. * @param z z coordinate
  24123. * @param ref vector to store the result
  24124. * @returns the GroundMesh.
  24125. */
  24126. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  24127. /**
  24128. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  24129. * if the ground has been updated.
  24130. * This can be used in the render loop.
  24131. * @returns the GroundMesh.
  24132. */
  24133. updateCoordinateHeights(): GroundMesh;
  24134. private _getFacetAt;
  24135. private _initHeightQuads;
  24136. private _computeHeightQuads;
  24137. /**
  24138. * Serializes this ground mesh
  24139. * @param serializationObject object to write serialization to
  24140. */
  24141. serialize(serializationObject: any): void;
  24142. /**
  24143. * Parses a serialized ground mesh
  24144. * @param parsedMesh the serialized mesh
  24145. * @param scene the scene to create the ground mesh in
  24146. * @returns the created ground mesh
  24147. */
  24148. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  24149. }
  24150. }
  24151. declare module "babylonjs/Physics/physicsJoint" {
  24152. import { Vector3 } from "babylonjs/Maths/math.vector";
  24153. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  24154. /**
  24155. * Interface for Physics-Joint data
  24156. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24157. */
  24158. export interface PhysicsJointData {
  24159. /**
  24160. * The main pivot of the joint
  24161. */
  24162. mainPivot?: Vector3;
  24163. /**
  24164. * The connected pivot of the joint
  24165. */
  24166. connectedPivot?: Vector3;
  24167. /**
  24168. * The main axis of the joint
  24169. */
  24170. mainAxis?: Vector3;
  24171. /**
  24172. * The connected axis of the joint
  24173. */
  24174. connectedAxis?: Vector3;
  24175. /**
  24176. * The collision of the joint
  24177. */
  24178. collision?: boolean;
  24179. /**
  24180. * Native Oimo/Cannon/Energy data
  24181. */
  24182. nativeParams?: any;
  24183. }
  24184. /**
  24185. * This is a holder class for the physics joint created by the physics plugin
  24186. * It holds a set of functions to control the underlying joint
  24187. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24188. */
  24189. export class PhysicsJoint {
  24190. /**
  24191. * The type of the physics joint
  24192. */
  24193. type: number;
  24194. /**
  24195. * The data for the physics joint
  24196. */
  24197. jointData: PhysicsJointData;
  24198. private _physicsJoint;
  24199. protected _physicsPlugin: IPhysicsEnginePlugin;
  24200. /**
  24201. * Initializes the physics joint
  24202. * @param type The type of the physics joint
  24203. * @param jointData The data for the physics joint
  24204. */
  24205. constructor(
  24206. /**
  24207. * The type of the physics joint
  24208. */
  24209. type: number,
  24210. /**
  24211. * The data for the physics joint
  24212. */
  24213. jointData: PhysicsJointData);
  24214. /**
  24215. * Gets the physics joint
  24216. */
  24217. get physicsJoint(): any;
  24218. /**
  24219. * Sets the physics joint
  24220. */
  24221. set physicsJoint(newJoint: any);
  24222. /**
  24223. * Sets the physics plugin
  24224. */
  24225. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  24226. /**
  24227. * Execute a function that is physics-plugin specific.
  24228. * @param {Function} func the function that will be executed.
  24229. * It accepts two parameters: the physics world and the physics joint
  24230. */
  24231. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  24232. /**
  24233. * Distance-Joint type
  24234. */
  24235. static DistanceJoint: number;
  24236. /**
  24237. * Hinge-Joint type
  24238. */
  24239. static HingeJoint: number;
  24240. /**
  24241. * Ball-and-Socket joint type
  24242. */
  24243. static BallAndSocketJoint: number;
  24244. /**
  24245. * Wheel-Joint type
  24246. */
  24247. static WheelJoint: number;
  24248. /**
  24249. * Slider-Joint type
  24250. */
  24251. static SliderJoint: number;
  24252. /**
  24253. * Prismatic-Joint type
  24254. */
  24255. static PrismaticJoint: number;
  24256. /**
  24257. * Universal-Joint type
  24258. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  24259. */
  24260. static UniversalJoint: number;
  24261. /**
  24262. * Hinge-Joint 2 type
  24263. */
  24264. static Hinge2Joint: number;
  24265. /**
  24266. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  24267. */
  24268. static PointToPointJoint: number;
  24269. /**
  24270. * Spring-Joint type
  24271. */
  24272. static SpringJoint: number;
  24273. /**
  24274. * Lock-Joint type
  24275. */
  24276. static LockJoint: number;
  24277. }
  24278. /**
  24279. * A class representing a physics distance joint
  24280. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24281. */
  24282. export class DistanceJoint extends PhysicsJoint {
  24283. /**
  24284. *
  24285. * @param jointData The data for the Distance-Joint
  24286. */
  24287. constructor(jointData: DistanceJointData);
  24288. /**
  24289. * Update the predefined distance.
  24290. * @param maxDistance The maximum preferred distance
  24291. * @param minDistance The minimum preferred distance
  24292. */
  24293. updateDistance(maxDistance: number, minDistance?: number): void;
  24294. }
  24295. /**
  24296. * Represents a Motor-Enabled Joint
  24297. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24298. */
  24299. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  24300. /**
  24301. * Initializes the Motor-Enabled Joint
  24302. * @param type The type of the joint
  24303. * @param jointData The physica joint data for the joint
  24304. */
  24305. constructor(type: number, jointData: PhysicsJointData);
  24306. /**
  24307. * Set the motor values.
  24308. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24309. * @param force the force to apply
  24310. * @param maxForce max force for this motor.
  24311. */
  24312. setMotor(force?: number, maxForce?: number): void;
  24313. /**
  24314. * Set the motor's limits.
  24315. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24316. * @param upperLimit The upper limit of the motor
  24317. * @param lowerLimit The lower limit of the motor
  24318. */
  24319. setLimit(upperLimit: number, lowerLimit?: number): void;
  24320. }
  24321. /**
  24322. * This class represents a single physics Hinge-Joint
  24323. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24324. */
  24325. export class HingeJoint extends MotorEnabledJoint {
  24326. /**
  24327. * Initializes the Hinge-Joint
  24328. * @param jointData The joint data for the Hinge-Joint
  24329. */
  24330. constructor(jointData: PhysicsJointData);
  24331. /**
  24332. * Set the motor values.
  24333. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24334. * @param {number} force the force to apply
  24335. * @param {number} maxForce max force for this motor.
  24336. */
  24337. setMotor(force?: number, maxForce?: number): void;
  24338. /**
  24339. * Set the motor's limits.
  24340. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24341. * @param upperLimit The upper limit of the motor
  24342. * @param lowerLimit The lower limit of the motor
  24343. */
  24344. setLimit(upperLimit: number, lowerLimit?: number): void;
  24345. }
  24346. /**
  24347. * This class represents a dual hinge physics joint (same as wheel joint)
  24348. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24349. */
  24350. export class Hinge2Joint extends MotorEnabledJoint {
  24351. /**
  24352. * Initializes the Hinge2-Joint
  24353. * @param jointData The joint data for the Hinge2-Joint
  24354. */
  24355. constructor(jointData: PhysicsJointData);
  24356. /**
  24357. * Set the motor values.
  24358. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24359. * @param {number} targetSpeed the speed the motor is to reach
  24360. * @param {number} maxForce max force for this motor.
  24361. * @param {motorIndex} the motor's index, 0 or 1.
  24362. */
  24363. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  24364. /**
  24365. * Set the motor limits.
  24366. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24367. * @param {number} upperLimit the upper limit
  24368. * @param {number} lowerLimit lower limit
  24369. * @param {motorIndex} the motor's index, 0 or 1.
  24370. */
  24371. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24372. }
  24373. /**
  24374. * Interface for a motor enabled joint
  24375. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24376. */
  24377. export interface IMotorEnabledJoint {
  24378. /**
  24379. * Physics joint
  24380. */
  24381. physicsJoint: any;
  24382. /**
  24383. * Sets the motor of the motor-enabled joint
  24384. * @param force The force of the motor
  24385. * @param maxForce The maximum force of the motor
  24386. * @param motorIndex The index of the motor
  24387. */
  24388. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24389. /**
  24390. * Sets the limit of the motor
  24391. * @param upperLimit The upper limit of the motor
  24392. * @param lowerLimit The lower limit of the motor
  24393. * @param motorIndex The index of the motor
  24394. */
  24395. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24396. }
  24397. /**
  24398. * Joint data for a Distance-Joint
  24399. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24400. */
  24401. export interface DistanceJointData extends PhysicsJointData {
  24402. /**
  24403. * Max distance the 2 joint objects can be apart
  24404. */
  24405. maxDistance: number;
  24406. }
  24407. /**
  24408. * Joint data from a spring joint
  24409. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24410. */
  24411. export interface SpringJointData extends PhysicsJointData {
  24412. /**
  24413. * Length of the spring
  24414. */
  24415. length: number;
  24416. /**
  24417. * Stiffness of the spring
  24418. */
  24419. stiffness: number;
  24420. /**
  24421. * Damping of the spring
  24422. */
  24423. damping: number;
  24424. /** this callback will be called when applying the force to the impostors. */
  24425. forceApplicationCallback: () => void;
  24426. }
  24427. }
  24428. declare module "babylonjs/Physics/physicsRaycastResult" {
  24429. import { Vector3 } from "babylonjs/Maths/math.vector";
  24430. /**
  24431. * Holds the data for the raycast result
  24432. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24433. */
  24434. export class PhysicsRaycastResult {
  24435. private _hasHit;
  24436. private _hitDistance;
  24437. private _hitNormalWorld;
  24438. private _hitPointWorld;
  24439. private _rayFromWorld;
  24440. private _rayToWorld;
  24441. /**
  24442. * Gets if there was a hit
  24443. */
  24444. get hasHit(): boolean;
  24445. /**
  24446. * Gets the distance from the hit
  24447. */
  24448. get hitDistance(): number;
  24449. /**
  24450. * Gets the hit normal/direction in the world
  24451. */
  24452. get hitNormalWorld(): Vector3;
  24453. /**
  24454. * Gets the hit point in the world
  24455. */
  24456. get hitPointWorld(): Vector3;
  24457. /**
  24458. * Gets the ray "start point" of the ray in the world
  24459. */
  24460. get rayFromWorld(): Vector3;
  24461. /**
  24462. * Gets the ray "end point" of the ray in the world
  24463. */
  24464. get rayToWorld(): Vector3;
  24465. /**
  24466. * Sets the hit data (normal & point in world space)
  24467. * @param hitNormalWorld defines the normal in world space
  24468. * @param hitPointWorld defines the point in world space
  24469. */
  24470. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  24471. /**
  24472. * Sets the distance from the start point to the hit point
  24473. * @param distance
  24474. */
  24475. setHitDistance(distance: number): void;
  24476. /**
  24477. * Calculates the distance manually
  24478. */
  24479. calculateHitDistance(): void;
  24480. /**
  24481. * Resets all the values to default
  24482. * @param from The from point on world space
  24483. * @param to The to point on world space
  24484. */
  24485. reset(from?: Vector3, to?: Vector3): void;
  24486. }
  24487. /**
  24488. * Interface for the size containing width and height
  24489. */
  24490. interface IXYZ {
  24491. /**
  24492. * X
  24493. */
  24494. x: number;
  24495. /**
  24496. * Y
  24497. */
  24498. y: number;
  24499. /**
  24500. * Z
  24501. */
  24502. z: number;
  24503. }
  24504. }
  24505. declare module "babylonjs/Physics/IPhysicsEngine" {
  24506. import { Nullable } from "babylonjs/types";
  24507. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  24508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24509. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24510. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  24511. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  24512. /**
  24513. * Interface used to describe a physics joint
  24514. */
  24515. export interface PhysicsImpostorJoint {
  24516. /** Defines the main impostor to which the joint is linked */
  24517. mainImpostor: PhysicsImpostor;
  24518. /** Defines the impostor that is connected to the main impostor using this joint */
  24519. connectedImpostor: PhysicsImpostor;
  24520. /** Defines the joint itself */
  24521. joint: PhysicsJoint;
  24522. }
  24523. /** @hidden */
  24524. export interface IPhysicsEnginePlugin {
  24525. world: any;
  24526. name: string;
  24527. setGravity(gravity: Vector3): void;
  24528. setTimeStep(timeStep: number): void;
  24529. getTimeStep(): number;
  24530. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24531. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24532. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24533. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24534. removePhysicsBody(impostor: PhysicsImpostor): void;
  24535. generateJoint(joint: PhysicsImpostorJoint): void;
  24536. removeJoint(joint: PhysicsImpostorJoint): void;
  24537. isSupported(): boolean;
  24538. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24539. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24540. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24541. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24542. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24543. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24544. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24545. getBodyMass(impostor: PhysicsImpostor): number;
  24546. getBodyFriction(impostor: PhysicsImpostor): number;
  24547. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24548. getBodyRestitution(impostor: PhysicsImpostor): number;
  24549. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24550. getBodyPressure?(impostor: PhysicsImpostor): number;
  24551. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  24552. getBodyStiffness?(impostor: PhysicsImpostor): number;
  24553. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  24554. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  24555. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  24556. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  24557. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  24558. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24559. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24560. sleepBody(impostor: PhysicsImpostor): void;
  24561. wakeUpBody(impostor: PhysicsImpostor): void;
  24562. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24563. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24564. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24565. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24566. getRadius(impostor: PhysicsImpostor): number;
  24567. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24568. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24569. dispose(): void;
  24570. }
  24571. /**
  24572. * Interface used to define a physics engine
  24573. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24574. */
  24575. export interface IPhysicsEngine {
  24576. /**
  24577. * Gets the gravity vector used by the simulation
  24578. */
  24579. gravity: Vector3;
  24580. /**
  24581. * Sets the gravity vector used by the simulation
  24582. * @param gravity defines the gravity vector to use
  24583. */
  24584. setGravity(gravity: Vector3): void;
  24585. /**
  24586. * Set the time step of the physics engine.
  24587. * Default is 1/60.
  24588. * To slow it down, enter 1/600 for example.
  24589. * To speed it up, 1/30
  24590. * @param newTimeStep the new timestep to apply to this world.
  24591. */
  24592. setTimeStep(newTimeStep: number): void;
  24593. /**
  24594. * Get the time step of the physics engine.
  24595. * @returns the current time step
  24596. */
  24597. getTimeStep(): number;
  24598. /**
  24599. * Set the sub time step of the physics engine.
  24600. * Default is 0 meaning there is no sub steps
  24601. * To increase physics resolution precision, set a small value (like 1 ms)
  24602. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24603. */
  24604. setSubTimeStep(subTimeStep: number): void;
  24605. /**
  24606. * Get the sub time step of the physics engine.
  24607. * @returns the current sub time step
  24608. */
  24609. getSubTimeStep(): number;
  24610. /**
  24611. * Release all resources
  24612. */
  24613. dispose(): void;
  24614. /**
  24615. * Gets the name of the current physics plugin
  24616. * @returns the name of the plugin
  24617. */
  24618. getPhysicsPluginName(): string;
  24619. /**
  24620. * Adding a new impostor for the impostor tracking.
  24621. * This will be done by the impostor itself.
  24622. * @param impostor the impostor to add
  24623. */
  24624. addImpostor(impostor: PhysicsImpostor): void;
  24625. /**
  24626. * Remove an impostor from the engine.
  24627. * This impostor and its mesh will not longer be updated by the physics engine.
  24628. * @param impostor the impostor to remove
  24629. */
  24630. removeImpostor(impostor: PhysicsImpostor): void;
  24631. /**
  24632. * Add a joint to the physics engine
  24633. * @param mainImpostor defines the main impostor to which the joint is added.
  24634. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24635. * @param joint defines the joint that will connect both impostors.
  24636. */
  24637. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24638. /**
  24639. * Removes a joint from the simulation
  24640. * @param mainImpostor defines the impostor used with the joint
  24641. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24642. * @param joint defines the joint to remove
  24643. */
  24644. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24645. /**
  24646. * Gets the current plugin used to run the simulation
  24647. * @returns current plugin
  24648. */
  24649. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24650. /**
  24651. * Gets the list of physic impostors
  24652. * @returns an array of PhysicsImpostor
  24653. */
  24654. getImpostors(): Array<PhysicsImpostor>;
  24655. /**
  24656. * Gets the impostor for a physics enabled object
  24657. * @param object defines the object impersonated by the impostor
  24658. * @returns the PhysicsImpostor or null if not found
  24659. */
  24660. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24661. /**
  24662. * Gets the impostor for a physics body object
  24663. * @param body defines physics body used by the impostor
  24664. * @returns the PhysicsImpostor or null if not found
  24665. */
  24666. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24667. /**
  24668. * Does a raycast in the physics world
  24669. * @param from when should the ray start?
  24670. * @param to when should the ray end?
  24671. * @returns PhysicsRaycastResult
  24672. */
  24673. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24674. /**
  24675. * Called by the scene. No need to call it.
  24676. * @param delta defines the timespam between frames
  24677. */
  24678. _step(delta: number): void;
  24679. }
  24680. }
  24681. declare module "babylonjs/Physics/physicsImpostor" {
  24682. import { Nullable, IndicesArray } from "babylonjs/types";
  24683. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24684. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24686. import { Scene } from "babylonjs/scene";
  24687. import { Bone } from "babylonjs/Bones/bone";
  24688. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24689. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24690. import { Space } from "babylonjs/Maths/math.axis";
  24691. /**
  24692. * The interface for the physics imposter parameters
  24693. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24694. */
  24695. export interface PhysicsImpostorParameters {
  24696. /**
  24697. * The mass of the physics imposter
  24698. */
  24699. mass: number;
  24700. /**
  24701. * The friction of the physics imposter
  24702. */
  24703. friction?: number;
  24704. /**
  24705. * The coefficient of restitution of the physics imposter
  24706. */
  24707. restitution?: number;
  24708. /**
  24709. * The native options of the physics imposter
  24710. */
  24711. nativeOptions?: any;
  24712. /**
  24713. * Specifies if the parent should be ignored
  24714. */
  24715. ignoreParent?: boolean;
  24716. /**
  24717. * Specifies if bi-directional transformations should be disabled
  24718. */
  24719. disableBidirectionalTransformation?: boolean;
  24720. /**
  24721. * The pressure inside the physics imposter, soft object only
  24722. */
  24723. pressure?: number;
  24724. /**
  24725. * The stiffness the physics imposter, soft object only
  24726. */
  24727. stiffness?: number;
  24728. /**
  24729. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24730. */
  24731. velocityIterations?: number;
  24732. /**
  24733. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24734. */
  24735. positionIterations?: number;
  24736. /**
  24737. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24738. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24739. * Add to fix multiple points
  24740. */
  24741. fixedPoints?: number;
  24742. /**
  24743. * The collision margin around a soft object
  24744. */
  24745. margin?: number;
  24746. /**
  24747. * The collision margin around a soft object
  24748. */
  24749. damping?: number;
  24750. /**
  24751. * The path for a rope based on an extrusion
  24752. */
  24753. path?: any;
  24754. /**
  24755. * The shape of an extrusion used for a rope based on an extrusion
  24756. */
  24757. shape?: any;
  24758. }
  24759. /**
  24760. * Interface for a physics-enabled object
  24761. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24762. */
  24763. export interface IPhysicsEnabledObject {
  24764. /**
  24765. * The position of the physics-enabled object
  24766. */
  24767. position: Vector3;
  24768. /**
  24769. * The rotation of the physics-enabled object
  24770. */
  24771. rotationQuaternion: Nullable<Quaternion>;
  24772. /**
  24773. * The scale of the physics-enabled object
  24774. */
  24775. scaling: Vector3;
  24776. /**
  24777. * The rotation of the physics-enabled object
  24778. */
  24779. rotation?: Vector3;
  24780. /**
  24781. * The parent of the physics-enabled object
  24782. */
  24783. parent?: any;
  24784. /**
  24785. * The bounding info of the physics-enabled object
  24786. * @returns The bounding info of the physics-enabled object
  24787. */
  24788. getBoundingInfo(): BoundingInfo;
  24789. /**
  24790. * Computes the world matrix
  24791. * @param force Specifies if the world matrix should be computed by force
  24792. * @returns A world matrix
  24793. */
  24794. computeWorldMatrix(force: boolean): Matrix;
  24795. /**
  24796. * Gets the world matrix
  24797. * @returns A world matrix
  24798. */
  24799. getWorldMatrix?(): Matrix;
  24800. /**
  24801. * Gets the child meshes
  24802. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24803. * @returns An array of abstract meshes
  24804. */
  24805. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24806. /**
  24807. * Gets the vertex data
  24808. * @param kind The type of vertex data
  24809. * @returns A nullable array of numbers, or a float32 array
  24810. */
  24811. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24812. /**
  24813. * Gets the indices from the mesh
  24814. * @returns A nullable array of index arrays
  24815. */
  24816. getIndices?(): Nullable<IndicesArray>;
  24817. /**
  24818. * Gets the scene from the mesh
  24819. * @returns the indices array or null
  24820. */
  24821. getScene?(): Scene;
  24822. /**
  24823. * Gets the absolute position from the mesh
  24824. * @returns the absolute position
  24825. */
  24826. getAbsolutePosition(): Vector3;
  24827. /**
  24828. * Gets the absolute pivot point from the mesh
  24829. * @returns the absolute pivot point
  24830. */
  24831. getAbsolutePivotPoint(): Vector3;
  24832. /**
  24833. * Rotates the mesh
  24834. * @param axis The axis of rotation
  24835. * @param amount The amount of rotation
  24836. * @param space The space of the rotation
  24837. * @returns The rotation transform node
  24838. */
  24839. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24840. /**
  24841. * Translates the mesh
  24842. * @param axis The axis of translation
  24843. * @param distance The distance of translation
  24844. * @param space The space of the translation
  24845. * @returns The transform node
  24846. */
  24847. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24848. /**
  24849. * Sets the absolute position of the mesh
  24850. * @param absolutePosition The absolute position of the mesh
  24851. * @returns The transform node
  24852. */
  24853. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24854. /**
  24855. * Gets the class name of the mesh
  24856. * @returns The class name
  24857. */
  24858. getClassName(): string;
  24859. }
  24860. /**
  24861. * Represents a physics imposter
  24862. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24863. */
  24864. export class PhysicsImpostor {
  24865. /**
  24866. * The physics-enabled object used as the physics imposter
  24867. */
  24868. object: IPhysicsEnabledObject;
  24869. /**
  24870. * The type of the physics imposter
  24871. */
  24872. type: number;
  24873. private _options;
  24874. private _scene?;
  24875. /**
  24876. * The default object size of the imposter
  24877. */
  24878. static DEFAULT_OBJECT_SIZE: Vector3;
  24879. /**
  24880. * The identity quaternion of the imposter
  24881. */
  24882. static IDENTITY_QUATERNION: Quaternion;
  24883. /** @hidden */
  24884. _pluginData: any;
  24885. private _physicsEngine;
  24886. private _physicsBody;
  24887. private _bodyUpdateRequired;
  24888. private _onBeforePhysicsStepCallbacks;
  24889. private _onAfterPhysicsStepCallbacks;
  24890. /** @hidden */
  24891. _onPhysicsCollideCallbacks: Array<{
  24892. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24893. otherImpostors: Array<PhysicsImpostor>;
  24894. }>;
  24895. private _deltaPosition;
  24896. private _deltaRotation;
  24897. private _deltaRotationConjugated;
  24898. /** @hidden */
  24899. _isFromLine: boolean;
  24900. private _parent;
  24901. private _isDisposed;
  24902. private static _tmpVecs;
  24903. private static _tmpQuat;
  24904. /**
  24905. * Specifies if the physics imposter is disposed
  24906. */
  24907. get isDisposed(): boolean;
  24908. /**
  24909. * Gets the mass of the physics imposter
  24910. */
  24911. get mass(): number;
  24912. set mass(value: number);
  24913. /**
  24914. * Gets the coefficient of friction
  24915. */
  24916. get friction(): number;
  24917. /**
  24918. * Sets the coefficient of friction
  24919. */
  24920. set friction(value: number);
  24921. /**
  24922. * Gets the coefficient of restitution
  24923. */
  24924. get restitution(): number;
  24925. /**
  24926. * Sets the coefficient of restitution
  24927. */
  24928. set restitution(value: number);
  24929. /**
  24930. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24931. */
  24932. get pressure(): number;
  24933. /**
  24934. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24935. */
  24936. set pressure(value: number);
  24937. /**
  24938. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24939. */
  24940. get stiffness(): number;
  24941. /**
  24942. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24943. */
  24944. set stiffness(value: number);
  24945. /**
  24946. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24947. */
  24948. get velocityIterations(): number;
  24949. /**
  24950. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24951. */
  24952. set velocityIterations(value: number);
  24953. /**
  24954. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24955. */
  24956. get positionIterations(): number;
  24957. /**
  24958. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24959. */
  24960. set positionIterations(value: number);
  24961. /**
  24962. * The unique id of the physics imposter
  24963. * set by the physics engine when adding this impostor to the array
  24964. */
  24965. uniqueId: number;
  24966. /**
  24967. * @hidden
  24968. */
  24969. soft: boolean;
  24970. /**
  24971. * @hidden
  24972. */
  24973. segments: number;
  24974. private _joints;
  24975. /**
  24976. * Initializes the physics imposter
  24977. * @param object The physics-enabled object used as the physics imposter
  24978. * @param type The type of the physics imposter
  24979. * @param _options The options for the physics imposter
  24980. * @param _scene The Babylon scene
  24981. */
  24982. constructor(
  24983. /**
  24984. * The physics-enabled object used as the physics imposter
  24985. */
  24986. object: IPhysicsEnabledObject,
  24987. /**
  24988. * The type of the physics imposter
  24989. */
  24990. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24991. /**
  24992. * This function will completly initialize this impostor.
  24993. * It will create a new body - but only if this mesh has no parent.
  24994. * If it has, this impostor will not be used other than to define the impostor
  24995. * of the child mesh.
  24996. * @hidden
  24997. */
  24998. _init(): void;
  24999. private _getPhysicsParent;
  25000. /**
  25001. * Should a new body be generated.
  25002. * @returns boolean specifying if body initialization is required
  25003. */
  25004. isBodyInitRequired(): boolean;
  25005. /**
  25006. * Sets the updated scaling
  25007. * @param updated Specifies if the scaling is updated
  25008. */
  25009. setScalingUpdated(): void;
  25010. /**
  25011. * Force a regeneration of this or the parent's impostor's body.
  25012. * Use under cautious - This will remove all joints already implemented.
  25013. */
  25014. forceUpdate(): void;
  25015. /**
  25016. * Gets the body that holds this impostor. Either its own, or its parent.
  25017. */
  25018. get physicsBody(): any;
  25019. /**
  25020. * Get the parent of the physics imposter
  25021. * @returns Physics imposter or null
  25022. */
  25023. get parent(): Nullable<PhysicsImpostor>;
  25024. /**
  25025. * Sets the parent of the physics imposter
  25026. */
  25027. set parent(value: Nullable<PhysicsImpostor>);
  25028. /**
  25029. * Set the physics body. Used mainly by the physics engine/plugin
  25030. */
  25031. set physicsBody(physicsBody: any);
  25032. /**
  25033. * Resets the update flags
  25034. */
  25035. resetUpdateFlags(): void;
  25036. /**
  25037. * Gets the object extend size
  25038. * @returns the object extend size
  25039. */
  25040. getObjectExtendSize(): Vector3;
  25041. /**
  25042. * Gets the object center
  25043. * @returns The object center
  25044. */
  25045. getObjectCenter(): Vector3;
  25046. /**
  25047. * Get a specific parameter from the options parameters
  25048. * @param paramName The object parameter name
  25049. * @returns The object parameter
  25050. */
  25051. getParam(paramName: string): any;
  25052. /**
  25053. * Sets a specific parameter in the options given to the physics plugin
  25054. * @param paramName The parameter name
  25055. * @param value The value of the parameter
  25056. */
  25057. setParam(paramName: string, value: number): void;
  25058. /**
  25059. * Specifically change the body's mass option. Won't recreate the physics body object
  25060. * @param mass The mass of the physics imposter
  25061. */
  25062. setMass(mass: number): void;
  25063. /**
  25064. * Gets the linear velocity
  25065. * @returns linear velocity or null
  25066. */
  25067. getLinearVelocity(): Nullable<Vector3>;
  25068. /**
  25069. * Sets the linear velocity
  25070. * @param velocity linear velocity or null
  25071. */
  25072. setLinearVelocity(velocity: Nullable<Vector3>): void;
  25073. /**
  25074. * Gets the angular velocity
  25075. * @returns angular velocity or null
  25076. */
  25077. getAngularVelocity(): Nullable<Vector3>;
  25078. /**
  25079. * Sets the angular velocity
  25080. * @param velocity The velocity or null
  25081. */
  25082. setAngularVelocity(velocity: Nullable<Vector3>): void;
  25083. /**
  25084. * Execute a function with the physics plugin native code
  25085. * Provide a function the will have two variables - the world object and the physics body object
  25086. * @param func The function to execute with the physics plugin native code
  25087. */
  25088. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  25089. /**
  25090. * Register a function that will be executed before the physics world is stepping forward
  25091. * @param func The function to execute before the physics world is stepped forward
  25092. */
  25093. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25094. /**
  25095. * Unregister a function that will be executed before the physics world is stepping forward
  25096. * @param func The function to execute before the physics world is stepped forward
  25097. */
  25098. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25099. /**
  25100. * Register a function that will be executed after the physics step
  25101. * @param func The function to execute after physics step
  25102. */
  25103. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25104. /**
  25105. * Unregisters a function that will be executed after the physics step
  25106. * @param func The function to execute after physics step
  25107. */
  25108. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25109. /**
  25110. * register a function that will be executed when this impostor collides against a different body
  25111. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  25112. * @param func Callback that is executed on collision
  25113. */
  25114. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  25115. /**
  25116. * Unregisters the physics imposter on contact
  25117. * @param collideAgainst The physics object to collide against
  25118. * @param func Callback to execute on collision
  25119. */
  25120. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  25121. private _tmpQuat;
  25122. private _tmpQuat2;
  25123. /**
  25124. * Get the parent rotation
  25125. * @returns The parent rotation
  25126. */
  25127. getParentsRotation(): Quaternion;
  25128. /**
  25129. * this function is executed by the physics engine.
  25130. */
  25131. beforeStep: () => void;
  25132. /**
  25133. * this function is executed by the physics engine
  25134. */
  25135. afterStep: () => void;
  25136. /**
  25137. * Legacy collision detection event support
  25138. */
  25139. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  25140. /**
  25141. * event and body object due to cannon's event-based architecture.
  25142. */
  25143. onCollide: (e: {
  25144. body: any;
  25145. }) => void;
  25146. /**
  25147. * Apply a force
  25148. * @param force The force to apply
  25149. * @param contactPoint The contact point for the force
  25150. * @returns The physics imposter
  25151. */
  25152. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  25153. /**
  25154. * Apply an impulse
  25155. * @param force The impulse force
  25156. * @param contactPoint The contact point for the impulse force
  25157. * @returns The physics imposter
  25158. */
  25159. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  25160. /**
  25161. * A help function to create a joint
  25162. * @param otherImpostor A physics imposter used to create a joint
  25163. * @param jointType The type of joint
  25164. * @param jointData The data for the joint
  25165. * @returns The physics imposter
  25166. */
  25167. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  25168. /**
  25169. * Add a joint to this impostor with a different impostor
  25170. * @param otherImpostor A physics imposter used to add a joint
  25171. * @param joint The joint to add
  25172. * @returns The physics imposter
  25173. */
  25174. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  25175. /**
  25176. * Add an anchor to a cloth impostor
  25177. * @param otherImpostor rigid impostor to anchor to
  25178. * @param width ratio across width from 0 to 1
  25179. * @param height ratio up height from 0 to 1
  25180. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  25181. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  25182. * @returns impostor the soft imposter
  25183. */
  25184. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  25185. /**
  25186. * Add a hook to a rope impostor
  25187. * @param otherImpostor rigid impostor to anchor to
  25188. * @param length ratio across rope from 0 to 1
  25189. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  25190. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  25191. * @returns impostor the rope imposter
  25192. */
  25193. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  25194. /**
  25195. * Will keep this body still, in a sleep mode.
  25196. * @returns the physics imposter
  25197. */
  25198. sleep(): PhysicsImpostor;
  25199. /**
  25200. * Wake the body up.
  25201. * @returns The physics imposter
  25202. */
  25203. wakeUp(): PhysicsImpostor;
  25204. /**
  25205. * Clones the physics imposter
  25206. * @param newObject The physics imposter clones to this physics-enabled object
  25207. * @returns A nullable physics imposter
  25208. */
  25209. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  25210. /**
  25211. * Disposes the physics imposter
  25212. */
  25213. dispose(): void;
  25214. /**
  25215. * Sets the delta position
  25216. * @param position The delta position amount
  25217. */
  25218. setDeltaPosition(position: Vector3): void;
  25219. /**
  25220. * Sets the delta rotation
  25221. * @param rotation The delta rotation amount
  25222. */
  25223. setDeltaRotation(rotation: Quaternion): void;
  25224. /**
  25225. * Gets the box size of the physics imposter and stores the result in the input parameter
  25226. * @param result Stores the box size
  25227. * @returns The physics imposter
  25228. */
  25229. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  25230. /**
  25231. * Gets the radius of the physics imposter
  25232. * @returns Radius of the physics imposter
  25233. */
  25234. getRadius(): number;
  25235. /**
  25236. * Sync a bone with this impostor
  25237. * @param bone The bone to sync to the impostor.
  25238. * @param boneMesh The mesh that the bone is influencing.
  25239. * @param jointPivot The pivot of the joint / bone in local space.
  25240. * @param distToJoint Optional distance from the impostor to the joint.
  25241. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25242. */
  25243. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  25244. /**
  25245. * Sync impostor to a bone
  25246. * @param bone The bone that the impostor will be synced to.
  25247. * @param boneMesh The mesh that the bone is influencing.
  25248. * @param jointPivot The pivot of the joint / bone in local space.
  25249. * @param distToJoint Optional distance from the impostor to the joint.
  25250. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25251. * @param boneAxis Optional vector3 axis the bone is aligned with
  25252. */
  25253. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  25254. /**
  25255. * No-Imposter type
  25256. */
  25257. static NoImpostor: number;
  25258. /**
  25259. * Sphere-Imposter type
  25260. */
  25261. static SphereImpostor: number;
  25262. /**
  25263. * Box-Imposter type
  25264. */
  25265. static BoxImpostor: number;
  25266. /**
  25267. * Plane-Imposter type
  25268. */
  25269. static PlaneImpostor: number;
  25270. /**
  25271. * Mesh-imposter type
  25272. */
  25273. static MeshImpostor: number;
  25274. /**
  25275. * Capsule-Impostor type (Ammo.js plugin only)
  25276. */
  25277. static CapsuleImpostor: number;
  25278. /**
  25279. * Cylinder-Imposter type
  25280. */
  25281. static CylinderImpostor: number;
  25282. /**
  25283. * Particle-Imposter type
  25284. */
  25285. static ParticleImpostor: number;
  25286. /**
  25287. * Heightmap-Imposter type
  25288. */
  25289. static HeightmapImpostor: number;
  25290. /**
  25291. * ConvexHull-Impostor type (Ammo.js plugin only)
  25292. */
  25293. static ConvexHullImpostor: number;
  25294. /**
  25295. * Custom-Imposter type (Ammo.js plugin only)
  25296. */
  25297. static CustomImpostor: number;
  25298. /**
  25299. * Rope-Imposter type
  25300. */
  25301. static RopeImpostor: number;
  25302. /**
  25303. * Cloth-Imposter type
  25304. */
  25305. static ClothImpostor: number;
  25306. /**
  25307. * Softbody-Imposter type
  25308. */
  25309. static SoftbodyImpostor: number;
  25310. }
  25311. }
  25312. declare module "babylonjs/Meshes/mesh" {
  25313. import { Observable } from "babylonjs/Misc/observable";
  25314. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25315. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  25316. import { Camera } from "babylonjs/Cameras/camera";
  25317. import { Scene } from "babylonjs/scene";
  25318. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  25319. import { Color4 } from "babylonjs/Maths/math.color";
  25320. import { Engine } from "babylonjs/Engines/engine";
  25321. import { Node } from "babylonjs/node";
  25322. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  25323. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  25324. import { Buffer } from "babylonjs/Meshes/buffer";
  25325. import { Geometry } from "babylonjs/Meshes/geometry";
  25326. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25327. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25328. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  25329. import { Effect } from "babylonjs/Materials/effect";
  25330. import { Material } from "babylonjs/Materials/material";
  25331. import { Skeleton } from "babylonjs/Bones/skeleton";
  25332. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  25333. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  25334. import { Path3D } from "babylonjs/Maths/math.path";
  25335. import { Plane } from "babylonjs/Maths/math.plane";
  25336. import { TransformNode } from "babylonjs/Meshes/transformNode";
  25337. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  25338. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  25339. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  25340. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  25341. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  25342. /**
  25343. * @hidden
  25344. **/
  25345. export class _CreationDataStorage {
  25346. closePath?: boolean;
  25347. closeArray?: boolean;
  25348. idx: number[];
  25349. dashSize: number;
  25350. gapSize: number;
  25351. path3D: Path3D;
  25352. pathArray: Vector3[][];
  25353. arc: number;
  25354. radius: number;
  25355. cap: number;
  25356. tessellation: number;
  25357. }
  25358. /**
  25359. * @hidden
  25360. **/
  25361. class _InstanceDataStorage {
  25362. visibleInstances: any;
  25363. batchCache: _InstancesBatch;
  25364. instancesBufferSize: number;
  25365. instancesBuffer: Nullable<Buffer>;
  25366. instancesData: Float32Array;
  25367. overridenInstanceCount: number;
  25368. isFrozen: boolean;
  25369. previousBatch: Nullable<_InstancesBatch>;
  25370. hardwareInstancedRendering: boolean;
  25371. sideOrientation: number;
  25372. manualUpdate: boolean;
  25373. }
  25374. /**
  25375. * @hidden
  25376. **/
  25377. export class _InstancesBatch {
  25378. mustReturn: boolean;
  25379. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  25380. renderSelf: boolean[];
  25381. hardwareInstancedRendering: boolean[];
  25382. }
  25383. /**
  25384. * Class used to represent renderable models
  25385. */
  25386. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  25387. /**
  25388. * Mesh side orientation : usually the external or front surface
  25389. */
  25390. static readonly FRONTSIDE: number;
  25391. /**
  25392. * Mesh side orientation : usually the internal or back surface
  25393. */
  25394. static readonly BACKSIDE: number;
  25395. /**
  25396. * Mesh side orientation : both internal and external or front and back surfaces
  25397. */
  25398. static readonly DOUBLESIDE: number;
  25399. /**
  25400. * Mesh side orientation : by default, `FRONTSIDE`
  25401. */
  25402. static readonly DEFAULTSIDE: number;
  25403. /**
  25404. * Mesh cap setting : no cap
  25405. */
  25406. static readonly NO_CAP: number;
  25407. /**
  25408. * Mesh cap setting : one cap at the beginning of the mesh
  25409. */
  25410. static readonly CAP_START: number;
  25411. /**
  25412. * Mesh cap setting : one cap at the end of the mesh
  25413. */
  25414. static readonly CAP_END: number;
  25415. /**
  25416. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  25417. */
  25418. static readonly CAP_ALL: number;
  25419. /**
  25420. * Mesh pattern setting : no flip or rotate
  25421. */
  25422. static readonly NO_FLIP: number;
  25423. /**
  25424. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  25425. */
  25426. static readonly FLIP_TILE: number;
  25427. /**
  25428. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  25429. */
  25430. static readonly ROTATE_TILE: number;
  25431. /**
  25432. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  25433. */
  25434. static readonly FLIP_ROW: number;
  25435. /**
  25436. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  25437. */
  25438. static readonly ROTATE_ROW: number;
  25439. /**
  25440. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  25441. */
  25442. static readonly FLIP_N_ROTATE_TILE: number;
  25443. /**
  25444. * Mesh pattern setting : rotate pattern and rotate
  25445. */
  25446. static readonly FLIP_N_ROTATE_ROW: number;
  25447. /**
  25448. * Mesh tile positioning : part tiles same on left/right or top/bottom
  25449. */
  25450. static readonly CENTER: number;
  25451. /**
  25452. * Mesh tile positioning : part tiles on left
  25453. */
  25454. static readonly LEFT: number;
  25455. /**
  25456. * Mesh tile positioning : part tiles on right
  25457. */
  25458. static readonly RIGHT: number;
  25459. /**
  25460. * Mesh tile positioning : part tiles on top
  25461. */
  25462. static readonly TOP: number;
  25463. /**
  25464. * Mesh tile positioning : part tiles on bottom
  25465. */
  25466. static readonly BOTTOM: number;
  25467. /**
  25468. * Gets the default side orientation.
  25469. * @param orientation the orientation to value to attempt to get
  25470. * @returns the default orientation
  25471. * @hidden
  25472. */
  25473. static _GetDefaultSideOrientation(orientation?: number): number;
  25474. private _internalMeshDataInfo;
  25475. /**
  25476. * An event triggered before rendering the mesh
  25477. */
  25478. get onBeforeRenderObservable(): Observable<Mesh>;
  25479. /**
  25480. * An event triggered before binding the mesh
  25481. */
  25482. get onBeforeBindObservable(): Observable<Mesh>;
  25483. /**
  25484. * An event triggered after rendering the mesh
  25485. */
  25486. get onAfterRenderObservable(): Observable<Mesh>;
  25487. /**
  25488. * An event triggered before drawing the mesh
  25489. */
  25490. get onBeforeDrawObservable(): Observable<Mesh>;
  25491. private _onBeforeDrawObserver;
  25492. /**
  25493. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  25494. */
  25495. set onBeforeDraw(callback: () => void);
  25496. get hasInstances(): boolean;
  25497. /**
  25498. * Gets the delay loading state of the mesh (when delay loading is turned on)
  25499. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  25500. */
  25501. delayLoadState: number;
  25502. /**
  25503. * Gets the list of instances created from this mesh
  25504. * it is not supposed to be modified manually.
  25505. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  25506. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25507. */
  25508. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  25509. /**
  25510. * Gets the file containing delay loading data for this mesh
  25511. */
  25512. delayLoadingFile: string;
  25513. /** @hidden */
  25514. _binaryInfo: any;
  25515. /**
  25516. * User defined function used to change how LOD level selection is done
  25517. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25518. */
  25519. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25520. /**
  25521. * Gets or sets the morph target manager
  25522. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25523. */
  25524. get morphTargetManager(): Nullable<MorphTargetManager>;
  25525. set morphTargetManager(value: Nullable<MorphTargetManager>);
  25526. /** @hidden */
  25527. _creationDataStorage: Nullable<_CreationDataStorage>;
  25528. /** @hidden */
  25529. _geometry: Nullable<Geometry>;
  25530. /** @hidden */
  25531. _delayInfo: Array<string>;
  25532. /** @hidden */
  25533. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25534. /** @hidden */
  25535. _instanceDataStorage: _InstanceDataStorage;
  25536. private _effectiveMaterial;
  25537. /** @hidden */
  25538. _shouldGenerateFlatShading: boolean;
  25539. /** @hidden */
  25540. _originalBuilderSideOrientation: number;
  25541. /**
  25542. * Use this property to change the original side orientation defined at construction time
  25543. */
  25544. overrideMaterialSideOrientation: Nullable<number>;
  25545. /**
  25546. * Gets the source mesh (the one used to clone this one from)
  25547. */
  25548. get source(): Nullable<Mesh>;
  25549. /**
  25550. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25551. */
  25552. get isUnIndexed(): boolean;
  25553. set isUnIndexed(value: boolean);
  25554. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  25555. get worldMatrixInstancedBuffer(): Float32Array;
  25556. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  25557. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  25558. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  25559. /**
  25560. * @constructor
  25561. * @param name The value used by scene.getMeshByName() to do a lookup.
  25562. * @param scene The scene to add this mesh to.
  25563. * @param parent The parent of this mesh, if it has one
  25564. * @param source An optional Mesh from which geometry is shared, cloned.
  25565. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25566. * When false, achieved by calling a clone(), also passing False.
  25567. * This will make creation of children, recursive.
  25568. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25569. */
  25570. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25571. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25572. doNotInstantiate: boolean;
  25573. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25574. /**
  25575. * Gets the class name
  25576. * @returns the string "Mesh".
  25577. */
  25578. getClassName(): string;
  25579. /** @hidden */
  25580. get _isMesh(): boolean;
  25581. /**
  25582. * Returns a description of this mesh
  25583. * @param fullDetails define if full details about this mesh must be used
  25584. * @returns a descriptive string representing this mesh
  25585. */
  25586. toString(fullDetails?: boolean): string;
  25587. /** @hidden */
  25588. _unBindEffect(): void;
  25589. /**
  25590. * Gets a boolean indicating if this mesh has LOD
  25591. */
  25592. get hasLODLevels(): boolean;
  25593. /**
  25594. * Gets the list of MeshLODLevel associated with the current mesh
  25595. * @returns an array of MeshLODLevel
  25596. */
  25597. getLODLevels(): MeshLODLevel[];
  25598. private _sortLODLevels;
  25599. /**
  25600. * Add a mesh as LOD level triggered at the given distance.
  25601. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25602. * @param distance The distance from the center of the object to show this level
  25603. * @param mesh The mesh to be added as LOD level (can be null)
  25604. * @return This mesh (for chaining)
  25605. */
  25606. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25607. /**
  25608. * Returns the LOD level mesh at the passed distance or null if not found.
  25609. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25610. * @param distance The distance from the center of the object to show this level
  25611. * @returns a Mesh or `null`
  25612. */
  25613. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25614. /**
  25615. * Remove a mesh from the LOD array
  25616. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25617. * @param mesh defines the mesh to be removed
  25618. * @return This mesh (for chaining)
  25619. */
  25620. removeLODLevel(mesh: Mesh): Mesh;
  25621. /**
  25622. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25623. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25624. * @param camera defines the camera to use to compute distance
  25625. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25626. * @return This mesh (for chaining)
  25627. */
  25628. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25629. /**
  25630. * Gets the mesh internal Geometry object
  25631. */
  25632. get geometry(): Nullable<Geometry>;
  25633. /**
  25634. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25635. * @returns the total number of vertices
  25636. */
  25637. getTotalVertices(): number;
  25638. /**
  25639. * Returns the content of an associated vertex buffer
  25640. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25641. * - VertexBuffer.PositionKind
  25642. * - VertexBuffer.UVKind
  25643. * - VertexBuffer.UV2Kind
  25644. * - VertexBuffer.UV3Kind
  25645. * - VertexBuffer.UV4Kind
  25646. * - VertexBuffer.UV5Kind
  25647. * - VertexBuffer.UV6Kind
  25648. * - VertexBuffer.ColorKind
  25649. * - VertexBuffer.MatricesIndicesKind
  25650. * - VertexBuffer.MatricesIndicesExtraKind
  25651. * - VertexBuffer.MatricesWeightsKind
  25652. * - VertexBuffer.MatricesWeightsExtraKind
  25653. * @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
  25654. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25655. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25656. */
  25657. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25658. /**
  25659. * Returns the mesh VertexBuffer object from the requested `kind`
  25660. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25661. * - VertexBuffer.PositionKind
  25662. * - VertexBuffer.NormalKind
  25663. * - VertexBuffer.UVKind
  25664. * - VertexBuffer.UV2Kind
  25665. * - VertexBuffer.UV3Kind
  25666. * - VertexBuffer.UV4Kind
  25667. * - VertexBuffer.UV5Kind
  25668. * - VertexBuffer.UV6Kind
  25669. * - VertexBuffer.ColorKind
  25670. * - VertexBuffer.MatricesIndicesKind
  25671. * - VertexBuffer.MatricesIndicesExtraKind
  25672. * - VertexBuffer.MatricesWeightsKind
  25673. * - VertexBuffer.MatricesWeightsExtraKind
  25674. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25675. */
  25676. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25677. /**
  25678. * Tests if a specific vertex buffer is associated with this mesh
  25679. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25680. * - VertexBuffer.PositionKind
  25681. * - VertexBuffer.NormalKind
  25682. * - VertexBuffer.UVKind
  25683. * - VertexBuffer.UV2Kind
  25684. * - VertexBuffer.UV3Kind
  25685. * - VertexBuffer.UV4Kind
  25686. * - VertexBuffer.UV5Kind
  25687. * - VertexBuffer.UV6Kind
  25688. * - VertexBuffer.ColorKind
  25689. * - VertexBuffer.MatricesIndicesKind
  25690. * - VertexBuffer.MatricesIndicesExtraKind
  25691. * - VertexBuffer.MatricesWeightsKind
  25692. * - VertexBuffer.MatricesWeightsExtraKind
  25693. * @returns a boolean
  25694. */
  25695. isVerticesDataPresent(kind: string): boolean;
  25696. /**
  25697. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25698. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25699. * - VertexBuffer.PositionKind
  25700. * - VertexBuffer.UVKind
  25701. * - VertexBuffer.UV2Kind
  25702. * - VertexBuffer.UV3Kind
  25703. * - VertexBuffer.UV4Kind
  25704. * - VertexBuffer.UV5Kind
  25705. * - VertexBuffer.UV6Kind
  25706. * - VertexBuffer.ColorKind
  25707. * - VertexBuffer.MatricesIndicesKind
  25708. * - VertexBuffer.MatricesIndicesExtraKind
  25709. * - VertexBuffer.MatricesWeightsKind
  25710. * - VertexBuffer.MatricesWeightsExtraKind
  25711. * @returns a boolean
  25712. */
  25713. isVertexBufferUpdatable(kind: string): boolean;
  25714. /**
  25715. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25716. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25717. * - VertexBuffer.PositionKind
  25718. * - VertexBuffer.NormalKind
  25719. * - VertexBuffer.UVKind
  25720. * - VertexBuffer.UV2Kind
  25721. * - VertexBuffer.UV3Kind
  25722. * - VertexBuffer.UV4Kind
  25723. * - VertexBuffer.UV5Kind
  25724. * - VertexBuffer.UV6Kind
  25725. * - VertexBuffer.ColorKind
  25726. * - VertexBuffer.MatricesIndicesKind
  25727. * - VertexBuffer.MatricesIndicesExtraKind
  25728. * - VertexBuffer.MatricesWeightsKind
  25729. * - VertexBuffer.MatricesWeightsExtraKind
  25730. * @returns an array of strings
  25731. */
  25732. getVerticesDataKinds(): string[];
  25733. /**
  25734. * Returns a positive integer : the total number of indices in this mesh geometry.
  25735. * @returns the numner of indices or zero if the mesh has no geometry.
  25736. */
  25737. getTotalIndices(): number;
  25738. /**
  25739. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25740. * @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.
  25741. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25742. * @returns the indices array or an empty array if the mesh has no geometry
  25743. */
  25744. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25745. get isBlocked(): boolean;
  25746. /**
  25747. * Determine if the current mesh is ready to be rendered
  25748. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25749. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25750. * @returns true if all associated assets are ready (material, textures, shaders)
  25751. */
  25752. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25753. /**
  25754. * 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.
  25755. */
  25756. get areNormalsFrozen(): boolean;
  25757. /**
  25758. * 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.
  25759. * @returns the current mesh
  25760. */
  25761. freezeNormals(): Mesh;
  25762. /**
  25763. * 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
  25764. * @returns the current mesh
  25765. */
  25766. unfreezeNormals(): Mesh;
  25767. /**
  25768. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25769. */
  25770. set overridenInstanceCount(count: number);
  25771. /** @hidden */
  25772. _preActivate(): Mesh;
  25773. /** @hidden */
  25774. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25775. /** @hidden */
  25776. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25777. /**
  25778. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25779. * This means the mesh underlying bounding box and sphere are recomputed.
  25780. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25781. * @returns the current mesh
  25782. */
  25783. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25784. /** @hidden */
  25785. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25786. /**
  25787. * This function will subdivide the mesh into multiple submeshes
  25788. * @param count defines the expected number of submeshes
  25789. */
  25790. subdivide(count: number): void;
  25791. /**
  25792. * Copy a FloatArray into a specific associated vertex buffer
  25793. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25794. * - VertexBuffer.PositionKind
  25795. * - VertexBuffer.UVKind
  25796. * - VertexBuffer.UV2Kind
  25797. * - VertexBuffer.UV3Kind
  25798. * - VertexBuffer.UV4Kind
  25799. * - VertexBuffer.UV5Kind
  25800. * - VertexBuffer.UV6Kind
  25801. * - VertexBuffer.ColorKind
  25802. * - VertexBuffer.MatricesIndicesKind
  25803. * - VertexBuffer.MatricesIndicesExtraKind
  25804. * - VertexBuffer.MatricesWeightsKind
  25805. * - VertexBuffer.MatricesWeightsExtraKind
  25806. * @param data defines the data source
  25807. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25808. * @param stride defines the data stride size (can be null)
  25809. * @returns the current mesh
  25810. */
  25811. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25812. /**
  25813. * Delete a vertex buffer associated with this mesh
  25814. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25815. * - VertexBuffer.PositionKind
  25816. * - VertexBuffer.UVKind
  25817. * - VertexBuffer.UV2Kind
  25818. * - VertexBuffer.UV3Kind
  25819. * - VertexBuffer.UV4Kind
  25820. * - VertexBuffer.UV5Kind
  25821. * - VertexBuffer.UV6Kind
  25822. * - VertexBuffer.ColorKind
  25823. * - VertexBuffer.MatricesIndicesKind
  25824. * - VertexBuffer.MatricesIndicesExtraKind
  25825. * - VertexBuffer.MatricesWeightsKind
  25826. * - VertexBuffer.MatricesWeightsExtraKind
  25827. */
  25828. removeVerticesData(kind: string): void;
  25829. /**
  25830. * Flags an associated vertex buffer as updatable
  25831. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25832. * - VertexBuffer.PositionKind
  25833. * - VertexBuffer.UVKind
  25834. * - VertexBuffer.UV2Kind
  25835. * - VertexBuffer.UV3Kind
  25836. * - VertexBuffer.UV4Kind
  25837. * - VertexBuffer.UV5Kind
  25838. * - VertexBuffer.UV6Kind
  25839. * - VertexBuffer.ColorKind
  25840. * - VertexBuffer.MatricesIndicesKind
  25841. * - VertexBuffer.MatricesIndicesExtraKind
  25842. * - VertexBuffer.MatricesWeightsKind
  25843. * - VertexBuffer.MatricesWeightsExtraKind
  25844. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25845. */
  25846. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25847. /**
  25848. * Sets the mesh global Vertex Buffer
  25849. * @param buffer defines the buffer to use
  25850. * @returns the current mesh
  25851. */
  25852. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25853. /**
  25854. * Update a specific associated vertex buffer
  25855. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25856. * - VertexBuffer.PositionKind
  25857. * - VertexBuffer.UVKind
  25858. * - VertexBuffer.UV2Kind
  25859. * - VertexBuffer.UV3Kind
  25860. * - VertexBuffer.UV4Kind
  25861. * - VertexBuffer.UV5Kind
  25862. * - VertexBuffer.UV6Kind
  25863. * - VertexBuffer.ColorKind
  25864. * - VertexBuffer.MatricesIndicesKind
  25865. * - VertexBuffer.MatricesIndicesExtraKind
  25866. * - VertexBuffer.MatricesWeightsKind
  25867. * - VertexBuffer.MatricesWeightsExtraKind
  25868. * @param data defines the data source
  25869. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25870. * @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)
  25871. * @returns the current mesh
  25872. */
  25873. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25874. /**
  25875. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25876. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25877. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25878. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25879. * @returns the current mesh
  25880. */
  25881. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25882. /**
  25883. * Creates a un-shared specific occurence of the geometry for the mesh.
  25884. * @returns the current mesh
  25885. */
  25886. makeGeometryUnique(): Mesh;
  25887. /**
  25888. * Set the index buffer of this mesh
  25889. * @param indices defines the source data
  25890. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25891. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25892. * @returns the current mesh
  25893. */
  25894. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25895. /**
  25896. * Update the current index buffer
  25897. * @param indices defines the source data
  25898. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25899. * @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)
  25900. * @returns the current mesh
  25901. */
  25902. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25903. /**
  25904. * Invert the geometry to move from a right handed system to a left handed one.
  25905. * @returns the current mesh
  25906. */
  25907. toLeftHanded(): Mesh;
  25908. /** @hidden */
  25909. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25910. /** @hidden */
  25911. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25912. /**
  25913. * Registers for this mesh a javascript function called just before the rendering process
  25914. * @param func defines the function to call before rendering this mesh
  25915. * @returns the current mesh
  25916. */
  25917. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25918. /**
  25919. * Disposes a previously registered javascript function called before the rendering
  25920. * @param func defines the function to remove
  25921. * @returns the current mesh
  25922. */
  25923. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25924. /**
  25925. * Registers for this mesh a javascript function called just after the rendering is complete
  25926. * @param func defines the function to call after rendering this mesh
  25927. * @returns the current mesh
  25928. */
  25929. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25930. /**
  25931. * Disposes a previously registered javascript function called after the rendering.
  25932. * @param func defines the function to remove
  25933. * @returns the current mesh
  25934. */
  25935. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25936. /** @hidden */
  25937. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25938. /** @hidden */
  25939. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25940. /** @hidden */
  25941. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25942. /** @hidden */
  25943. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25944. /** @hidden */
  25945. _rebuild(): void;
  25946. /** @hidden */
  25947. _freeze(): void;
  25948. /** @hidden */
  25949. _unFreeze(): void;
  25950. /**
  25951. * 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
  25952. * @param subMesh defines the subMesh to render
  25953. * @param enableAlphaMode defines if alpha mode can be changed
  25954. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25955. * @returns the current mesh
  25956. */
  25957. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25958. private _onBeforeDraw;
  25959. /**
  25960. * Renormalize the mesh and patch it up if there are no weights
  25961. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25962. * However in the case of zero weights then we set just a single influence to 1.
  25963. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25964. */
  25965. cleanMatrixWeights(): void;
  25966. private normalizeSkinFourWeights;
  25967. private normalizeSkinWeightsAndExtra;
  25968. /**
  25969. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25970. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25971. * the user know there was an issue with importing the mesh
  25972. * @returns a validation object with skinned, valid and report string
  25973. */
  25974. validateSkinning(): {
  25975. skinned: boolean;
  25976. valid: boolean;
  25977. report: string;
  25978. };
  25979. /** @hidden */
  25980. _checkDelayState(): Mesh;
  25981. private _queueLoad;
  25982. /**
  25983. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25984. * A mesh is in the frustum if its bounding box intersects the frustum
  25985. * @param frustumPlanes defines the frustum to test
  25986. * @returns true if the mesh is in the frustum planes
  25987. */
  25988. isInFrustum(frustumPlanes: Plane[]): boolean;
  25989. /**
  25990. * Sets the mesh material by the material or multiMaterial `id` property
  25991. * @param id is a string identifying the material or the multiMaterial
  25992. * @returns the current mesh
  25993. */
  25994. setMaterialByID(id: string): Mesh;
  25995. /**
  25996. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25997. * @returns an array of IAnimatable
  25998. */
  25999. getAnimatables(): IAnimatable[];
  26000. /**
  26001. * Modifies the mesh geometry according to the passed transformation matrix.
  26002. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  26003. * The mesh normals are modified using the same transformation.
  26004. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26005. * @param transform defines the transform matrix to use
  26006. * @see http://doc.babylonjs.com/resources/baking_transformations
  26007. * @returns the current mesh
  26008. */
  26009. bakeTransformIntoVertices(transform: Matrix): Mesh;
  26010. /**
  26011. * Modifies the mesh geometry according to its own current World Matrix.
  26012. * The mesh World Matrix is then reset.
  26013. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  26014. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26015. * @see http://doc.babylonjs.com/resources/baking_transformations
  26016. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  26017. * @returns the current mesh
  26018. */
  26019. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  26020. /** @hidden */
  26021. get _positions(): Nullable<Vector3[]>;
  26022. /** @hidden */
  26023. _resetPointsArrayCache(): Mesh;
  26024. /** @hidden */
  26025. _generatePointsArray(): boolean;
  26026. /**
  26027. * Returns a new Mesh object generated from the current mesh properties.
  26028. * This method must not get confused with createInstance()
  26029. * @param name is a string, the name given to the new mesh
  26030. * @param newParent can be any Node object (default `null`)
  26031. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  26032. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  26033. * @returns a new mesh
  26034. */
  26035. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  26036. /**
  26037. * Releases resources associated with this mesh.
  26038. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26039. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26040. */
  26041. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26042. /** @hidden */
  26043. _disposeInstanceSpecificData(): void;
  26044. /**
  26045. * Modifies the mesh geometry according to a displacement map.
  26046. * 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.
  26047. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26048. * @param url is a string, the URL from the image file is to be downloaded.
  26049. * @param minHeight is the lower limit of the displacement.
  26050. * @param maxHeight is the upper limit of the displacement.
  26051. * @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.
  26052. * @param uvOffset is an optional vector2 used to offset UV.
  26053. * @param uvScale is an optional vector2 used to scale UV.
  26054. * @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.
  26055. * @returns the Mesh.
  26056. */
  26057. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26058. /**
  26059. * Modifies the mesh geometry according to a displacementMap buffer.
  26060. * 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.
  26061. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26062. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  26063. * @param heightMapWidth is the width of the buffer image.
  26064. * @param heightMapHeight is the height of the buffer image.
  26065. * @param minHeight is the lower limit of the displacement.
  26066. * @param maxHeight is the upper limit of the displacement.
  26067. * @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.
  26068. * @param uvOffset is an optional vector2 used to offset UV.
  26069. * @param uvScale is an optional vector2 used to scale UV.
  26070. * @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.
  26071. * @returns the Mesh.
  26072. */
  26073. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26074. /**
  26075. * Modify the mesh to get a flat shading rendering.
  26076. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  26077. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  26078. * @returns current mesh
  26079. */
  26080. convertToFlatShadedMesh(): Mesh;
  26081. /**
  26082. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  26083. * In other words, more vertices, no more indices and a single bigger VBO.
  26084. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  26085. * @returns current mesh
  26086. */
  26087. convertToUnIndexedMesh(): Mesh;
  26088. /**
  26089. * Inverses facet orientations.
  26090. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  26091. * @param flipNormals will also inverts the normals
  26092. * @returns current mesh
  26093. */
  26094. flipFaces(flipNormals?: boolean): Mesh;
  26095. /**
  26096. * Increase the number of facets and hence vertices in a mesh
  26097. * Vertex normals are interpolated from existing vertex normals
  26098. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  26099. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  26100. */
  26101. increaseVertices(numberPerEdge: number): void;
  26102. /**
  26103. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  26104. * This will undo any application of covertToFlatShadedMesh
  26105. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  26106. */
  26107. forceSharedVertices(): void;
  26108. /** @hidden */
  26109. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  26110. /** @hidden */
  26111. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  26112. /**
  26113. * Creates a new InstancedMesh object from the mesh model.
  26114. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26115. * @param name defines the name of the new instance
  26116. * @returns a new InstancedMesh
  26117. */
  26118. createInstance(name: string): InstancedMesh;
  26119. /**
  26120. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  26121. * After this call, all the mesh instances have the same submeshes than the current mesh.
  26122. * @returns the current mesh
  26123. */
  26124. synchronizeInstances(): Mesh;
  26125. /**
  26126. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  26127. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  26128. * This should be used together with the simplification to avoid disappearing triangles.
  26129. * @param successCallback an optional success callback to be called after the optimization finished.
  26130. * @returns the current mesh
  26131. */
  26132. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  26133. /**
  26134. * Serialize current mesh
  26135. * @param serializationObject defines the object which will receive the serialization data
  26136. */
  26137. serialize(serializationObject: any): void;
  26138. /** @hidden */
  26139. _syncGeometryWithMorphTargetManager(): void;
  26140. /** @hidden */
  26141. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  26142. /**
  26143. * Returns a new Mesh object parsed from the source provided.
  26144. * @param parsedMesh is the source
  26145. * @param scene defines the hosting scene
  26146. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  26147. * @returns a new Mesh
  26148. */
  26149. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  26150. /**
  26151. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  26152. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26153. * @param name defines the name of the mesh to create
  26154. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  26155. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  26156. * @param closePath creates a seam between the first and the last points of each path of the path array
  26157. * @param offset is taken in account only if the `pathArray` is containing a single path
  26158. * @param scene defines the hosting scene
  26159. * @param updatable defines if the mesh must be flagged as updatable
  26160. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26161. * @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)
  26162. * @returns a new Mesh
  26163. */
  26164. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26165. /**
  26166. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  26167. * @param name defines the name of the mesh to create
  26168. * @param radius sets the radius size (float) of the polygon (default 0.5)
  26169. * @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
  26170. * @param scene defines the hosting scene
  26171. * @param updatable defines if the mesh must be flagged as updatable
  26172. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26173. * @returns a new Mesh
  26174. */
  26175. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26176. /**
  26177. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  26178. * @param name defines the name of the mesh to create
  26179. * @param size sets the size (float) of each box side (default 1)
  26180. * @param scene defines the hosting scene
  26181. * @param updatable defines if the mesh must be flagged as updatable
  26182. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26183. * @returns a new Mesh
  26184. */
  26185. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26186. /**
  26187. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  26188. * @param name defines the name of the mesh to create
  26189. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  26190. * @param diameter sets the diameter size (float) of the sphere (default 1)
  26191. * @param scene defines the hosting scene
  26192. * @param updatable defines if the mesh must be flagged as updatable
  26193. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26194. * @returns a new Mesh
  26195. */
  26196. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26197. /**
  26198. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  26199. * @param name defines the name of the mesh to create
  26200. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  26201. * @param diameter sets the diameter size (float) of the sphere (default 1)
  26202. * @param scene defines the hosting scene
  26203. * @returns a new Mesh
  26204. */
  26205. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  26206. /**
  26207. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  26208. * @param name defines the name of the mesh to create
  26209. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  26210. * @param diameterTop set the top cap diameter (floats, default 1)
  26211. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  26212. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  26213. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  26214. * @param scene defines the hosting scene
  26215. * @param updatable defines if the mesh must be flagged as updatable
  26216. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26217. * @returns a new Mesh
  26218. */
  26219. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  26220. /**
  26221. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  26222. * @param name defines the name of the mesh to create
  26223. * @param diameter sets the diameter size (float) of the torus (default 1)
  26224. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  26225. * @param tessellation sets the number of torus sides (postive integer, default 16)
  26226. * @param scene defines the hosting scene
  26227. * @param updatable defines if the mesh must be flagged as updatable
  26228. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26229. * @returns a new Mesh
  26230. */
  26231. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26232. /**
  26233. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  26234. * @param name defines the name of the mesh to create
  26235. * @param radius sets the global radius size (float) of the torus knot (default 2)
  26236. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  26237. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  26238. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  26239. * @param p the number of windings on X axis (positive integers, default 2)
  26240. * @param q the number of windings on Y axis (positive integers, default 3)
  26241. * @param scene defines the hosting scene
  26242. * @param updatable defines if the mesh must be flagged as updatable
  26243. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26244. * @returns a new Mesh
  26245. */
  26246. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26247. /**
  26248. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  26249. * @param name defines the name of the mesh to create
  26250. * @param points is an array successive Vector3
  26251. * @param scene defines the hosting scene
  26252. * @param updatable defines if the mesh must be flagged as updatable
  26253. * @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).
  26254. * @returns a new Mesh
  26255. */
  26256. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  26257. /**
  26258. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  26259. * @param name defines the name of the mesh to create
  26260. * @param points is an array successive Vector3
  26261. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  26262. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  26263. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  26264. * @param scene defines the hosting scene
  26265. * @param updatable defines if the mesh must be flagged as updatable
  26266. * @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)
  26267. * @returns a new Mesh
  26268. */
  26269. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  26270. /**
  26271. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  26272. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  26273. * 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.
  26274. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26275. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  26276. * Remember you can only change the shape positions, not their number when updating a polygon.
  26277. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  26278. * @param name defines the name of the mesh to create
  26279. * @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
  26280. * @param scene defines the hosting scene
  26281. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26282. * @param updatable defines if the mesh must be flagged as updatable
  26283. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26284. * @param earcutInjection can be used to inject your own earcut reference
  26285. * @returns a new Mesh
  26286. */
  26287. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  26288. /**
  26289. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  26290. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  26291. * @param name defines the name of the mesh to create
  26292. * @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
  26293. * @param depth defines the height of extrusion
  26294. * @param scene defines the hosting scene
  26295. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26296. * @param updatable defines if the mesh must be flagged as updatable
  26297. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26298. * @param earcutInjection can be used to inject your own earcut reference
  26299. * @returns a new Mesh
  26300. */
  26301. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  26302. /**
  26303. * Creates an extruded shape mesh.
  26304. * 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
  26305. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26306. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26307. * @param name defines the name of the mesh to create
  26308. * @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
  26309. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26310. * @param scale is the value to scale the shape
  26311. * @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
  26312. * @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
  26313. * @param scene defines the hosting scene
  26314. * @param updatable defines if the mesh must be flagged as updatable
  26315. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26316. * @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)
  26317. * @returns a new Mesh
  26318. */
  26319. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26320. /**
  26321. * Creates an custom extruded shape mesh.
  26322. * The custom extrusion is a parametric shape.
  26323. * It has no predefined shape. Its final shape will depend on the input parameters.
  26324. * Please consider using the same method from the MeshBuilder class instead
  26325. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26326. * @param name defines the name of the mesh to create
  26327. * @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
  26328. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26329. * @param scaleFunction is a custom Javascript function called on each path point
  26330. * @param rotationFunction is a custom Javascript function called on each path point
  26331. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  26332. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  26333. * @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
  26334. * @param scene defines the hosting scene
  26335. * @param updatable defines if the mesh must be flagged as updatable
  26336. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26337. * @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)
  26338. * @returns a new Mesh
  26339. */
  26340. 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;
  26341. /**
  26342. * Creates lathe mesh.
  26343. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  26344. * Please consider using the same method from the MeshBuilder class instead
  26345. * @param name defines the name of the mesh to create
  26346. * @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
  26347. * @param radius is the radius value of the lathe
  26348. * @param tessellation is the side number of the lathe.
  26349. * @param scene defines the hosting scene
  26350. * @param updatable defines if the mesh must be flagged as updatable
  26351. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26352. * @returns a new Mesh
  26353. */
  26354. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26355. /**
  26356. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  26357. * @param name defines the name of the mesh to create
  26358. * @param size sets the size (float) of both sides of the plane at once (default 1)
  26359. * @param scene defines the hosting scene
  26360. * @param updatable defines if the mesh must be flagged as updatable
  26361. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26362. * @returns a new Mesh
  26363. */
  26364. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26365. /**
  26366. * Creates a ground mesh.
  26367. * Please consider using the same method from the MeshBuilder class instead
  26368. * @param name defines the name of the mesh to create
  26369. * @param width set the width of the ground
  26370. * @param height set the height of the ground
  26371. * @param subdivisions sets the number of subdivisions per side
  26372. * @param scene defines the hosting scene
  26373. * @param updatable defines if the mesh must be flagged as updatable
  26374. * @returns a new Mesh
  26375. */
  26376. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  26377. /**
  26378. * Creates a tiled ground mesh.
  26379. * Please consider using the same method from the MeshBuilder class instead
  26380. * @param name defines the name of the mesh to create
  26381. * @param xmin set the ground minimum X coordinate
  26382. * @param zmin set the ground minimum Y coordinate
  26383. * @param xmax set the ground maximum X coordinate
  26384. * @param zmax set the ground maximum Z coordinate
  26385. * @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
  26386. * @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
  26387. * @param scene defines the hosting scene
  26388. * @param updatable defines if the mesh must be flagged as updatable
  26389. * @returns a new Mesh
  26390. */
  26391. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  26392. w: number;
  26393. h: number;
  26394. }, precision: {
  26395. w: number;
  26396. h: number;
  26397. }, scene: Scene, updatable?: boolean): Mesh;
  26398. /**
  26399. * Creates a ground mesh from a height map.
  26400. * Please consider using the same method from the MeshBuilder class instead
  26401. * @see http://doc.babylonjs.com/babylon101/height_map
  26402. * @param name defines the name of the mesh to create
  26403. * @param url sets the URL of the height map image resource
  26404. * @param width set the ground width size
  26405. * @param height set the ground height size
  26406. * @param subdivisions sets the number of subdivision per side
  26407. * @param minHeight is the minimum altitude on the ground
  26408. * @param maxHeight is the maximum altitude on the ground
  26409. * @param scene defines the hosting scene
  26410. * @param updatable defines if the mesh must be flagged as updatable
  26411. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  26412. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  26413. * @returns a new Mesh
  26414. */
  26415. 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;
  26416. /**
  26417. * Creates a tube mesh.
  26418. * The tube is a parametric shape.
  26419. * It has no predefined shape. Its final shape will depend on the input parameters.
  26420. * Please consider using the same method from the MeshBuilder class instead
  26421. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26422. * @param name defines the name of the mesh to create
  26423. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  26424. * @param radius sets the tube radius size
  26425. * @param tessellation is the number of sides on the tubular surface
  26426. * @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
  26427. * @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
  26428. * @param scene defines the hosting scene
  26429. * @param updatable defines if the mesh must be flagged as updatable
  26430. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26431. * @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)
  26432. * @returns a new Mesh
  26433. */
  26434. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  26435. (i: number, distance: number): number;
  26436. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26437. /**
  26438. * Creates a polyhedron mesh.
  26439. * Please consider using the same method from the MeshBuilder class instead.
  26440. * * 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
  26441. * * The parameter `size` (positive float, default 1) sets the polygon size
  26442. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26443. * * 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`
  26444. * * 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
  26445. * * 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)`)
  26446. * * 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
  26447. * * 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
  26448. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26449. * * If you create a double-sided mesh, you can choose what parts of 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
  26450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26451. * @param name defines the name of the mesh to create
  26452. * @param options defines the options used to create the mesh
  26453. * @param scene defines the hosting scene
  26454. * @returns a new Mesh
  26455. */
  26456. static CreatePolyhedron(name: string, options: {
  26457. type?: number;
  26458. size?: number;
  26459. sizeX?: number;
  26460. sizeY?: number;
  26461. sizeZ?: number;
  26462. custom?: any;
  26463. faceUV?: Vector4[];
  26464. faceColors?: Color4[];
  26465. updatable?: boolean;
  26466. sideOrientation?: number;
  26467. }, scene: Scene): Mesh;
  26468. /**
  26469. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26470. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26471. * * 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`)
  26472. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26473. * * 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
  26474. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26475. * * If you create a double-sided mesh, you can choose what parts of 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
  26476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26477. * @param name defines the name of the mesh
  26478. * @param options defines the options used to create the mesh
  26479. * @param scene defines the hosting scene
  26480. * @returns a new Mesh
  26481. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26482. */
  26483. static CreateIcoSphere(name: string, options: {
  26484. radius?: number;
  26485. flat?: boolean;
  26486. subdivisions?: number;
  26487. sideOrientation?: number;
  26488. updatable?: boolean;
  26489. }, scene: Scene): Mesh;
  26490. /**
  26491. * Creates a decal mesh.
  26492. * Please consider using the same method from the MeshBuilder class instead.
  26493. * A decal is a mesh usually applied as a model onto the surface of another mesh
  26494. * @param name defines the name of the mesh
  26495. * @param sourceMesh defines the mesh receiving the decal
  26496. * @param position sets the position of the decal in world coordinates
  26497. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  26498. * @param size sets the decal scaling
  26499. * @param angle sets the angle to rotate the decal
  26500. * @returns a new Mesh
  26501. */
  26502. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  26503. /**
  26504. * Prepare internal position array for software CPU skinning
  26505. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  26506. */
  26507. setPositionsForCPUSkinning(): Float32Array;
  26508. /**
  26509. * Prepare internal normal array for software CPU skinning
  26510. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  26511. */
  26512. setNormalsForCPUSkinning(): Float32Array;
  26513. /**
  26514. * Updates the vertex buffer by applying transformation from the bones
  26515. * @param skeleton defines the skeleton to apply to current mesh
  26516. * @returns the current mesh
  26517. */
  26518. applySkeleton(skeleton: Skeleton): Mesh;
  26519. /**
  26520. * 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
  26521. * @param meshes defines the list of meshes to scan
  26522. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26523. */
  26524. static MinMax(meshes: AbstractMesh[]): {
  26525. min: Vector3;
  26526. max: Vector3;
  26527. };
  26528. /**
  26529. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26530. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26531. * @returns a vector3
  26532. */
  26533. static Center(meshesOrMinMaxVector: {
  26534. min: Vector3;
  26535. max: Vector3;
  26536. } | AbstractMesh[]): Vector3;
  26537. /**
  26538. * Merge the array of meshes into a single mesh for performance reasons.
  26539. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26540. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26541. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26542. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26543. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26544. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  26545. * @returns a new mesh
  26546. */
  26547. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  26548. /** @hidden */
  26549. addInstance(instance: InstancedMesh): void;
  26550. /** @hidden */
  26551. removeInstance(instance: InstancedMesh): void;
  26552. }
  26553. }
  26554. declare module "babylonjs/Cameras/camera" {
  26555. import { SmartArray } from "babylonjs/Misc/smartArray";
  26556. import { Observable } from "babylonjs/Misc/observable";
  26557. import { Nullable } from "babylonjs/types";
  26558. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26559. import { Scene } from "babylonjs/scene";
  26560. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  26561. import { Node } from "babylonjs/node";
  26562. import { Mesh } from "babylonjs/Meshes/mesh";
  26563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26564. import { ICullable } from "babylonjs/Culling/boundingInfo";
  26565. import { Viewport } from "babylonjs/Maths/math.viewport";
  26566. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26567. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26568. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26569. import { Ray } from "babylonjs/Culling/ray";
  26570. /**
  26571. * This is the base class of all the camera used in the application.
  26572. * @see http://doc.babylonjs.com/features/cameras
  26573. */
  26574. export class Camera extends Node {
  26575. /** @hidden */
  26576. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26577. /**
  26578. * This is the default projection mode used by the cameras.
  26579. * It helps recreating a feeling of perspective and better appreciate depth.
  26580. * This is the best way to simulate real life cameras.
  26581. */
  26582. static readonly PERSPECTIVE_CAMERA: number;
  26583. /**
  26584. * This helps creating camera with an orthographic mode.
  26585. * 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.
  26586. */
  26587. static readonly ORTHOGRAPHIC_CAMERA: number;
  26588. /**
  26589. * This is the default FOV mode for perspective cameras.
  26590. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26591. */
  26592. static readonly FOVMODE_VERTICAL_FIXED: number;
  26593. /**
  26594. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26595. */
  26596. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26597. /**
  26598. * This specifies ther is no need for a camera rig.
  26599. * Basically only one eye is rendered corresponding to the camera.
  26600. */
  26601. static readonly RIG_MODE_NONE: number;
  26602. /**
  26603. * Simulates a camera Rig with one blue eye and one red eye.
  26604. * This can be use with 3d blue and red glasses.
  26605. */
  26606. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26607. /**
  26608. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26609. */
  26610. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26611. /**
  26612. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26613. */
  26614. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26615. /**
  26616. * Defines that both eyes of the camera will be rendered over under each other.
  26617. */
  26618. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26619. /**
  26620. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26621. */
  26622. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26623. /**
  26624. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26625. */
  26626. static readonly RIG_MODE_VR: number;
  26627. /**
  26628. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26629. */
  26630. static readonly RIG_MODE_WEBVR: number;
  26631. /**
  26632. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26633. */
  26634. static readonly RIG_MODE_CUSTOM: number;
  26635. /**
  26636. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26637. */
  26638. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26639. /**
  26640. * Define the input manager associated with the camera.
  26641. */
  26642. inputs: CameraInputsManager<Camera>;
  26643. /** @hidden */
  26644. _position: Vector3;
  26645. /**
  26646. * Define the current local position of the camera in the scene
  26647. */
  26648. get position(): Vector3;
  26649. set position(newPosition: Vector3);
  26650. /**
  26651. * The vector the camera should consider as up.
  26652. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26653. */
  26654. upVector: Vector3;
  26655. /**
  26656. * Define the current limit on the left side for an orthographic camera
  26657. * In scene unit
  26658. */
  26659. orthoLeft: Nullable<number>;
  26660. /**
  26661. * Define the current limit on the right side for an orthographic camera
  26662. * In scene unit
  26663. */
  26664. orthoRight: Nullable<number>;
  26665. /**
  26666. * Define the current limit on the bottom side for an orthographic camera
  26667. * In scene unit
  26668. */
  26669. orthoBottom: Nullable<number>;
  26670. /**
  26671. * Define the current limit on the top side for an orthographic camera
  26672. * In scene unit
  26673. */
  26674. orthoTop: Nullable<number>;
  26675. /**
  26676. * Field Of View is set in Radians. (default is 0.8)
  26677. */
  26678. fov: number;
  26679. /**
  26680. * Define the minimum distance the camera can see from.
  26681. * This is important to note that the depth buffer are not infinite and the closer it starts
  26682. * the more your scene might encounter depth fighting issue.
  26683. */
  26684. minZ: number;
  26685. /**
  26686. * Define the maximum distance the camera can see to.
  26687. * This is important to note that the depth buffer are not infinite and the further it end
  26688. * the more your scene might encounter depth fighting issue.
  26689. */
  26690. maxZ: number;
  26691. /**
  26692. * Define the default inertia of the camera.
  26693. * This helps giving a smooth feeling to the camera movement.
  26694. */
  26695. inertia: number;
  26696. /**
  26697. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26698. */
  26699. mode: number;
  26700. /**
  26701. * Define whether the camera is intermediate.
  26702. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26703. */
  26704. isIntermediate: boolean;
  26705. /**
  26706. * Define the viewport of the camera.
  26707. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26708. */
  26709. viewport: Viewport;
  26710. /**
  26711. * Restricts the camera to viewing objects with the same layerMask.
  26712. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26713. */
  26714. layerMask: number;
  26715. /**
  26716. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26717. */
  26718. fovMode: number;
  26719. /**
  26720. * Rig mode of the camera.
  26721. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26722. * This is normally controlled byt the camera themselves as internal use.
  26723. */
  26724. cameraRigMode: number;
  26725. /**
  26726. * Defines the distance between both "eyes" in case of a RIG
  26727. */
  26728. interaxialDistance: number;
  26729. /**
  26730. * Defines if stereoscopic rendering is done side by side or over under.
  26731. */
  26732. isStereoscopicSideBySide: boolean;
  26733. /**
  26734. * 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
  26735. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26736. * else in the scene. (Eg. security camera)
  26737. *
  26738. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  26739. */
  26740. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26741. /**
  26742. * When set, the camera will render to this render target instead of the default canvas
  26743. *
  26744. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26745. */
  26746. outputRenderTarget: Nullable<RenderTargetTexture>;
  26747. /**
  26748. * Observable triggered when the camera view matrix has changed.
  26749. */
  26750. onViewMatrixChangedObservable: Observable<Camera>;
  26751. /**
  26752. * Observable triggered when the camera Projection matrix has changed.
  26753. */
  26754. onProjectionMatrixChangedObservable: Observable<Camera>;
  26755. /**
  26756. * Observable triggered when the inputs have been processed.
  26757. */
  26758. onAfterCheckInputsObservable: Observable<Camera>;
  26759. /**
  26760. * Observable triggered when reset has been called and applied to the camera.
  26761. */
  26762. onRestoreStateObservable: Observable<Camera>;
  26763. /**
  26764. * Is this camera a part of a rig system?
  26765. */
  26766. isRigCamera: boolean;
  26767. /**
  26768. * If isRigCamera set to true this will be set with the parent camera.
  26769. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26770. */
  26771. rigParent?: Camera;
  26772. /** @hidden */
  26773. _cameraRigParams: any;
  26774. /** @hidden */
  26775. _rigCameras: Camera[];
  26776. /** @hidden */
  26777. _rigPostProcess: Nullable<PostProcess>;
  26778. protected _webvrViewMatrix: Matrix;
  26779. /** @hidden */
  26780. _skipRendering: boolean;
  26781. /** @hidden */
  26782. _projectionMatrix: Matrix;
  26783. /** @hidden */
  26784. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26785. /** @hidden */
  26786. _activeMeshes: SmartArray<AbstractMesh>;
  26787. protected _globalPosition: Vector3;
  26788. /** @hidden */
  26789. _computedViewMatrix: Matrix;
  26790. private _doNotComputeProjectionMatrix;
  26791. private _transformMatrix;
  26792. private _frustumPlanes;
  26793. private _refreshFrustumPlanes;
  26794. private _storedFov;
  26795. private _stateStored;
  26796. /**
  26797. * Instantiates a new camera object.
  26798. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26799. * @see http://doc.babylonjs.com/features/cameras
  26800. * @param name Defines the name of the camera in the scene
  26801. * @param position Defines the position of the camera
  26802. * @param scene Defines the scene the camera belongs too
  26803. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26804. */
  26805. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26806. /**
  26807. * Store current camera state (fov, position, etc..)
  26808. * @returns the camera
  26809. */
  26810. storeState(): Camera;
  26811. /**
  26812. * Restores the camera state values if it has been stored. You must call storeState() first
  26813. */
  26814. protected _restoreStateValues(): boolean;
  26815. /**
  26816. * Restored camera state. You must call storeState() first.
  26817. * @returns true if restored and false otherwise
  26818. */
  26819. restoreState(): boolean;
  26820. /**
  26821. * Gets the class name of the camera.
  26822. * @returns the class name
  26823. */
  26824. getClassName(): string;
  26825. /** @hidden */
  26826. readonly _isCamera: boolean;
  26827. /**
  26828. * Gets a string representation of the camera useful for debug purpose.
  26829. * @param fullDetails Defines that a more verboe level of logging is required
  26830. * @returns the string representation
  26831. */
  26832. toString(fullDetails?: boolean): string;
  26833. /**
  26834. * Gets the current world space position of the camera.
  26835. */
  26836. get globalPosition(): Vector3;
  26837. /**
  26838. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26839. * @returns the active meshe list
  26840. */
  26841. getActiveMeshes(): SmartArray<AbstractMesh>;
  26842. /**
  26843. * Check whether a mesh is part of the current active mesh list of the camera
  26844. * @param mesh Defines the mesh to check
  26845. * @returns true if active, false otherwise
  26846. */
  26847. isActiveMesh(mesh: Mesh): boolean;
  26848. /**
  26849. * Is this camera ready to be used/rendered
  26850. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26851. * @return true if the camera is ready
  26852. */
  26853. isReady(completeCheck?: boolean): boolean;
  26854. /** @hidden */
  26855. _initCache(): void;
  26856. /** @hidden */
  26857. _updateCache(ignoreParentClass?: boolean): void;
  26858. /** @hidden */
  26859. _isSynchronized(): boolean;
  26860. /** @hidden */
  26861. _isSynchronizedViewMatrix(): boolean;
  26862. /** @hidden */
  26863. _isSynchronizedProjectionMatrix(): boolean;
  26864. /**
  26865. * Attach the input controls to a specific dom element to get the input from.
  26866. * @param element Defines the element the controls should be listened from
  26867. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26868. */
  26869. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26870. /**
  26871. * Detach the current controls from the specified dom element.
  26872. * @param element Defines the element to stop listening the inputs from
  26873. */
  26874. detachControl(element: HTMLElement): void;
  26875. /**
  26876. * Update the camera state according to the different inputs gathered during the frame.
  26877. */
  26878. update(): void;
  26879. /** @hidden */
  26880. _checkInputs(): void;
  26881. /** @hidden */
  26882. get rigCameras(): Camera[];
  26883. /**
  26884. * Gets the post process used by the rig cameras
  26885. */
  26886. get rigPostProcess(): Nullable<PostProcess>;
  26887. /**
  26888. * Internal, gets the first post proces.
  26889. * @returns the first post process to be run on this camera.
  26890. */
  26891. _getFirstPostProcess(): Nullable<PostProcess>;
  26892. private _cascadePostProcessesToRigCams;
  26893. /**
  26894. * Attach a post process to the camera.
  26895. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26896. * @param postProcess The post process to attach to the camera
  26897. * @param insertAt The position of the post process in case several of them are in use in the scene
  26898. * @returns the position the post process has been inserted at
  26899. */
  26900. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26901. /**
  26902. * Detach a post process to the camera.
  26903. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26904. * @param postProcess The post process to detach from the camera
  26905. */
  26906. detachPostProcess(postProcess: PostProcess): void;
  26907. /**
  26908. * Gets the current world matrix of the camera
  26909. */
  26910. getWorldMatrix(): Matrix;
  26911. /** @hidden */
  26912. _getViewMatrix(): Matrix;
  26913. /**
  26914. * Gets the current view matrix of the camera.
  26915. * @param force forces the camera to recompute the matrix without looking at the cached state
  26916. * @returns the view matrix
  26917. */
  26918. getViewMatrix(force?: boolean): Matrix;
  26919. /**
  26920. * Freeze the projection matrix.
  26921. * It will prevent the cache check of the camera projection compute and can speed up perf
  26922. * if no parameter of the camera are meant to change
  26923. * @param projection Defines manually a projection if necessary
  26924. */
  26925. freezeProjectionMatrix(projection?: Matrix): void;
  26926. /**
  26927. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26928. */
  26929. unfreezeProjectionMatrix(): void;
  26930. /**
  26931. * Gets the current projection matrix of the camera.
  26932. * @param force forces the camera to recompute the matrix without looking at the cached state
  26933. * @returns the projection matrix
  26934. */
  26935. getProjectionMatrix(force?: boolean): Matrix;
  26936. /**
  26937. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26938. * @returns a Matrix
  26939. */
  26940. getTransformationMatrix(): Matrix;
  26941. private _updateFrustumPlanes;
  26942. /**
  26943. * Checks if a cullable object (mesh...) is in the camera frustum
  26944. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26945. * @param target The object to check
  26946. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26947. * @returns true if the object is in frustum otherwise false
  26948. */
  26949. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26950. /**
  26951. * Checks if a cullable object (mesh...) is in the camera frustum
  26952. * Unlike isInFrustum this cheks the full bounding box
  26953. * @param target The object to check
  26954. * @returns true if the object is in frustum otherwise false
  26955. */
  26956. isCompletelyInFrustum(target: ICullable): boolean;
  26957. /**
  26958. * Gets a ray in the forward direction from the camera.
  26959. * @param length Defines the length of the ray to create
  26960. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26961. * @param origin Defines the start point of the ray which defaults to the camera position
  26962. * @returns the forward ray
  26963. */
  26964. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26965. /**
  26966. * Releases resources associated with this node.
  26967. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26968. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26969. */
  26970. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26971. /** @hidden */
  26972. _isLeftCamera: boolean;
  26973. /**
  26974. * Gets the left camera of a rig setup in case of Rigged Camera
  26975. */
  26976. get isLeftCamera(): boolean;
  26977. /** @hidden */
  26978. _isRightCamera: boolean;
  26979. /**
  26980. * Gets the right camera of a rig setup in case of Rigged Camera
  26981. */
  26982. get isRightCamera(): boolean;
  26983. /**
  26984. * Gets the left camera of a rig setup in case of Rigged Camera
  26985. */
  26986. get leftCamera(): Nullable<FreeCamera>;
  26987. /**
  26988. * Gets the right camera of a rig setup in case of Rigged Camera
  26989. */
  26990. get rightCamera(): Nullable<FreeCamera>;
  26991. /**
  26992. * Gets the left camera target of a rig setup in case of Rigged Camera
  26993. * @returns the target position
  26994. */
  26995. getLeftTarget(): Nullable<Vector3>;
  26996. /**
  26997. * Gets the right camera target of a rig setup in case of Rigged Camera
  26998. * @returns the target position
  26999. */
  27000. getRightTarget(): Nullable<Vector3>;
  27001. /**
  27002. * @hidden
  27003. */
  27004. setCameraRigMode(mode: number, rigParams: any): void;
  27005. /** @hidden */
  27006. static _setStereoscopicRigMode(camera: Camera): void;
  27007. /** @hidden */
  27008. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  27009. /** @hidden */
  27010. static _setVRRigMode(camera: Camera, rigParams: any): void;
  27011. /** @hidden */
  27012. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  27013. /** @hidden */
  27014. _getVRProjectionMatrix(): Matrix;
  27015. protected _updateCameraRotationMatrix(): void;
  27016. protected _updateWebVRCameraRotationMatrix(): void;
  27017. /**
  27018. * This function MUST be overwritten by the different WebVR cameras available.
  27019. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  27020. * @hidden
  27021. */
  27022. _getWebVRProjectionMatrix(): Matrix;
  27023. /**
  27024. * This function MUST be overwritten by the different WebVR cameras available.
  27025. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  27026. * @hidden
  27027. */
  27028. _getWebVRViewMatrix(): Matrix;
  27029. /** @hidden */
  27030. setCameraRigParameter(name: string, value: any): void;
  27031. /**
  27032. * needs to be overridden by children so sub has required properties to be copied
  27033. * @hidden
  27034. */
  27035. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  27036. /**
  27037. * May need to be overridden by children
  27038. * @hidden
  27039. */
  27040. _updateRigCameras(): void;
  27041. /** @hidden */
  27042. _setupInputs(): void;
  27043. /**
  27044. * Serialiaze the camera setup to a json represention
  27045. * @returns the JSON representation
  27046. */
  27047. serialize(): any;
  27048. /**
  27049. * Clones the current camera.
  27050. * @param name The cloned camera name
  27051. * @returns the cloned camera
  27052. */
  27053. clone(name: string): Camera;
  27054. /**
  27055. * Gets the direction of the camera relative to a given local axis.
  27056. * @param localAxis Defines the reference axis to provide a relative direction.
  27057. * @return the direction
  27058. */
  27059. getDirection(localAxis: Vector3): Vector3;
  27060. /**
  27061. * Returns the current camera absolute rotation
  27062. */
  27063. get absoluteRotation(): Quaternion;
  27064. /**
  27065. * Gets the direction of the camera relative to a given local axis into a passed vector.
  27066. * @param localAxis Defines the reference axis to provide a relative direction.
  27067. * @param result Defines the vector to store the result in
  27068. */
  27069. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  27070. /**
  27071. * Gets a camera constructor for a given camera type
  27072. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  27073. * @param name The name of the camera the result will be able to instantiate
  27074. * @param scene The scene the result will construct the camera in
  27075. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  27076. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  27077. * @returns a factory method to construc the camera
  27078. */
  27079. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  27080. /**
  27081. * Compute the world matrix of the camera.
  27082. * @returns the camera world matrix
  27083. */
  27084. computeWorldMatrix(): Matrix;
  27085. /**
  27086. * Parse a JSON and creates the camera from the parsed information
  27087. * @param parsedCamera The JSON to parse
  27088. * @param scene The scene to instantiate the camera in
  27089. * @returns the newly constructed camera
  27090. */
  27091. static Parse(parsedCamera: any, scene: Scene): Camera;
  27092. }
  27093. }
  27094. declare module "babylonjs/Meshes/Builders/discBuilder" {
  27095. import { Nullable } from "babylonjs/types";
  27096. import { Scene } from "babylonjs/scene";
  27097. import { Vector4 } from "babylonjs/Maths/math.vector";
  27098. import { Mesh } from "babylonjs/Meshes/mesh";
  27099. /**
  27100. * Class containing static functions to help procedurally build meshes
  27101. */
  27102. export class DiscBuilder {
  27103. /**
  27104. * Creates a plane polygonal mesh. By default, this is a disc
  27105. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  27106. * * 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
  27107. * * 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
  27108. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27109. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  27110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27111. * @param name defines the name of the mesh
  27112. * @param options defines the options used to create the mesh
  27113. * @param scene defines the hosting scene
  27114. * @returns the plane polygonal mesh
  27115. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  27116. */
  27117. static CreateDisc(name: string, options: {
  27118. radius?: number;
  27119. tessellation?: number;
  27120. arc?: number;
  27121. updatable?: boolean;
  27122. sideOrientation?: number;
  27123. frontUVs?: Vector4;
  27124. backUVs?: Vector4;
  27125. }, scene?: Nullable<Scene>): Mesh;
  27126. }
  27127. }
  27128. declare module "babylonjs/Materials/fresnelParameters" {
  27129. import { DeepImmutable } from "babylonjs/types";
  27130. import { Color3 } from "babylonjs/Maths/math.color";
  27131. /**
  27132. * Options to be used when creating a FresnelParameters.
  27133. */
  27134. export type IFresnelParametersCreationOptions = {
  27135. /**
  27136. * Define the color used on edges (grazing angle)
  27137. */
  27138. leftColor?: Color3;
  27139. /**
  27140. * Define the color used on center
  27141. */
  27142. rightColor?: Color3;
  27143. /**
  27144. * Define bias applied to computed fresnel term
  27145. */
  27146. bias?: number;
  27147. /**
  27148. * Defined the power exponent applied to fresnel term
  27149. */
  27150. power?: number;
  27151. /**
  27152. * Define if the fresnel effect is enable or not.
  27153. */
  27154. isEnabled?: boolean;
  27155. };
  27156. /**
  27157. * Serialized format for FresnelParameters.
  27158. */
  27159. export type IFresnelParametersSerialized = {
  27160. /**
  27161. * Define the color used on edges (grazing angle) [as an array]
  27162. */
  27163. leftColor: number[];
  27164. /**
  27165. * Define the color used on center [as an array]
  27166. */
  27167. rightColor: number[];
  27168. /**
  27169. * Define bias applied to computed fresnel term
  27170. */
  27171. bias: number;
  27172. /**
  27173. * Defined the power exponent applied to fresnel term
  27174. */
  27175. power?: number;
  27176. /**
  27177. * Define if the fresnel effect is enable or not.
  27178. */
  27179. isEnabled: boolean;
  27180. };
  27181. /**
  27182. * This represents all the required information to add a fresnel effect on a material:
  27183. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27184. */
  27185. export class FresnelParameters {
  27186. private _isEnabled;
  27187. /**
  27188. * Define if the fresnel effect is enable or not.
  27189. */
  27190. get isEnabled(): boolean;
  27191. set isEnabled(value: boolean);
  27192. /**
  27193. * Define the color used on edges (grazing angle)
  27194. */
  27195. leftColor: Color3;
  27196. /**
  27197. * Define the color used on center
  27198. */
  27199. rightColor: Color3;
  27200. /**
  27201. * Define bias applied to computed fresnel term
  27202. */
  27203. bias: number;
  27204. /**
  27205. * Defined the power exponent applied to fresnel term
  27206. */
  27207. power: number;
  27208. /**
  27209. * Creates a new FresnelParameters object.
  27210. *
  27211. * @param options provide your own settings to optionally to override defaults
  27212. */
  27213. constructor(options?: IFresnelParametersCreationOptions);
  27214. /**
  27215. * Clones the current fresnel and its valuues
  27216. * @returns a clone fresnel configuration
  27217. */
  27218. clone(): FresnelParameters;
  27219. /**
  27220. * Determines equality between FresnelParameters objects
  27221. * @param otherFresnelParameters defines the second operand
  27222. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  27223. */
  27224. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  27225. /**
  27226. * Serializes the current fresnel parameters to a JSON representation.
  27227. * @return the JSON serialization
  27228. */
  27229. serialize(): IFresnelParametersSerialized;
  27230. /**
  27231. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27232. * @param parsedFresnelParameters Define the JSON representation
  27233. * @returns the parsed parameters
  27234. */
  27235. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  27236. }
  27237. }
  27238. declare module "babylonjs/Materials/pushMaterial" {
  27239. import { Nullable } from "babylonjs/types";
  27240. import { Scene } from "babylonjs/scene";
  27241. import { Matrix } from "babylonjs/Maths/math.vector";
  27242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27243. import { Mesh } from "babylonjs/Meshes/mesh";
  27244. import { Material } from "babylonjs/Materials/material";
  27245. import { Effect } from "babylonjs/Materials/effect";
  27246. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27247. /**
  27248. * Base class of materials working in push mode in babylon JS
  27249. * @hidden
  27250. */
  27251. export class PushMaterial extends Material {
  27252. protected _activeEffect: Effect;
  27253. protected _normalMatrix: Matrix;
  27254. /**
  27255. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  27256. * This means that the material can keep using a previous shader while a new one is being compiled.
  27257. * This is mostly used when shader parallel compilation is supported (true by default)
  27258. */
  27259. allowShaderHotSwapping: boolean;
  27260. constructor(name: string, scene: Scene);
  27261. getEffect(): Effect;
  27262. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  27263. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  27264. /**
  27265. * Binds the given world matrix to the active effect
  27266. *
  27267. * @param world the matrix to bind
  27268. */
  27269. bindOnlyWorldMatrix(world: Matrix): void;
  27270. /**
  27271. * Binds the given normal matrix to the active effect
  27272. *
  27273. * @param normalMatrix the matrix to bind
  27274. */
  27275. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  27276. bind(world: Matrix, mesh?: Mesh): void;
  27277. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  27278. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  27279. }
  27280. }
  27281. declare module "babylonjs/Materials/materialFlags" {
  27282. /**
  27283. * This groups all the flags used to control the materials channel.
  27284. */
  27285. export class MaterialFlags {
  27286. private static _DiffuseTextureEnabled;
  27287. /**
  27288. * Are diffuse textures enabled in the application.
  27289. */
  27290. static get DiffuseTextureEnabled(): boolean;
  27291. static set DiffuseTextureEnabled(value: boolean);
  27292. private static _AmbientTextureEnabled;
  27293. /**
  27294. * Are ambient textures enabled in the application.
  27295. */
  27296. static get AmbientTextureEnabled(): boolean;
  27297. static set AmbientTextureEnabled(value: boolean);
  27298. private static _OpacityTextureEnabled;
  27299. /**
  27300. * Are opacity textures enabled in the application.
  27301. */
  27302. static get OpacityTextureEnabled(): boolean;
  27303. static set OpacityTextureEnabled(value: boolean);
  27304. private static _ReflectionTextureEnabled;
  27305. /**
  27306. * Are reflection textures enabled in the application.
  27307. */
  27308. static get ReflectionTextureEnabled(): boolean;
  27309. static set ReflectionTextureEnabled(value: boolean);
  27310. private static _EmissiveTextureEnabled;
  27311. /**
  27312. * Are emissive textures enabled in the application.
  27313. */
  27314. static get EmissiveTextureEnabled(): boolean;
  27315. static set EmissiveTextureEnabled(value: boolean);
  27316. private static _SpecularTextureEnabled;
  27317. /**
  27318. * Are specular textures enabled in the application.
  27319. */
  27320. static get SpecularTextureEnabled(): boolean;
  27321. static set SpecularTextureEnabled(value: boolean);
  27322. private static _BumpTextureEnabled;
  27323. /**
  27324. * Are bump textures enabled in the application.
  27325. */
  27326. static get BumpTextureEnabled(): boolean;
  27327. static set BumpTextureEnabled(value: boolean);
  27328. private static _LightmapTextureEnabled;
  27329. /**
  27330. * Are lightmap textures enabled in the application.
  27331. */
  27332. static get LightmapTextureEnabled(): boolean;
  27333. static set LightmapTextureEnabled(value: boolean);
  27334. private static _RefractionTextureEnabled;
  27335. /**
  27336. * Are refraction textures enabled in the application.
  27337. */
  27338. static get RefractionTextureEnabled(): boolean;
  27339. static set RefractionTextureEnabled(value: boolean);
  27340. private static _ColorGradingTextureEnabled;
  27341. /**
  27342. * Are color grading textures enabled in the application.
  27343. */
  27344. static get ColorGradingTextureEnabled(): boolean;
  27345. static set ColorGradingTextureEnabled(value: boolean);
  27346. private static _FresnelEnabled;
  27347. /**
  27348. * Are fresnels enabled in the application.
  27349. */
  27350. static get FresnelEnabled(): boolean;
  27351. static set FresnelEnabled(value: boolean);
  27352. private static _ClearCoatTextureEnabled;
  27353. /**
  27354. * Are clear coat textures enabled in the application.
  27355. */
  27356. static get ClearCoatTextureEnabled(): boolean;
  27357. static set ClearCoatTextureEnabled(value: boolean);
  27358. private static _ClearCoatBumpTextureEnabled;
  27359. /**
  27360. * Are clear coat bump textures enabled in the application.
  27361. */
  27362. static get ClearCoatBumpTextureEnabled(): boolean;
  27363. static set ClearCoatBumpTextureEnabled(value: boolean);
  27364. private static _ClearCoatTintTextureEnabled;
  27365. /**
  27366. * Are clear coat tint textures enabled in the application.
  27367. */
  27368. static get ClearCoatTintTextureEnabled(): boolean;
  27369. static set ClearCoatTintTextureEnabled(value: boolean);
  27370. private static _SheenTextureEnabled;
  27371. /**
  27372. * Are sheen textures enabled in the application.
  27373. */
  27374. static get SheenTextureEnabled(): boolean;
  27375. static set SheenTextureEnabled(value: boolean);
  27376. private static _AnisotropicTextureEnabled;
  27377. /**
  27378. * Are anisotropic textures enabled in the application.
  27379. */
  27380. static get AnisotropicTextureEnabled(): boolean;
  27381. static set AnisotropicTextureEnabled(value: boolean);
  27382. private static _ThicknessTextureEnabled;
  27383. /**
  27384. * Are thickness textures enabled in the application.
  27385. */
  27386. static get ThicknessTextureEnabled(): boolean;
  27387. static set ThicknessTextureEnabled(value: boolean);
  27388. }
  27389. }
  27390. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  27391. /** @hidden */
  27392. export var defaultFragmentDeclaration: {
  27393. name: string;
  27394. shader: string;
  27395. };
  27396. }
  27397. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  27398. /** @hidden */
  27399. export var defaultUboDeclaration: {
  27400. name: string;
  27401. shader: string;
  27402. };
  27403. }
  27404. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  27405. /** @hidden */
  27406. export var lightFragmentDeclaration: {
  27407. name: string;
  27408. shader: string;
  27409. };
  27410. }
  27411. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  27412. /** @hidden */
  27413. export var lightUboDeclaration: {
  27414. name: string;
  27415. shader: string;
  27416. };
  27417. }
  27418. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  27419. /** @hidden */
  27420. export var lightsFragmentFunctions: {
  27421. name: string;
  27422. shader: string;
  27423. };
  27424. }
  27425. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  27426. /** @hidden */
  27427. export var shadowsFragmentFunctions: {
  27428. name: string;
  27429. shader: string;
  27430. };
  27431. }
  27432. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  27433. /** @hidden */
  27434. export var fresnelFunction: {
  27435. name: string;
  27436. shader: string;
  27437. };
  27438. }
  27439. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  27440. /** @hidden */
  27441. export var reflectionFunction: {
  27442. name: string;
  27443. shader: string;
  27444. };
  27445. }
  27446. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  27447. /** @hidden */
  27448. export var bumpFragmentFunctions: {
  27449. name: string;
  27450. shader: string;
  27451. };
  27452. }
  27453. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  27454. /** @hidden */
  27455. export var logDepthDeclaration: {
  27456. name: string;
  27457. shader: string;
  27458. };
  27459. }
  27460. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  27461. /** @hidden */
  27462. export var bumpFragment: {
  27463. name: string;
  27464. shader: string;
  27465. };
  27466. }
  27467. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  27468. /** @hidden */
  27469. export var depthPrePass: {
  27470. name: string;
  27471. shader: string;
  27472. };
  27473. }
  27474. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  27475. /** @hidden */
  27476. export var lightFragment: {
  27477. name: string;
  27478. shader: string;
  27479. };
  27480. }
  27481. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  27482. /** @hidden */
  27483. export var logDepthFragment: {
  27484. name: string;
  27485. shader: string;
  27486. };
  27487. }
  27488. declare module "babylonjs/Shaders/default.fragment" {
  27489. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  27490. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27491. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27492. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27493. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27494. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  27495. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  27496. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  27497. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  27498. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  27499. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  27500. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  27501. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  27502. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27503. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  27504. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  27505. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  27506. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  27507. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  27508. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  27509. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27510. /** @hidden */
  27511. export var defaultPixelShader: {
  27512. name: string;
  27513. shader: string;
  27514. };
  27515. }
  27516. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  27517. /** @hidden */
  27518. export var defaultVertexDeclaration: {
  27519. name: string;
  27520. shader: string;
  27521. };
  27522. }
  27523. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  27524. /** @hidden */
  27525. export var bumpVertexDeclaration: {
  27526. name: string;
  27527. shader: string;
  27528. };
  27529. }
  27530. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  27531. /** @hidden */
  27532. export var bumpVertex: {
  27533. name: string;
  27534. shader: string;
  27535. };
  27536. }
  27537. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  27538. /** @hidden */
  27539. export var fogVertex: {
  27540. name: string;
  27541. shader: string;
  27542. };
  27543. }
  27544. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  27545. /** @hidden */
  27546. export var shadowsVertex: {
  27547. name: string;
  27548. shader: string;
  27549. };
  27550. }
  27551. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  27552. /** @hidden */
  27553. export var pointCloudVertex: {
  27554. name: string;
  27555. shader: string;
  27556. };
  27557. }
  27558. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  27559. /** @hidden */
  27560. export var logDepthVertex: {
  27561. name: string;
  27562. shader: string;
  27563. };
  27564. }
  27565. declare module "babylonjs/Shaders/default.vertex" {
  27566. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  27567. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27568. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27569. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27570. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27571. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27572. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27573. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27574. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27575. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27576. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27577. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27578. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27579. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27580. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27581. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27582. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27583. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27584. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27585. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27586. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  27587. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27588. /** @hidden */
  27589. export var defaultVertexShader: {
  27590. name: string;
  27591. shader: string;
  27592. };
  27593. }
  27594. declare module "babylonjs/Materials/standardMaterial" {
  27595. import { SmartArray } from "babylonjs/Misc/smartArray";
  27596. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27597. import { Nullable } from "babylonjs/types";
  27598. import { Scene } from "babylonjs/scene";
  27599. import { Matrix } from "babylonjs/Maths/math.vector";
  27600. import { Color3 } from "babylonjs/Maths/math.color";
  27601. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27603. import { Mesh } from "babylonjs/Meshes/mesh";
  27604. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27605. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27606. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  27607. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27608. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27609. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27610. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27611. import "babylonjs/Shaders/default.fragment";
  27612. import "babylonjs/Shaders/default.vertex";
  27613. /** @hidden */
  27614. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  27615. MAINUV1: boolean;
  27616. MAINUV2: boolean;
  27617. DIFFUSE: boolean;
  27618. DIFFUSEDIRECTUV: number;
  27619. AMBIENT: boolean;
  27620. AMBIENTDIRECTUV: number;
  27621. OPACITY: boolean;
  27622. OPACITYDIRECTUV: number;
  27623. OPACITYRGB: boolean;
  27624. REFLECTION: boolean;
  27625. EMISSIVE: boolean;
  27626. EMISSIVEDIRECTUV: number;
  27627. SPECULAR: boolean;
  27628. SPECULARDIRECTUV: number;
  27629. BUMP: boolean;
  27630. BUMPDIRECTUV: number;
  27631. PARALLAX: boolean;
  27632. PARALLAXOCCLUSION: boolean;
  27633. SPECULAROVERALPHA: boolean;
  27634. CLIPPLANE: boolean;
  27635. CLIPPLANE2: boolean;
  27636. CLIPPLANE3: boolean;
  27637. CLIPPLANE4: boolean;
  27638. CLIPPLANE5: boolean;
  27639. CLIPPLANE6: boolean;
  27640. ALPHATEST: boolean;
  27641. DEPTHPREPASS: boolean;
  27642. ALPHAFROMDIFFUSE: boolean;
  27643. POINTSIZE: boolean;
  27644. FOG: boolean;
  27645. SPECULARTERM: boolean;
  27646. DIFFUSEFRESNEL: boolean;
  27647. OPACITYFRESNEL: boolean;
  27648. REFLECTIONFRESNEL: boolean;
  27649. REFRACTIONFRESNEL: boolean;
  27650. EMISSIVEFRESNEL: boolean;
  27651. FRESNEL: boolean;
  27652. NORMAL: boolean;
  27653. UV1: boolean;
  27654. UV2: boolean;
  27655. VERTEXCOLOR: boolean;
  27656. VERTEXALPHA: boolean;
  27657. NUM_BONE_INFLUENCERS: number;
  27658. BonesPerMesh: number;
  27659. BONETEXTURE: boolean;
  27660. INSTANCES: boolean;
  27661. GLOSSINESS: boolean;
  27662. ROUGHNESS: boolean;
  27663. EMISSIVEASILLUMINATION: boolean;
  27664. LINKEMISSIVEWITHDIFFUSE: boolean;
  27665. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27666. LIGHTMAP: boolean;
  27667. LIGHTMAPDIRECTUV: number;
  27668. OBJECTSPACE_NORMALMAP: boolean;
  27669. USELIGHTMAPASSHADOWMAP: boolean;
  27670. REFLECTIONMAP_3D: boolean;
  27671. REFLECTIONMAP_SPHERICAL: boolean;
  27672. REFLECTIONMAP_PLANAR: boolean;
  27673. REFLECTIONMAP_CUBIC: boolean;
  27674. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27675. REFLECTIONMAP_PROJECTION: boolean;
  27676. REFLECTIONMAP_SKYBOX: boolean;
  27677. REFLECTIONMAP_EXPLICIT: boolean;
  27678. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27679. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27680. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27681. INVERTCUBICMAP: boolean;
  27682. LOGARITHMICDEPTH: boolean;
  27683. REFRACTION: boolean;
  27684. REFRACTIONMAP_3D: boolean;
  27685. REFLECTIONOVERALPHA: boolean;
  27686. TWOSIDEDLIGHTING: boolean;
  27687. SHADOWFLOAT: boolean;
  27688. MORPHTARGETS: boolean;
  27689. MORPHTARGETS_NORMAL: boolean;
  27690. MORPHTARGETS_TANGENT: boolean;
  27691. MORPHTARGETS_UV: boolean;
  27692. NUM_MORPH_INFLUENCERS: number;
  27693. NONUNIFORMSCALING: boolean;
  27694. PREMULTIPLYALPHA: boolean;
  27695. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  27696. ALPHABLEND: boolean;
  27697. IMAGEPROCESSING: boolean;
  27698. VIGNETTE: boolean;
  27699. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27700. VIGNETTEBLENDMODEOPAQUE: boolean;
  27701. TONEMAPPING: boolean;
  27702. TONEMAPPING_ACES: boolean;
  27703. CONTRAST: boolean;
  27704. COLORCURVES: boolean;
  27705. COLORGRADING: boolean;
  27706. COLORGRADING3D: boolean;
  27707. SAMPLER3DGREENDEPTH: boolean;
  27708. SAMPLER3DBGRMAP: boolean;
  27709. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27710. MULTIVIEW: boolean;
  27711. /**
  27712. * If the reflection texture on this material is in linear color space
  27713. * @hidden
  27714. */
  27715. IS_REFLECTION_LINEAR: boolean;
  27716. /**
  27717. * If the refraction texture on this material is in linear color space
  27718. * @hidden
  27719. */
  27720. IS_REFRACTION_LINEAR: boolean;
  27721. EXPOSURE: boolean;
  27722. constructor();
  27723. setReflectionMode(modeToEnable: string): void;
  27724. }
  27725. /**
  27726. * This is the default material used in Babylon. It is the best trade off between quality
  27727. * and performances.
  27728. * @see http://doc.babylonjs.com/babylon101/materials
  27729. */
  27730. export class StandardMaterial extends PushMaterial {
  27731. private _diffuseTexture;
  27732. /**
  27733. * The basic texture of the material as viewed under a light.
  27734. */
  27735. diffuseTexture: Nullable<BaseTexture>;
  27736. private _ambientTexture;
  27737. /**
  27738. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27739. */
  27740. ambientTexture: Nullable<BaseTexture>;
  27741. private _opacityTexture;
  27742. /**
  27743. * Define the transparency of the material from a texture.
  27744. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27745. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27746. */
  27747. opacityTexture: Nullable<BaseTexture>;
  27748. private _reflectionTexture;
  27749. /**
  27750. * Define the texture used to display the reflection.
  27751. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27752. */
  27753. reflectionTexture: Nullable<BaseTexture>;
  27754. private _emissiveTexture;
  27755. /**
  27756. * Define texture of the material as if self lit.
  27757. * This will be mixed in the final result even in the absence of light.
  27758. */
  27759. emissiveTexture: Nullable<BaseTexture>;
  27760. private _specularTexture;
  27761. /**
  27762. * Define how the color and intensity of the highlight given by the light in the material.
  27763. */
  27764. specularTexture: Nullable<BaseTexture>;
  27765. private _bumpTexture;
  27766. /**
  27767. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27768. * 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.
  27769. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27770. */
  27771. bumpTexture: Nullable<BaseTexture>;
  27772. private _lightmapTexture;
  27773. /**
  27774. * Complex lighting can be computationally expensive to compute at runtime.
  27775. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27776. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27777. */
  27778. lightmapTexture: Nullable<BaseTexture>;
  27779. private _refractionTexture;
  27780. /**
  27781. * Define the texture used to display the refraction.
  27782. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27783. */
  27784. refractionTexture: Nullable<BaseTexture>;
  27785. /**
  27786. * The color of the material lit by the environmental background lighting.
  27787. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27788. */
  27789. ambientColor: Color3;
  27790. /**
  27791. * The basic color of the material as viewed under a light.
  27792. */
  27793. diffuseColor: Color3;
  27794. /**
  27795. * Define how the color and intensity of the highlight given by the light in the material.
  27796. */
  27797. specularColor: Color3;
  27798. /**
  27799. * Define the color of the material as if self lit.
  27800. * This will be mixed in the final result even in the absence of light.
  27801. */
  27802. emissiveColor: Color3;
  27803. /**
  27804. * Defines how sharp are the highlights in the material.
  27805. * The bigger the value the sharper giving a more glossy feeling to the result.
  27806. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27807. */
  27808. specularPower: number;
  27809. private _useAlphaFromDiffuseTexture;
  27810. /**
  27811. * Does the transparency come from the diffuse texture alpha channel.
  27812. */
  27813. useAlphaFromDiffuseTexture: boolean;
  27814. private _useEmissiveAsIllumination;
  27815. /**
  27816. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27817. */
  27818. useEmissiveAsIllumination: boolean;
  27819. private _linkEmissiveWithDiffuse;
  27820. /**
  27821. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27822. * the emissive level when the final color is close to one.
  27823. */
  27824. linkEmissiveWithDiffuse: boolean;
  27825. private _useSpecularOverAlpha;
  27826. /**
  27827. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27828. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27829. */
  27830. useSpecularOverAlpha: boolean;
  27831. private _useReflectionOverAlpha;
  27832. /**
  27833. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27834. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27835. */
  27836. useReflectionOverAlpha: boolean;
  27837. private _disableLighting;
  27838. /**
  27839. * Does lights from the scene impacts this material.
  27840. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27841. */
  27842. disableLighting: boolean;
  27843. private _useObjectSpaceNormalMap;
  27844. /**
  27845. * Allows using an object space normal map (instead of tangent space).
  27846. */
  27847. useObjectSpaceNormalMap: boolean;
  27848. private _useParallax;
  27849. /**
  27850. * Is parallax enabled or not.
  27851. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27852. */
  27853. useParallax: boolean;
  27854. private _useParallaxOcclusion;
  27855. /**
  27856. * Is parallax occlusion enabled or not.
  27857. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27858. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27859. */
  27860. useParallaxOcclusion: boolean;
  27861. /**
  27862. * 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.
  27863. */
  27864. parallaxScaleBias: number;
  27865. private _roughness;
  27866. /**
  27867. * Helps to define how blurry the reflections should appears in the material.
  27868. */
  27869. roughness: number;
  27870. /**
  27871. * In case of refraction, define the value of the index of refraction.
  27872. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27873. */
  27874. indexOfRefraction: number;
  27875. /**
  27876. * Invert the refraction texture alongside the y axis.
  27877. * It can be useful with procedural textures or probe for instance.
  27878. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27879. */
  27880. invertRefractionY: boolean;
  27881. /**
  27882. * Defines the alpha limits in alpha test mode.
  27883. */
  27884. alphaCutOff: number;
  27885. private _useLightmapAsShadowmap;
  27886. /**
  27887. * In case of light mapping, define whether the map contains light or shadow informations.
  27888. */
  27889. useLightmapAsShadowmap: boolean;
  27890. private _diffuseFresnelParameters;
  27891. /**
  27892. * Define the diffuse fresnel parameters of the material.
  27893. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27894. */
  27895. diffuseFresnelParameters: FresnelParameters;
  27896. private _opacityFresnelParameters;
  27897. /**
  27898. * Define the opacity fresnel parameters of the material.
  27899. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27900. */
  27901. opacityFresnelParameters: FresnelParameters;
  27902. private _reflectionFresnelParameters;
  27903. /**
  27904. * Define the reflection fresnel parameters of the material.
  27905. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27906. */
  27907. reflectionFresnelParameters: FresnelParameters;
  27908. private _refractionFresnelParameters;
  27909. /**
  27910. * Define the refraction fresnel parameters of the material.
  27911. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27912. */
  27913. refractionFresnelParameters: FresnelParameters;
  27914. private _emissiveFresnelParameters;
  27915. /**
  27916. * Define the emissive fresnel parameters of the material.
  27917. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27918. */
  27919. emissiveFresnelParameters: FresnelParameters;
  27920. private _useReflectionFresnelFromSpecular;
  27921. /**
  27922. * If true automatically deducts the fresnels values from the material specularity.
  27923. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27924. */
  27925. useReflectionFresnelFromSpecular: boolean;
  27926. private _useGlossinessFromSpecularMapAlpha;
  27927. /**
  27928. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27929. */
  27930. useGlossinessFromSpecularMapAlpha: boolean;
  27931. private _maxSimultaneousLights;
  27932. /**
  27933. * Defines the maximum number of lights that can be used in the material
  27934. */
  27935. maxSimultaneousLights: number;
  27936. private _invertNormalMapX;
  27937. /**
  27938. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27939. */
  27940. invertNormalMapX: boolean;
  27941. private _invertNormalMapY;
  27942. /**
  27943. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27944. */
  27945. invertNormalMapY: boolean;
  27946. private _twoSidedLighting;
  27947. /**
  27948. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27949. */
  27950. twoSidedLighting: boolean;
  27951. /**
  27952. * Default configuration related to image processing available in the standard Material.
  27953. */
  27954. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27955. /**
  27956. * Gets the image processing configuration used either in this material.
  27957. */
  27958. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27959. /**
  27960. * Sets the Default image processing configuration used either in the this material.
  27961. *
  27962. * If sets to null, the scene one is in use.
  27963. */
  27964. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27965. /**
  27966. * Keep track of the image processing observer to allow dispose and replace.
  27967. */
  27968. private _imageProcessingObserver;
  27969. /**
  27970. * Attaches a new image processing configuration to the Standard Material.
  27971. * @param configuration
  27972. */
  27973. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27974. /**
  27975. * Gets wether the color curves effect is enabled.
  27976. */
  27977. get cameraColorCurvesEnabled(): boolean;
  27978. /**
  27979. * Sets wether the color curves effect is enabled.
  27980. */
  27981. set cameraColorCurvesEnabled(value: boolean);
  27982. /**
  27983. * Gets wether the color grading effect is enabled.
  27984. */
  27985. get cameraColorGradingEnabled(): boolean;
  27986. /**
  27987. * Gets wether the color grading effect is enabled.
  27988. */
  27989. set cameraColorGradingEnabled(value: boolean);
  27990. /**
  27991. * Gets wether tonemapping is enabled or not.
  27992. */
  27993. get cameraToneMappingEnabled(): boolean;
  27994. /**
  27995. * Sets wether tonemapping is enabled or not
  27996. */
  27997. set cameraToneMappingEnabled(value: boolean);
  27998. /**
  27999. * The camera exposure used on this material.
  28000. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28001. * This corresponds to a photographic exposure.
  28002. */
  28003. get cameraExposure(): number;
  28004. /**
  28005. * The camera exposure used on this material.
  28006. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28007. * This corresponds to a photographic exposure.
  28008. */
  28009. set cameraExposure(value: number);
  28010. /**
  28011. * Gets The camera contrast used on this material.
  28012. */
  28013. get cameraContrast(): number;
  28014. /**
  28015. * Sets The camera contrast used on this material.
  28016. */
  28017. set cameraContrast(value: number);
  28018. /**
  28019. * Gets the Color Grading 2D Lookup Texture.
  28020. */
  28021. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  28022. /**
  28023. * Sets the Color Grading 2D Lookup Texture.
  28024. */
  28025. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  28026. /**
  28027. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28028. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28029. * 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;
  28030. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28031. */
  28032. get cameraColorCurves(): Nullable<ColorCurves>;
  28033. /**
  28034. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28035. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28036. * 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;
  28037. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28038. */
  28039. set cameraColorCurves(value: Nullable<ColorCurves>);
  28040. protected _renderTargets: SmartArray<RenderTargetTexture>;
  28041. protected _worldViewProjectionMatrix: Matrix;
  28042. protected _globalAmbientColor: Color3;
  28043. protected _useLogarithmicDepth: boolean;
  28044. protected _rebuildInParallel: boolean;
  28045. /**
  28046. * Instantiates a new standard material.
  28047. * This is the default material used in Babylon. It is the best trade off between quality
  28048. * and performances.
  28049. * @see http://doc.babylonjs.com/babylon101/materials
  28050. * @param name Define the name of the material in the scene
  28051. * @param scene Define the scene the material belong to
  28052. */
  28053. constructor(name: string, scene: Scene);
  28054. /**
  28055. * Gets a boolean indicating that current material needs to register RTT
  28056. */
  28057. get hasRenderTargetTextures(): boolean;
  28058. /**
  28059. * Gets the current class name of the material e.g. "StandardMaterial"
  28060. * Mainly use in serialization.
  28061. * @returns the class name
  28062. */
  28063. getClassName(): string;
  28064. /**
  28065. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  28066. * You can try switching to logarithmic depth.
  28067. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  28068. */
  28069. get useLogarithmicDepth(): boolean;
  28070. set useLogarithmicDepth(value: boolean);
  28071. /**
  28072. * Specifies if the material will require alpha blending
  28073. * @returns a boolean specifying if alpha blending is needed
  28074. */
  28075. needAlphaBlending(): boolean;
  28076. /**
  28077. * Specifies if this material should be rendered in alpha test mode
  28078. * @returns a boolean specifying if an alpha test is needed.
  28079. */
  28080. needAlphaTesting(): boolean;
  28081. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  28082. /**
  28083. * Get the texture used for alpha test purpose.
  28084. * @returns the diffuse texture in case of the standard material.
  28085. */
  28086. getAlphaTestTexture(): Nullable<BaseTexture>;
  28087. /**
  28088. * Get if the submesh is ready to be used and all its information available.
  28089. * Child classes can use it to update shaders
  28090. * @param mesh defines the mesh to check
  28091. * @param subMesh defines which submesh to check
  28092. * @param useInstances specifies that instances should be used
  28093. * @returns a boolean indicating that the submesh is ready or not
  28094. */
  28095. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  28096. /**
  28097. * Builds the material UBO layouts.
  28098. * Used internally during the effect preparation.
  28099. */
  28100. buildUniformLayout(): void;
  28101. /**
  28102. * Unbinds the material from the mesh
  28103. */
  28104. unbind(): void;
  28105. /**
  28106. * Binds the submesh to this material by preparing the effect and shader to draw
  28107. * @param world defines the world transformation matrix
  28108. * @param mesh defines the mesh containing the submesh
  28109. * @param subMesh defines the submesh to bind the material to
  28110. */
  28111. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  28112. /**
  28113. * Get the list of animatables in the material.
  28114. * @returns the list of animatables object used in the material
  28115. */
  28116. getAnimatables(): IAnimatable[];
  28117. /**
  28118. * Gets the active textures from the material
  28119. * @returns an array of textures
  28120. */
  28121. getActiveTextures(): BaseTexture[];
  28122. /**
  28123. * Specifies if the material uses a texture
  28124. * @param texture defines the texture to check against the material
  28125. * @returns a boolean specifying if the material uses the texture
  28126. */
  28127. hasTexture(texture: BaseTexture): boolean;
  28128. /**
  28129. * Disposes the material
  28130. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  28131. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  28132. */
  28133. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  28134. /**
  28135. * Makes a duplicate of the material, and gives it a new name
  28136. * @param name defines the new name for the duplicated material
  28137. * @returns the cloned material
  28138. */
  28139. clone(name: string): StandardMaterial;
  28140. /**
  28141. * Serializes this material in a JSON representation
  28142. * @returns the serialized material object
  28143. */
  28144. serialize(): any;
  28145. /**
  28146. * Creates a standard material from parsed material data
  28147. * @param source defines the JSON representation of the material
  28148. * @param scene defines the hosting scene
  28149. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28150. * @returns a new standard material
  28151. */
  28152. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  28153. /**
  28154. * Are diffuse textures enabled in the application.
  28155. */
  28156. static get DiffuseTextureEnabled(): boolean;
  28157. static set DiffuseTextureEnabled(value: boolean);
  28158. /**
  28159. * Are ambient textures enabled in the application.
  28160. */
  28161. static get AmbientTextureEnabled(): boolean;
  28162. static set AmbientTextureEnabled(value: boolean);
  28163. /**
  28164. * Are opacity textures enabled in the application.
  28165. */
  28166. static get OpacityTextureEnabled(): boolean;
  28167. static set OpacityTextureEnabled(value: boolean);
  28168. /**
  28169. * Are reflection textures enabled in the application.
  28170. */
  28171. static get ReflectionTextureEnabled(): boolean;
  28172. static set ReflectionTextureEnabled(value: boolean);
  28173. /**
  28174. * Are emissive textures enabled in the application.
  28175. */
  28176. static get EmissiveTextureEnabled(): boolean;
  28177. static set EmissiveTextureEnabled(value: boolean);
  28178. /**
  28179. * Are specular textures enabled in the application.
  28180. */
  28181. static get SpecularTextureEnabled(): boolean;
  28182. static set SpecularTextureEnabled(value: boolean);
  28183. /**
  28184. * Are bump textures enabled in the application.
  28185. */
  28186. static get BumpTextureEnabled(): boolean;
  28187. static set BumpTextureEnabled(value: boolean);
  28188. /**
  28189. * Are lightmap textures enabled in the application.
  28190. */
  28191. static get LightmapTextureEnabled(): boolean;
  28192. static set LightmapTextureEnabled(value: boolean);
  28193. /**
  28194. * Are refraction textures enabled in the application.
  28195. */
  28196. static get RefractionTextureEnabled(): boolean;
  28197. static set RefractionTextureEnabled(value: boolean);
  28198. /**
  28199. * Are color grading textures enabled in the application.
  28200. */
  28201. static get ColorGradingTextureEnabled(): boolean;
  28202. static set ColorGradingTextureEnabled(value: boolean);
  28203. /**
  28204. * Are fresnels enabled in the application.
  28205. */
  28206. static get FresnelEnabled(): boolean;
  28207. static set FresnelEnabled(value: boolean);
  28208. }
  28209. }
  28210. declare module "babylonjs/Particles/solidParticleSystem" {
  28211. import { Nullable } from "babylonjs/types";
  28212. import { Vector3 } from "babylonjs/Maths/math.vector";
  28213. import { Mesh } from "babylonjs/Meshes/mesh";
  28214. import { Scene, IDisposable } from "babylonjs/scene";
  28215. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  28216. import { Material } from "babylonjs/Materials/material";
  28217. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  28218. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28219. /**
  28220. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  28221. *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.
  28222. * The SPS is also a particle system. It provides some methods to manage the particles.
  28223. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  28224. *
  28225. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  28226. */
  28227. export class SolidParticleSystem implements IDisposable {
  28228. /**
  28229. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  28230. * Example : var p = SPS.particles[i];
  28231. */
  28232. particles: SolidParticle[];
  28233. /**
  28234. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  28235. */
  28236. nbParticles: number;
  28237. /**
  28238. * If the particles must ever face the camera (default false). Useful for planar particles.
  28239. */
  28240. billboard: boolean;
  28241. /**
  28242. * Recompute normals when adding a shape
  28243. */
  28244. recomputeNormals: boolean;
  28245. /**
  28246. * This a counter ofr your own usage. It's not set by any SPS functions.
  28247. */
  28248. counter: number;
  28249. /**
  28250. * The SPS name. This name is also given to the underlying mesh.
  28251. */
  28252. name: string;
  28253. /**
  28254. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  28255. */
  28256. mesh: Mesh;
  28257. /**
  28258. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  28259. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  28260. */
  28261. vars: any;
  28262. /**
  28263. * This array is populated when the SPS is set as 'pickable'.
  28264. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  28265. * Each element of this array is an object `{idx: int, faceId: int}`.
  28266. * `idx` is the picked particle index in the `SPS.particles` array
  28267. * `faceId` is the picked face index counted within this particle.
  28268. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  28269. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  28270. * Use the method SPS.pickedParticle(pickingInfo) instead.
  28271. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  28272. */
  28273. pickedParticles: {
  28274. idx: number;
  28275. faceId: number;
  28276. }[];
  28277. /**
  28278. * This array is populated when the SPS is set as 'pickable'
  28279. * Each key of this array is a submesh index.
  28280. * Each element of this array is a second array defined like this :
  28281. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  28282. * Each element of this second array is an object `{idx: int, faceId: int}`.
  28283. * `idx` is the picked particle index in the `SPS.particles` array
  28284. * `faceId` is the picked face index counted within this particle.
  28285. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  28286. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  28287. */
  28288. pickedBySubMesh: {
  28289. idx: number;
  28290. faceId: number;
  28291. }[][];
  28292. /**
  28293. * This array is populated when `enableDepthSort` is set to true.
  28294. * Each element of this array is an instance of the class DepthSortedParticle.
  28295. */
  28296. depthSortedParticles: DepthSortedParticle[];
  28297. /**
  28298. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  28299. * @hidden
  28300. */
  28301. _bSphereOnly: boolean;
  28302. /**
  28303. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  28304. * @hidden
  28305. */
  28306. _bSphereRadiusFactor: number;
  28307. private _scene;
  28308. private _positions;
  28309. private _indices;
  28310. private _normals;
  28311. private _colors;
  28312. private _uvs;
  28313. private _indices32;
  28314. private _positions32;
  28315. private _normals32;
  28316. private _fixedNormal32;
  28317. private _colors32;
  28318. private _uvs32;
  28319. private _index;
  28320. private _updatable;
  28321. private _pickable;
  28322. private _isVisibilityBoxLocked;
  28323. private _alwaysVisible;
  28324. private _depthSort;
  28325. private _expandable;
  28326. private _shapeCounter;
  28327. private _copy;
  28328. private _color;
  28329. private _computeParticleColor;
  28330. private _computeParticleTexture;
  28331. private _computeParticleRotation;
  28332. private _computeParticleVertex;
  28333. private _computeBoundingBox;
  28334. private _depthSortParticles;
  28335. private _camera;
  28336. private _mustUnrotateFixedNormals;
  28337. private _particlesIntersect;
  28338. private _needs32Bits;
  28339. private _isNotBuilt;
  28340. private _lastParticleId;
  28341. private _idxOfId;
  28342. private _multimaterialEnabled;
  28343. private _useModelMaterial;
  28344. private _indicesByMaterial;
  28345. private _materialIndexes;
  28346. private _depthSortFunction;
  28347. private _materialSortFunction;
  28348. private _materials;
  28349. private _multimaterial;
  28350. private _materialIndexesById;
  28351. private _defaultMaterial;
  28352. private _autoUpdateSubMeshes;
  28353. /**
  28354. * Creates a SPS (Solid Particle System) object.
  28355. * @param name (String) is the SPS name, this will be the underlying mesh name.
  28356. * @param scene (Scene) is the scene in which the SPS is added.
  28357. * @param options defines the options of the sps e.g.
  28358. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  28359. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  28360. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  28361. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  28362. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  28363. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  28364. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  28365. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  28366. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  28367. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  28368. */
  28369. constructor(name: string, scene: Scene, options?: {
  28370. updatable?: boolean;
  28371. isPickable?: boolean;
  28372. enableDepthSort?: boolean;
  28373. particleIntersection?: boolean;
  28374. boundingSphereOnly?: boolean;
  28375. bSphereRadiusFactor?: number;
  28376. expandable?: boolean;
  28377. useModelMaterial?: boolean;
  28378. enableMultiMaterial?: boolean;
  28379. });
  28380. /**
  28381. * Builds the SPS underlying mesh. Returns a standard Mesh.
  28382. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  28383. * @returns the created mesh
  28384. */
  28385. buildMesh(): Mesh;
  28386. /**
  28387. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  28388. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  28389. * Thus the particles generated from `digest()` have their property `position` set yet.
  28390. * @param mesh ( Mesh ) is the mesh to be digested
  28391. * @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
  28392. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  28393. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  28394. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  28395. * @returns the current SPS
  28396. */
  28397. digest(mesh: Mesh, options?: {
  28398. facetNb?: number;
  28399. number?: number;
  28400. delta?: number;
  28401. storage?: [];
  28402. }): SolidParticleSystem;
  28403. /**
  28404. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  28405. * @hidden
  28406. */
  28407. private _unrotateFixedNormals;
  28408. /**
  28409. * Resets the temporary working copy particle
  28410. * @hidden
  28411. */
  28412. private _resetCopy;
  28413. /**
  28414. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  28415. * @param p the current index in the positions array to be updated
  28416. * @param ind the current index in the indices array
  28417. * @param shape a Vector3 array, the shape geometry
  28418. * @param positions the positions array to be updated
  28419. * @param meshInd the shape indices array
  28420. * @param indices the indices array to be updated
  28421. * @param meshUV the shape uv array
  28422. * @param uvs the uv array to be updated
  28423. * @param meshCol the shape color array
  28424. * @param colors the color array to be updated
  28425. * @param meshNor the shape normals array
  28426. * @param normals the normals array to be updated
  28427. * @param idx the particle index
  28428. * @param idxInShape the particle index in its shape
  28429. * @param options the addShape() method passed options
  28430. * @model the particle model
  28431. * @hidden
  28432. */
  28433. private _meshBuilder;
  28434. /**
  28435. * Returns a shape Vector3 array from positions float array
  28436. * @param positions float array
  28437. * @returns a vector3 array
  28438. * @hidden
  28439. */
  28440. private _posToShape;
  28441. /**
  28442. * Returns a shapeUV array from a float uvs (array deep copy)
  28443. * @param uvs as a float array
  28444. * @returns a shapeUV array
  28445. * @hidden
  28446. */
  28447. private _uvsToShapeUV;
  28448. /**
  28449. * Adds a new particle object in the particles array
  28450. * @param idx particle index in particles array
  28451. * @param id particle id
  28452. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  28453. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  28454. * @param model particle ModelShape object
  28455. * @param shapeId model shape identifier
  28456. * @param idxInShape index of the particle in the current model
  28457. * @param bInfo model bounding info object
  28458. * @param storage target storage array, if any
  28459. * @hidden
  28460. */
  28461. private _addParticle;
  28462. /**
  28463. * Adds some particles to the SPS from the model shape. Returns the shape id.
  28464. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  28465. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  28466. * @param nb (positive integer) the number of particles to be created from this model
  28467. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  28468. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  28469. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  28470. * @returns the number of shapes in the system
  28471. */
  28472. addShape(mesh: Mesh, nb: number, options?: {
  28473. positionFunction?: any;
  28474. vertexFunction?: any;
  28475. storage?: [];
  28476. }): number;
  28477. /**
  28478. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  28479. * @hidden
  28480. */
  28481. private _rebuildParticle;
  28482. /**
  28483. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  28484. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  28485. * @returns the SPS.
  28486. */
  28487. rebuildMesh(reset?: boolean): SolidParticleSystem;
  28488. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  28489. * Returns an array with the removed particles.
  28490. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  28491. * The SPS can't be empty so at least one particle needs to remain in place.
  28492. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  28493. * @param start index of the first particle to remove
  28494. * @param end index of the last particle to remove (included)
  28495. * @returns an array populated with the removed particles
  28496. */
  28497. removeParticles(start: number, end: number): SolidParticle[];
  28498. /**
  28499. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  28500. * @param solidParticleArray an array populated with Solid Particles objects
  28501. * @returns the SPS
  28502. */
  28503. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  28504. /**
  28505. * Creates a new particle and modifies the SPS mesh geometry :
  28506. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  28507. * - calls _addParticle() to populate the particle array
  28508. * factorized code from addShape() and insertParticlesFromArray()
  28509. * @param idx particle index in the particles array
  28510. * @param i particle index in its shape
  28511. * @param modelShape particle ModelShape object
  28512. * @param shape shape vertex array
  28513. * @param meshInd shape indices array
  28514. * @param meshUV shape uv array
  28515. * @param meshCol shape color array
  28516. * @param meshNor shape normals array
  28517. * @param bbInfo shape bounding info
  28518. * @param storage target particle storage
  28519. * @options addShape() passed options
  28520. * @hidden
  28521. */
  28522. private _insertNewParticle;
  28523. /**
  28524. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  28525. * This method calls `updateParticle()` for each particle of the SPS.
  28526. * For an animated SPS, it is usually called within the render loop.
  28527. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  28528. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  28529. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  28530. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  28531. * @returns the SPS.
  28532. */
  28533. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  28534. /**
  28535. * Disposes the SPS.
  28536. */
  28537. dispose(): void;
  28538. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  28539. * idx is the particle index in the SPS
  28540. * faceId is the picked face index counted within this particle.
  28541. * Returns null if the pickInfo can't identify a picked particle.
  28542. * @param pickingInfo (PickingInfo object)
  28543. * @returns {idx: number, faceId: number} or null
  28544. */
  28545. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  28546. idx: number;
  28547. faceId: number;
  28548. }>;
  28549. /**
  28550. * Returns a SolidParticle object from its identifier : particle.id
  28551. * @param id (integer) the particle Id
  28552. * @returns the searched particle or null if not found in the SPS.
  28553. */
  28554. getParticleById(id: number): Nullable<SolidParticle>;
  28555. /**
  28556. * Returns a new array populated with the particles having the passed shapeId.
  28557. * @param shapeId (integer) the shape identifier
  28558. * @returns a new solid particle array
  28559. */
  28560. getParticlesByShapeId(shapeId: number): SolidParticle[];
  28561. /**
  28562. * Populates the passed array "ref" with the particles having the passed shapeId.
  28563. * @param shapeId the shape identifier
  28564. * @returns the SPS
  28565. * @param ref
  28566. */
  28567. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  28568. /**
  28569. * Computes the required SubMeshes according the materials assigned to the particles.
  28570. * @returns the solid particle system.
  28571. * Does nothing if called before the SPS mesh is built.
  28572. */
  28573. computeSubMeshes(): SolidParticleSystem;
  28574. /**
  28575. * Sorts the solid particles by material when MultiMaterial is enabled.
  28576. * Updates the indices32 array.
  28577. * Updates the indicesByMaterial array.
  28578. * Updates the mesh indices array.
  28579. * @returns the SPS
  28580. * @hidden
  28581. */
  28582. private _sortParticlesByMaterial;
  28583. /**
  28584. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  28585. * @hidden
  28586. */
  28587. private _setMaterialIndexesById;
  28588. /**
  28589. * Returns an array with unique values of Materials from the passed array
  28590. * @param array the material array to be checked and filtered
  28591. * @hidden
  28592. */
  28593. private _filterUniqueMaterialId;
  28594. /**
  28595. * Sets a new Standard Material as _defaultMaterial if not already set.
  28596. * @hidden
  28597. */
  28598. private _setDefaultMaterial;
  28599. /**
  28600. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  28601. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28602. * @returns the SPS.
  28603. */
  28604. refreshVisibleSize(): SolidParticleSystem;
  28605. /**
  28606. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  28607. * @param size the size (float) of the visibility box
  28608. * note : this doesn't lock the SPS mesh bounding box.
  28609. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28610. */
  28611. setVisibilityBox(size: number): void;
  28612. /**
  28613. * Gets whether the SPS as always visible or not
  28614. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28615. */
  28616. get isAlwaysVisible(): boolean;
  28617. /**
  28618. * Sets the SPS as always visible or not
  28619. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28620. */
  28621. set isAlwaysVisible(val: boolean);
  28622. /**
  28623. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28624. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28625. */
  28626. set isVisibilityBoxLocked(val: boolean);
  28627. /**
  28628. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28629. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28630. */
  28631. get isVisibilityBoxLocked(): boolean;
  28632. /**
  28633. * Tells to `setParticles()` to compute the particle rotations or not.
  28634. * Default value : true. The SPS is faster when it's set to false.
  28635. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28636. */
  28637. set computeParticleRotation(val: boolean);
  28638. /**
  28639. * Tells to `setParticles()` to compute the particle colors or not.
  28640. * Default value : true. The SPS is faster when it's set to false.
  28641. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28642. */
  28643. set computeParticleColor(val: boolean);
  28644. set computeParticleTexture(val: boolean);
  28645. /**
  28646. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  28647. * Default value : false. The SPS is faster when it's set to false.
  28648. * Note : the particle custom vertex positions aren't stored values.
  28649. */
  28650. set computeParticleVertex(val: boolean);
  28651. /**
  28652. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28653. */
  28654. set computeBoundingBox(val: boolean);
  28655. /**
  28656. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28657. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28658. * Default : `true`
  28659. */
  28660. set depthSortParticles(val: boolean);
  28661. /**
  28662. * Gets if `setParticles()` computes the particle rotations or not.
  28663. * Default value : true. The SPS is faster when it's set to false.
  28664. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28665. */
  28666. get computeParticleRotation(): boolean;
  28667. /**
  28668. * Gets if `setParticles()` computes the particle colors or not.
  28669. * Default value : true. The SPS is faster when it's set to false.
  28670. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28671. */
  28672. get computeParticleColor(): boolean;
  28673. /**
  28674. * Gets if `setParticles()` computes the particle textures or not.
  28675. * Default value : true. The SPS is faster when it's set to false.
  28676. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28677. */
  28678. get computeParticleTexture(): boolean;
  28679. /**
  28680. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28681. * Default value : false. The SPS is faster when it's set to false.
  28682. * Note : the particle custom vertex positions aren't stored values.
  28683. */
  28684. get computeParticleVertex(): boolean;
  28685. /**
  28686. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28687. */
  28688. get computeBoundingBox(): boolean;
  28689. /**
  28690. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28691. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28692. * Default : `true`
  28693. */
  28694. get depthSortParticles(): boolean;
  28695. /**
  28696. * Gets if the SPS is created as expandable at construction time.
  28697. * Default : `false`
  28698. */
  28699. get expandable(): boolean;
  28700. /**
  28701. * Gets if the SPS supports the Multi Materials
  28702. */
  28703. get multimaterialEnabled(): boolean;
  28704. /**
  28705. * Gets if the SPS uses the model materials for its own multimaterial.
  28706. */
  28707. get useModelMaterial(): boolean;
  28708. /**
  28709. * The SPS used material array.
  28710. */
  28711. get materials(): Material[];
  28712. /**
  28713. * Sets the SPS MultiMaterial from the passed materials.
  28714. * Note : the passed array is internally copied and not used then by reference.
  28715. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28716. */
  28717. setMultiMaterial(materials: Material[]): void;
  28718. /**
  28719. * The SPS computed multimaterial object
  28720. */
  28721. get multimaterial(): MultiMaterial;
  28722. set multimaterial(mm: MultiMaterial);
  28723. /**
  28724. * If the subMeshes must be updated on the next call to setParticles()
  28725. */
  28726. get autoUpdateSubMeshes(): boolean;
  28727. set autoUpdateSubMeshes(val: boolean);
  28728. /**
  28729. * This function does nothing. It may be overwritten to set all the particle first values.
  28730. * The SPS doesn't call this function, you may have to call it by your own.
  28731. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28732. */
  28733. initParticles(): void;
  28734. /**
  28735. * This function does nothing. It may be overwritten to recycle a particle.
  28736. * The SPS doesn't call this function, you may have to call it by your own.
  28737. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28738. * @param particle The particle to recycle
  28739. * @returns the recycled particle
  28740. */
  28741. recycleParticle(particle: SolidParticle): SolidParticle;
  28742. /**
  28743. * Updates a particle : this function should be overwritten by the user.
  28744. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28745. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28746. * @example : just set a particle position or velocity and recycle conditions
  28747. * @param particle The particle to update
  28748. * @returns the updated particle
  28749. */
  28750. updateParticle(particle: SolidParticle): SolidParticle;
  28751. /**
  28752. * Updates a vertex of a particle : it can be overwritten by the user.
  28753. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28754. * @param particle the current particle
  28755. * @param vertex the current index of the current particle
  28756. * @param pt the index of the current vertex in the particle shape
  28757. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28758. * @example : just set a vertex particle position
  28759. * @returns the updated vertex
  28760. */
  28761. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28762. /**
  28763. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28764. * This does nothing and may be overwritten by the user.
  28765. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28766. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28767. * @param update the boolean update value actually passed to setParticles()
  28768. */
  28769. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28770. /**
  28771. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28772. * This will be passed three parameters.
  28773. * This does nothing and may be overwritten by the user.
  28774. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28775. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28776. * @param update the boolean update value actually passed to setParticles()
  28777. */
  28778. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28779. }
  28780. }
  28781. declare module "babylonjs/Particles/solidParticle" {
  28782. import { Nullable } from "babylonjs/types";
  28783. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28784. import { Color4 } from "babylonjs/Maths/math.color";
  28785. import { Mesh } from "babylonjs/Meshes/mesh";
  28786. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28787. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28788. import { Plane } from "babylonjs/Maths/math.plane";
  28789. import { Material } from "babylonjs/Materials/material";
  28790. /**
  28791. * Represents one particle of a solid particle system.
  28792. */
  28793. export class SolidParticle {
  28794. /**
  28795. * particle global index
  28796. */
  28797. idx: number;
  28798. /**
  28799. * particle identifier
  28800. */
  28801. id: number;
  28802. /**
  28803. * The color of the particle
  28804. */
  28805. color: Nullable<Color4>;
  28806. /**
  28807. * The world space position of the particle.
  28808. */
  28809. position: Vector3;
  28810. /**
  28811. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28812. */
  28813. rotation: Vector3;
  28814. /**
  28815. * The world space rotation quaternion of the particle.
  28816. */
  28817. rotationQuaternion: Nullable<Quaternion>;
  28818. /**
  28819. * The scaling of the particle.
  28820. */
  28821. scaling: Vector3;
  28822. /**
  28823. * The uvs of the particle.
  28824. */
  28825. uvs: Vector4;
  28826. /**
  28827. * The current speed of the particle.
  28828. */
  28829. velocity: Vector3;
  28830. /**
  28831. * The pivot point in the particle local space.
  28832. */
  28833. pivot: Vector3;
  28834. /**
  28835. * Must the particle be translated from its pivot point in its local space ?
  28836. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28837. * Default : false
  28838. */
  28839. translateFromPivot: boolean;
  28840. /**
  28841. * Is the particle active or not ?
  28842. */
  28843. alive: boolean;
  28844. /**
  28845. * Is the particle visible or not ?
  28846. */
  28847. isVisible: boolean;
  28848. /**
  28849. * Index of this particle in the global "positions" array (Internal use)
  28850. * @hidden
  28851. */
  28852. _pos: number;
  28853. /**
  28854. * @hidden Index of this particle in the global "indices" array (Internal use)
  28855. */
  28856. _ind: number;
  28857. /**
  28858. * @hidden ModelShape of this particle (Internal use)
  28859. */
  28860. _model: ModelShape;
  28861. /**
  28862. * ModelShape id of this particle
  28863. */
  28864. shapeId: number;
  28865. /**
  28866. * Index of the particle in its shape id
  28867. */
  28868. idxInShape: number;
  28869. /**
  28870. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28871. */
  28872. _modelBoundingInfo: BoundingInfo;
  28873. /**
  28874. * @hidden Particle BoundingInfo object (Internal use)
  28875. */
  28876. _boundingInfo: BoundingInfo;
  28877. /**
  28878. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28879. */
  28880. _sps: SolidParticleSystem;
  28881. /**
  28882. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28883. */
  28884. _stillInvisible: boolean;
  28885. /**
  28886. * @hidden Last computed particle rotation matrix
  28887. */
  28888. _rotationMatrix: number[];
  28889. /**
  28890. * Parent particle Id, if any.
  28891. * Default null.
  28892. */
  28893. parentId: Nullable<number>;
  28894. /**
  28895. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28896. */
  28897. materialIndex: Nullable<number>;
  28898. /**
  28899. * Custom object or properties.
  28900. */
  28901. props: Nullable<any>;
  28902. /**
  28903. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28904. * The possible values are :
  28905. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28906. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28907. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28908. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28909. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28910. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28911. * */
  28912. cullingStrategy: number;
  28913. /**
  28914. * @hidden Internal global position in the SPS.
  28915. */
  28916. _globalPosition: Vector3;
  28917. /**
  28918. * Creates a Solid Particle object.
  28919. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28920. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28921. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28922. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28923. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28924. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28925. * @param shapeId (integer) is the model shape identifier in the SPS.
  28926. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28927. * @param sps defines the sps it is associated to
  28928. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28929. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28930. */
  28931. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28932. /**
  28933. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28934. * @param target the particle target
  28935. * @returns the current particle
  28936. */
  28937. copyToRef(target: SolidParticle): SolidParticle;
  28938. /**
  28939. * Legacy support, changed scale to scaling
  28940. */
  28941. get scale(): Vector3;
  28942. /**
  28943. * Legacy support, changed scale to scaling
  28944. */
  28945. set scale(scale: Vector3);
  28946. /**
  28947. * Legacy support, changed quaternion to rotationQuaternion
  28948. */
  28949. get quaternion(): Nullable<Quaternion>;
  28950. /**
  28951. * Legacy support, changed quaternion to rotationQuaternion
  28952. */
  28953. set quaternion(q: Nullable<Quaternion>);
  28954. /**
  28955. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28956. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28957. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28958. * @returns true if it intersects
  28959. */
  28960. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28961. /**
  28962. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28963. * A particle is in the frustum if its bounding box intersects the frustum
  28964. * @param frustumPlanes defines the frustum to test
  28965. * @returns true if the particle is in the frustum planes
  28966. */
  28967. isInFrustum(frustumPlanes: Plane[]): boolean;
  28968. /**
  28969. * get the rotation matrix of the particle
  28970. * @hidden
  28971. */
  28972. getRotationMatrix(m: Matrix): void;
  28973. }
  28974. /**
  28975. * Represents the shape of the model used by one particle of a solid particle system.
  28976. * SPS internal tool, don't use it manually.
  28977. */
  28978. export class ModelShape {
  28979. /**
  28980. * The shape id
  28981. * @hidden
  28982. */
  28983. shapeID: number;
  28984. /**
  28985. * flat array of model positions (internal use)
  28986. * @hidden
  28987. */
  28988. _shape: Vector3[];
  28989. /**
  28990. * flat array of model UVs (internal use)
  28991. * @hidden
  28992. */
  28993. _shapeUV: number[];
  28994. /**
  28995. * color array of the model
  28996. * @hidden
  28997. */
  28998. _shapeColors: number[];
  28999. /**
  29000. * indices array of the model
  29001. * @hidden
  29002. */
  29003. _indices: number[];
  29004. /**
  29005. * normals array of the model
  29006. * @hidden
  29007. */
  29008. _normals: number[];
  29009. /**
  29010. * length of the shape in the model indices array (internal use)
  29011. * @hidden
  29012. */
  29013. _indicesLength: number;
  29014. /**
  29015. * Custom position function (internal use)
  29016. * @hidden
  29017. */
  29018. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  29019. /**
  29020. * Custom vertex function (internal use)
  29021. * @hidden
  29022. */
  29023. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  29024. /**
  29025. * Model material (internal use)
  29026. * @hidden
  29027. */
  29028. _material: Nullable<Material>;
  29029. /**
  29030. * 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.
  29031. * SPS internal tool, don't use it manually.
  29032. * @hidden
  29033. */
  29034. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  29035. }
  29036. /**
  29037. * Represents a Depth Sorted Particle in the solid particle system.
  29038. * @hidden
  29039. */
  29040. export class DepthSortedParticle {
  29041. /**
  29042. * Particle index
  29043. */
  29044. idx: number;
  29045. /**
  29046. * Index of the particle in the "indices" array
  29047. */
  29048. ind: number;
  29049. /**
  29050. * Length of the particle shape in the "indices" array
  29051. */
  29052. indicesLength: number;
  29053. /**
  29054. * Squared distance from the particle to the camera
  29055. */
  29056. sqDistance: number;
  29057. /**
  29058. * Material index when used with MultiMaterials
  29059. */
  29060. materialIndex: number;
  29061. /**
  29062. * Creates a new sorted particle
  29063. * @param materialIndex
  29064. */
  29065. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  29066. }
  29067. }
  29068. declare module "babylonjs/Collisions/meshCollisionData" {
  29069. import { Collider } from "babylonjs/Collisions/collider";
  29070. import { Vector3 } from "babylonjs/Maths/math.vector";
  29071. import { Nullable } from "babylonjs/types";
  29072. import { Observer } from "babylonjs/Misc/observable";
  29073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29074. /**
  29075. * @hidden
  29076. */
  29077. export class _MeshCollisionData {
  29078. _checkCollisions: boolean;
  29079. _collisionMask: number;
  29080. _collisionGroup: number;
  29081. _surroundingMeshes: Nullable<AbstractMesh[]>;
  29082. _collider: Nullable<Collider>;
  29083. _oldPositionForCollisions: Vector3;
  29084. _diffPositionForCollisions: Vector3;
  29085. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  29086. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  29087. }
  29088. }
  29089. declare module "babylonjs/Meshes/abstractMesh" {
  29090. import { Observable } from "babylonjs/Misc/observable";
  29091. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  29092. import { Camera } from "babylonjs/Cameras/camera";
  29093. import { Scene, IDisposable } from "babylonjs/scene";
  29094. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  29095. import { Node } from "babylonjs/node";
  29096. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  29097. import { TransformNode } from "babylonjs/Meshes/transformNode";
  29098. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29099. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  29100. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  29101. import { Material } from "babylonjs/Materials/material";
  29102. import { Light } from "babylonjs/Lights/light";
  29103. import { Skeleton } from "babylonjs/Bones/skeleton";
  29104. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  29105. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  29106. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29107. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  29108. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29109. import { Plane } from "babylonjs/Maths/math.plane";
  29110. import { Ray } from "babylonjs/Culling/ray";
  29111. import { Collider } from "babylonjs/Collisions/collider";
  29112. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  29113. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  29114. /** @hidden */
  29115. class _FacetDataStorage {
  29116. facetPositions: Vector3[];
  29117. facetNormals: Vector3[];
  29118. facetPartitioning: number[][];
  29119. facetNb: number;
  29120. partitioningSubdivisions: number;
  29121. partitioningBBoxRatio: number;
  29122. facetDataEnabled: boolean;
  29123. facetParameters: any;
  29124. bbSize: Vector3;
  29125. subDiv: {
  29126. max: number;
  29127. X: number;
  29128. Y: number;
  29129. Z: number;
  29130. };
  29131. facetDepthSort: boolean;
  29132. facetDepthSortEnabled: boolean;
  29133. depthSortedIndices: IndicesArray;
  29134. depthSortedFacets: {
  29135. ind: number;
  29136. sqDistance: number;
  29137. }[];
  29138. facetDepthSortFunction: (f1: {
  29139. ind: number;
  29140. sqDistance: number;
  29141. }, f2: {
  29142. ind: number;
  29143. sqDistance: number;
  29144. }) => number;
  29145. facetDepthSortFrom: Vector3;
  29146. facetDepthSortOrigin: Vector3;
  29147. invertedMatrix: Matrix;
  29148. }
  29149. /**
  29150. * @hidden
  29151. **/
  29152. class _InternalAbstractMeshDataInfo {
  29153. _hasVertexAlpha: boolean;
  29154. _useVertexColors: boolean;
  29155. _numBoneInfluencers: number;
  29156. _applyFog: boolean;
  29157. _receiveShadows: boolean;
  29158. _facetData: _FacetDataStorage;
  29159. _visibility: number;
  29160. _skeleton: Nullable<Skeleton>;
  29161. _layerMask: number;
  29162. _computeBonesUsingShaders: boolean;
  29163. _isActive: boolean;
  29164. _onlyForInstances: boolean;
  29165. _isActiveIntermediate: boolean;
  29166. _onlyForInstancesIntermediate: boolean;
  29167. _actAsRegularMesh: boolean;
  29168. }
  29169. /**
  29170. * Class used to store all common mesh properties
  29171. */
  29172. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  29173. /** No occlusion */
  29174. static OCCLUSION_TYPE_NONE: number;
  29175. /** Occlusion set to optimisitic */
  29176. static OCCLUSION_TYPE_OPTIMISTIC: number;
  29177. /** Occlusion set to strict */
  29178. static OCCLUSION_TYPE_STRICT: number;
  29179. /** Use an accurante occlusion algorithm */
  29180. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  29181. /** Use a conservative occlusion algorithm */
  29182. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  29183. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  29184. * Test order :
  29185. * Is the bounding sphere outside the frustum ?
  29186. * If not, are the bounding box vertices outside the frustum ?
  29187. * It not, then the cullable object is in the frustum.
  29188. */
  29189. static readonly CULLINGSTRATEGY_STANDARD: number;
  29190. /** Culling strategy : Bounding Sphere Only.
  29191. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  29192. * It's also less accurate than the standard because some not visible objects can still be selected.
  29193. * Test : is the bounding sphere outside the frustum ?
  29194. * If not, then the cullable object is in the frustum.
  29195. */
  29196. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  29197. /** Culling strategy : Optimistic Inclusion.
  29198. * This in an inclusion test first, then the standard exclusion test.
  29199. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  29200. * 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.
  29201. * Anyway, it's as accurate as the standard strategy.
  29202. * Test :
  29203. * Is the cullable object bounding sphere center in the frustum ?
  29204. * If not, apply the default culling strategy.
  29205. */
  29206. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  29207. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  29208. * This in an inclusion test first, then the bounding sphere only exclusion test.
  29209. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  29210. * 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.
  29211. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  29212. * Test :
  29213. * Is the cullable object bounding sphere center in the frustum ?
  29214. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  29215. */
  29216. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  29217. /**
  29218. * No billboard
  29219. */
  29220. static get BILLBOARDMODE_NONE(): number;
  29221. /** Billboard on X axis */
  29222. static get BILLBOARDMODE_X(): number;
  29223. /** Billboard on Y axis */
  29224. static get BILLBOARDMODE_Y(): number;
  29225. /** Billboard on Z axis */
  29226. static get BILLBOARDMODE_Z(): number;
  29227. /** Billboard on all axes */
  29228. static get BILLBOARDMODE_ALL(): number;
  29229. /** Billboard on using position instead of orientation */
  29230. static get BILLBOARDMODE_USE_POSITION(): number;
  29231. /** @hidden */
  29232. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  29233. /**
  29234. * The culling strategy to use to check whether the mesh must be rendered or not.
  29235. * This value can be changed at any time and will be used on the next render mesh selection.
  29236. * The possible values are :
  29237. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  29238. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  29239. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  29240. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  29241. * Please read each static variable documentation to get details about the culling process.
  29242. * */
  29243. cullingStrategy: number;
  29244. /**
  29245. * Gets the number of facets in the mesh
  29246. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  29247. */
  29248. get facetNb(): number;
  29249. /**
  29250. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  29251. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  29252. */
  29253. get partitioningSubdivisions(): number;
  29254. set partitioningSubdivisions(nb: number);
  29255. /**
  29256. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  29257. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  29258. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  29259. */
  29260. get partitioningBBoxRatio(): number;
  29261. set partitioningBBoxRatio(ratio: number);
  29262. /**
  29263. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  29264. * Works only for updatable meshes.
  29265. * Doesn't work with multi-materials
  29266. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  29267. */
  29268. get mustDepthSortFacets(): boolean;
  29269. set mustDepthSortFacets(sort: boolean);
  29270. /**
  29271. * The location (Vector3) where the facet depth sort must be computed from.
  29272. * By default, the active camera position.
  29273. * Used only when facet depth sort is enabled
  29274. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  29275. */
  29276. get facetDepthSortFrom(): Vector3;
  29277. set facetDepthSortFrom(location: Vector3);
  29278. /**
  29279. * gets a boolean indicating if facetData is enabled
  29280. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  29281. */
  29282. get isFacetDataEnabled(): boolean;
  29283. /** @hidden */
  29284. _updateNonUniformScalingState(value: boolean): boolean;
  29285. /**
  29286. * An event triggered when this mesh collides with another one
  29287. */
  29288. onCollideObservable: Observable<AbstractMesh>;
  29289. /** Set a function to call when this mesh collides with another one */
  29290. set onCollide(callback: () => void);
  29291. /**
  29292. * An event triggered when the collision's position changes
  29293. */
  29294. onCollisionPositionChangeObservable: Observable<Vector3>;
  29295. /** Set a function to call when the collision's position changes */
  29296. set onCollisionPositionChange(callback: () => void);
  29297. /**
  29298. * An event triggered when material is changed
  29299. */
  29300. onMaterialChangedObservable: Observable<AbstractMesh>;
  29301. /**
  29302. * Gets or sets the orientation for POV movement & rotation
  29303. */
  29304. definedFacingForward: boolean;
  29305. /** @hidden */
  29306. _occlusionQuery: Nullable<WebGLQuery>;
  29307. /** @hidden */
  29308. _renderingGroup: Nullable<RenderingGroup>;
  29309. /**
  29310. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  29311. */
  29312. get visibility(): number;
  29313. /**
  29314. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  29315. */
  29316. set visibility(value: number);
  29317. /** Gets or sets the alpha index used to sort transparent meshes
  29318. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  29319. */
  29320. alphaIndex: number;
  29321. /**
  29322. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  29323. */
  29324. isVisible: boolean;
  29325. /**
  29326. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  29327. */
  29328. isPickable: boolean;
  29329. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  29330. showSubMeshesBoundingBox: boolean;
  29331. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  29332. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  29333. */
  29334. isBlocker: boolean;
  29335. /**
  29336. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  29337. */
  29338. enablePointerMoveEvents: boolean;
  29339. /**
  29340. * Specifies the rendering group id for this mesh (0 by default)
  29341. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  29342. */
  29343. renderingGroupId: number;
  29344. private _material;
  29345. /** Gets or sets current material */
  29346. get material(): Nullable<Material>;
  29347. set material(value: Nullable<Material>);
  29348. /**
  29349. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  29350. * @see http://doc.babylonjs.com/babylon101/shadows
  29351. */
  29352. get receiveShadows(): boolean;
  29353. set receiveShadows(value: boolean);
  29354. /** Defines color to use when rendering outline */
  29355. outlineColor: Color3;
  29356. /** Define width to use when rendering outline */
  29357. outlineWidth: number;
  29358. /** Defines color to use when rendering overlay */
  29359. overlayColor: Color3;
  29360. /** Defines alpha to use when rendering overlay */
  29361. overlayAlpha: number;
  29362. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  29363. get hasVertexAlpha(): boolean;
  29364. set hasVertexAlpha(value: boolean);
  29365. /** 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) */
  29366. get useVertexColors(): boolean;
  29367. set useVertexColors(value: boolean);
  29368. /**
  29369. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  29370. */
  29371. get computeBonesUsingShaders(): boolean;
  29372. set computeBonesUsingShaders(value: boolean);
  29373. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  29374. get numBoneInfluencers(): number;
  29375. set numBoneInfluencers(value: number);
  29376. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  29377. get applyFog(): boolean;
  29378. set applyFog(value: boolean);
  29379. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  29380. useOctreeForRenderingSelection: boolean;
  29381. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  29382. useOctreeForPicking: boolean;
  29383. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  29384. useOctreeForCollisions: boolean;
  29385. /**
  29386. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  29387. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  29388. */
  29389. get layerMask(): number;
  29390. set layerMask(value: number);
  29391. /**
  29392. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  29393. */
  29394. alwaysSelectAsActiveMesh: boolean;
  29395. /**
  29396. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  29397. */
  29398. doNotSyncBoundingInfo: boolean;
  29399. /**
  29400. * Gets or sets the current action manager
  29401. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29402. */
  29403. actionManager: Nullable<AbstractActionManager>;
  29404. private _meshCollisionData;
  29405. /**
  29406. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  29407. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29408. */
  29409. ellipsoid: Vector3;
  29410. /**
  29411. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  29412. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29413. */
  29414. ellipsoidOffset: Vector3;
  29415. /**
  29416. * Gets or sets a collision mask used to mask collisions (default is -1).
  29417. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  29418. */
  29419. get collisionMask(): number;
  29420. set collisionMask(mask: number);
  29421. /**
  29422. * Gets or sets the current collision group mask (-1 by default).
  29423. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  29424. */
  29425. get collisionGroup(): number;
  29426. set collisionGroup(mask: number);
  29427. /**
  29428. * Gets or sets current surrounding meshes (null by default).
  29429. *
  29430. * By default collision detection is tested against every mesh in the scene.
  29431. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  29432. * meshes will be tested for the collision.
  29433. *
  29434. * Note: if set to an empty array no collision will happen when this mesh is moved.
  29435. */
  29436. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  29437. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  29438. /**
  29439. * Defines edge width used when edgesRenderer is enabled
  29440. * @see https://www.babylonjs-playground.com/#10OJSG#13
  29441. */
  29442. edgesWidth: number;
  29443. /**
  29444. * Defines edge color used when edgesRenderer is enabled
  29445. * @see https://www.babylonjs-playground.com/#10OJSG#13
  29446. */
  29447. edgesColor: Color4;
  29448. /** @hidden */
  29449. _edgesRenderer: Nullable<IEdgesRenderer>;
  29450. /** @hidden */
  29451. _masterMesh: Nullable<AbstractMesh>;
  29452. /** @hidden */
  29453. _boundingInfo: Nullable<BoundingInfo>;
  29454. /** @hidden */
  29455. _renderId: number;
  29456. /**
  29457. * Gets or sets the list of subMeshes
  29458. * @see http://doc.babylonjs.com/how_to/multi_materials
  29459. */
  29460. subMeshes: SubMesh[];
  29461. /** @hidden */
  29462. _intersectionsInProgress: AbstractMesh[];
  29463. /** @hidden */
  29464. _unIndexed: boolean;
  29465. /** @hidden */
  29466. _lightSources: Light[];
  29467. /** Gets the list of lights affecting that mesh */
  29468. get lightSources(): Light[];
  29469. /** @hidden */
  29470. get _positions(): Nullable<Vector3[]>;
  29471. /** @hidden */
  29472. _waitingData: {
  29473. lods: Nullable<any>;
  29474. actions: Nullable<any>;
  29475. freezeWorldMatrix: Nullable<boolean>;
  29476. };
  29477. /** @hidden */
  29478. _bonesTransformMatrices: Nullable<Float32Array>;
  29479. /** @hidden */
  29480. _transformMatrixTexture: Nullable<RawTexture>;
  29481. /**
  29482. * Gets or sets a skeleton to apply skining transformations
  29483. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  29484. */
  29485. set skeleton(value: Nullable<Skeleton>);
  29486. get skeleton(): Nullable<Skeleton>;
  29487. /**
  29488. * An event triggered when the mesh is rebuilt.
  29489. */
  29490. onRebuildObservable: Observable<AbstractMesh>;
  29491. /**
  29492. * Creates a new AbstractMesh
  29493. * @param name defines the name of the mesh
  29494. * @param scene defines the hosting scene
  29495. */
  29496. constructor(name: string, scene?: Nullable<Scene>);
  29497. /**
  29498. * Returns the string "AbstractMesh"
  29499. * @returns "AbstractMesh"
  29500. */
  29501. getClassName(): string;
  29502. /**
  29503. * Gets a string representation of the current mesh
  29504. * @param fullDetails defines a boolean indicating if full details must be included
  29505. * @returns a string representation of the current mesh
  29506. */
  29507. toString(fullDetails?: boolean): string;
  29508. /**
  29509. * @hidden
  29510. */
  29511. protected _getEffectiveParent(): Nullable<Node>;
  29512. /** @hidden */
  29513. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29514. /** @hidden */
  29515. _rebuild(): void;
  29516. /** @hidden */
  29517. _resyncLightSources(): void;
  29518. /** @hidden */
  29519. _resyncLightSource(light: Light): void;
  29520. /** @hidden */
  29521. _unBindEffect(): void;
  29522. /** @hidden */
  29523. _removeLightSource(light: Light, dispose: boolean): void;
  29524. private _markSubMeshesAsDirty;
  29525. /** @hidden */
  29526. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  29527. /** @hidden */
  29528. _markSubMeshesAsAttributesDirty(): void;
  29529. /** @hidden */
  29530. _markSubMeshesAsMiscDirty(): void;
  29531. /**
  29532. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  29533. */
  29534. get scaling(): Vector3;
  29535. set scaling(newScaling: Vector3);
  29536. /**
  29537. * Returns true if the mesh is blocked. Implemented by child classes
  29538. */
  29539. get isBlocked(): boolean;
  29540. /**
  29541. * Returns the mesh itself by default. Implemented by child classes
  29542. * @param camera defines the camera to use to pick the right LOD level
  29543. * @returns the currentAbstractMesh
  29544. */
  29545. getLOD(camera: Camera): Nullable<AbstractMesh>;
  29546. /**
  29547. * Returns 0 by default. Implemented by child classes
  29548. * @returns an integer
  29549. */
  29550. getTotalVertices(): number;
  29551. /**
  29552. * Returns a positive integer : the total number of indices in this mesh geometry.
  29553. * @returns the numner of indices or zero if the mesh has no geometry.
  29554. */
  29555. getTotalIndices(): number;
  29556. /**
  29557. * Returns null by default. Implemented by child classes
  29558. * @returns null
  29559. */
  29560. getIndices(): Nullable<IndicesArray>;
  29561. /**
  29562. * Returns the array of the requested vertex data kind. Implemented by child classes
  29563. * @param kind defines the vertex data kind to use
  29564. * @returns null
  29565. */
  29566. getVerticesData(kind: string): Nullable<FloatArray>;
  29567. /**
  29568. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29569. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29570. * Note that a new underlying VertexBuffer object is created each call.
  29571. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29572. * @param kind defines vertex data kind:
  29573. * * VertexBuffer.PositionKind
  29574. * * VertexBuffer.UVKind
  29575. * * VertexBuffer.UV2Kind
  29576. * * VertexBuffer.UV3Kind
  29577. * * VertexBuffer.UV4Kind
  29578. * * VertexBuffer.UV5Kind
  29579. * * VertexBuffer.UV6Kind
  29580. * * VertexBuffer.ColorKind
  29581. * * VertexBuffer.MatricesIndicesKind
  29582. * * VertexBuffer.MatricesIndicesExtraKind
  29583. * * VertexBuffer.MatricesWeightsKind
  29584. * * VertexBuffer.MatricesWeightsExtraKind
  29585. * @param data defines the data source
  29586. * @param updatable defines if the data must be flagged as updatable (or static)
  29587. * @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
  29588. * @returns the current mesh
  29589. */
  29590. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29591. /**
  29592. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29593. * If the mesh has no geometry, it is simply returned as it is.
  29594. * @param kind defines vertex data kind:
  29595. * * VertexBuffer.PositionKind
  29596. * * VertexBuffer.UVKind
  29597. * * VertexBuffer.UV2Kind
  29598. * * VertexBuffer.UV3Kind
  29599. * * VertexBuffer.UV4Kind
  29600. * * VertexBuffer.UV5Kind
  29601. * * VertexBuffer.UV6Kind
  29602. * * VertexBuffer.ColorKind
  29603. * * VertexBuffer.MatricesIndicesKind
  29604. * * VertexBuffer.MatricesIndicesExtraKind
  29605. * * VertexBuffer.MatricesWeightsKind
  29606. * * VertexBuffer.MatricesWeightsExtraKind
  29607. * @param data defines the data source
  29608. * @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
  29609. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  29610. * @returns the current mesh
  29611. */
  29612. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29613. /**
  29614. * Sets the mesh indices,
  29615. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29616. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  29617. * @param totalVertices Defines the total number of vertices
  29618. * @returns the current mesh
  29619. */
  29620. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  29621. /**
  29622. * Gets a boolean indicating if specific vertex data is present
  29623. * @param kind defines the vertex data kind to use
  29624. * @returns true is data kind is present
  29625. */
  29626. isVerticesDataPresent(kind: string): boolean;
  29627. /**
  29628. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  29629. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  29630. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  29631. * @returns a BoundingInfo
  29632. */
  29633. getBoundingInfo(): BoundingInfo;
  29634. /**
  29635. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29636. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29637. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29638. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29639. * @returns the current mesh
  29640. */
  29641. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29642. /**
  29643. * Overwrite the current bounding info
  29644. * @param boundingInfo defines the new bounding info
  29645. * @returns the current mesh
  29646. */
  29647. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29648. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29649. get useBones(): boolean;
  29650. /** @hidden */
  29651. _preActivate(): void;
  29652. /** @hidden */
  29653. _preActivateForIntermediateRendering(renderId: number): void;
  29654. /** @hidden */
  29655. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29656. /** @hidden */
  29657. _postActivate(): void;
  29658. /** @hidden */
  29659. _freeze(): void;
  29660. /** @hidden */
  29661. _unFreeze(): void;
  29662. /**
  29663. * Gets the current world matrix
  29664. * @returns a Matrix
  29665. */
  29666. getWorldMatrix(): Matrix;
  29667. /** @hidden */
  29668. _getWorldMatrixDeterminant(): number;
  29669. /**
  29670. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29671. */
  29672. get isAnInstance(): boolean;
  29673. /**
  29674. * Gets a boolean indicating if this mesh has instances
  29675. */
  29676. get hasInstances(): boolean;
  29677. /**
  29678. * Perform relative position change from the point of view of behind the front of the mesh.
  29679. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29680. * Supports definition of mesh facing forward or backward
  29681. * @param amountRight defines the distance on the right axis
  29682. * @param amountUp defines the distance on the up axis
  29683. * @param amountForward defines the distance on the forward axis
  29684. * @returns the current mesh
  29685. */
  29686. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29687. /**
  29688. * Calculate relative position change from the point of view of behind the front of the mesh.
  29689. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29690. * Supports definition of mesh facing forward or backward
  29691. * @param amountRight defines the distance on the right axis
  29692. * @param amountUp defines the distance on the up axis
  29693. * @param amountForward defines the distance on the forward axis
  29694. * @returns the new displacement vector
  29695. */
  29696. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29697. /**
  29698. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29699. * Supports definition of mesh facing forward or backward
  29700. * @param flipBack defines the flip
  29701. * @param twirlClockwise defines the twirl
  29702. * @param tiltRight defines the tilt
  29703. * @returns the current mesh
  29704. */
  29705. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29706. /**
  29707. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29708. * Supports definition of mesh facing forward or backward.
  29709. * @param flipBack defines the flip
  29710. * @param twirlClockwise defines the twirl
  29711. * @param tiltRight defines the tilt
  29712. * @returns the new rotation vector
  29713. */
  29714. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29715. /**
  29716. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29717. * This means the mesh underlying bounding box and sphere are recomputed.
  29718. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29719. * @returns the current mesh
  29720. */
  29721. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29722. /** @hidden */
  29723. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29724. /** @hidden */
  29725. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29726. /** @hidden */
  29727. _updateBoundingInfo(): AbstractMesh;
  29728. /** @hidden */
  29729. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29730. /** @hidden */
  29731. protected _afterComputeWorldMatrix(): void;
  29732. /** @hidden */
  29733. get _effectiveMesh(): AbstractMesh;
  29734. /**
  29735. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29736. * A mesh is in the frustum if its bounding box intersects the frustum
  29737. * @param frustumPlanes defines the frustum to test
  29738. * @returns true if the mesh is in the frustum planes
  29739. */
  29740. isInFrustum(frustumPlanes: Plane[]): boolean;
  29741. /**
  29742. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29743. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29744. * @param frustumPlanes defines the frustum to test
  29745. * @returns true if the mesh is completely in the frustum planes
  29746. */
  29747. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29748. /**
  29749. * True if the mesh intersects another mesh or a SolidParticle object
  29750. * @param mesh defines a target mesh or SolidParticle to test
  29751. * @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)
  29752. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29753. * @returns true if there is an intersection
  29754. */
  29755. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29756. /**
  29757. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29758. * @param point defines the point to test
  29759. * @returns true if there is an intersection
  29760. */
  29761. intersectsPoint(point: Vector3): boolean;
  29762. /**
  29763. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29764. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29765. */
  29766. get checkCollisions(): boolean;
  29767. set checkCollisions(collisionEnabled: boolean);
  29768. /**
  29769. * Gets Collider object used to compute collisions (not physics)
  29770. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29771. */
  29772. get collider(): Nullable<Collider>;
  29773. /**
  29774. * Move the mesh using collision engine
  29775. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29776. * @param displacement defines the requested displacement vector
  29777. * @returns the current mesh
  29778. */
  29779. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29780. private _onCollisionPositionChange;
  29781. /** @hidden */
  29782. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29783. /** @hidden */
  29784. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29785. /** @hidden */
  29786. _checkCollision(collider: Collider): AbstractMesh;
  29787. /** @hidden */
  29788. _generatePointsArray(): boolean;
  29789. /**
  29790. * Checks if the passed Ray intersects with the mesh
  29791. * @param ray defines the ray to use
  29792. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29793. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29794. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  29795. * @returns the picking info
  29796. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29797. */
  29798. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  29799. /**
  29800. * Clones the current mesh
  29801. * @param name defines the mesh name
  29802. * @param newParent defines the new mesh parent
  29803. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29804. * @returns the new mesh
  29805. */
  29806. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29807. /**
  29808. * Disposes all the submeshes of the current meshnp
  29809. * @returns the current mesh
  29810. */
  29811. releaseSubMeshes(): AbstractMesh;
  29812. /**
  29813. * Releases resources associated with this abstract mesh.
  29814. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29815. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29816. */
  29817. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29818. /**
  29819. * Adds the passed mesh as a child to the current mesh
  29820. * @param mesh defines the child mesh
  29821. * @returns the current mesh
  29822. */
  29823. addChild(mesh: AbstractMesh): AbstractMesh;
  29824. /**
  29825. * Removes the passed mesh from the current mesh children list
  29826. * @param mesh defines the child mesh
  29827. * @returns the current mesh
  29828. */
  29829. removeChild(mesh: AbstractMesh): AbstractMesh;
  29830. /** @hidden */
  29831. private _initFacetData;
  29832. /**
  29833. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29834. * This method can be called within the render loop.
  29835. * 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
  29836. * @returns the current mesh
  29837. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29838. */
  29839. updateFacetData(): AbstractMesh;
  29840. /**
  29841. * Returns the facetLocalNormals array.
  29842. * The normals are expressed in the mesh local spac
  29843. * @returns an array of Vector3
  29844. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29845. */
  29846. getFacetLocalNormals(): Vector3[];
  29847. /**
  29848. * Returns the facetLocalPositions array.
  29849. * The facet positions are expressed in the mesh local space
  29850. * @returns an array of Vector3
  29851. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29852. */
  29853. getFacetLocalPositions(): Vector3[];
  29854. /**
  29855. * Returns the facetLocalPartioning array
  29856. * @returns an array of array of numbers
  29857. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29858. */
  29859. getFacetLocalPartitioning(): number[][];
  29860. /**
  29861. * Returns the i-th facet position in the world system.
  29862. * This method allocates a new Vector3 per call
  29863. * @param i defines the facet index
  29864. * @returns a new Vector3
  29865. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29866. */
  29867. getFacetPosition(i: number): Vector3;
  29868. /**
  29869. * Sets the reference Vector3 with the i-th facet position in the world system
  29870. * @param i defines the facet index
  29871. * @param ref defines the target vector
  29872. * @returns the current mesh
  29873. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29874. */
  29875. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29876. /**
  29877. * Returns the i-th facet normal in the world system.
  29878. * This method allocates a new Vector3 per call
  29879. * @param i defines the facet index
  29880. * @returns a new Vector3
  29881. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29882. */
  29883. getFacetNormal(i: number): Vector3;
  29884. /**
  29885. * Sets the reference Vector3 with the i-th facet normal in the world system
  29886. * @param i defines the facet index
  29887. * @param ref defines the target vector
  29888. * @returns the current mesh
  29889. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29890. */
  29891. getFacetNormalToRef(i: number, ref: Vector3): this;
  29892. /**
  29893. * 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)
  29894. * @param x defines x coordinate
  29895. * @param y defines y coordinate
  29896. * @param z defines z coordinate
  29897. * @returns the array of facet indexes
  29898. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29899. */
  29900. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29901. /**
  29902. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29903. * @param projected sets as the (x,y,z) world projection on the facet
  29904. * @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
  29905. * @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
  29906. * @param x defines x coordinate
  29907. * @param y defines y coordinate
  29908. * @param z defines z coordinate
  29909. * @returns the face index if found (or null instead)
  29910. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29911. */
  29912. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29913. /**
  29914. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29915. * @param projected sets as the (x,y,z) local projection on the facet
  29916. * @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
  29917. * @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
  29918. * @param x defines x coordinate
  29919. * @param y defines y coordinate
  29920. * @param z defines z coordinate
  29921. * @returns the face index if found (or null instead)
  29922. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29923. */
  29924. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29925. /**
  29926. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29927. * @returns the parameters
  29928. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29929. */
  29930. getFacetDataParameters(): any;
  29931. /**
  29932. * Disables the feature FacetData and frees the related memory
  29933. * @returns the current mesh
  29934. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29935. */
  29936. disableFacetData(): AbstractMesh;
  29937. /**
  29938. * Updates the AbstractMesh indices array
  29939. * @param indices defines the data source
  29940. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29941. * @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)
  29942. * @returns the current mesh
  29943. */
  29944. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29945. /**
  29946. * Creates new normals data for the mesh
  29947. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29948. * @returns the current mesh
  29949. */
  29950. createNormals(updatable: boolean): AbstractMesh;
  29951. /**
  29952. * Align the mesh with a normal
  29953. * @param normal defines the normal to use
  29954. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29955. * @returns the current mesh
  29956. */
  29957. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29958. /** @hidden */
  29959. _checkOcclusionQuery(): boolean;
  29960. /**
  29961. * Disables the mesh edge rendering mode
  29962. * @returns the currentAbstractMesh
  29963. */
  29964. disableEdgesRendering(): AbstractMesh;
  29965. /**
  29966. * Enables the edge rendering mode on the mesh.
  29967. * This mode makes the mesh edges visible
  29968. * @param epsilon defines the maximal distance between two angles to detect a face
  29969. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29970. * @returns the currentAbstractMesh
  29971. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29972. */
  29973. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29974. }
  29975. }
  29976. declare module "babylonjs/Actions/actionEvent" {
  29977. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29978. import { Nullable } from "babylonjs/types";
  29979. import { Sprite } from "babylonjs/Sprites/sprite";
  29980. import { Scene } from "babylonjs/scene";
  29981. import { Vector2 } from "babylonjs/Maths/math.vector";
  29982. /**
  29983. * Interface used to define ActionEvent
  29984. */
  29985. export interface IActionEvent {
  29986. /** The mesh or sprite that triggered the action */
  29987. source: any;
  29988. /** The X mouse cursor position at the time of the event */
  29989. pointerX: number;
  29990. /** The Y mouse cursor position at the time of the event */
  29991. pointerY: number;
  29992. /** The mesh that is currently pointed at (can be null) */
  29993. meshUnderPointer: Nullable<AbstractMesh>;
  29994. /** the original (browser) event that triggered the ActionEvent */
  29995. sourceEvent?: any;
  29996. /** additional data for the event */
  29997. additionalData?: any;
  29998. }
  29999. /**
  30000. * ActionEvent is the event being sent when an action is triggered.
  30001. */
  30002. export class ActionEvent implements IActionEvent {
  30003. /** The mesh or sprite that triggered the action */
  30004. source: any;
  30005. /** The X mouse cursor position at the time of the event */
  30006. pointerX: number;
  30007. /** The Y mouse cursor position at the time of the event */
  30008. pointerY: number;
  30009. /** The mesh that is currently pointed at (can be null) */
  30010. meshUnderPointer: Nullable<AbstractMesh>;
  30011. /** the original (browser) event that triggered the ActionEvent */
  30012. sourceEvent?: any;
  30013. /** additional data for the event */
  30014. additionalData?: any;
  30015. /**
  30016. * Creates a new ActionEvent
  30017. * @param source The mesh or sprite that triggered the action
  30018. * @param pointerX The X mouse cursor position at the time of the event
  30019. * @param pointerY The Y mouse cursor position at the time of the event
  30020. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  30021. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  30022. * @param additionalData additional data for the event
  30023. */
  30024. constructor(
  30025. /** The mesh or sprite that triggered the action */
  30026. source: any,
  30027. /** The X mouse cursor position at the time of the event */
  30028. pointerX: number,
  30029. /** The Y mouse cursor position at the time of the event */
  30030. pointerY: number,
  30031. /** The mesh that is currently pointed at (can be null) */
  30032. meshUnderPointer: Nullable<AbstractMesh>,
  30033. /** the original (browser) event that triggered the ActionEvent */
  30034. sourceEvent?: any,
  30035. /** additional data for the event */
  30036. additionalData?: any);
  30037. /**
  30038. * Helper function to auto-create an ActionEvent from a source mesh.
  30039. * @param source The source mesh that triggered the event
  30040. * @param evt The original (browser) event
  30041. * @param additionalData additional data for the event
  30042. * @returns the new ActionEvent
  30043. */
  30044. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  30045. /**
  30046. * Helper function to auto-create an ActionEvent from a source sprite
  30047. * @param source The source sprite that triggered the event
  30048. * @param scene Scene associated with the sprite
  30049. * @param evt The original (browser) event
  30050. * @param additionalData additional data for the event
  30051. * @returns the new ActionEvent
  30052. */
  30053. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  30054. /**
  30055. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  30056. * @param scene the scene where the event occurred
  30057. * @param evt The original (browser) event
  30058. * @returns the new ActionEvent
  30059. */
  30060. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  30061. /**
  30062. * Helper function to auto-create an ActionEvent from a primitive
  30063. * @param prim defines the target primitive
  30064. * @param pointerPos defines the pointer position
  30065. * @param evt The original (browser) event
  30066. * @param additionalData additional data for the event
  30067. * @returns the new ActionEvent
  30068. */
  30069. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  30070. }
  30071. }
  30072. declare module "babylonjs/Actions/abstractActionManager" {
  30073. import { IDisposable } from "babylonjs/scene";
  30074. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  30075. import { IAction } from "babylonjs/Actions/action";
  30076. import { Nullable } from "babylonjs/types";
  30077. /**
  30078. * Abstract class used to decouple action Manager from scene and meshes.
  30079. * Do not instantiate.
  30080. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  30081. */
  30082. export abstract class AbstractActionManager implements IDisposable {
  30083. /** Gets the list of active triggers */
  30084. static Triggers: {
  30085. [key: string]: number;
  30086. };
  30087. /** Gets the cursor to use when hovering items */
  30088. hoverCursor: string;
  30089. /** Gets the list of actions */
  30090. actions: IAction[];
  30091. /**
  30092. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  30093. */
  30094. isRecursive: boolean;
  30095. /**
  30096. * Releases all associated resources
  30097. */
  30098. abstract dispose(): void;
  30099. /**
  30100. * Does this action manager has pointer triggers
  30101. */
  30102. abstract get hasPointerTriggers(): boolean;
  30103. /**
  30104. * Does this action manager has pick triggers
  30105. */
  30106. abstract get hasPickTriggers(): boolean;
  30107. /**
  30108. * Process a specific trigger
  30109. * @param trigger defines the trigger to process
  30110. * @param evt defines the event details to be processed
  30111. */
  30112. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  30113. /**
  30114. * Does this action manager handles actions of any of the given triggers
  30115. * @param triggers defines the triggers to be tested
  30116. * @return a boolean indicating whether one (or more) of the triggers is handled
  30117. */
  30118. abstract hasSpecificTriggers(triggers: number[]): boolean;
  30119. /**
  30120. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  30121. * speed.
  30122. * @param triggerA defines the trigger to be tested
  30123. * @param triggerB defines the trigger to be tested
  30124. * @return a boolean indicating whether one (or more) of the triggers is handled
  30125. */
  30126. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  30127. /**
  30128. * Does this action manager handles actions of a given trigger
  30129. * @param trigger defines the trigger to be tested
  30130. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  30131. * @return whether the trigger is handled
  30132. */
  30133. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  30134. /**
  30135. * Serialize this manager to a JSON object
  30136. * @param name defines the property name to store this manager
  30137. * @returns a JSON representation of this manager
  30138. */
  30139. abstract serialize(name: string): any;
  30140. /**
  30141. * Registers an action to this action manager
  30142. * @param action defines the action to be registered
  30143. * @return the action amended (prepared) after registration
  30144. */
  30145. abstract registerAction(action: IAction): Nullable<IAction>;
  30146. /**
  30147. * Unregisters an action to this action manager
  30148. * @param action defines the action to be unregistered
  30149. * @return a boolean indicating whether the action has been unregistered
  30150. */
  30151. abstract unregisterAction(action: IAction): Boolean;
  30152. /**
  30153. * Does exist one action manager with at least one trigger
  30154. **/
  30155. static get HasTriggers(): boolean;
  30156. /**
  30157. * Does exist one action manager with at least one pick trigger
  30158. **/
  30159. static get HasPickTriggers(): boolean;
  30160. /**
  30161. * Does exist one action manager that handles actions of a given trigger
  30162. * @param trigger defines the trigger to be tested
  30163. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  30164. **/
  30165. static HasSpecificTrigger(trigger: number): boolean;
  30166. }
  30167. }
  30168. declare module "babylonjs/node" {
  30169. import { Scene } from "babylonjs/scene";
  30170. import { Nullable } from "babylonjs/types";
  30171. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  30172. import { Engine } from "babylonjs/Engines/engine";
  30173. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  30174. import { Observable } from "babylonjs/Misc/observable";
  30175. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  30176. import { IInspectable } from "babylonjs/Misc/iInspectable";
  30177. import { Animatable } from "babylonjs/Animations/animatable";
  30178. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  30179. import { Animation } from "babylonjs/Animations/animation";
  30180. import { AnimationRange } from "babylonjs/Animations/animationRange";
  30181. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30182. /**
  30183. * Defines how a node can be built from a string name.
  30184. */
  30185. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  30186. /**
  30187. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  30188. */
  30189. export class Node implements IBehaviorAware<Node> {
  30190. /** @hidden */
  30191. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  30192. private static _NodeConstructors;
  30193. /**
  30194. * Add a new node constructor
  30195. * @param type defines the type name of the node to construct
  30196. * @param constructorFunc defines the constructor function
  30197. */
  30198. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  30199. /**
  30200. * Returns a node constructor based on type name
  30201. * @param type defines the type name
  30202. * @param name defines the new node name
  30203. * @param scene defines the hosting scene
  30204. * @param options defines optional options to transmit to constructors
  30205. * @returns the new constructor or null
  30206. */
  30207. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  30208. /**
  30209. * Gets or sets the name of the node
  30210. */
  30211. name: string;
  30212. /**
  30213. * Gets or sets the id of the node
  30214. */
  30215. id: string;
  30216. /**
  30217. * Gets or sets the unique id of the node
  30218. */
  30219. uniqueId: number;
  30220. /**
  30221. * Gets or sets a string used to store user defined state for the node
  30222. */
  30223. state: string;
  30224. /**
  30225. * Gets or sets an object used to store user defined information for the node
  30226. */
  30227. metadata: any;
  30228. /**
  30229. * For internal use only. Please do not use.
  30230. */
  30231. reservedDataStore: any;
  30232. /**
  30233. * List of inspectable custom properties (used by the Inspector)
  30234. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30235. */
  30236. inspectableCustomProperties: IInspectable[];
  30237. private _doNotSerialize;
  30238. /**
  30239. * Gets or sets a boolean used to define if the node must be serialized
  30240. */
  30241. get doNotSerialize(): boolean;
  30242. set doNotSerialize(value: boolean);
  30243. /** @hidden */
  30244. _isDisposed: boolean;
  30245. /**
  30246. * Gets a list of Animations associated with the node
  30247. */
  30248. animations: import("babylonjs/Animations/animation").Animation[];
  30249. protected _ranges: {
  30250. [name: string]: Nullable<AnimationRange>;
  30251. };
  30252. /**
  30253. * Callback raised when the node is ready to be used
  30254. */
  30255. onReady: Nullable<(node: Node) => void>;
  30256. private _isEnabled;
  30257. private _isParentEnabled;
  30258. private _isReady;
  30259. /** @hidden */
  30260. _currentRenderId: number;
  30261. private _parentUpdateId;
  30262. /** @hidden */
  30263. _childUpdateId: number;
  30264. /** @hidden */
  30265. _waitingParentId: Nullable<string>;
  30266. /** @hidden */
  30267. _scene: Scene;
  30268. /** @hidden */
  30269. _cache: any;
  30270. private _parentNode;
  30271. private _children;
  30272. /** @hidden */
  30273. _worldMatrix: Matrix;
  30274. /** @hidden */
  30275. _worldMatrixDeterminant: number;
  30276. /** @hidden */
  30277. _worldMatrixDeterminantIsDirty: boolean;
  30278. /** @hidden */
  30279. private _sceneRootNodesIndex;
  30280. /**
  30281. * Gets a boolean indicating if the node has been disposed
  30282. * @returns true if the node was disposed
  30283. */
  30284. isDisposed(): boolean;
  30285. /**
  30286. * Gets or sets the parent of the node (without keeping the current position in the scene)
  30287. * @see https://doc.babylonjs.com/how_to/parenting
  30288. */
  30289. set parent(parent: Nullable<Node>);
  30290. get parent(): Nullable<Node>;
  30291. /** @hidden */
  30292. _addToSceneRootNodes(): void;
  30293. /** @hidden */
  30294. _removeFromSceneRootNodes(): void;
  30295. private _animationPropertiesOverride;
  30296. /**
  30297. * Gets or sets the animation properties override
  30298. */
  30299. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  30300. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  30301. /**
  30302. * Gets a string idenfifying the name of the class
  30303. * @returns "Node" string
  30304. */
  30305. getClassName(): string;
  30306. /** @hidden */
  30307. readonly _isNode: boolean;
  30308. /**
  30309. * An event triggered when the mesh is disposed
  30310. */
  30311. onDisposeObservable: Observable<Node>;
  30312. private _onDisposeObserver;
  30313. /**
  30314. * Sets a callback that will be raised when the node will be disposed
  30315. */
  30316. set onDispose(callback: () => void);
  30317. /**
  30318. * Creates a new Node
  30319. * @param name the name and id to be given to this node
  30320. * @param scene the scene this node will be added to
  30321. */
  30322. constructor(name: string, scene?: Nullable<Scene>);
  30323. /**
  30324. * Gets the scene of the node
  30325. * @returns a scene
  30326. */
  30327. getScene(): Scene;
  30328. /**
  30329. * Gets the engine of the node
  30330. * @returns a Engine
  30331. */
  30332. getEngine(): Engine;
  30333. private _behaviors;
  30334. /**
  30335. * Attach a behavior to the node
  30336. * @see http://doc.babylonjs.com/features/behaviour
  30337. * @param behavior defines the behavior to attach
  30338. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  30339. * @returns the current Node
  30340. */
  30341. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  30342. /**
  30343. * Remove an attached behavior
  30344. * @see http://doc.babylonjs.com/features/behaviour
  30345. * @param behavior defines the behavior to attach
  30346. * @returns the current Node
  30347. */
  30348. removeBehavior(behavior: Behavior<Node>): Node;
  30349. /**
  30350. * Gets the list of attached behaviors
  30351. * @see http://doc.babylonjs.com/features/behaviour
  30352. */
  30353. get behaviors(): Behavior<Node>[];
  30354. /**
  30355. * Gets an attached behavior by name
  30356. * @param name defines the name of the behavior to look for
  30357. * @see http://doc.babylonjs.com/features/behaviour
  30358. * @returns null if behavior was not found else the requested behavior
  30359. */
  30360. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  30361. /**
  30362. * Returns the latest update of the World matrix
  30363. * @returns a Matrix
  30364. */
  30365. getWorldMatrix(): Matrix;
  30366. /** @hidden */
  30367. _getWorldMatrixDeterminant(): number;
  30368. /**
  30369. * Returns directly the latest state of the mesh World matrix.
  30370. * A Matrix is returned.
  30371. */
  30372. get worldMatrixFromCache(): Matrix;
  30373. /** @hidden */
  30374. _initCache(): void;
  30375. /** @hidden */
  30376. updateCache(force?: boolean): void;
  30377. /** @hidden */
  30378. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  30379. /** @hidden */
  30380. _updateCache(ignoreParentClass?: boolean): void;
  30381. /** @hidden */
  30382. _isSynchronized(): boolean;
  30383. /** @hidden */
  30384. _markSyncedWithParent(): void;
  30385. /** @hidden */
  30386. isSynchronizedWithParent(): boolean;
  30387. /** @hidden */
  30388. isSynchronized(): boolean;
  30389. /**
  30390. * Is this node ready to be used/rendered
  30391. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  30392. * @return true if the node is ready
  30393. */
  30394. isReady(completeCheck?: boolean): boolean;
  30395. /**
  30396. * Is this node enabled?
  30397. * 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
  30398. * @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
  30399. * @return whether this node (and its parent) is enabled
  30400. */
  30401. isEnabled(checkAncestors?: boolean): boolean;
  30402. /** @hidden */
  30403. protected _syncParentEnabledState(): void;
  30404. /**
  30405. * Set the enabled state of this node
  30406. * @param value defines the new enabled state
  30407. */
  30408. setEnabled(value: boolean): void;
  30409. /**
  30410. * Is this node a descendant of the given node?
  30411. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  30412. * @param ancestor defines the parent node to inspect
  30413. * @returns a boolean indicating if this node is a descendant of the given node
  30414. */
  30415. isDescendantOf(ancestor: Node): boolean;
  30416. /** @hidden */
  30417. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  30418. /**
  30419. * Will return all nodes that have this node as ascendant
  30420. * @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
  30421. * @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
  30422. * @return all children nodes of all types
  30423. */
  30424. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  30425. /**
  30426. * Get all child-meshes of this node
  30427. * @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)
  30428. * @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
  30429. * @returns an array of AbstractMesh
  30430. */
  30431. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  30432. /**
  30433. * Get all direct children of this node
  30434. * @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
  30435. * @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)
  30436. * @returns an array of Node
  30437. */
  30438. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  30439. /** @hidden */
  30440. _setReady(state: boolean): void;
  30441. /**
  30442. * Get an animation by name
  30443. * @param name defines the name of the animation to look for
  30444. * @returns null if not found else the requested animation
  30445. */
  30446. getAnimationByName(name: string): Nullable<Animation>;
  30447. /**
  30448. * Creates an animation range for this node
  30449. * @param name defines the name of the range
  30450. * @param from defines the starting key
  30451. * @param to defines the end key
  30452. */
  30453. createAnimationRange(name: string, from: number, to: number): void;
  30454. /**
  30455. * Delete a specific animation range
  30456. * @param name defines the name of the range to delete
  30457. * @param deleteFrames defines if animation frames from the range must be deleted as well
  30458. */
  30459. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  30460. /**
  30461. * Get an animation range by name
  30462. * @param name defines the name of the animation range to look for
  30463. * @returns null if not found else the requested animation range
  30464. */
  30465. getAnimationRange(name: string): Nullable<AnimationRange>;
  30466. /**
  30467. * Gets the list of all animation ranges defined on this node
  30468. * @returns an array
  30469. */
  30470. getAnimationRanges(): Nullable<AnimationRange>[];
  30471. /**
  30472. * Will start the animation sequence
  30473. * @param name defines the range frames for animation sequence
  30474. * @param loop defines if the animation should loop (false by default)
  30475. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  30476. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  30477. * @returns the object created for this animation. If range does not exist, it will return null
  30478. */
  30479. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  30480. /**
  30481. * Serialize animation ranges into a JSON compatible object
  30482. * @returns serialization object
  30483. */
  30484. serializeAnimationRanges(): any;
  30485. /**
  30486. * Computes the world matrix of the node
  30487. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  30488. * @returns the world matrix
  30489. */
  30490. computeWorldMatrix(force?: boolean): Matrix;
  30491. /**
  30492. * Releases resources associated with this node.
  30493. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30494. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30495. */
  30496. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30497. /**
  30498. * Parse animation range data from a serialization object and store them into a given node
  30499. * @param node defines where to store the animation ranges
  30500. * @param parsedNode defines the serialization object to read data from
  30501. * @param scene defines the hosting scene
  30502. */
  30503. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  30504. /**
  30505. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  30506. * @param includeDescendants Include bounding info from descendants as well (true by default)
  30507. * @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
  30508. * @returns the new bounding vectors
  30509. */
  30510. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  30511. min: Vector3;
  30512. max: Vector3;
  30513. };
  30514. }
  30515. }
  30516. declare module "babylonjs/Animations/animation" {
  30517. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  30518. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  30519. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  30520. import { Nullable } from "babylonjs/types";
  30521. import { Scene } from "babylonjs/scene";
  30522. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  30523. import { AnimationRange } from "babylonjs/Animations/animationRange";
  30524. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  30525. import { Node } from "babylonjs/node";
  30526. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30527. import { Size } from "babylonjs/Maths/math.size";
  30528. import { Animatable } from "babylonjs/Animations/animatable";
  30529. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  30530. /**
  30531. * @hidden
  30532. */
  30533. export class _IAnimationState {
  30534. key: number;
  30535. repeatCount: number;
  30536. workValue?: any;
  30537. loopMode?: number;
  30538. offsetValue?: any;
  30539. highLimitValue?: any;
  30540. }
  30541. /**
  30542. * Class used to store any kind of animation
  30543. */
  30544. export class Animation {
  30545. /**Name of the animation */
  30546. name: string;
  30547. /**Property to animate */
  30548. targetProperty: string;
  30549. /**The frames per second of the animation */
  30550. framePerSecond: number;
  30551. /**The data type of the animation */
  30552. dataType: number;
  30553. /**The loop mode of the animation */
  30554. loopMode?: number | undefined;
  30555. /**Specifies if blending should be enabled */
  30556. enableBlending?: boolean | undefined;
  30557. /**
  30558. * Use matrix interpolation instead of using direct key value when animating matrices
  30559. */
  30560. static AllowMatricesInterpolation: boolean;
  30561. /**
  30562. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  30563. */
  30564. static AllowMatrixDecomposeForInterpolation: boolean;
  30565. /**
  30566. * Stores the key frames of the animation
  30567. */
  30568. private _keys;
  30569. /**
  30570. * Stores the easing function of the animation
  30571. */
  30572. private _easingFunction;
  30573. /**
  30574. * @hidden Internal use only
  30575. */
  30576. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  30577. /**
  30578. * The set of event that will be linked to this animation
  30579. */
  30580. private _events;
  30581. /**
  30582. * Stores an array of target property paths
  30583. */
  30584. targetPropertyPath: string[];
  30585. /**
  30586. * Stores the blending speed of the animation
  30587. */
  30588. blendingSpeed: number;
  30589. /**
  30590. * Stores the animation ranges for the animation
  30591. */
  30592. private _ranges;
  30593. /**
  30594. * @hidden Internal use
  30595. */
  30596. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  30597. /**
  30598. * Sets up an animation
  30599. * @param property The property to animate
  30600. * @param animationType The animation type to apply
  30601. * @param framePerSecond The frames per second of the animation
  30602. * @param easingFunction The easing function used in the animation
  30603. * @returns The created animation
  30604. */
  30605. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  30606. /**
  30607. * Create and start an animation on a node
  30608. * @param name defines the name of the global animation that will be run on all nodes
  30609. * @param node defines the root node where the animation will take place
  30610. * @param targetProperty defines property to animate
  30611. * @param framePerSecond defines the number of frame per second yo use
  30612. * @param totalFrame defines the number of frames in total
  30613. * @param from defines the initial value
  30614. * @param to defines the final value
  30615. * @param loopMode defines which loop mode you want to use (off by default)
  30616. * @param easingFunction defines the easing function to use (linear by default)
  30617. * @param onAnimationEnd defines the callback to call when animation end
  30618. * @returns the animatable created for this animation
  30619. */
  30620. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30621. /**
  30622. * Create and start an animation on a node and its descendants
  30623. * @param name defines the name of the global animation that will be run on all nodes
  30624. * @param node defines the root node where the animation will take place
  30625. * @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
  30626. * @param targetProperty defines property to animate
  30627. * @param framePerSecond defines the number of frame per second to use
  30628. * @param totalFrame defines the number of frames in total
  30629. * @param from defines the initial value
  30630. * @param to defines the final value
  30631. * @param loopMode defines which loop mode you want to use (off by default)
  30632. * @param easingFunction defines the easing function to use (linear by default)
  30633. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  30634. * @returns the list of animatables created for all nodes
  30635. * @example https://www.babylonjs-playground.com/#MH0VLI
  30636. */
  30637. 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[]>;
  30638. /**
  30639. * Creates a new animation, merges it with the existing animations and starts it
  30640. * @param name Name of the animation
  30641. * @param node Node which contains the scene that begins the animations
  30642. * @param targetProperty Specifies which property to animate
  30643. * @param framePerSecond The frames per second of the animation
  30644. * @param totalFrame The total number of frames
  30645. * @param from The frame at the beginning of the animation
  30646. * @param to The frame at the end of the animation
  30647. * @param loopMode Specifies the loop mode of the animation
  30648. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30649. * @param onAnimationEnd Callback to run once the animation is complete
  30650. * @returns Nullable animation
  30651. */
  30652. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30653. /**
  30654. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  30655. * @param sourceAnimation defines the Animation containing keyframes to convert
  30656. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  30657. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  30658. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  30659. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  30660. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  30661. */
  30662. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  30663. /**
  30664. * Transition property of an host to the target Value
  30665. * @param property The property to transition
  30666. * @param targetValue The target Value of the property
  30667. * @param host The object where the property to animate belongs
  30668. * @param scene Scene used to run the animation
  30669. * @param frameRate Framerate (in frame/s) to use
  30670. * @param transition The transition type we want to use
  30671. * @param duration The duration of the animation, in milliseconds
  30672. * @param onAnimationEnd Callback trigger at the end of the animation
  30673. * @returns Nullable animation
  30674. */
  30675. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30676. /**
  30677. * Return the array of runtime animations currently using this animation
  30678. */
  30679. get runtimeAnimations(): RuntimeAnimation[];
  30680. /**
  30681. * Specifies if any of the runtime animations are currently running
  30682. */
  30683. get hasRunningRuntimeAnimations(): boolean;
  30684. /**
  30685. * Initializes the animation
  30686. * @param name Name of the animation
  30687. * @param targetProperty Property to animate
  30688. * @param framePerSecond The frames per second of the animation
  30689. * @param dataType The data type of the animation
  30690. * @param loopMode The loop mode of the animation
  30691. * @param enableBlending Specifies if blending should be enabled
  30692. */
  30693. constructor(
  30694. /**Name of the animation */
  30695. name: string,
  30696. /**Property to animate */
  30697. targetProperty: string,
  30698. /**The frames per second of the animation */
  30699. framePerSecond: number,
  30700. /**The data type of the animation */
  30701. dataType: number,
  30702. /**The loop mode of the animation */
  30703. loopMode?: number | undefined,
  30704. /**Specifies if blending should be enabled */
  30705. enableBlending?: boolean | undefined);
  30706. /**
  30707. * Converts the animation to a string
  30708. * @param fullDetails support for multiple levels of logging within scene loading
  30709. * @returns String form of the animation
  30710. */
  30711. toString(fullDetails?: boolean): string;
  30712. /**
  30713. * Add an event to this animation
  30714. * @param event Event to add
  30715. */
  30716. addEvent(event: AnimationEvent): void;
  30717. /**
  30718. * Remove all events found at the given frame
  30719. * @param frame The frame to remove events from
  30720. */
  30721. removeEvents(frame: number): void;
  30722. /**
  30723. * Retrieves all the events from the animation
  30724. * @returns Events from the animation
  30725. */
  30726. getEvents(): AnimationEvent[];
  30727. /**
  30728. * Creates an animation range
  30729. * @param name Name of the animation range
  30730. * @param from Starting frame of the animation range
  30731. * @param to Ending frame of the animation
  30732. */
  30733. createRange(name: string, from: number, to: number): void;
  30734. /**
  30735. * Deletes an animation range by name
  30736. * @param name Name of the animation range to delete
  30737. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30738. */
  30739. deleteRange(name: string, deleteFrames?: boolean): void;
  30740. /**
  30741. * Gets the animation range by name, or null if not defined
  30742. * @param name Name of the animation range
  30743. * @returns Nullable animation range
  30744. */
  30745. getRange(name: string): Nullable<AnimationRange>;
  30746. /**
  30747. * Gets the key frames from the animation
  30748. * @returns The key frames of the animation
  30749. */
  30750. getKeys(): Array<IAnimationKey>;
  30751. /**
  30752. * Gets the highest frame rate of the animation
  30753. * @returns Highest frame rate of the animation
  30754. */
  30755. getHighestFrame(): number;
  30756. /**
  30757. * Gets the easing function of the animation
  30758. * @returns Easing function of the animation
  30759. */
  30760. getEasingFunction(): IEasingFunction;
  30761. /**
  30762. * Sets the easing function of the animation
  30763. * @param easingFunction A custom mathematical formula for animation
  30764. */
  30765. setEasingFunction(easingFunction: EasingFunction): void;
  30766. /**
  30767. * Interpolates a scalar linearly
  30768. * @param startValue Start value of the animation curve
  30769. * @param endValue End value of the animation curve
  30770. * @param gradient Scalar amount to interpolate
  30771. * @returns Interpolated scalar value
  30772. */
  30773. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30774. /**
  30775. * Interpolates a scalar cubically
  30776. * @param startValue Start value of the animation curve
  30777. * @param outTangent End tangent of the animation
  30778. * @param endValue End value of the animation curve
  30779. * @param inTangent Start tangent of the animation curve
  30780. * @param gradient Scalar amount to interpolate
  30781. * @returns Interpolated scalar value
  30782. */
  30783. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30784. /**
  30785. * Interpolates a quaternion using a spherical linear interpolation
  30786. * @param startValue Start value of the animation curve
  30787. * @param endValue End value of the animation curve
  30788. * @param gradient Scalar amount to interpolate
  30789. * @returns Interpolated quaternion value
  30790. */
  30791. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30792. /**
  30793. * Interpolates a quaternion cubically
  30794. * @param startValue Start value of the animation curve
  30795. * @param outTangent End tangent of the animation curve
  30796. * @param endValue End value of the animation curve
  30797. * @param inTangent Start tangent of the animation curve
  30798. * @param gradient Scalar amount to interpolate
  30799. * @returns Interpolated quaternion value
  30800. */
  30801. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30802. /**
  30803. * Interpolates a Vector3 linearl
  30804. * @param startValue Start value of the animation curve
  30805. * @param endValue End value of the animation curve
  30806. * @param gradient Scalar amount to interpolate
  30807. * @returns Interpolated scalar value
  30808. */
  30809. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30810. /**
  30811. * Interpolates a Vector3 cubically
  30812. * @param startValue Start value of the animation curve
  30813. * @param outTangent End tangent of the animation
  30814. * @param endValue End value of the animation curve
  30815. * @param inTangent Start tangent of the animation curve
  30816. * @param gradient Scalar amount to interpolate
  30817. * @returns InterpolatedVector3 value
  30818. */
  30819. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30820. /**
  30821. * Interpolates a Vector2 linearly
  30822. * @param startValue Start value of the animation curve
  30823. * @param endValue End value of the animation curve
  30824. * @param gradient Scalar amount to interpolate
  30825. * @returns Interpolated Vector2 value
  30826. */
  30827. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30828. /**
  30829. * Interpolates a Vector2 cubically
  30830. * @param startValue Start value of the animation curve
  30831. * @param outTangent End tangent of the animation
  30832. * @param endValue End value of the animation curve
  30833. * @param inTangent Start tangent of the animation curve
  30834. * @param gradient Scalar amount to interpolate
  30835. * @returns Interpolated Vector2 value
  30836. */
  30837. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30838. /**
  30839. * Interpolates a size linearly
  30840. * @param startValue Start value of the animation curve
  30841. * @param endValue End value of the animation curve
  30842. * @param gradient Scalar amount to interpolate
  30843. * @returns Interpolated Size value
  30844. */
  30845. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30846. /**
  30847. * Interpolates a Color3 linearly
  30848. * @param startValue Start value of the animation curve
  30849. * @param endValue End value of the animation curve
  30850. * @param gradient Scalar amount to interpolate
  30851. * @returns Interpolated Color3 value
  30852. */
  30853. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30854. /**
  30855. * Interpolates a Color4 linearly
  30856. * @param startValue Start value of the animation curve
  30857. * @param endValue End value of the animation curve
  30858. * @param gradient Scalar amount to interpolate
  30859. * @returns Interpolated Color3 value
  30860. */
  30861. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30862. /**
  30863. * @hidden Internal use only
  30864. */
  30865. _getKeyValue(value: any): any;
  30866. /**
  30867. * @hidden Internal use only
  30868. */
  30869. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30870. /**
  30871. * Defines the function to use to interpolate matrices
  30872. * @param startValue defines the start matrix
  30873. * @param endValue defines the end matrix
  30874. * @param gradient defines the gradient between both matrices
  30875. * @param result defines an optional target matrix where to store the interpolation
  30876. * @returns the interpolated matrix
  30877. */
  30878. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30879. /**
  30880. * Makes a copy of the animation
  30881. * @returns Cloned animation
  30882. */
  30883. clone(): Animation;
  30884. /**
  30885. * Sets the key frames of the animation
  30886. * @param values The animation key frames to set
  30887. */
  30888. setKeys(values: Array<IAnimationKey>): void;
  30889. /**
  30890. * Serializes the animation to an object
  30891. * @returns Serialized object
  30892. */
  30893. serialize(): any;
  30894. /**
  30895. * Float animation type
  30896. */
  30897. static readonly ANIMATIONTYPE_FLOAT: number;
  30898. /**
  30899. * Vector3 animation type
  30900. */
  30901. static readonly ANIMATIONTYPE_VECTOR3: number;
  30902. /**
  30903. * Quaternion animation type
  30904. */
  30905. static readonly ANIMATIONTYPE_QUATERNION: number;
  30906. /**
  30907. * Matrix animation type
  30908. */
  30909. static readonly ANIMATIONTYPE_MATRIX: number;
  30910. /**
  30911. * Color3 animation type
  30912. */
  30913. static readonly ANIMATIONTYPE_COLOR3: number;
  30914. /**
  30915. * Color3 animation type
  30916. */
  30917. static readonly ANIMATIONTYPE_COLOR4: number;
  30918. /**
  30919. * Vector2 animation type
  30920. */
  30921. static readonly ANIMATIONTYPE_VECTOR2: number;
  30922. /**
  30923. * Size animation type
  30924. */
  30925. static readonly ANIMATIONTYPE_SIZE: number;
  30926. /**
  30927. * Relative Loop Mode
  30928. */
  30929. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30930. /**
  30931. * Cycle Loop Mode
  30932. */
  30933. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30934. /**
  30935. * Constant Loop Mode
  30936. */
  30937. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30938. /** @hidden */
  30939. static _UniversalLerp(left: any, right: any, amount: number): any;
  30940. /**
  30941. * Parses an animation object and creates an animation
  30942. * @param parsedAnimation Parsed animation object
  30943. * @returns Animation object
  30944. */
  30945. static Parse(parsedAnimation: any): Animation;
  30946. /**
  30947. * Appends the serialized animations from the source animations
  30948. * @param source Source containing the animations
  30949. * @param destination Target to store the animations
  30950. */
  30951. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30952. }
  30953. }
  30954. declare module "babylonjs/Animations/animatable.interface" {
  30955. import { Nullable } from "babylonjs/types";
  30956. import { Animation } from "babylonjs/Animations/animation";
  30957. /**
  30958. * Interface containing an array of animations
  30959. */
  30960. export interface IAnimatable {
  30961. /**
  30962. * Array of animations
  30963. */
  30964. animations: Nullable<Array<Animation>>;
  30965. }
  30966. }
  30967. declare module "babylonjs/Misc/decorators" {
  30968. import { Nullable } from "babylonjs/types";
  30969. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30970. import { Scene } from "babylonjs/scene";
  30971. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30972. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30973. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30974. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30975. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30976. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30977. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30978. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30979. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30980. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30981. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30982. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30983. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30984. /**
  30985. * Decorator used to define property that can be serialized as reference to a camera
  30986. * @param sourceName defines the name of the property to decorate
  30987. */
  30988. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30989. /**
  30990. * Class used to help serialization objects
  30991. */
  30992. export class SerializationHelper {
  30993. /** @hidden */
  30994. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30995. /** @hidden */
  30996. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30997. /** @hidden */
  30998. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30999. /** @hidden */
  31000. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  31001. /**
  31002. * Appends the serialized animations from the source animations
  31003. * @param source Source containing the animations
  31004. * @param destination Target to store the animations
  31005. */
  31006. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  31007. /**
  31008. * Static function used to serialized a specific entity
  31009. * @param entity defines the entity to serialize
  31010. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  31011. * @returns a JSON compatible object representing the serialization of the entity
  31012. */
  31013. static Serialize<T>(entity: T, serializationObject?: any): any;
  31014. /**
  31015. * Creates a new entity from a serialization data object
  31016. * @param creationFunction defines a function used to instanciated the new entity
  31017. * @param source defines the source serialization data
  31018. * @param scene defines the hosting scene
  31019. * @param rootUrl defines the root url for resources
  31020. * @returns a new entity
  31021. */
  31022. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  31023. /**
  31024. * Clones an object
  31025. * @param creationFunction defines the function used to instanciate the new object
  31026. * @param source defines the source object
  31027. * @returns the cloned object
  31028. */
  31029. static Clone<T>(creationFunction: () => T, source: T): T;
  31030. /**
  31031. * Instanciates a new object based on a source one (some data will be shared between both object)
  31032. * @param creationFunction defines the function used to instanciate the new object
  31033. * @param source defines the source object
  31034. * @returns the new object
  31035. */
  31036. static Instanciate<T>(creationFunction: () => T, source: T): T;
  31037. }
  31038. }
  31039. declare module "babylonjs/Materials/Textures/baseTexture" {
  31040. import { Observable } from "babylonjs/Misc/observable";
  31041. import { Nullable } from "babylonjs/types";
  31042. import { Scene } from "babylonjs/scene";
  31043. import { Matrix } from "babylonjs/Maths/math.vector";
  31044. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31045. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31046. import { ISize } from "babylonjs/Maths/math.size";
  31047. import "babylonjs/Misc/fileTools";
  31048. /**
  31049. * Base class of all the textures in babylon.
  31050. * It groups all the common properties the materials, post process, lights... might need
  31051. * in order to make a correct use of the texture.
  31052. */
  31053. export class BaseTexture implements IAnimatable {
  31054. /**
  31055. * Default anisotropic filtering level for the application.
  31056. * It is set to 4 as a good tradeoff between perf and quality.
  31057. */
  31058. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  31059. /**
  31060. * Gets or sets the unique id of the texture
  31061. */
  31062. uniqueId: number;
  31063. /**
  31064. * Define the name of the texture.
  31065. */
  31066. name: string;
  31067. /**
  31068. * Gets or sets an object used to store user defined information.
  31069. */
  31070. metadata: any;
  31071. /**
  31072. * For internal use only. Please do not use.
  31073. */
  31074. reservedDataStore: any;
  31075. private _hasAlpha;
  31076. /**
  31077. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  31078. */
  31079. set hasAlpha(value: boolean);
  31080. get hasAlpha(): boolean;
  31081. /**
  31082. * Defines if the alpha value should be determined via the rgb values.
  31083. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  31084. */
  31085. getAlphaFromRGB: boolean;
  31086. /**
  31087. * Intensity or strength of the texture.
  31088. * It is commonly used by materials to fine tune the intensity of the texture
  31089. */
  31090. level: number;
  31091. /**
  31092. * Define the UV chanel to use starting from 0 and defaulting to 0.
  31093. * This is part of the texture as textures usually maps to one uv set.
  31094. */
  31095. coordinatesIndex: number;
  31096. private _coordinatesMode;
  31097. /**
  31098. * How a texture is mapped.
  31099. *
  31100. * | Value | Type | Description |
  31101. * | ----- | ----------------------------------- | ----------- |
  31102. * | 0 | EXPLICIT_MODE | |
  31103. * | 1 | SPHERICAL_MODE | |
  31104. * | 2 | PLANAR_MODE | |
  31105. * | 3 | CUBIC_MODE | |
  31106. * | 4 | PROJECTION_MODE | |
  31107. * | 5 | SKYBOX_MODE | |
  31108. * | 6 | INVCUBIC_MODE | |
  31109. * | 7 | EQUIRECTANGULAR_MODE | |
  31110. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  31111. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  31112. */
  31113. set coordinatesMode(value: number);
  31114. get coordinatesMode(): number;
  31115. /**
  31116. * | Value | Type | Description |
  31117. * | ----- | ------------------ | ----------- |
  31118. * | 0 | CLAMP_ADDRESSMODE | |
  31119. * | 1 | WRAP_ADDRESSMODE | |
  31120. * | 2 | MIRROR_ADDRESSMODE | |
  31121. */
  31122. wrapU: number;
  31123. /**
  31124. * | Value | Type | Description |
  31125. * | ----- | ------------------ | ----------- |
  31126. * | 0 | CLAMP_ADDRESSMODE | |
  31127. * | 1 | WRAP_ADDRESSMODE | |
  31128. * | 2 | MIRROR_ADDRESSMODE | |
  31129. */
  31130. wrapV: number;
  31131. /**
  31132. * | Value | Type | Description |
  31133. * | ----- | ------------------ | ----------- |
  31134. * | 0 | CLAMP_ADDRESSMODE | |
  31135. * | 1 | WRAP_ADDRESSMODE | |
  31136. * | 2 | MIRROR_ADDRESSMODE | |
  31137. */
  31138. wrapR: number;
  31139. /**
  31140. * With compliant hardware and browser (supporting anisotropic filtering)
  31141. * this defines the level of anisotropic filtering in the texture.
  31142. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  31143. */
  31144. anisotropicFilteringLevel: number;
  31145. /**
  31146. * Define if the texture is a cube texture or if false a 2d texture.
  31147. */
  31148. get isCube(): boolean;
  31149. set isCube(value: boolean);
  31150. /**
  31151. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  31152. */
  31153. get is3D(): boolean;
  31154. set is3D(value: boolean);
  31155. /**
  31156. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  31157. */
  31158. get is2DArray(): boolean;
  31159. set is2DArray(value: boolean);
  31160. /**
  31161. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  31162. * HDR texture are usually stored in linear space.
  31163. * This only impacts the PBR and Background materials
  31164. */
  31165. gammaSpace: boolean;
  31166. /**
  31167. * Gets or sets whether or not the texture contains RGBD data.
  31168. */
  31169. get isRGBD(): boolean;
  31170. set isRGBD(value: boolean);
  31171. /**
  31172. * Is Z inverted in the texture (useful in a cube texture).
  31173. */
  31174. invertZ: boolean;
  31175. /**
  31176. * Are mip maps generated for this texture or not.
  31177. */
  31178. get noMipmap(): boolean;
  31179. /**
  31180. * @hidden
  31181. */
  31182. lodLevelInAlpha: boolean;
  31183. /**
  31184. * With prefiltered texture, defined the offset used during the prefiltering steps.
  31185. */
  31186. get lodGenerationOffset(): number;
  31187. set lodGenerationOffset(value: number);
  31188. /**
  31189. * With prefiltered texture, defined the scale used during the prefiltering steps.
  31190. */
  31191. get lodGenerationScale(): number;
  31192. set lodGenerationScale(value: number);
  31193. /**
  31194. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  31195. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  31196. * average roughness values.
  31197. */
  31198. get linearSpecularLOD(): boolean;
  31199. set linearSpecularLOD(value: boolean);
  31200. /**
  31201. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  31202. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  31203. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  31204. */
  31205. get irradianceTexture(): Nullable<BaseTexture>;
  31206. set irradianceTexture(value: Nullable<BaseTexture>);
  31207. /**
  31208. * Define if the texture is a render target.
  31209. */
  31210. isRenderTarget: boolean;
  31211. /**
  31212. * Define the unique id of the texture in the scene.
  31213. */
  31214. get uid(): string;
  31215. /**
  31216. * Return a string representation of the texture.
  31217. * @returns the texture as a string
  31218. */
  31219. toString(): string;
  31220. /**
  31221. * Get the class name of the texture.
  31222. * @returns "BaseTexture"
  31223. */
  31224. getClassName(): string;
  31225. /**
  31226. * Define the list of animation attached to the texture.
  31227. */
  31228. animations: import("babylonjs/Animations/animation").Animation[];
  31229. /**
  31230. * An event triggered when the texture is disposed.
  31231. */
  31232. onDisposeObservable: Observable<BaseTexture>;
  31233. private _onDisposeObserver;
  31234. /**
  31235. * Callback triggered when the texture has been disposed.
  31236. * Kept for back compatibility, you can use the onDisposeObservable instead.
  31237. */
  31238. set onDispose(callback: () => void);
  31239. /**
  31240. * Define the current state of the loading sequence when in delayed load mode.
  31241. */
  31242. delayLoadState: number;
  31243. private _scene;
  31244. /** @hidden */
  31245. _texture: Nullable<InternalTexture>;
  31246. private _uid;
  31247. /**
  31248. * Define if the texture is preventinga material to render or not.
  31249. * If not and the texture is not ready, the engine will use a default black texture instead.
  31250. */
  31251. get isBlocking(): boolean;
  31252. /**
  31253. * Instantiates a new BaseTexture.
  31254. * Base class of all the textures in babylon.
  31255. * It groups all the common properties the materials, post process, lights... might need
  31256. * in order to make a correct use of the texture.
  31257. * @param scene Define the scene the texture blongs to
  31258. */
  31259. constructor(scene: Nullable<Scene>);
  31260. /**
  31261. * Get the scene the texture belongs to.
  31262. * @returns the scene or null if undefined
  31263. */
  31264. getScene(): Nullable<Scene>;
  31265. /**
  31266. * Get the texture transform matrix used to offset tile the texture for istance.
  31267. * @returns the transformation matrix
  31268. */
  31269. getTextureMatrix(): Matrix;
  31270. /**
  31271. * Get the texture reflection matrix used to rotate/transform the reflection.
  31272. * @returns the reflection matrix
  31273. */
  31274. getReflectionTextureMatrix(): Matrix;
  31275. /**
  31276. * Get the underlying lower level texture from Babylon.
  31277. * @returns the insternal texture
  31278. */
  31279. getInternalTexture(): Nullable<InternalTexture>;
  31280. /**
  31281. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  31282. * @returns true if ready or not blocking
  31283. */
  31284. isReadyOrNotBlocking(): boolean;
  31285. /**
  31286. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  31287. * @returns true if fully ready
  31288. */
  31289. isReady(): boolean;
  31290. private _cachedSize;
  31291. /**
  31292. * Get the size of the texture.
  31293. * @returns the texture size.
  31294. */
  31295. getSize(): ISize;
  31296. /**
  31297. * Get the base size of the texture.
  31298. * It can be different from the size if the texture has been resized for POT for instance
  31299. * @returns the base size
  31300. */
  31301. getBaseSize(): ISize;
  31302. /**
  31303. * Update the sampling mode of the texture.
  31304. * Default is Trilinear mode.
  31305. *
  31306. * | Value | Type | Description |
  31307. * | ----- | ------------------ | ----------- |
  31308. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  31309. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  31310. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  31311. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  31312. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  31313. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  31314. * | 7 | NEAREST_LINEAR | |
  31315. * | 8 | NEAREST_NEAREST | |
  31316. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  31317. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  31318. * | 11 | LINEAR_LINEAR | |
  31319. * | 12 | LINEAR_NEAREST | |
  31320. *
  31321. * > _mag_: magnification filter (close to the viewer)
  31322. * > _min_: minification filter (far from the viewer)
  31323. * > _mip_: filter used between mip map levels
  31324. *@param samplingMode Define the new sampling mode of the texture
  31325. */
  31326. updateSamplingMode(samplingMode: number): void;
  31327. /**
  31328. * Scales the texture if is `canRescale()`
  31329. * @param ratio the resize factor we want to use to rescale
  31330. */
  31331. scale(ratio: number): void;
  31332. /**
  31333. * Get if the texture can rescale.
  31334. */
  31335. get canRescale(): boolean;
  31336. /** @hidden */
  31337. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  31338. /** @hidden */
  31339. _rebuild(): void;
  31340. /**
  31341. * Triggers the load sequence in delayed load mode.
  31342. */
  31343. delayLoad(): void;
  31344. /**
  31345. * Clones the texture.
  31346. * @returns the cloned texture
  31347. */
  31348. clone(): Nullable<BaseTexture>;
  31349. /**
  31350. * Get the texture underlying type (INT, FLOAT...)
  31351. */
  31352. get textureType(): number;
  31353. /**
  31354. * Get the texture underlying format (RGB, RGBA...)
  31355. */
  31356. get textureFormat(): number;
  31357. /**
  31358. * Indicates that textures need to be re-calculated for all materials
  31359. */
  31360. protected _markAllSubMeshesAsTexturesDirty(): void;
  31361. /**
  31362. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  31363. * This will returns an RGBA array buffer containing either in values (0-255) or
  31364. * float values (0-1) depending of the underlying buffer type.
  31365. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  31366. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  31367. * @param buffer defines a user defined buffer to fill with data (can be null)
  31368. * @returns The Array buffer containing the pixels data.
  31369. */
  31370. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  31371. /**
  31372. * Release and destroy the underlying lower level texture aka internalTexture.
  31373. */
  31374. releaseInternalTexture(): void;
  31375. /** @hidden */
  31376. get _lodTextureHigh(): Nullable<BaseTexture>;
  31377. /** @hidden */
  31378. get _lodTextureMid(): Nullable<BaseTexture>;
  31379. /** @hidden */
  31380. get _lodTextureLow(): Nullable<BaseTexture>;
  31381. /**
  31382. * Dispose the texture and release its associated resources.
  31383. */
  31384. dispose(): void;
  31385. /**
  31386. * Serialize the texture into a JSON representation that can be parsed later on.
  31387. * @returns the JSON representation of the texture
  31388. */
  31389. serialize(): any;
  31390. /**
  31391. * Helper function to be called back once a list of texture contains only ready textures.
  31392. * @param textures Define the list of textures to wait for
  31393. * @param callback Define the callback triggered once the entire list will be ready
  31394. */
  31395. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  31396. }
  31397. }
  31398. declare module "babylonjs/Materials/effect" {
  31399. import { Observable } from "babylonjs/Misc/observable";
  31400. import { Nullable } from "babylonjs/types";
  31401. import { IDisposable } from "babylonjs/scene";
  31402. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31403. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31404. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  31405. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31406. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31407. import { Engine } from "babylonjs/Engines/engine";
  31408. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31409. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31410. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31411. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31412. /**
  31413. * Options to be used when creating an effect.
  31414. */
  31415. export interface IEffectCreationOptions {
  31416. /**
  31417. * Atrributes that will be used in the shader.
  31418. */
  31419. attributes: string[];
  31420. /**
  31421. * Uniform varible names that will be set in the shader.
  31422. */
  31423. uniformsNames: string[];
  31424. /**
  31425. * Uniform buffer variable names that will be set in the shader.
  31426. */
  31427. uniformBuffersNames: string[];
  31428. /**
  31429. * Sampler texture variable names that will be set in the shader.
  31430. */
  31431. samplers: string[];
  31432. /**
  31433. * Define statements that will be set in the shader.
  31434. */
  31435. defines: any;
  31436. /**
  31437. * Possible fallbacks for this effect to improve performance when needed.
  31438. */
  31439. fallbacks: Nullable<IEffectFallbacks>;
  31440. /**
  31441. * Callback that will be called when the shader is compiled.
  31442. */
  31443. onCompiled: Nullable<(effect: Effect) => void>;
  31444. /**
  31445. * Callback that will be called if an error occurs during shader compilation.
  31446. */
  31447. onError: Nullable<(effect: Effect, errors: string) => void>;
  31448. /**
  31449. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31450. */
  31451. indexParameters?: any;
  31452. /**
  31453. * Max number of lights that can be used in the shader.
  31454. */
  31455. maxSimultaneousLights?: number;
  31456. /**
  31457. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  31458. */
  31459. transformFeedbackVaryings?: Nullable<string[]>;
  31460. }
  31461. /**
  31462. * Effect containing vertex and fragment shader that can be executed on an object.
  31463. */
  31464. export class Effect implements IDisposable {
  31465. /**
  31466. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31467. */
  31468. static ShadersRepository: string;
  31469. /**
  31470. * Enable logging of the shader code when a compilation error occurs
  31471. */
  31472. static LogShaderCodeOnCompilationError: boolean;
  31473. /**
  31474. * Name of the effect.
  31475. */
  31476. name: any;
  31477. /**
  31478. * String container all the define statements that should be set on the shader.
  31479. */
  31480. defines: string;
  31481. /**
  31482. * Callback that will be called when the shader is compiled.
  31483. */
  31484. onCompiled: Nullable<(effect: Effect) => void>;
  31485. /**
  31486. * Callback that will be called if an error occurs during shader compilation.
  31487. */
  31488. onError: Nullable<(effect: Effect, errors: string) => void>;
  31489. /**
  31490. * Callback that will be called when effect is bound.
  31491. */
  31492. onBind: Nullable<(effect: Effect) => void>;
  31493. /**
  31494. * Unique ID of the effect.
  31495. */
  31496. uniqueId: number;
  31497. /**
  31498. * Observable that will be called when the shader is compiled.
  31499. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  31500. */
  31501. onCompileObservable: Observable<Effect>;
  31502. /**
  31503. * Observable that will be called if an error occurs during shader compilation.
  31504. */
  31505. onErrorObservable: Observable<Effect>;
  31506. /** @hidden */
  31507. _onBindObservable: Nullable<Observable<Effect>>;
  31508. /**
  31509. * @hidden
  31510. * Specifies if the effect was previously ready
  31511. */
  31512. _wasPreviouslyReady: boolean;
  31513. /**
  31514. * Observable that will be called when effect is bound.
  31515. */
  31516. get onBindObservable(): Observable<Effect>;
  31517. /** @hidden */
  31518. _bonesComputationForcedToCPU: boolean;
  31519. private static _uniqueIdSeed;
  31520. private _engine;
  31521. private _uniformBuffersNames;
  31522. private _uniformBuffersNamesList;
  31523. private _uniformsNames;
  31524. private _samplerList;
  31525. private _samplers;
  31526. private _isReady;
  31527. private _compilationError;
  31528. private _allFallbacksProcessed;
  31529. private _attributesNames;
  31530. private _attributes;
  31531. private _attributeLocationByName;
  31532. private _uniforms;
  31533. /**
  31534. * Key for the effect.
  31535. * @hidden
  31536. */
  31537. _key: string;
  31538. private _indexParameters;
  31539. private _fallbacks;
  31540. private _vertexSourceCode;
  31541. private _fragmentSourceCode;
  31542. private _vertexSourceCodeOverride;
  31543. private _fragmentSourceCodeOverride;
  31544. private _transformFeedbackVaryings;
  31545. /**
  31546. * Compiled shader to webGL program.
  31547. * @hidden
  31548. */
  31549. _pipelineContext: Nullable<IPipelineContext>;
  31550. private _valueCache;
  31551. private static _baseCache;
  31552. /**
  31553. * Instantiates an effect.
  31554. * An effect can be used to create/manage/execute vertex and fragment shaders.
  31555. * @param baseName Name of the effect.
  31556. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  31557. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  31558. * @param samplers List of sampler variables that will be passed to the shader.
  31559. * @param engine Engine to be used to render the effect
  31560. * @param defines Define statements to be added to the shader.
  31561. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  31562. * @param onCompiled Callback that will be called when the shader is compiled.
  31563. * @param onError Callback that will be called if an error occurs during shader compilation.
  31564. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31565. */
  31566. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  31567. private _useFinalCode;
  31568. /**
  31569. * Unique key for this effect
  31570. */
  31571. get key(): string;
  31572. /**
  31573. * If the effect has been compiled and prepared.
  31574. * @returns if the effect is compiled and prepared.
  31575. */
  31576. isReady(): boolean;
  31577. private _isReadyInternal;
  31578. /**
  31579. * The engine the effect was initialized with.
  31580. * @returns the engine.
  31581. */
  31582. getEngine(): Engine;
  31583. /**
  31584. * The pipeline context for this effect
  31585. * @returns the associated pipeline context
  31586. */
  31587. getPipelineContext(): Nullable<IPipelineContext>;
  31588. /**
  31589. * The set of names of attribute variables for the shader.
  31590. * @returns An array of attribute names.
  31591. */
  31592. getAttributesNames(): string[];
  31593. /**
  31594. * Returns the attribute at the given index.
  31595. * @param index The index of the attribute.
  31596. * @returns The location of the attribute.
  31597. */
  31598. getAttributeLocation(index: number): number;
  31599. /**
  31600. * Returns the attribute based on the name of the variable.
  31601. * @param name of the attribute to look up.
  31602. * @returns the attribute location.
  31603. */
  31604. getAttributeLocationByName(name: string): number;
  31605. /**
  31606. * The number of attributes.
  31607. * @returns the numnber of attributes.
  31608. */
  31609. getAttributesCount(): number;
  31610. /**
  31611. * Gets the index of a uniform variable.
  31612. * @param uniformName of the uniform to look up.
  31613. * @returns the index.
  31614. */
  31615. getUniformIndex(uniformName: string): number;
  31616. /**
  31617. * Returns the attribute based on the name of the variable.
  31618. * @param uniformName of the uniform to look up.
  31619. * @returns the location of the uniform.
  31620. */
  31621. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  31622. /**
  31623. * Returns an array of sampler variable names
  31624. * @returns The array of sampler variable names.
  31625. */
  31626. getSamplers(): string[];
  31627. /**
  31628. * Returns an array of uniform variable names
  31629. * @returns The array of uniform variable names.
  31630. */
  31631. getUniformNames(): string[];
  31632. /**
  31633. * Returns an array of uniform buffer variable names
  31634. * @returns The array of uniform buffer variable names.
  31635. */
  31636. getUniformBuffersNames(): string[];
  31637. /**
  31638. * Returns the index parameters used to create the effect
  31639. * @returns The index parameters object
  31640. */
  31641. getIndexParameters(): any;
  31642. /**
  31643. * The error from the last compilation.
  31644. * @returns the error string.
  31645. */
  31646. getCompilationError(): string;
  31647. /**
  31648. * Gets a boolean indicating that all fallbacks were used during compilation
  31649. * @returns true if all fallbacks were used
  31650. */
  31651. allFallbacksProcessed(): boolean;
  31652. /**
  31653. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31654. * @param func The callback to be used.
  31655. */
  31656. executeWhenCompiled(func: (effect: Effect) => void): void;
  31657. private _checkIsReady;
  31658. private _loadShader;
  31659. /**
  31660. * Gets the vertex shader source code of this effect
  31661. */
  31662. get vertexSourceCode(): string;
  31663. /**
  31664. * Gets the fragment shader source code of this effect
  31665. */
  31666. get fragmentSourceCode(): string;
  31667. /**
  31668. * Recompiles the webGL program
  31669. * @param vertexSourceCode The source code for the vertex shader.
  31670. * @param fragmentSourceCode The source code for the fragment shader.
  31671. * @param onCompiled Callback called when completed.
  31672. * @param onError Callback called on error.
  31673. * @hidden
  31674. */
  31675. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31676. /**
  31677. * Prepares the effect
  31678. * @hidden
  31679. */
  31680. _prepareEffect(): void;
  31681. private _getShaderCodeAndErrorLine;
  31682. private _processCompilationErrors;
  31683. /**
  31684. * Checks if the effect is supported. (Must be called after compilation)
  31685. */
  31686. get isSupported(): boolean;
  31687. /**
  31688. * Binds a texture to the engine to be used as output of the shader.
  31689. * @param channel Name of the output variable.
  31690. * @param texture Texture to bind.
  31691. * @hidden
  31692. */
  31693. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31694. /**
  31695. * Sets a texture on the engine to be used in the shader.
  31696. * @param channel Name of the sampler variable.
  31697. * @param texture Texture to set.
  31698. */
  31699. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31700. /**
  31701. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31702. * @param channel Name of the sampler variable.
  31703. * @param texture Texture to set.
  31704. */
  31705. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31706. /**
  31707. * Sets an array of textures on the engine to be used in the shader.
  31708. * @param channel Name of the variable.
  31709. * @param textures Textures to set.
  31710. */
  31711. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31712. /**
  31713. * 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)
  31714. * @param channel Name of the sampler variable.
  31715. * @param postProcess Post process to get the input texture from.
  31716. */
  31717. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31718. /**
  31719. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31720. * 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)
  31721. * @param channel Name of the sampler variable.
  31722. * @param postProcess Post process to get the output texture from.
  31723. */
  31724. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31725. /** @hidden */
  31726. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31727. /** @hidden */
  31728. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31729. /** @hidden */
  31730. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31731. /** @hidden */
  31732. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31733. /**
  31734. * Binds a buffer to a uniform.
  31735. * @param buffer Buffer to bind.
  31736. * @param name Name of the uniform variable to bind to.
  31737. */
  31738. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31739. /**
  31740. * Binds block to a uniform.
  31741. * @param blockName Name of the block to bind.
  31742. * @param index Index to bind.
  31743. */
  31744. bindUniformBlock(blockName: string, index: number): void;
  31745. /**
  31746. * Sets an interger value on a uniform variable.
  31747. * @param uniformName Name of the variable.
  31748. * @param value Value to be set.
  31749. * @returns this effect.
  31750. */
  31751. setInt(uniformName: string, value: number): Effect;
  31752. /**
  31753. * Sets an int array on a uniform variable.
  31754. * @param uniformName Name of the variable.
  31755. * @param array array to be set.
  31756. * @returns this effect.
  31757. */
  31758. setIntArray(uniformName: string, array: Int32Array): Effect;
  31759. /**
  31760. * 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)
  31761. * @param uniformName Name of the variable.
  31762. * @param array array to be set.
  31763. * @returns this effect.
  31764. */
  31765. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31766. /**
  31767. * 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)
  31768. * @param uniformName Name of the variable.
  31769. * @param array array to be set.
  31770. * @returns this effect.
  31771. */
  31772. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31773. /**
  31774. * 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)
  31775. * @param uniformName Name of the variable.
  31776. * @param array array to be set.
  31777. * @returns this effect.
  31778. */
  31779. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31780. /**
  31781. * Sets an float array on a uniform variable.
  31782. * @param uniformName Name of the variable.
  31783. * @param array array to be set.
  31784. * @returns this effect.
  31785. */
  31786. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31787. /**
  31788. * 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)
  31789. * @param uniformName Name of the variable.
  31790. * @param array array to be set.
  31791. * @returns this effect.
  31792. */
  31793. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31794. /**
  31795. * 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)
  31796. * @param uniformName Name of the variable.
  31797. * @param array array to be set.
  31798. * @returns this effect.
  31799. */
  31800. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31801. /**
  31802. * 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)
  31803. * @param uniformName Name of the variable.
  31804. * @param array array to be set.
  31805. * @returns this effect.
  31806. */
  31807. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31808. /**
  31809. * Sets an array on a uniform variable.
  31810. * @param uniformName Name of the variable.
  31811. * @param array array to be set.
  31812. * @returns this effect.
  31813. */
  31814. setArray(uniformName: string, array: number[]): Effect;
  31815. /**
  31816. * 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)
  31817. * @param uniformName Name of the variable.
  31818. * @param array array to be set.
  31819. * @returns this effect.
  31820. */
  31821. setArray2(uniformName: string, array: number[]): Effect;
  31822. /**
  31823. * 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)
  31824. * @param uniformName Name of the variable.
  31825. * @param array array to be set.
  31826. * @returns this effect.
  31827. */
  31828. setArray3(uniformName: string, array: number[]): Effect;
  31829. /**
  31830. * 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)
  31831. * @param uniformName Name of the variable.
  31832. * @param array array to be set.
  31833. * @returns this effect.
  31834. */
  31835. setArray4(uniformName: string, array: number[]): Effect;
  31836. /**
  31837. * Sets matrices on a uniform variable.
  31838. * @param uniformName Name of the variable.
  31839. * @param matrices matrices to be set.
  31840. * @returns this effect.
  31841. */
  31842. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31843. /**
  31844. * Sets matrix on a uniform variable.
  31845. * @param uniformName Name of the variable.
  31846. * @param matrix matrix to be set.
  31847. * @returns this effect.
  31848. */
  31849. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31850. /**
  31851. * 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)
  31852. * @param uniformName Name of the variable.
  31853. * @param matrix matrix to be set.
  31854. * @returns this effect.
  31855. */
  31856. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31857. /**
  31858. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31859. * @param uniformName Name of the variable.
  31860. * @param matrix matrix to be set.
  31861. * @returns this effect.
  31862. */
  31863. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31864. /**
  31865. * Sets a float on a uniform variable.
  31866. * @param uniformName Name of the variable.
  31867. * @param value value to be set.
  31868. * @returns this effect.
  31869. */
  31870. setFloat(uniformName: string, value: number): Effect;
  31871. /**
  31872. * Sets a boolean on a uniform variable.
  31873. * @param uniformName Name of the variable.
  31874. * @param bool value to be set.
  31875. * @returns this effect.
  31876. */
  31877. setBool(uniformName: string, bool: boolean): Effect;
  31878. /**
  31879. * Sets a Vector2 on a uniform variable.
  31880. * @param uniformName Name of the variable.
  31881. * @param vector2 vector2 to be set.
  31882. * @returns this effect.
  31883. */
  31884. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31885. /**
  31886. * Sets a float2 on a uniform variable.
  31887. * @param uniformName Name of the variable.
  31888. * @param x First float in float2.
  31889. * @param y Second float in float2.
  31890. * @returns this effect.
  31891. */
  31892. setFloat2(uniformName: string, x: number, y: number): Effect;
  31893. /**
  31894. * Sets a Vector3 on a uniform variable.
  31895. * @param uniformName Name of the variable.
  31896. * @param vector3 Value to be set.
  31897. * @returns this effect.
  31898. */
  31899. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31900. /**
  31901. * Sets a float3 on a uniform variable.
  31902. * @param uniformName Name of the variable.
  31903. * @param x First float in float3.
  31904. * @param y Second float in float3.
  31905. * @param z Third float in float3.
  31906. * @returns this effect.
  31907. */
  31908. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31909. /**
  31910. * Sets a Vector4 on a uniform variable.
  31911. * @param uniformName Name of the variable.
  31912. * @param vector4 Value to be set.
  31913. * @returns this effect.
  31914. */
  31915. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31916. /**
  31917. * Sets a float4 on a uniform variable.
  31918. * @param uniformName Name of the variable.
  31919. * @param x First float in float4.
  31920. * @param y Second float in float4.
  31921. * @param z Third float in float4.
  31922. * @param w Fourth float in float4.
  31923. * @returns this effect.
  31924. */
  31925. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31926. /**
  31927. * Sets a Color3 on a uniform variable.
  31928. * @param uniformName Name of the variable.
  31929. * @param color3 Value to be set.
  31930. * @returns this effect.
  31931. */
  31932. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31933. /**
  31934. * Sets a Color4 on a uniform variable.
  31935. * @param uniformName Name of the variable.
  31936. * @param color3 Value to be set.
  31937. * @param alpha Alpha value to be set.
  31938. * @returns this effect.
  31939. */
  31940. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31941. /**
  31942. * Sets a Color4 on a uniform variable
  31943. * @param uniformName defines the name of the variable
  31944. * @param color4 defines the value to be set
  31945. * @returns this effect.
  31946. */
  31947. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31948. /** Release all associated resources */
  31949. dispose(): void;
  31950. /**
  31951. * This function will add a new shader to the shader store
  31952. * @param name the name of the shader
  31953. * @param pixelShader optional pixel shader content
  31954. * @param vertexShader optional vertex shader content
  31955. */
  31956. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31957. /**
  31958. * Store of each shader (The can be looked up using effect.key)
  31959. */
  31960. static ShadersStore: {
  31961. [key: string]: string;
  31962. };
  31963. /**
  31964. * Store of each included file for a shader (The can be looked up using effect.key)
  31965. */
  31966. static IncludesShadersStore: {
  31967. [key: string]: string;
  31968. };
  31969. /**
  31970. * Resets the cache of effects.
  31971. */
  31972. static ResetCache(): void;
  31973. }
  31974. }
  31975. declare module "babylonjs/Engines/engineCapabilities" {
  31976. /**
  31977. * Interface used to describe the capabilities of the engine relatively to the current browser
  31978. */
  31979. export interface EngineCapabilities {
  31980. /** Maximum textures units per fragment shader */
  31981. maxTexturesImageUnits: number;
  31982. /** Maximum texture units per vertex shader */
  31983. maxVertexTextureImageUnits: number;
  31984. /** Maximum textures units in the entire pipeline */
  31985. maxCombinedTexturesImageUnits: number;
  31986. /** Maximum texture size */
  31987. maxTextureSize: number;
  31988. /** Maximum texture samples */
  31989. maxSamples?: number;
  31990. /** Maximum cube texture size */
  31991. maxCubemapTextureSize: number;
  31992. /** Maximum render texture size */
  31993. maxRenderTextureSize: number;
  31994. /** Maximum number of vertex attributes */
  31995. maxVertexAttribs: number;
  31996. /** Maximum number of varyings */
  31997. maxVaryingVectors: number;
  31998. /** Maximum number of uniforms per vertex shader */
  31999. maxVertexUniformVectors: number;
  32000. /** Maximum number of uniforms per fragment shader */
  32001. maxFragmentUniformVectors: number;
  32002. /** Defines if standard derivates (dx/dy) are supported */
  32003. standardDerivatives: boolean;
  32004. /** Defines if s3tc texture compression is supported */
  32005. s3tc?: WEBGL_compressed_texture_s3tc;
  32006. /** Defines if pvrtc texture compression is supported */
  32007. pvrtc: any;
  32008. /** Defines if etc1 texture compression is supported */
  32009. etc1: any;
  32010. /** Defines if etc2 texture compression is supported */
  32011. etc2: any;
  32012. /** Defines if astc texture compression is supported */
  32013. astc: any;
  32014. /** Defines if float textures are supported */
  32015. textureFloat: boolean;
  32016. /** Defines if vertex array objects are supported */
  32017. vertexArrayObject: boolean;
  32018. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  32019. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  32020. /** Gets the maximum level of anisotropy supported */
  32021. maxAnisotropy: number;
  32022. /** Defines if instancing is supported */
  32023. instancedArrays: boolean;
  32024. /** Defines if 32 bits indices are supported */
  32025. uintIndices: boolean;
  32026. /** Defines if high precision shaders are supported */
  32027. highPrecisionShaderSupported: boolean;
  32028. /** Defines if depth reading in the fragment shader is supported */
  32029. fragmentDepthSupported: boolean;
  32030. /** Defines if float texture linear filtering is supported*/
  32031. textureFloatLinearFiltering: boolean;
  32032. /** Defines if rendering to float textures is supported */
  32033. textureFloatRender: boolean;
  32034. /** Defines if half float textures are supported*/
  32035. textureHalfFloat: boolean;
  32036. /** Defines if half float texture linear filtering is supported*/
  32037. textureHalfFloatLinearFiltering: boolean;
  32038. /** Defines if rendering to half float textures is supported */
  32039. textureHalfFloatRender: boolean;
  32040. /** Defines if textureLOD shader command is supported */
  32041. textureLOD: boolean;
  32042. /** Defines if draw buffers extension is supported */
  32043. drawBuffersExtension: boolean;
  32044. /** Defines if depth textures are supported */
  32045. depthTextureExtension: boolean;
  32046. /** Defines if float color buffer are supported */
  32047. colorBufferFloat: boolean;
  32048. /** Gets disjoint timer query extension (null if not supported) */
  32049. timerQuery?: EXT_disjoint_timer_query;
  32050. /** Defines if timestamp can be used with timer query */
  32051. canUseTimestampForTimerQuery: boolean;
  32052. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  32053. multiview?: any;
  32054. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  32055. oculusMultiview?: any;
  32056. /** Function used to let the system compiles shaders in background */
  32057. parallelShaderCompile?: {
  32058. COMPLETION_STATUS_KHR: number;
  32059. };
  32060. /** Max number of texture samples for MSAA */
  32061. maxMSAASamples: number;
  32062. /** Defines if the blend min max extension is supported */
  32063. blendMinMax: boolean;
  32064. }
  32065. }
  32066. declare module "babylonjs/States/depthCullingState" {
  32067. import { Nullable } from "babylonjs/types";
  32068. /**
  32069. * @hidden
  32070. **/
  32071. export class DepthCullingState {
  32072. private _isDepthTestDirty;
  32073. private _isDepthMaskDirty;
  32074. private _isDepthFuncDirty;
  32075. private _isCullFaceDirty;
  32076. private _isCullDirty;
  32077. private _isZOffsetDirty;
  32078. private _isFrontFaceDirty;
  32079. private _depthTest;
  32080. private _depthMask;
  32081. private _depthFunc;
  32082. private _cull;
  32083. private _cullFace;
  32084. private _zOffset;
  32085. private _frontFace;
  32086. /**
  32087. * Initializes the state.
  32088. */
  32089. constructor();
  32090. get isDirty(): boolean;
  32091. get zOffset(): number;
  32092. set zOffset(value: number);
  32093. get cullFace(): Nullable<number>;
  32094. set cullFace(value: Nullable<number>);
  32095. get cull(): Nullable<boolean>;
  32096. set cull(value: Nullable<boolean>);
  32097. get depthFunc(): Nullable<number>;
  32098. set depthFunc(value: Nullable<number>);
  32099. get depthMask(): boolean;
  32100. set depthMask(value: boolean);
  32101. get depthTest(): boolean;
  32102. set depthTest(value: boolean);
  32103. get frontFace(): Nullable<number>;
  32104. set frontFace(value: Nullable<number>);
  32105. reset(): void;
  32106. apply(gl: WebGLRenderingContext): void;
  32107. }
  32108. }
  32109. declare module "babylonjs/States/stencilState" {
  32110. /**
  32111. * @hidden
  32112. **/
  32113. export class StencilState {
  32114. /** 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 */
  32115. static readonly ALWAYS: number;
  32116. /** Passed to stencilOperation to specify that stencil value must be kept */
  32117. static readonly KEEP: number;
  32118. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32119. static readonly REPLACE: number;
  32120. private _isStencilTestDirty;
  32121. private _isStencilMaskDirty;
  32122. private _isStencilFuncDirty;
  32123. private _isStencilOpDirty;
  32124. private _stencilTest;
  32125. private _stencilMask;
  32126. private _stencilFunc;
  32127. private _stencilFuncRef;
  32128. private _stencilFuncMask;
  32129. private _stencilOpStencilFail;
  32130. private _stencilOpDepthFail;
  32131. private _stencilOpStencilDepthPass;
  32132. get isDirty(): boolean;
  32133. get stencilFunc(): number;
  32134. set stencilFunc(value: number);
  32135. get stencilFuncRef(): number;
  32136. set stencilFuncRef(value: number);
  32137. get stencilFuncMask(): number;
  32138. set stencilFuncMask(value: number);
  32139. get stencilOpStencilFail(): number;
  32140. set stencilOpStencilFail(value: number);
  32141. get stencilOpDepthFail(): number;
  32142. set stencilOpDepthFail(value: number);
  32143. get stencilOpStencilDepthPass(): number;
  32144. set stencilOpStencilDepthPass(value: number);
  32145. get stencilMask(): number;
  32146. set stencilMask(value: number);
  32147. get stencilTest(): boolean;
  32148. set stencilTest(value: boolean);
  32149. constructor();
  32150. reset(): void;
  32151. apply(gl: WebGLRenderingContext): void;
  32152. }
  32153. }
  32154. declare module "babylonjs/States/alphaCullingState" {
  32155. /**
  32156. * @hidden
  32157. **/
  32158. export class AlphaState {
  32159. private _isAlphaBlendDirty;
  32160. private _isBlendFunctionParametersDirty;
  32161. private _isBlendEquationParametersDirty;
  32162. private _isBlendConstantsDirty;
  32163. private _alphaBlend;
  32164. private _blendFunctionParameters;
  32165. private _blendEquationParameters;
  32166. private _blendConstants;
  32167. /**
  32168. * Initializes the state.
  32169. */
  32170. constructor();
  32171. get isDirty(): boolean;
  32172. get alphaBlend(): boolean;
  32173. set alphaBlend(value: boolean);
  32174. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  32175. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  32176. setAlphaEquationParameters(rgb: number, alpha: number): void;
  32177. reset(): void;
  32178. apply(gl: WebGLRenderingContext): void;
  32179. }
  32180. }
  32181. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  32182. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  32183. /** @hidden */
  32184. export class WebGL2ShaderProcessor implements IShaderProcessor {
  32185. attributeProcessor(attribute: string): string;
  32186. varyingProcessor(varying: string, isFragment: boolean): string;
  32187. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  32188. }
  32189. }
  32190. declare module "babylonjs/Engines/instancingAttributeInfo" {
  32191. /**
  32192. * Interface for attribute information associated with buffer instanciation
  32193. */
  32194. export interface InstancingAttributeInfo {
  32195. /**
  32196. * Name of the GLSL attribute
  32197. * if attribute index is not specified, this is used to retrieve the index from the effect
  32198. */
  32199. attributeName: string;
  32200. /**
  32201. * Index/offset of the attribute in the vertex shader
  32202. * if not specified, this will be computes from the name.
  32203. */
  32204. index?: number;
  32205. /**
  32206. * size of the attribute, 1, 2, 3 or 4
  32207. */
  32208. attributeSize: number;
  32209. /**
  32210. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  32211. */
  32212. offset: number;
  32213. /**
  32214. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  32215. * default to 1
  32216. */
  32217. divisor?: number;
  32218. /**
  32219. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  32220. * default is FLOAT
  32221. */
  32222. attributeType?: number;
  32223. /**
  32224. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  32225. */
  32226. normalized?: boolean;
  32227. }
  32228. }
  32229. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  32230. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32231. import { Nullable } from "babylonjs/types";
  32232. module "babylonjs/Engines/thinEngine" {
  32233. interface ThinEngine {
  32234. /**
  32235. * Update a video texture
  32236. * @param texture defines the texture to update
  32237. * @param video defines the video element to use
  32238. * @param invertY defines if data must be stored with Y axis inverted
  32239. */
  32240. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32241. }
  32242. }
  32243. }
  32244. declare module "babylonjs/Materials/Textures/videoTexture" {
  32245. import { Observable } from "babylonjs/Misc/observable";
  32246. import { Nullable } from "babylonjs/types";
  32247. import { Scene } from "babylonjs/scene";
  32248. import { Texture } from "babylonjs/Materials/Textures/texture";
  32249. import "babylonjs/Engines/Extensions/engine.videoTexture";
  32250. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  32251. /**
  32252. * Settings for finer control over video usage
  32253. */
  32254. export interface VideoTextureSettings {
  32255. /**
  32256. * Applies `autoplay` to video, if specified
  32257. */
  32258. autoPlay?: boolean;
  32259. /**
  32260. * Applies `loop` to video, if specified
  32261. */
  32262. loop?: boolean;
  32263. /**
  32264. * Automatically updates internal texture from video at every frame in the render loop
  32265. */
  32266. autoUpdateTexture: boolean;
  32267. /**
  32268. * Image src displayed during the video loading or until the user interacts with the video.
  32269. */
  32270. poster?: string;
  32271. }
  32272. /**
  32273. * If you want to display a video in your scene, this is the special texture for that.
  32274. * This special texture works similar to other textures, with the exception of a few parameters.
  32275. * @see https://doc.babylonjs.com/how_to/video_texture
  32276. */
  32277. export class VideoTexture extends Texture {
  32278. /**
  32279. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  32280. */
  32281. readonly autoUpdateTexture: boolean;
  32282. /**
  32283. * The video instance used by the texture internally
  32284. */
  32285. readonly video: HTMLVideoElement;
  32286. private _onUserActionRequestedObservable;
  32287. /**
  32288. * Event triggerd when a dom action is required by the user to play the video.
  32289. * This happens due to recent changes in browser policies preventing video to auto start.
  32290. */
  32291. get onUserActionRequestedObservable(): Observable<Texture>;
  32292. private _generateMipMaps;
  32293. private _engine;
  32294. private _stillImageCaptured;
  32295. private _displayingPosterTexture;
  32296. private _settings;
  32297. private _createInternalTextureOnEvent;
  32298. private _frameId;
  32299. private _currentSrc;
  32300. /**
  32301. * Creates a video texture.
  32302. * If you want to display a video in your scene, this is the special texture for that.
  32303. * This special texture works similar to other textures, with the exception of a few parameters.
  32304. * @see https://doc.babylonjs.com/how_to/video_texture
  32305. * @param name optional name, will detect from video source, if not defined
  32306. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  32307. * @param scene is obviously the current scene.
  32308. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  32309. * @param invertY is false by default but can be used to invert video on Y axis
  32310. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  32311. * @param settings allows finer control over video usage
  32312. */
  32313. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  32314. private _getName;
  32315. private _getVideo;
  32316. private _createInternalTexture;
  32317. private reset;
  32318. /**
  32319. * @hidden Internal method to initiate `update`.
  32320. */
  32321. _rebuild(): void;
  32322. /**
  32323. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  32324. */
  32325. update(): void;
  32326. /**
  32327. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  32328. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  32329. */
  32330. updateTexture(isVisible: boolean): void;
  32331. protected _updateInternalTexture: () => void;
  32332. /**
  32333. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  32334. * @param url New url.
  32335. */
  32336. updateURL(url: string): void;
  32337. /**
  32338. * Clones the texture.
  32339. * @returns the cloned texture
  32340. */
  32341. clone(): VideoTexture;
  32342. /**
  32343. * Dispose the texture and release its associated resources.
  32344. */
  32345. dispose(): void;
  32346. /**
  32347. * Creates a video texture straight from a stream.
  32348. * @param scene Define the scene the texture should be created in
  32349. * @param stream Define the stream the texture should be created from
  32350. * @returns The created video texture as a promise
  32351. */
  32352. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  32353. /**
  32354. * Creates a video texture straight from your WebCam video feed.
  32355. * @param scene Define the scene the texture should be created in
  32356. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  32357. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  32358. * @returns The created video texture as a promise
  32359. */
  32360. static CreateFromWebCamAsync(scene: Scene, constraints: {
  32361. minWidth: number;
  32362. maxWidth: number;
  32363. minHeight: number;
  32364. maxHeight: number;
  32365. deviceId: string;
  32366. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  32367. /**
  32368. * Creates a video texture straight from your WebCam video feed.
  32369. * @param scene Define the scene the texture should be created in
  32370. * @param onReady Define a callback to triggered once the texture will be ready
  32371. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  32372. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  32373. */
  32374. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  32375. minWidth: number;
  32376. maxWidth: number;
  32377. minHeight: number;
  32378. maxHeight: number;
  32379. deviceId: string;
  32380. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  32381. }
  32382. }
  32383. declare module "babylonjs/Engines/thinEngine" {
  32384. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  32385. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  32386. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  32387. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32388. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  32389. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  32390. import { Observable } from "babylonjs/Misc/observable";
  32391. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  32392. import { StencilState } from "babylonjs/States/stencilState";
  32393. import { AlphaState } from "babylonjs/States/alphaCullingState";
  32394. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32395. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  32396. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32397. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32398. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  32399. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  32400. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  32401. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  32402. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32403. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32404. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  32405. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  32406. import { WebRequest } from "babylonjs/Misc/webRequest";
  32407. import { LoadFileError } from "babylonjs/Misc/fileTools";
  32408. /**
  32409. * Defines the interface used by objects working like Scene
  32410. * @hidden
  32411. */
  32412. export interface ISceneLike {
  32413. _addPendingData(data: any): void;
  32414. _removePendingData(data: any): void;
  32415. offlineProvider: IOfflineProvider;
  32416. }
  32417. /** Interface defining initialization parameters for Engine class */
  32418. export interface EngineOptions extends WebGLContextAttributes {
  32419. /**
  32420. * Defines if the engine should no exceed a specified device ratio
  32421. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  32422. */
  32423. limitDeviceRatio?: number;
  32424. /**
  32425. * Defines if webvr should be enabled automatically
  32426. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32427. */
  32428. autoEnableWebVR?: boolean;
  32429. /**
  32430. * Defines if webgl2 should be turned off even if supported
  32431. * @see http://doc.babylonjs.com/features/webgl2
  32432. */
  32433. disableWebGL2Support?: boolean;
  32434. /**
  32435. * Defines if webaudio should be initialized as well
  32436. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32437. */
  32438. audioEngine?: boolean;
  32439. /**
  32440. * Defines if animations should run using a deterministic lock step
  32441. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32442. */
  32443. deterministicLockstep?: boolean;
  32444. /** Defines the maximum steps to use with deterministic lock step mode */
  32445. lockstepMaxSteps?: number;
  32446. /** Defines the seconds between each deterministic lock step */
  32447. timeStep?: number;
  32448. /**
  32449. * Defines that engine should ignore context lost events
  32450. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  32451. */
  32452. doNotHandleContextLost?: boolean;
  32453. /**
  32454. * Defines that engine should ignore modifying touch action attribute and style
  32455. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  32456. */
  32457. doNotHandleTouchAction?: boolean;
  32458. /**
  32459. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  32460. */
  32461. useHighPrecisionFloats?: boolean;
  32462. }
  32463. /**
  32464. * The base engine class (root of all engines)
  32465. */
  32466. export class ThinEngine {
  32467. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  32468. static ExceptionList: ({
  32469. key: string;
  32470. capture: string;
  32471. captureConstraint: number;
  32472. targets: string[];
  32473. } | {
  32474. key: string;
  32475. capture: null;
  32476. captureConstraint: null;
  32477. targets: string[];
  32478. })[];
  32479. /** @hidden */
  32480. static _TextureLoaders: IInternalTextureLoader[];
  32481. /**
  32482. * Returns the current npm package of the sdk
  32483. */
  32484. static get NpmPackage(): string;
  32485. /**
  32486. * Returns the current version of the framework
  32487. */
  32488. static get Version(): string;
  32489. /**
  32490. * Returns a string describing the current engine
  32491. */
  32492. get description(): string;
  32493. /**
  32494. * Gets or sets the epsilon value used by collision engine
  32495. */
  32496. static CollisionsEpsilon: number;
  32497. /**
  32498. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  32499. */
  32500. static get ShadersRepository(): string;
  32501. static set ShadersRepository(value: string);
  32502. /** @hidden */
  32503. _shaderProcessor: IShaderProcessor;
  32504. /**
  32505. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  32506. */
  32507. forcePOTTextures: boolean;
  32508. /**
  32509. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  32510. */
  32511. isFullscreen: boolean;
  32512. /**
  32513. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  32514. */
  32515. cullBackFaces: boolean;
  32516. /**
  32517. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  32518. */
  32519. renderEvenInBackground: boolean;
  32520. /**
  32521. * Gets or sets a boolean indicating that cache can be kept between frames
  32522. */
  32523. preventCacheWipeBetweenFrames: boolean;
  32524. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  32525. validateShaderPrograms: boolean;
  32526. /**
  32527. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  32528. * This can provide greater z depth for distant objects.
  32529. */
  32530. useReverseDepthBuffer: boolean;
  32531. /**
  32532. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  32533. */
  32534. disableUniformBuffers: boolean;
  32535. /** @hidden */
  32536. _uniformBuffers: UniformBuffer[];
  32537. /**
  32538. * Gets a boolean indicating that the engine supports uniform buffers
  32539. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  32540. */
  32541. get supportsUniformBuffers(): boolean;
  32542. /** @hidden */
  32543. _gl: WebGLRenderingContext;
  32544. /** @hidden */
  32545. _webGLVersion: number;
  32546. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  32547. protected _windowIsBackground: boolean;
  32548. protected _creationOptions: EngineOptions;
  32549. protected _highPrecisionShadersAllowed: boolean;
  32550. /** @hidden */
  32551. get _shouldUseHighPrecisionShader(): boolean;
  32552. /**
  32553. * Gets a boolean indicating that only power of 2 textures are supported
  32554. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  32555. */
  32556. get needPOTTextures(): boolean;
  32557. /** @hidden */
  32558. _badOS: boolean;
  32559. /** @hidden */
  32560. _badDesktopOS: boolean;
  32561. private _hardwareScalingLevel;
  32562. /** @hidden */
  32563. _caps: EngineCapabilities;
  32564. private _isStencilEnable;
  32565. private _glVersion;
  32566. private _glRenderer;
  32567. private _glVendor;
  32568. /** @hidden */
  32569. _videoTextureSupported: boolean;
  32570. protected _renderingQueueLaunched: boolean;
  32571. protected _activeRenderLoops: (() => void)[];
  32572. /**
  32573. * Observable signaled when a context lost event is raised
  32574. */
  32575. onContextLostObservable: Observable<ThinEngine>;
  32576. /**
  32577. * Observable signaled when a context restored event is raised
  32578. */
  32579. onContextRestoredObservable: Observable<ThinEngine>;
  32580. private _onContextLost;
  32581. private _onContextRestored;
  32582. protected _contextWasLost: boolean;
  32583. /** @hidden */
  32584. _doNotHandleContextLost: boolean;
  32585. /**
  32586. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  32587. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  32588. */
  32589. get doNotHandleContextLost(): boolean;
  32590. set doNotHandleContextLost(value: boolean);
  32591. /**
  32592. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  32593. */
  32594. disableVertexArrayObjects: boolean;
  32595. /** @hidden */
  32596. protected _colorWrite: boolean;
  32597. /** @hidden */
  32598. protected _colorWriteChanged: boolean;
  32599. /** @hidden */
  32600. protected _depthCullingState: DepthCullingState;
  32601. /** @hidden */
  32602. protected _stencilState: StencilState;
  32603. /** @hidden */
  32604. _alphaState: AlphaState;
  32605. /** @hidden */
  32606. _alphaMode: number;
  32607. /** @hidden */
  32608. _alphaEquation: number;
  32609. /** @hidden */
  32610. _internalTexturesCache: InternalTexture[];
  32611. /** @hidden */
  32612. protected _activeChannel: number;
  32613. private _currentTextureChannel;
  32614. /** @hidden */
  32615. protected _boundTexturesCache: {
  32616. [key: string]: Nullable<InternalTexture>;
  32617. };
  32618. /** @hidden */
  32619. protected _currentEffect: Nullable<Effect>;
  32620. /** @hidden */
  32621. protected _currentProgram: Nullable<WebGLProgram>;
  32622. private _compiledEffects;
  32623. private _vertexAttribArraysEnabled;
  32624. /** @hidden */
  32625. protected _cachedViewport: Nullable<IViewportLike>;
  32626. private _cachedVertexArrayObject;
  32627. /** @hidden */
  32628. protected _cachedVertexBuffers: any;
  32629. /** @hidden */
  32630. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  32631. /** @hidden */
  32632. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  32633. /** @hidden */
  32634. _currentRenderTarget: Nullable<InternalTexture>;
  32635. private _uintIndicesCurrentlySet;
  32636. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  32637. /** @hidden */
  32638. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  32639. private _currentBufferPointers;
  32640. private _currentInstanceLocations;
  32641. private _currentInstanceBuffers;
  32642. private _textureUnits;
  32643. /** @hidden */
  32644. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32645. /** @hidden */
  32646. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32647. /** @hidden */
  32648. _boundRenderFunction: any;
  32649. private _vaoRecordInProgress;
  32650. private _mustWipeVertexAttributes;
  32651. private _emptyTexture;
  32652. private _emptyCubeTexture;
  32653. private _emptyTexture3D;
  32654. private _emptyTexture2DArray;
  32655. /** @hidden */
  32656. _frameHandler: number;
  32657. private _nextFreeTextureSlots;
  32658. private _maxSimultaneousTextures;
  32659. private _activeRequests;
  32660. /** @hidden */
  32661. _transformTextureUrl: Nullable<(url: string) => string>;
  32662. protected get _supportsHardwareTextureRescaling(): boolean;
  32663. private _framebufferDimensionsObject;
  32664. /**
  32665. * sets the object from which width and height will be taken from when getting render width and height
  32666. * Will fallback to the gl object
  32667. * @param dimensions the framebuffer width and height that will be used.
  32668. */
  32669. set framebufferDimensionsObject(dimensions: Nullable<{
  32670. framebufferWidth: number;
  32671. framebufferHeight: number;
  32672. }>);
  32673. /**
  32674. * Gets the current viewport
  32675. */
  32676. get currentViewport(): Nullable<IViewportLike>;
  32677. /**
  32678. * Gets the default empty texture
  32679. */
  32680. get emptyTexture(): InternalTexture;
  32681. /**
  32682. * Gets the default empty 3D texture
  32683. */
  32684. get emptyTexture3D(): InternalTexture;
  32685. /**
  32686. * Gets the default empty 2D array texture
  32687. */
  32688. get emptyTexture2DArray(): InternalTexture;
  32689. /**
  32690. * Gets the default empty cube texture
  32691. */
  32692. get emptyCubeTexture(): InternalTexture;
  32693. /**
  32694. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32695. */
  32696. readonly premultipliedAlpha: boolean;
  32697. /**
  32698. * Observable event triggered before each texture is initialized
  32699. */
  32700. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32701. /**
  32702. * Creates a new engine
  32703. * @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
  32704. * @param antialias defines enable antialiasing (default: false)
  32705. * @param options defines further options to be sent to the getContext() function
  32706. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32707. */
  32708. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32709. private _rebuildInternalTextures;
  32710. private _rebuildEffects;
  32711. /**
  32712. * Gets a boolean indicating if all created effects are ready
  32713. * @returns true if all effects are ready
  32714. */
  32715. areAllEffectsReady(): boolean;
  32716. protected _rebuildBuffers(): void;
  32717. protected _initGLContext(): void;
  32718. /**
  32719. * Gets version of the current webGL context
  32720. */
  32721. get webGLVersion(): number;
  32722. /**
  32723. * Gets a string idenfifying the name of the class
  32724. * @returns "Engine" string
  32725. */
  32726. getClassName(): string;
  32727. /**
  32728. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32729. */
  32730. get isStencilEnable(): boolean;
  32731. /** @hidden */
  32732. _prepareWorkingCanvas(): void;
  32733. /**
  32734. * Reset the texture cache to empty state
  32735. */
  32736. resetTextureCache(): void;
  32737. /**
  32738. * Gets an object containing information about the current webGL context
  32739. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32740. */
  32741. getGlInfo(): {
  32742. vendor: string;
  32743. renderer: string;
  32744. version: string;
  32745. };
  32746. /**
  32747. * Defines the hardware scaling level.
  32748. * By default the hardware scaling level is computed from the window device ratio.
  32749. * 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.
  32750. * @param level defines the level to use
  32751. */
  32752. setHardwareScalingLevel(level: number): void;
  32753. /**
  32754. * Gets the current hardware scaling level.
  32755. * By default the hardware scaling level is computed from the window device ratio.
  32756. * 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.
  32757. * @returns a number indicating the current hardware scaling level
  32758. */
  32759. getHardwareScalingLevel(): number;
  32760. /**
  32761. * Gets the list of loaded textures
  32762. * @returns an array containing all loaded textures
  32763. */
  32764. getLoadedTexturesCache(): InternalTexture[];
  32765. /**
  32766. * Gets the object containing all engine capabilities
  32767. * @returns the EngineCapabilities object
  32768. */
  32769. getCaps(): EngineCapabilities;
  32770. /**
  32771. * stop executing a render loop function and remove it from the execution array
  32772. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32773. */
  32774. stopRenderLoop(renderFunction?: () => void): void;
  32775. /** @hidden */
  32776. _renderLoop(): void;
  32777. /**
  32778. * Gets the HTML canvas attached with the current webGL context
  32779. * @returns a HTML canvas
  32780. */
  32781. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32782. /**
  32783. * Gets host window
  32784. * @returns the host window object
  32785. */
  32786. getHostWindow(): Nullable<Window>;
  32787. /**
  32788. * Gets the current render width
  32789. * @param useScreen defines if screen size must be used (or the current render target if any)
  32790. * @returns a number defining the current render width
  32791. */
  32792. getRenderWidth(useScreen?: boolean): number;
  32793. /**
  32794. * Gets the current render height
  32795. * @param useScreen defines if screen size must be used (or the current render target if any)
  32796. * @returns a number defining the current render height
  32797. */
  32798. getRenderHeight(useScreen?: boolean): number;
  32799. /**
  32800. * Can be used to override the current requestAnimationFrame requester.
  32801. * @hidden
  32802. */
  32803. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32804. /**
  32805. * Register and execute a render loop. The engine can have more than one render function
  32806. * @param renderFunction defines the function to continuously execute
  32807. */
  32808. runRenderLoop(renderFunction: () => void): void;
  32809. /**
  32810. * Clear the current render buffer or the current render target (if any is set up)
  32811. * @param color defines the color to use
  32812. * @param backBuffer defines if the back buffer must be cleared
  32813. * @param depth defines if the depth buffer must be cleared
  32814. * @param stencil defines if the stencil buffer must be cleared
  32815. */
  32816. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32817. private _viewportCached;
  32818. /** @hidden */
  32819. _viewport(x: number, y: number, width: number, height: number): void;
  32820. /**
  32821. * Set the WebGL's viewport
  32822. * @param viewport defines the viewport element to be used
  32823. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32824. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32825. */
  32826. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32827. /**
  32828. * Begin a new frame
  32829. */
  32830. beginFrame(): void;
  32831. /**
  32832. * Enf the current frame
  32833. */
  32834. endFrame(): void;
  32835. /**
  32836. * Resize the view according to the canvas' size
  32837. */
  32838. resize(): void;
  32839. /**
  32840. * Force a specific size of the canvas
  32841. * @param width defines the new canvas' width
  32842. * @param height defines the new canvas' height
  32843. */
  32844. setSize(width: number, height: number): void;
  32845. /**
  32846. * Binds the frame buffer to the specified texture.
  32847. * @param texture The texture to render to or null for the default canvas
  32848. * @param faceIndex The face of the texture to render to in case of cube texture
  32849. * @param requiredWidth The width of the target to render to
  32850. * @param requiredHeight The height of the target to render to
  32851. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32852. * @param lodLevel defines the lod level to bind to the frame buffer
  32853. * @param layer defines the 2d array index to bind to frame buffer to
  32854. */
  32855. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32856. /** @hidden */
  32857. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32858. /**
  32859. * Unbind the current render target texture from the webGL context
  32860. * @param texture defines the render target texture to unbind
  32861. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32862. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32863. */
  32864. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32865. /**
  32866. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32867. */
  32868. flushFramebuffer(): void;
  32869. /**
  32870. * Unbind the current render target and bind the default framebuffer
  32871. */
  32872. restoreDefaultFramebuffer(): void;
  32873. /** @hidden */
  32874. protected _resetVertexBufferBinding(): void;
  32875. /**
  32876. * Creates a vertex buffer
  32877. * @param data the data for the vertex buffer
  32878. * @returns the new WebGL static buffer
  32879. */
  32880. createVertexBuffer(data: DataArray): DataBuffer;
  32881. private _createVertexBuffer;
  32882. /**
  32883. * Creates a dynamic vertex buffer
  32884. * @param data the data for the dynamic vertex buffer
  32885. * @returns the new WebGL dynamic buffer
  32886. */
  32887. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32888. protected _resetIndexBufferBinding(): void;
  32889. /**
  32890. * Creates a new index buffer
  32891. * @param indices defines the content of the index buffer
  32892. * @param updatable defines if the index buffer must be updatable
  32893. * @returns a new webGL buffer
  32894. */
  32895. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32896. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32897. /**
  32898. * Bind a webGL buffer to the webGL context
  32899. * @param buffer defines the buffer to bind
  32900. */
  32901. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32902. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32903. private bindBuffer;
  32904. /**
  32905. * update the bound buffer with the given data
  32906. * @param data defines the data to update
  32907. */
  32908. updateArrayBuffer(data: Float32Array): void;
  32909. private _vertexAttribPointer;
  32910. /** @hidden */
  32911. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32912. private _bindVertexBuffersAttributes;
  32913. /**
  32914. * Records a vertex array object
  32915. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32916. * @param vertexBuffers defines the list of vertex buffers to store
  32917. * @param indexBuffer defines the index buffer to store
  32918. * @param effect defines the effect to store
  32919. * @returns the new vertex array object
  32920. */
  32921. recordVertexArrayObject(vertexBuffers: {
  32922. [key: string]: VertexBuffer;
  32923. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32924. /**
  32925. * Bind a specific vertex array object
  32926. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32927. * @param vertexArrayObject defines the vertex array object to bind
  32928. * @param indexBuffer defines the index buffer to bind
  32929. */
  32930. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32931. /**
  32932. * Bind webGl buffers directly to the webGL context
  32933. * @param vertexBuffer defines the vertex buffer to bind
  32934. * @param indexBuffer defines the index buffer to bind
  32935. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32936. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32937. * @param effect defines the effect associated with the vertex buffer
  32938. */
  32939. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32940. private _unbindVertexArrayObject;
  32941. /**
  32942. * Bind a list of vertex buffers to the webGL context
  32943. * @param vertexBuffers defines the list of vertex buffers to bind
  32944. * @param indexBuffer defines the index buffer to bind
  32945. * @param effect defines the effect associated with the vertex buffers
  32946. */
  32947. bindBuffers(vertexBuffers: {
  32948. [key: string]: Nullable<VertexBuffer>;
  32949. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32950. /**
  32951. * Unbind all instance attributes
  32952. */
  32953. unbindInstanceAttributes(): void;
  32954. /**
  32955. * Release and free the memory of a vertex array object
  32956. * @param vao defines the vertex array object to delete
  32957. */
  32958. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32959. /** @hidden */
  32960. _releaseBuffer(buffer: DataBuffer): boolean;
  32961. protected _deleteBuffer(buffer: DataBuffer): void;
  32962. /**
  32963. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32964. * @param instancesBuffer defines the webGL buffer to update and bind
  32965. * @param data defines the data to store in the buffer
  32966. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32967. */
  32968. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32969. /**
  32970. * Bind the content of a webGL buffer used with instantiation
  32971. * @param instancesBuffer defines the webGL buffer to bind
  32972. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32973. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32974. */
  32975. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32976. /**
  32977. * Disable the instance attribute corresponding to the name in parameter
  32978. * @param name defines the name of the attribute to disable
  32979. */
  32980. disableInstanceAttributeByName(name: string): void;
  32981. /**
  32982. * Disable the instance attribute corresponding to the location in parameter
  32983. * @param attributeLocation defines the attribute location of the attribute to disable
  32984. */
  32985. disableInstanceAttribute(attributeLocation: number): void;
  32986. /**
  32987. * Disable the attribute corresponding to the location in parameter
  32988. * @param attributeLocation defines the attribute location of the attribute to disable
  32989. */
  32990. disableAttributeByIndex(attributeLocation: number): void;
  32991. /**
  32992. * Send a draw order
  32993. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32994. * @param indexStart defines the starting index
  32995. * @param indexCount defines the number of index to draw
  32996. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32997. */
  32998. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32999. /**
  33000. * Draw a list of points
  33001. * @param verticesStart defines the index of first vertex to draw
  33002. * @param verticesCount defines the count of vertices to draw
  33003. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33004. */
  33005. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  33006. /**
  33007. * Draw a list of unindexed primitives
  33008. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  33009. * @param verticesStart defines the index of first vertex to draw
  33010. * @param verticesCount defines the count of vertices to draw
  33011. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33012. */
  33013. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  33014. /**
  33015. * Draw a list of indexed primitives
  33016. * @param fillMode defines the primitive to use
  33017. * @param indexStart defines the starting index
  33018. * @param indexCount defines the number of index to draw
  33019. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33020. */
  33021. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  33022. /**
  33023. * Draw a list of unindexed primitives
  33024. * @param fillMode defines the primitive to use
  33025. * @param verticesStart defines the index of first vertex to draw
  33026. * @param verticesCount defines the count of vertices to draw
  33027. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33028. */
  33029. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  33030. private _drawMode;
  33031. /** @hidden */
  33032. protected _reportDrawCall(): void;
  33033. /** @hidden */
  33034. _releaseEffect(effect: Effect): void;
  33035. /** @hidden */
  33036. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33037. /**
  33038. * Create a new effect (used to store vertex/fragment shaders)
  33039. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  33040. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  33041. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  33042. * @param samplers defines an array of string used to represent textures
  33043. * @param defines defines the string containing the defines to use to compile the shaders
  33044. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  33045. * @param onCompiled defines a function to call when the effect creation is successful
  33046. * @param onError defines a function to call when the effect creation has failed
  33047. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  33048. * @returns the new Effect
  33049. */
  33050. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  33051. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  33052. private _compileShader;
  33053. private _compileRawShader;
  33054. /** @hidden */
  33055. _getShaderSource(shader: WebGLShader): Nullable<string>;
  33056. /**
  33057. * Directly creates a webGL program
  33058. * @param pipelineContext defines the pipeline context to attach to
  33059. * @param vertexCode defines the vertex shader code to use
  33060. * @param fragmentCode defines the fragment shader code to use
  33061. * @param context defines the webGL context to use (if not set, the current one will be used)
  33062. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  33063. * @returns the new webGL program
  33064. */
  33065. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33066. /**
  33067. * Creates a webGL program
  33068. * @param pipelineContext defines the pipeline context to attach to
  33069. * @param vertexCode defines the vertex shader code to use
  33070. * @param fragmentCode defines the fragment shader code to use
  33071. * @param defines defines the string containing the defines to use to compile the shaders
  33072. * @param context defines the webGL context to use (if not set, the current one will be used)
  33073. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  33074. * @returns the new webGL program
  33075. */
  33076. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33077. /**
  33078. * Creates a new pipeline context
  33079. * @returns the new pipeline
  33080. */
  33081. createPipelineContext(): IPipelineContext;
  33082. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33083. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  33084. /** @hidden */
  33085. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  33086. /** @hidden */
  33087. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  33088. /** @hidden */
  33089. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  33090. /**
  33091. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  33092. * @param pipelineContext defines the pipeline context to use
  33093. * @param uniformsNames defines the list of uniform names
  33094. * @returns an array of webGL uniform locations
  33095. */
  33096. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  33097. /**
  33098. * Gets the lsit of active attributes for a given webGL program
  33099. * @param pipelineContext defines the pipeline context to use
  33100. * @param attributesNames defines the list of attribute names to get
  33101. * @returns an array of indices indicating the offset of each attribute
  33102. */
  33103. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  33104. /**
  33105. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  33106. * @param effect defines the effect to activate
  33107. */
  33108. enableEffect(effect: Nullable<Effect>): void;
  33109. /**
  33110. * Set the value of an uniform to a number (int)
  33111. * @param uniform defines the webGL uniform location where to store the value
  33112. * @param value defines the int number to store
  33113. */
  33114. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  33115. /**
  33116. * Set the value of an uniform to an array of int32
  33117. * @param uniform defines the webGL uniform location where to store the value
  33118. * @param array defines the array of int32 to store
  33119. */
  33120. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  33121. /**
  33122. * Set the value of an uniform to an array of int32 (stored as vec2)
  33123. * @param uniform defines the webGL uniform location where to store the value
  33124. * @param array defines the array of int32 to store
  33125. */
  33126. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  33127. /**
  33128. * Set the value of an uniform to an array of int32 (stored as vec3)
  33129. * @param uniform defines the webGL uniform location where to store the value
  33130. * @param array defines the array of int32 to store
  33131. */
  33132. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  33133. /**
  33134. * Set the value of an uniform to an array of int32 (stored as vec4)
  33135. * @param uniform defines the webGL uniform location where to store the value
  33136. * @param array defines the array of int32 to store
  33137. */
  33138. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  33139. /**
  33140. * Set the value of an uniform to an array of number
  33141. * @param uniform defines the webGL uniform location where to store the value
  33142. * @param array defines the array of number to store
  33143. */
  33144. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  33145. /**
  33146. * Set the value of an uniform to an array of number (stored as vec2)
  33147. * @param uniform defines the webGL uniform location where to store the value
  33148. * @param array defines the array of number to store
  33149. */
  33150. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  33151. /**
  33152. * Set the value of an uniform to an array of number (stored as vec3)
  33153. * @param uniform defines the webGL uniform location where to store the value
  33154. * @param array defines the array of number to store
  33155. */
  33156. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  33157. /**
  33158. * Set the value of an uniform to an array of number (stored as vec4)
  33159. * @param uniform defines the webGL uniform location where to store the value
  33160. * @param array defines the array of number to store
  33161. */
  33162. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  33163. /**
  33164. * Set the value of an uniform to an array of float32 (stored as matrices)
  33165. * @param uniform defines the webGL uniform location where to store the value
  33166. * @param matrices defines the array of float32 to store
  33167. */
  33168. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  33169. /**
  33170. * Set the value of an uniform to a matrix (3x3)
  33171. * @param uniform defines the webGL uniform location where to store the value
  33172. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  33173. */
  33174. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  33175. /**
  33176. * Set the value of an uniform to a matrix (2x2)
  33177. * @param uniform defines the webGL uniform location where to store the value
  33178. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  33179. */
  33180. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  33181. /**
  33182. * Set the value of an uniform to a number (float)
  33183. * @param uniform defines the webGL uniform location where to store the value
  33184. * @param value defines the float number to store
  33185. */
  33186. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  33187. /**
  33188. * Set the value of an uniform to a vec2
  33189. * @param uniform defines the webGL uniform location where to store the value
  33190. * @param x defines the 1st component of the value
  33191. * @param y defines the 2nd component of the value
  33192. */
  33193. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  33194. /**
  33195. * Set the value of an uniform to a vec3
  33196. * @param uniform defines the webGL uniform location where to store the value
  33197. * @param x defines the 1st component of the value
  33198. * @param y defines the 2nd component of the value
  33199. * @param z defines the 3rd component of the value
  33200. */
  33201. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  33202. /**
  33203. * Set the value of an uniform to a vec4
  33204. * @param uniform defines the webGL uniform location where to store the value
  33205. * @param x defines the 1st component of the value
  33206. * @param y defines the 2nd component of the value
  33207. * @param z defines the 3rd component of the value
  33208. * @param w defines the 4th component of the value
  33209. */
  33210. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  33211. /**
  33212. * Apply all cached states (depth, culling, stencil and alpha)
  33213. */
  33214. applyStates(): void;
  33215. /**
  33216. * Enable or disable color writing
  33217. * @param enable defines the state to set
  33218. */
  33219. setColorWrite(enable: boolean): void;
  33220. /**
  33221. * Gets a boolean indicating if color writing is enabled
  33222. * @returns the current color writing state
  33223. */
  33224. getColorWrite(): boolean;
  33225. /**
  33226. * Gets the depth culling state manager
  33227. */
  33228. get depthCullingState(): DepthCullingState;
  33229. /**
  33230. * Gets the alpha state manager
  33231. */
  33232. get alphaState(): AlphaState;
  33233. /**
  33234. * Gets the stencil state manager
  33235. */
  33236. get stencilState(): StencilState;
  33237. /**
  33238. * Clears the list of texture accessible through engine.
  33239. * This can help preventing texture load conflict due to name collision.
  33240. */
  33241. clearInternalTexturesCache(): void;
  33242. /**
  33243. * Force the entire cache to be cleared
  33244. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  33245. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  33246. */
  33247. wipeCaches(bruteForce?: boolean): void;
  33248. /** @hidden */
  33249. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  33250. min: number;
  33251. mag: number;
  33252. };
  33253. /** @hidden */
  33254. _createTexture(): WebGLTexture;
  33255. /**
  33256. * Usually called from Texture.ts.
  33257. * Passed information to create a WebGLTexture
  33258. * @param url defines a value which contains one of the following:
  33259. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  33260. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  33261. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  33262. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  33263. * @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)
  33264. * @param scene needed for loading to the correct scene
  33265. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  33266. * @param onLoad optional callback to be called upon successful completion
  33267. * @param onError optional callback to be called upon failure
  33268. * @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
  33269. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  33270. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  33271. * @param forcedExtension defines the extension to use to pick the right loader
  33272. * @param mimeType defines an optional mime type
  33273. * @returns a InternalTexture for assignment back into BABYLON.Texture
  33274. */
  33275. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  33276. /**
  33277. * Loads an image as an HTMLImageElement.
  33278. * @param input url string, ArrayBuffer, or Blob to load
  33279. * @param onLoad callback called when the image successfully loads
  33280. * @param onError callback called when the image fails to load
  33281. * @param offlineProvider offline provider for caching
  33282. * @param mimeType optional mime type
  33283. * @returns the HTMLImageElement of the loaded image
  33284. * @hidden
  33285. */
  33286. static _FileToolsLoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33287. /**
  33288. * @hidden
  33289. */
  33290. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33291. private _unpackFlipYCached;
  33292. /**
  33293. * In case you are sharing the context with other applications, it might
  33294. * be interested to not cache the unpack flip y state to ensure a consistent
  33295. * value would be set.
  33296. */
  33297. enableUnpackFlipYCached: boolean;
  33298. /** @hidden */
  33299. _unpackFlipY(value: boolean): void;
  33300. /** @hidden */
  33301. _getUnpackAlignement(): number;
  33302. private _getTextureTarget;
  33303. /**
  33304. * Update the sampling mode of a given texture
  33305. * @param samplingMode defines the required sampling mode
  33306. * @param texture defines the texture to update
  33307. * @param generateMipMaps defines whether to generate mipmaps for the texture
  33308. */
  33309. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  33310. /**
  33311. * Update the sampling mode of a given texture
  33312. * @param texture defines the texture to update
  33313. * @param wrapU defines the texture wrap mode of the u coordinates
  33314. * @param wrapV defines the texture wrap mode of the v coordinates
  33315. * @param wrapR defines the texture wrap mode of the r coordinates
  33316. */
  33317. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  33318. /** @hidden */
  33319. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  33320. width: number;
  33321. height: number;
  33322. layers?: number;
  33323. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  33324. /** @hidden */
  33325. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  33326. /** @hidden */
  33327. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  33328. /**
  33329. * Update a portion of an internal texture
  33330. * @param texture defines the texture to update
  33331. * @param imageData defines the data to store into the texture
  33332. * @param xOffset defines the x coordinates of the update rectangle
  33333. * @param yOffset defines the y coordinates of the update rectangle
  33334. * @param width defines the width of the update rectangle
  33335. * @param height defines the height of the update rectangle
  33336. * @param faceIndex defines the face index if texture is a cube (0 by default)
  33337. * @param lod defines the lod level to update (0 by default)
  33338. */
  33339. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  33340. /** @hidden */
  33341. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  33342. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  33343. private _prepareWebGLTexture;
  33344. /** @hidden */
  33345. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  33346. private _getDepthStencilBuffer;
  33347. /** @hidden */
  33348. _releaseFramebufferObjects(texture: InternalTexture): void;
  33349. /** @hidden */
  33350. _releaseTexture(texture: InternalTexture): void;
  33351. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  33352. protected _setProgram(program: WebGLProgram): void;
  33353. protected _boundUniforms: {
  33354. [key: number]: WebGLUniformLocation;
  33355. };
  33356. /**
  33357. * Binds an effect to the webGL context
  33358. * @param effect defines the effect to bind
  33359. */
  33360. bindSamplers(effect: Effect): void;
  33361. private _activateCurrentTexture;
  33362. /** @hidden */
  33363. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  33364. /** @hidden */
  33365. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  33366. /**
  33367. * Unbind all textures from the webGL context
  33368. */
  33369. unbindAllTextures(): void;
  33370. /**
  33371. * Sets a texture to the according uniform.
  33372. * @param channel The texture channel
  33373. * @param uniform The uniform to set
  33374. * @param texture The texture to apply
  33375. */
  33376. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  33377. private _bindSamplerUniformToChannel;
  33378. private _getTextureWrapMode;
  33379. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  33380. /**
  33381. * Sets an array of texture to the webGL context
  33382. * @param channel defines the channel where the texture array must be set
  33383. * @param uniform defines the associated uniform location
  33384. * @param textures defines the array of textures to bind
  33385. */
  33386. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  33387. /** @hidden */
  33388. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  33389. private _setTextureParameterFloat;
  33390. private _setTextureParameterInteger;
  33391. /**
  33392. * Unbind all vertex attributes from the webGL context
  33393. */
  33394. unbindAllAttributes(): void;
  33395. /**
  33396. * 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
  33397. */
  33398. releaseEffects(): void;
  33399. /**
  33400. * Dispose and release all associated resources
  33401. */
  33402. dispose(): void;
  33403. /**
  33404. * Attach a new callback raised when context lost event is fired
  33405. * @param callback defines the callback to call
  33406. */
  33407. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  33408. /**
  33409. * Attach a new callback raised when context restored event is fired
  33410. * @param callback defines the callback to call
  33411. */
  33412. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  33413. /**
  33414. * Get the current error code of the webGL context
  33415. * @returns the error code
  33416. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  33417. */
  33418. getError(): number;
  33419. private _canRenderToFloatFramebuffer;
  33420. private _canRenderToHalfFloatFramebuffer;
  33421. private _canRenderToFramebuffer;
  33422. /** @hidden */
  33423. _getWebGLTextureType(type: number): number;
  33424. /** @hidden */
  33425. _getInternalFormat(format: number): number;
  33426. /** @hidden */
  33427. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  33428. /** @hidden */
  33429. _getRGBAMultiSampleBufferFormat(type: number): number;
  33430. /** @hidden */
  33431. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  33432. /**
  33433. * Loads a file from a url
  33434. * @param url url to load
  33435. * @param onSuccess callback called when the file successfully loads
  33436. * @param onProgress callback called while file is loading (if the server supports this mode)
  33437. * @param offlineProvider defines the offline provider for caching
  33438. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33439. * @param onError callback called when the file fails to load
  33440. * @returns a file request object
  33441. * @hidden
  33442. */
  33443. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  33444. /**
  33445. * Reads pixels from the current frame buffer. Please note that this function can be slow
  33446. * @param x defines the x coordinate of the rectangle where pixels must be read
  33447. * @param y defines the y coordinate of the rectangle where pixels must be read
  33448. * @param width defines the width of the rectangle where pixels must be read
  33449. * @param height defines the height of the rectangle where pixels must be read
  33450. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  33451. * @returns a Uint8Array containing RGBA colors
  33452. */
  33453. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  33454. private static _isSupported;
  33455. /**
  33456. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  33457. * @returns true if the engine can be created
  33458. * @ignorenaming
  33459. */
  33460. static isSupported(): boolean;
  33461. /**
  33462. * Find the next highest power of two.
  33463. * @param x Number to start search from.
  33464. * @return Next highest power of two.
  33465. */
  33466. static CeilingPOT(x: number): number;
  33467. /**
  33468. * Find the next lowest power of two.
  33469. * @param x Number to start search from.
  33470. * @return Next lowest power of two.
  33471. */
  33472. static FloorPOT(x: number): number;
  33473. /**
  33474. * Find the nearest power of two.
  33475. * @param x Number to start search from.
  33476. * @return Next nearest power of two.
  33477. */
  33478. static NearestPOT(x: number): number;
  33479. /**
  33480. * Get the closest exponent of two
  33481. * @param value defines the value to approximate
  33482. * @param max defines the maximum value to return
  33483. * @param mode defines how to define the closest value
  33484. * @returns closest exponent of two of the given value
  33485. */
  33486. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  33487. /**
  33488. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  33489. * @param func - the function to be called
  33490. * @param requester - the object that will request the next frame. Falls back to window.
  33491. * @returns frame number
  33492. */
  33493. static QueueNewFrame(func: () => void, requester?: any): number;
  33494. /**
  33495. * Gets host document
  33496. * @returns the host document object
  33497. */
  33498. getHostDocument(): Nullable<Document>;
  33499. }
  33500. }
  33501. declare module "babylonjs/Maths/sphericalPolynomial" {
  33502. import { Vector3 } from "babylonjs/Maths/math.vector";
  33503. import { Color3 } from "babylonjs/Maths/math.color";
  33504. /**
  33505. * Class representing spherical harmonics coefficients to the 3rd degree
  33506. */
  33507. export class SphericalHarmonics {
  33508. /**
  33509. * Defines whether or not the harmonics have been prescaled for rendering.
  33510. */
  33511. preScaled: boolean;
  33512. /**
  33513. * The l0,0 coefficients of the spherical harmonics
  33514. */
  33515. l00: Vector3;
  33516. /**
  33517. * The l1,-1 coefficients of the spherical harmonics
  33518. */
  33519. l1_1: Vector3;
  33520. /**
  33521. * The l1,0 coefficients of the spherical harmonics
  33522. */
  33523. l10: Vector3;
  33524. /**
  33525. * The l1,1 coefficients of the spherical harmonics
  33526. */
  33527. l11: Vector3;
  33528. /**
  33529. * The l2,-2 coefficients of the spherical harmonics
  33530. */
  33531. l2_2: Vector3;
  33532. /**
  33533. * The l2,-1 coefficients of the spherical harmonics
  33534. */
  33535. l2_1: Vector3;
  33536. /**
  33537. * The l2,0 coefficients of the spherical harmonics
  33538. */
  33539. l20: Vector3;
  33540. /**
  33541. * The l2,1 coefficients of the spherical harmonics
  33542. */
  33543. l21: Vector3;
  33544. /**
  33545. * The l2,2 coefficients of the spherical harmonics
  33546. */
  33547. l22: Vector3;
  33548. /**
  33549. * Adds a light to the spherical harmonics
  33550. * @param direction the direction of the light
  33551. * @param color the color of the light
  33552. * @param deltaSolidAngle the delta solid angle of the light
  33553. */
  33554. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  33555. /**
  33556. * Scales the spherical harmonics by the given amount
  33557. * @param scale the amount to scale
  33558. */
  33559. scaleInPlace(scale: number): void;
  33560. /**
  33561. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  33562. *
  33563. * ```
  33564. * E_lm = A_l * L_lm
  33565. * ```
  33566. *
  33567. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  33568. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  33569. * the scaling factors are given in equation 9.
  33570. */
  33571. convertIncidentRadianceToIrradiance(): void;
  33572. /**
  33573. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  33574. *
  33575. * ```
  33576. * L = (1/pi) * E * rho
  33577. * ```
  33578. *
  33579. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  33580. */
  33581. convertIrradianceToLambertianRadiance(): void;
  33582. /**
  33583. * Integrates the reconstruction coefficients directly in to the SH preventing further
  33584. * required operations at run time.
  33585. *
  33586. * This is simply done by scaling back the SH with Ylm constants parameter.
  33587. * The trigonometric part being applied by the shader at run time.
  33588. */
  33589. preScaleForRendering(): void;
  33590. /**
  33591. * Constructs a spherical harmonics from an array.
  33592. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33593. * @returns the spherical harmonics
  33594. */
  33595. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33596. /**
  33597. * Gets the spherical harmonics from polynomial
  33598. * @param polynomial the spherical polynomial
  33599. * @returns the spherical harmonics
  33600. */
  33601. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33602. }
  33603. /**
  33604. * Class representing spherical polynomial coefficients to the 3rd degree
  33605. */
  33606. export class SphericalPolynomial {
  33607. private _harmonics;
  33608. /**
  33609. * The spherical harmonics used to create the polynomials.
  33610. */
  33611. get preScaledHarmonics(): SphericalHarmonics;
  33612. /**
  33613. * The x coefficients of the spherical polynomial
  33614. */
  33615. x: Vector3;
  33616. /**
  33617. * The y coefficients of the spherical polynomial
  33618. */
  33619. y: Vector3;
  33620. /**
  33621. * The z coefficients of the spherical polynomial
  33622. */
  33623. z: Vector3;
  33624. /**
  33625. * The xx coefficients of the spherical polynomial
  33626. */
  33627. xx: Vector3;
  33628. /**
  33629. * The yy coefficients of the spherical polynomial
  33630. */
  33631. yy: Vector3;
  33632. /**
  33633. * The zz coefficients of the spherical polynomial
  33634. */
  33635. zz: Vector3;
  33636. /**
  33637. * The xy coefficients of the spherical polynomial
  33638. */
  33639. xy: Vector3;
  33640. /**
  33641. * The yz coefficients of the spherical polynomial
  33642. */
  33643. yz: Vector3;
  33644. /**
  33645. * The zx coefficients of the spherical polynomial
  33646. */
  33647. zx: Vector3;
  33648. /**
  33649. * Adds an ambient color to the spherical polynomial
  33650. * @param color the color to add
  33651. */
  33652. addAmbient(color: Color3): void;
  33653. /**
  33654. * Scales the spherical polynomial by the given amount
  33655. * @param scale the amount to scale
  33656. */
  33657. scaleInPlace(scale: number): void;
  33658. /**
  33659. * Gets the spherical polynomial from harmonics
  33660. * @param harmonics the spherical harmonics
  33661. * @returns the spherical polynomial
  33662. */
  33663. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33664. /**
  33665. * Constructs a spherical polynomial from an array.
  33666. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33667. * @returns the spherical polynomial
  33668. */
  33669. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33670. }
  33671. }
  33672. declare module "babylonjs/Materials/Textures/internalTexture" {
  33673. import { Observable } from "babylonjs/Misc/observable";
  33674. import { Nullable, int } from "babylonjs/types";
  33675. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33676. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33677. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33678. /**
  33679. * Defines the source of the internal texture
  33680. */
  33681. export enum InternalTextureSource {
  33682. /**
  33683. * The source of the texture data is unknown
  33684. */
  33685. Unknown = 0,
  33686. /**
  33687. * Texture data comes from an URL
  33688. */
  33689. Url = 1,
  33690. /**
  33691. * Texture data is only used for temporary storage
  33692. */
  33693. Temp = 2,
  33694. /**
  33695. * Texture data comes from raw data (ArrayBuffer)
  33696. */
  33697. Raw = 3,
  33698. /**
  33699. * Texture content is dynamic (video or dynamic texture)
  33700. */
  33701. Dynamic = 4,
  33702. /**
  33703. * Texture content is generated by rendering to it
  33704. */
  33705. RenderTarget = 5,
  33706. /**
  33707. * Texture content is part of a multi render target process
  33708. */
  33709. MultiRenderTarget = 6,
  33710. /**
  33711. * Texture data comes from a cube data file
  33712. */
  33713. Cube = 7,
  33714. /**
  33715. * Texture data comes from a raw cube data
  33716. */
  33717. CubeRaw = 8,
  33718. /**
  33719. * Texture data come from a prefiltered cube data file
  33720. */
  33721. CubePrefiltered = 9,
  33722. /**
  33723. * Texture content is raw 3D data
  33724. */
  33725. Raw3D = 10,
  33726. /**
  33727. * Texture content is raw 2D array data
  33728. */
  33729. Raw2DArray = 11,
  33730. /**
  33731. * Texture content is a depth texture
  33732. */
  33733. Depth = 12,
  33734. /**
  33735. * Texture data comes from a raw cube data encoded with RGBD
  33736. */
  33737. CubeRawRGBD = 13
  33738. }
  33739. /**
  33740. * Class used to store data associated with WebGL texture data for the engine
  33741. * This class should not be used directly
  33742. */
  33743. export class InternalTexture {
  33744. /** @hidden */
  33745. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33746. /**
  33747. * Defines if the texture is ready
  33748. */
  33749. isReady: boolean;
  33750. /**
  33751. * Defines if the texture is a cube texture
  33752. */
  33753. isCube: boolean;
  33754. /**
  33755. * Defines if the texture contains 3D data
  33756. */
  33757. is3D: boolean;
  33758. /**
  33759. * Defines if the texture contains 2D array data
  33760. */
  33761. is2DArray: boolean;
  33762. /**
  33763. * Defines if the texture contains multiview data
  33764. */
  33765. isMultiview: boolean;
  33766. /**
  33767. * Gets the URL used to load this texture
  33768. */
  33769. url: string;
  33770. /**
  33771. * Gets the sampling mode of the texture
  33772. */
  33773. samplingMode: number;
  33774. /**
  33775. * Gets a boolean indicating if the texture needs mipmaps generation
  33776. */
  33777. generateMipMaps: boolean;
  33778. /**
  33779. * Gets the number of samples used by the texture (WebGL2+ only)
  33780. */
  33781. samples: number;
  33782. /**
  33783. * Gets the type of the texture (int, float...)
  33784. */
  33785. type: number;
  33786. /**
  33787. * Gets the format of the texture (RGB, RGBA...)
  33788. */
  33789. format: number;
  33790. /**
  33791. * Observable called when the texture is loaded
  33792. */
  33793. onLoadedObservable: Observable<InternalTexture>;
  33794. /**
  33795. * Gets the width of the texture
  33796. */
  33797. width: number;
  33798. /**
  33799. * Gets the height of the texture
  33800. */
  33801. height: number;
  33802. /**
  33803. * Gets the depth of the texture
  33804. */
  33805. depth: number;
  33806. /**
  33807. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33808. */
  33809. baseWidth: number;
  33810. /**
  33811. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33812. */
  33813. baseHeight: number;
  33814. /**
  33815. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33816. */
  33817. baseDepth: number;
  33818. /**
  33819. * Gets a boolean indicating if the texture is inverted on Y axis
  33820. */
  33821. invertY: boolean;
  33822. /** @hidden */
  33823. _invertVScale: boolean;
  33824. /** @hidden */
  33825. _associatedChannel: number;
  33826. /** @hidden */
  33827. _source: InternalTextureSource;
  33828. /** @hidden */
  33829. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33830. /** @hidden */
  33831. _bufferView: Nullable<ArrayBufferView>;
  33832. /** @hidden */
  33833. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33834. /** @hidden */
  33835. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33836. /** @hidden */
  33837. _size: number;
  33838. /** @hidden */
  33839. _extension: string;
  33840. /** @hidden */
  33841. _files: Nullable<string[]>;
  33842. /** @hidden */
  33843. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33844. /** @hidden */
  33845. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33846. /** @hidden */
  33847. _framebuffer: Nullable<WebGLFramebuffer>;
  33848. /** @hidden */
  33849. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33850. /** @hidden */
  33851. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33852. /** @hidden */
  33853. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33854. /** @hidden */
  33855. _attachments: Nullable<number[]>;
  33856. /** @hidden */
  33857. _cachedCoordinatesMode: Nullable<number>;
  33858. /** @hidden */
  33859. _cachedWrapU: Nullable<number>;
  33860. /** @hidden */
  33861. _cachedWrapV: Nullable<number>;
  33862. /** @hidden */
  33863. _cachedWrapR: Nullable<number>;
  33864. /** @hidden */
  33865. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33866. /** @hidden */
  33867. _isDisabled: boolean;
  33868. /** @hidden */
  33869. _compression: Nullable<string>;
  33870. /** @hidden */
  33871. _generateStencilBuffer: boolean;
  33872. /** @hidden */
  33873. _generateDepthBuffer: boolean;
  33874. /** @hidden */
  33875. _comparisonFunction: number;
  33876. /** @hidden */
  33877. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33878. /** @hidden */
  33879. _lodGenerationScale: number;
  33880. /** @hidden */
  33881. _lodGenerationOffset: number;
  33882. /** @hidden */
  33883. _depthStencilTexture: Nullable<InternalTexture>;
  33884. /** @hidden */
  33885. _colorTextureArray: Nullable<WebGLTexture>;
  33886. /** @hidden */
  33887. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33888. /** @hidden */
  33889. _lodTextureHigh: Nullable<BaseTexture>;
  33890. /** @hidden */
  33891. _lodTextureMid: Nullable<BaseTexture>;
  33892. /** @hidden */
  33893. _lodTextureLow: Nullable<BaseTexture>;
  33894. /** @hidden */
  33895. _isRGBD: boolean;
  33896. /** @hidden */
  33897. _linearSpecularLOD: boolean;
  33898. /** @hidden */
  33899. _irradianceTexture: Nullable<BaseTexture>;
  33900. /** @hidden */
  33901. _webGLTexture: Nullable<WebGLTexture>;
  33902. /** @hidden */
  33903. _references: number;
  33904. private _engine;
  33905. /**
  33906. * Gets the Engine the texture belongs to.
  33907. * @returns The babylon engine
  33908. */
  33909. getEngine(): ThinEngine;
  33910. /**
  33911. * Gets the data source type of the texture
  33912. */
  33913. get source(): InternalTextureSource;
  33914. /**
  33915. * Creates a new InternalTexture
  33916. * @param engine defines the engine to use
  33917. * @param source defines the type of data that will be used
  33918. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33919. */
  33920. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33921. /**
  33922. * Increments the number of references (ie. the number of Texture that point to it)
  33923. */
  33924. incrementReferences(): void;
  33925. /**
  33926. * Change the size of the texture (not the size of the content)
  33927. * @param width defines the new width
  33928. * @param height defines the new height
  33929. * @param depth defines the new depth (1 by default)
  33930. */
  33931. updateSize(width: int, height: int, depth?: int): void;
  33932. /** @hidden */
  33933. _rebuild(): void;
  33934. /** @hidden */
  33935. _swapAndDie(target: InternalTexture): void;
  33936. /**
  33937. * Dispose the current allocated resources
  33938. */
  33939. dispose(): void;
  33940. }
  33941. }
  33942. declare module "babylonjs/Audio/analyser" {
  33943. import { Scene } from "babylonjs/scene";
  33944. /**
  33945. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33946. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33947. */
  33948. export class Analyser {
  33949. /**
  33950. * Gets or sets the smoothing
  33951. * @ignorenaming
  33952. */
  33953. SMOOTHING: number;
  33954. /**
  33955. * Gets or sets the FFT table size
  33956. * @ignorenaming
  33957. */
  33958. FFT_SIZE: number;
  33959. /**
  33960. * Gets or sets the bar graph amplitude
  33961. * @ignorenaming
  33962. */
  33963. BARGRAPHAMPLITUDE: number;
  33964. /**
  33965. * Gets or sets the position of the debug canvas
  33966. * @ignorenaming
  33967. */
  33968. DEBUGCANVASPOS: {
  33969. x: number;
  33970. y: number;
  33971. };
  33972. /**
  33973. * Gets or sets the debug canvas size
  33974. * @ignorenaming
  33975. */
  33976. DEBUGCANVASSIZE: {
  33977. width: number;
  33978. height: number;
  33979. };
  33980. private _byteFreqs;
  33981. private _byteTime;
  33982. private _floatFreqs;
  33983. private _webAudioAnalyser;
  33984. private _debugCanvas;
  33985. private _debugCanvasContext;
  33986. private _scene;
  33987. private _registerFunc;
  33988. private _audioEngine;
  33989. /**
  33990. * Creates a new analyser
  33991. * @param scene defines hosting scene
  33992. */
  33993. constructor(scene: Scene);
  33994. /**
  33995. * Get the number of data values you will have to play with for the visualization
  33996. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33997. * @returns a number
  33998. */
  33999. getFrequencyBinCount(): number;
  34000. /**
  34001. * Gets the current frequency data as a byte array
  34002. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  34003. * @returns a Uint8Array
  34004. */
  34005. getByteFrequencyData(): Uint8Array;
  34006. /**
  34007. * Gets the current waveform as a byte array
  34008. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  34009. * @returns a Uint8Array
  34010. */
  34011. getByteTimeDomainData(): Uint8Array;
  34012. /**
  34013. * Gets the current frequency data as a float array
  34014. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  34015. * @returns a Float32Array
  34016. */
  34017. getFloatFrequencyData(): Float32Array;
  34018. /**
  34019. * Renders the debug canvas
  34020. */
  34021. drawDebugCanvas(): void;
  34022. /**
  34023. * Stops rendering the debug canvas and removes it
  34024. */
  34025. stopDebugCanvas(): void;
  34026. /**
  34027. * Connects two audio nodes
  34028. * @param inputAudioNode defines first node to connect
  34029. * @param outputAudioNode defines second node to connect
  34030. */
  34031. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  34032. /**
  34033. * Releases all associated resources
  34034. */
  34035. dispose(): void;
  34036. }
  34037. }
  34038. declare module "babylonjs/Audio/audioEngine" {
  34039. import { IDisposable } from "babylonjs/scene";
  34040. import { Analyser } from "babylonjs/Audio/analyser";
  34041. import { Nullable } from "babylonjs/types";
  34042. import { Observable } from "babylonjs/Misc/observable";
  34043. /**
  34044. * This represents an audio engine and it is responsible
  34045. * to play, synchronize and analyse sounds throughout the application.
  34046. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34047. */
  34048. export interface IAudioEngine extends IDisposable {
  34049. /**
  34050. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  34051. */
  34052. readonly canUseWebAudio: boolean;
  34053. /**
  34054. * Gets the current AudioContext if available.
  34055. */
  34056. readonly audioContext: Nullable<AudioContext>;
  34057. /**
  34058. * The master gain node defines the global audio volume of your audio engine.
  34059. */
  34060. readonly masterGain: GainNode;
  34061. /**
  34062. * Gets whether or not mp3 are supported by your browser.
  34063. */
  34064. readonly isMP3supported: boolean;
  34065. /**
  34066. * Gets whether or not ogg are supported by your browser.
  34067. */
  34068. readonly isOGGsupported: boolean;
  34069. /**
  34070. * Defines if Babylon should emit a warning if WebAudio is not supported.
  34071. * @ignoreNaming
  34072. */
  34073. WarnedWebAudioUnsupported: boolean;
  34074. /**
  34075. * Defines if the audio engine relies on a custom unlocked button.
  34076. * In this case, the embedded button will not be displayed.
  34077. */
  34078. useCustomUnlockedButton: boolean;
  34079. /**
  34080. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  34081. */
  34082. readonly unlocked: boolean;
  34083. /**
  34084. * Event raised when audio has been unlocked on the browser.
  34085. */
  34086. onAudioUnlockedObservable: Observable<AudioEngine>;
  34087. /**
  34088. * Event raised when audio has been locked on the browser.
  34089. */
  34090. onAudioLockedObservable: Observable<AudioEngine>;
  34091. /**
  34092. * Flags the audio engine in Locked state.
  34093. * This happens due to new browser policies preventing audio to autoplay.
  34094. */
  34095. lock(): void;
  34096. /**
  34097. * Unlocks the audio engine once a user action has been done on the dom.
  34098. * This is helpful to resume play once browser policies have been satisfied.
  34099. */
  34100. unlock(): void;
  34101. /**
  34102. * Gets the global volume sets on the master gain.
  34103. * @returns the global volume if set or -1 otherwise
  34104. */
  34105. getGlobalVolume(): number;
  34106. /**
  34107. * Sets the global volume of your experience (sets on the master gain).
  34108. * @param newVolume Defines the new global volume of the application
  34109. */
  34110. setGlobalVolume(newVolume: number): void;
  34111. /**
  34112. * Connect the audio engine to an audio analyser allowing some amazing
  34113. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34114. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34115. * @param analyser The analyser to connect to the engine
  34116. */
  34117. connectToAnalyser(analyser: Analyser): void;
  34118. }
  34119. /**
  34120. * This represents the default audio engine used in babylon.
  34121. * It is responsible to play, synchronize and analyse sounds throughout the application.
  34122. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34123. */
  34124. export class AudioEngine implements IAudioEngine {
  34125. private _audioContext;
  34126. private _audioContextInitialized;
  34127. private _muteButton;
  34128. private _hostElement;
  34129. /**
  34130. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  34131. */
  34132. canUseWebAudio: boolean;
  34133. /**
  34134. * The master gain node defines the global audio volume of your audio engine.
  34135. */
  34136. masterGain: GainNode;
  34137. /**
  34138. * Defines if Babylon should emit a warning if WebAudio is not supported.
  34139. * @ignoreNaming
  34140. */
  34141. WarnedWebAudioUnsupported: boolean;
  34142. /**
  34143. * Gets whether or not mp3 are supported by your browser.
  34144. */
  34145. isMP3supported: boolean;
  34146. /**
  34147. * Gets whether or not ogg are supported by your browser.
  34148. */
  34149. isOGGsupported: boolean;
  34150. /**
  34151. * Gets whether audio has been unlocked on the device.
  34152. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  34153. * a user interaction has happened.
  34154. */
  34155. unlocked: boolean;
  34156. /**
  34157. * Defines if the audio engine relies on a custom unlocked button.
  34158. * In this case, the embedded button will not be displayed.
  34159. */
  34160. useCustomUnlockedButton: boolean;
  34161. /**
  34162. * Event raised when audio has been unlocked on the browser.
  34163. */
  34164. onAudioUnlockedObservable: Observable<AudioEngine>;
  34165. /**
  34166. * Event raised when audio has been locked on the browser.
  34167. */
  34168. onAudioLockedObservable: Observable<AudioEngine>;
  34169. /**
  34170. * Gets the current AudioContext if available.
  34171. */
  34172. get audioContext(): Nullable<AudioContext>;
  34173. private _connectedAnalyser;
  34174. /**
  34175. * Instantiates a new audio engine.
  34176. *
  34177. * There should be only one per page as some browsers restrict the number
  34178. * of audio contexts you can create.
  34179. * @param hostElement defines the host element where to display the mute icon if necessary
  34180. */
  34181. constructor(hostElement?: Nullable<HTMLElement>);
  34182. /**
  34183. * Flags the audio engine in Locked state.
  34184. * This happens due to new browser policies preventing audio to autoplay.
  34185. */
  34186. lock(): void;
  34187. /**
  34188. * Unlocks the audio engine once a user action has been done on the dom.
  34189. * This is helpful to resume play once browser policies have been satisfied.
  34190. */
  34191. unlock(): void;
  34192. private _resumeAudioContext;
  34193. private _initializeAudioContext;
  34194. private _tryToRun;
  34195. private _triggerRunningState;
  34196. private _triggerSuspendedState;
  34197. private _displayMuteButton;
  34198. private _moveButtonToTopLeft;
  34199. private _onResize;
  34200. private _hideMuteButton;
  34201. /**
  34202. * Destroy and release the resources associated with the audio ccontext.
  34203. */
  34204. dispose(): void;
  34205. /**
  34206. * Gets the global volume sets on the master gain.
  34207. * @returns the global volume if set or -1 otherwise
  34208. */
  34209. getGlobalVolume(): number;
  34210. /**
  34211. * Sets the global volume of your experience (sets on the master gain).
  34212. * @param newVolume Defines the new global volume of the application
  34213. */
  34214. setGlobalVolume(newVolume: number): void;
  34215. /**
  34216. * Connect the audio engine to an audio analyser allowing some amazing
  34217. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34218. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34219. * @param analyser The analyser to connect to the engine
  34220. */
  34221. connectToAnalyser(analyser: Analyser): void;
  34222. }
  34223. }
  34224. declare module "babylonjs/Loading/loadingScreen" {
  34225. /**
  34226. * Interface used to present a loading screen while loading a scene
  34227. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34228. */
  34229. export interface ILoadingScreen {
  34230. /**
  34231. * Function called to display the loading screen
  34232. */
  34233. displayLoadingUI: () => void;
  34234. /**
  34235. * Function called to hide the loading screen
  34236. */
  34237. hideLoadingUI: () => void;
  34238. /**
  34239. * Gets or sets the color to use for the background
  34240. */
  34241. loadingUIBackgroundColor: string;
  34242. /**
  34243. * Gets or sets the text to display while loading
  34244. */
  34245. loadingUIText: string;
  34246. }
  34247. /**
  34248. * Class used for the default loading screen
  34249. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34250. */
  34251. export class DefaultLoadingScreen implements ILoadingScreen {
  34252. private _renderingCanvas;
  34253. private _loadingText;
  34254. private _loadingDivBackgroundColor;
  34255. private _loadingDiv;
  34256. private _loadingTextDiv;
  34257. /** Gets or sets the logo url to use for the default loading screen */
  34258. static DefaultLogoUrl: string;
  34259. /** Gets or sets the spinner url to use for the default loading screen */
  34260. static DefaultSpinnerUrl: string;
  34261. /**
  34262. * Creates a new default loading screen
  34263. * @param _renderingCanvas defines the canvas used to render the scene
  34264. * @param _loadingText defines the default text to display
  34265. * @param _loadingDivBackgroundColor defines the default background color
  34266. */
  34267. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  34268. /**
  34269. * Function called to display the loading screen
  34270. */
  34271. displayLoadingUI(): void;
  34272. /**
  34273. * Function called to hide the loading screen
  34274. */
  34275. hideLoadingUI(): void;
  34276. /**
  34277. * Gets or sets the text to display while loading
  34278. */
  34279. set loadingUIText(text: string);
  34280. get loadingUIText(): string;
  34281. /**
  34282. * Gets or sets the color to use for the background
  34283. */
  34284. get loadingUIBackgroundColor(): string;
  34285. set loadingUIBackgroundColor(color: string);
  34286. private _resizeLoadingUI;
  34287. }
  34288. }
  34289. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  34290. /**
  34291. * Interface for any object that can request an animation frame
  34292. */
  34293. export interface ICustomAnimationFrameRequester {
  34294. /**
  34295. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  34296. */
  34297. renderFunction?: Function;
  34298. /**
  34299. * Called to request the next frame to render to
  34300. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  34301. */
  34302. requestAnimationFrame: Function;
  34303. /**
  34304. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  34305. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  34306. */
  34307. requestID?: number;
  34308. }
  34309. }
  34310. declare module "babylonjs/Misc/performanceMonitor" {
  34311. /**
  34312. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  34313. */
  34314. export class PerformanceMonitor {
  34315. private _enabled;
  34316. private _rollingFrameTime;
  34317. private _lastFrameTimeMs;
  34318. /**
  34319. * constructor
  34320. * @param frameSampleSize The number of samples required to saturate the sliding window
  34321. */
  34322. constructor(frameSampleSize?: number);
  34323. /**
  34324. * Samples current frame
  34325. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  34326. */
  34327. sampleFrame(timeMs?: number): void;
  34328. /**
  34329. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  34330. */
  34331. get averageFrameTime(): number;
  34332. /**
  34333. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  34334. */
  34335. get averageFrameTimeVariance(): number;
  34336. /**
  34337. * Returns the frame time of the most recent frame
  34338. */
  34339. get instantaneousFrameTime(): number;
  34340. /**
  34341. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  34342. */
  34343. get averageFPS(): number;
  34344. /**
  34345. * Returns the average framerate in frames per second using the most recent frame time
  34346. */
  34347. get instantaneousFPS(): number;
  34348. /**
  34349. * Returns true if enough samples have been taken to completely fill the sliding window
  34350. */
  34351. get isSaturated(): boolean;
  34352. /**
  34353. * Enables contributions to the sliding window sample set
  34354. */
  34355. enable(): void;
  34356. /**
  34357. * Disables contributions to the sliding window sample set
  34358. * Samples will not be interpolated over the disabled period
  34359. */
  34360. disable(): void;
  34361. /**
  34362. * Returns true if sampling is enabled
  34363. */
  34364. get isEnabled(): boolean;
  34365. /**
  34366. * Resets performance monitor
  34367. */
  34368. reset(): void;
  34369. }
  34370. /**
  34371. * RollingAverage
  34372. *
  34373. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  34374. */
  34375. export class RollingAverage {
  34376. /**
  34377. * Current average
  34378. */
  34379. average: number;
  34380. /**
  34381. * Current variance
  34382. */
  34383. variance: number;
  34384. protected _samples: Array<number>;
  34385. protected _sampleCount: number;
  34386. protected _pos: number;
  34387. protected _m2: number;
  34388. /**
  34389. * constructor
  34390. * @param length The number of samples required to saturate the sliding window
  34391. */
  34392. constructor(length: number);
  34393. /**
  34394. * Adds a sample to the sample set
  34395. * @param v The sample value
  34396. */
  34397. add(v: number): void;
  34398. /**
  34399. * Returns previously added values or null if outside of history or outside the sliding window domain
  34400. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  34401. * @return Value previously recorded with add() or null if outside of range
  34402. */
  34403. history(i: number): number;
  34404. /**
  34405. * Returns true if enough samples have been taken to completely fill the sliding window
  34406. * @return true if sample-set saturated
  34407. */
  34408. isSaturated(): boolean;
  34409. /**
  34410. * Resets the rolling average (equivalent to 0 samples taken so far)
  34411. */
  34412. reset(): void;
  34413. /**
  34414. * Wraps a value around the sample range boundaries
  34415. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  34416. * @return Wrapped position in sample range
  34417. */
  34418. protected _wrapPosition(i: number): number;
  34419. }
  34420. }
  34421. declare module "babylonjs/Misc/perfCounter" {
  34422. /**
  34423. * This class is used to track a performance counter which is number based.
  34424. * The user has access to many properties which give statistics of different nature.
  34425. *
  34426. * The implementer can track two kinds of Performance Counter: time and count.
  34427. * 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.
  34428. * 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.
  34429. */
  34430. export class PerfCounter {
  34431. /**
  34432. * Gets or sets a global boolean to turn on and off all the counters
  34433. */
  34434. static Enabled: boolean;
  34435. /**
  34436. * Returns the smallest value ever
  34437. */
  34438. get min(): number;
  34439. /**
  34440. * Returns the biggest value ever
  34441. */
  34442. get max(): number;
  34443. /**
  34444. * Returns the average value since the performance counter is running
  34445. */
  34446. get average(): number;
  34447. /**
  34448. * Returns the average value of the last second the counter was monitored
  34449. */
  34450. get lastSecAverage(): number;
  34451. /**
  34452. * Returns the current value
  34453. */
  34454. get current(): number;
  34455. /**
  34456. * Gets the accumulated total
  34457. */
  34458. get total(): number;
  34459. /**
  34460. * Gets the total value count
  34461. */
  34462. get count(): number;
  34463. /**
  34464. * Creates a new counter
  34465. */
  34466. constructor();
  34467. /**
  34468. * Call this method to start monitoring a new frame.
  34469. * 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.
  34470. */
  34471. fetchNewFrame(): void;
  34472. /**
  34473. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  34474. * @param newCount the count value to add to the monitored count
  34475. * @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.
  34476. */
  34477. addCount(newCount: number, fetchResult: boolean): void;
  34478. /**
  34479. * Start monitoring this performance counter
  34480. */
  34481. beginMonitoring(): void;
  34482. /**
  34483. * Compute the time lapsed since the previous beginMonitoring() call.
  34484. * @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
  34485. */
  34486. endMonitoring(newFrame?: boolean): void;
  34487. private _fetchResult;
  34488. private _startMonitoringTime;
  34489. private _min;
  34490. private _max;
  34491. private _average;
  34492. private _current;
  34493. private _totalValueCount;
  34494. private _totalAccumulated;
  34495. private _lastSecAverage;
  34496. private _lastSecAccumulated;
  34497. private _lastSecTime;
  34498. private _lastSecValueCount;
  34499. }
  34500. }
  34501. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  34502. module "babylonjs/Engines/thinEngine" {
  34503. interface ThinEngine {
  34504. /**
  34505. * Sets alpha constants used by some alpha blending modes
  34506. * @param r defines the red component
  34507. * @param g defines the green component
  34508. * @param b defines the blue component
  34509. * @param a defines the alpha component
  34510. */
  34511. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  34512. /**
  34513. * Sets the current alpha mode
  34514. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  34515. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  34516. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34517. */
  34518. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  34519. /**
  34520. * Gets the current alpha mode
  34521. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34522. * @returns the current alpha mode
  34523. */
  34524. getAlphaMode(): number;
  34525. /**
  34526. * Sets the current alpha equation
  34527. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  34528. */
  34529. setAlphaEquation(equation: number): void;
  34530. /**
  34531. * Gets the current alpha equation.
  34532. * @returns the current alpha equation
  34533. */
  34534. getAlphaEquation(): number;
  34535. }
  34536. }
  34537. }
  34538. declare module "babylonjs/Engines/engine" {
  34539. import { Observable } from "babylonjs/Misc/observable";
  34540. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  34541. import { Scene } from "babylonjs/scene";
  34542. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34543. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  34544. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34545. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  34546. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  34547. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34548. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  34549. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  34550. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  34551. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34552. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  34553. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34554. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34555. import "babylonjs/Engines/Extensions/engine.alpha";
  34556. import { Material } from "babylonjs/Materials/material";
  34557. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34558. /**
  34559. * Defines the interface used by display changed events
  34560. */
  34561. export interface IDisplayChangedEventArgs {
  34562. /** Gets the vrDisplay object (if any) */
  34563. vrDisplay: Nullable<any>;
  34564. /** Gets a boolean indicating if webVR is supported */
  34565. vrSupported: boolean;
  34566. }
  34567. /**
  34568. * Defines the interface used by objects containing a viewport (like a camera)
  34569. */
  34570. interface IViewportOwnerLike {
  34571. /**
  34572. * Gets or sets the viewport
  34573. */
  34574. viewport: IViewportLike;
  34575. }
  34576. /**
  34577. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  34578. */
  34579. export class Engine extends ThinEngine {
  34580. /** Defines that alpha blending is disabled */
  34581. static readonly ALPHA_DISABLE: number;
  34582. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34583. static readonly ALPHA_ADD: number;
  34584. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34585. static readonly ALPHA_COMBINE: number;
  34586. /** Defines that alpha blending to DEST - SRC * DEST */
  34587. static readonly ALPHA_SUBTRACT: number;
  34588. /** Defines that alpha blending to SRC * DEST */
  34589. static readonly ALPHA_MULTIPLY: number;
  34590. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34591. static readonly ALPHA_MAXIMIZED: number;
  34592. /** Defines that alpha blending to SRC + DEST */
  34593. static readonly ALPHA_ONEONE: number;
  34594. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34595. static readonly ALPHA_PREMULTIPLIED: number;
  34596. /**
  34597. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34598. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34599. */
  34600. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  34601. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34602. static readonly ALPHA_INTERPOLATE: number;
  34603. /**
  34604. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34605. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34606. */
  34607. static readonly ALPHA_SCREENMODE: number;
  34608. /** Defines that the ressource is not delayed*/
  34609. static readonly DELAYLOADSTATE_NONE: number;
  34610. /** Defines that the ressource was successfully delay loaded */
  34611. static readonly DELAYLOADSTATE_LOADED: number;
  34612. /** Defines that the ressource is currently delay loading */
  34613. static readonly DELAYLOADSTATE_LOADING: number;
  34614. /** Defines that the ressource is delayed and has not started loading */
  34615. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34616. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34617. static readonly NEVER: number;
  34618. /** 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 */
  34619. static readonly ALWAYS: number;
  34620. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34621. static readonly LESS: number;
  34622. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34623. static readonly EQUAL: number;
  34624. /** 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 */
  34625. static readonly LEQUAL: number;
  34626. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34627. static readonly GREATER: number;
  34628. /** 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 */
  34629. static readonly GEQUAL: number;
  34630. /** 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 */
  34631. static readonly NOTEQUAL: number;
  34632. /** Passed to stencilOperation to specify that stencil value must be kept */
  34633. static readonly KEEP: number;
  34634. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34635. static readonly REPLACE: number;
  34636. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34637. static readonly INCR: number;
  34638. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34639. static readonly DECR: number;
  34640. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34641. static readonly INVERT: number;
  34642. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34643. static readonly INCR_WRAP: number;
  34644. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34645. static readonly DECR_WRAP: number;
  34646. /** Texture is not repeating outside of 0..1 UVs */
  34647. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34648. /** Texture is repeating outside of 0..1 UVs */
  34649. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34650. /** Texture is repeating and mirrored */
  34651. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34652. /** ALPHA */
  34653. static readonly TEXTUREFORMAT_ALPHA: number;
  34654. /** LUMINANCE */
  34655. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34656. /** LUMINANCE_ALPHA */
  34657. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34658. /** RGB */
  34659. static readonly TEXTUREFORMAT_RGB: number;
  34660. /** RGBA */
  34661. static readonly TEXTUREFORMAT_RGBA: number;
  34662. /** RED */
  34663. static readonly TEXTUREFORMAT_RED: number;
  34664. /** RED (2nd reference) */
  34665. static readonly TEXTUREFORMAT_R: number;
  34666. /** RG */
  34667. static readonly TEXTUREFORMAT_RG: number;
  34668. /** RED_INTEGER */
  34669. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34670. /** RED_INTEGER (2nd reference) */
  34671. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34672. /** RG_INTEGER */
  34673. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34674. /** RGB_INTEGER */
  34675. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34676. /** RGBA_INTEGER */
  34677. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34678. /** UNSIGNED_BYTE */
  34679. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34680. /** UNSIGNED_BYTE (2nd reference) */
  34681. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34682. /** FLOAT */
  34683. static readonly TEXTURETYPE_FLOAT: number;
  34684. /** HALF_FLOAT */
  34685. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34686. /** BYTE */
  34687. static readonly TEXTURETYPE_BYTE: number;
  34688. /** SHORT */
  34689. static readonly TEXTURETYPE_SHORT: number;
  34690. /** UNSIGNED_SHORT */
  34691. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34692. /** INT */
  34693. static readonly TEXTURETYPE_INT: number;
  34694. /** UNSIGNED_INT */
  34695. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34696. /** UNSIGNED_SHORT_4_4_4_4 */
  34697. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34698. /** UNSIGNED_SHORT_5_5_5_1 */
  34699. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34700. /** UNSIGNED_SHORT_5_6_5 */
  34701. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34702. /** UNSIGNED_INT_2_10_10_10_REV */
  34703. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34704. /** UNSIGNED_INT_24_8 */
  34705. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34706. /** UNSIGNED_INT_10F_11F_11F_REV */
  34707. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34708. /** UNSIGNED_INT_5_9_9_9_REV */
  34709. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34710. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34711. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34712. /** nearest is mag = nearest and min = nearest and mip = linear */
  34713. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34714. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34715. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34716. /** Trilinear is mag = linear and min = linear and mip = linear */
  34717. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34718. /** nearest is mag = nearest and min = nearest and mip = linear */
  34719. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34720. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34721. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34722. /** Trilinear is mag = linear and min = linear and mip = linear */
  34723. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34724. /** mag = nearest and min = nearest and mip = nearest */
  34725. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34726. /** mag = nearest and min = linear and mip = nearest */
  34727. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34728. /** mag = nearest and min = linear and mip = linear */
  34729. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34730. /** mag = nearest and min = linear and mip = none */
  34731. static readonly TEXTURE_NEAREST_LINEAR: number;
  34732. /** mag = nearest and min = nearest and mip = none */
  34733. static readonly TEXTURE_NEAREST_NEAREST: number;
  34734. /** mag = linear and min = nearest and mip = nearest */
  34735. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34736. /** mag = linear and min = nearest and mip = linear */
  34737. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34738. /** mag = linear and min = linear and mip = none */
  34739. static readonly TEXTURE_LINEAR_LINEAR: number;
  34740. /** mag = linear and min = nearest and mip = none */
  34741. static readonly TEXTURE_LINEAR_NEAREST: number;
  34742. /** Explicit coordinates mode */
  34743. static readonly TEXTURE_EXPLICIT_MODE: number;
  34744. /** Spherical coordinates mode */
  34745. static readonly TEXTURE_SPHERICAL_MODE: number;
  34746. /** Planar coordinates mode */
  34747. static readonly TEXTURE_PLANAR_MODE: number;
  34748. /** Cubic coordinates mode */
  34749. static readonly TEXTURE_CUBIC_MODE: number;
  34750. /** Projection coordinates mode */
  34751. static readonly TEXTURE_PROJECTION_MODE: number;
  34752. /** Skybox coordinates mode */
  34753. static readonly TEXTURE_SKYBOX_MODE: number;
  34754. /** Inverse Cubic coordinates mode */
  34755. static readonly TEXTURE_INVCUBIC_MODE: number;
  34756. /** Equirectangular coordinates mode */
  34757. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34758. /** Equirectangular Fixed coordinates mode */
  34759. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34760. /** Equirectangular Fixed Mirrored coordinates mode */
  34761. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34762. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34763. static readonly SCALEMODE_FLOOR: number;
  34764. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34765. static readonly SCALEMODE_NEAREST: number;
  34766. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34767. static readonly SCALEMODE_CEILING: number;
  34768. /**
  34769. * Returns the current npm package of the sdk
  34770. */
  34771. static get NpmPackage(): string;
  34772. /**
  34773. * Returns the current version of the framework
  34774. */
  34775. static get Version(): string;
  34776. /** Gets the list of created engines */
  34777. static get Instances(): Engine[];
  34778. /**
  34779. * Gets the latest created engine
  34780. */
  34781. static get LastCreatedEngine(): Nullable<Engine>;
  34782. /**
  34783. * Gets the latest created scene
  34784. */
  34785. static get LastCreatedScene(): Nullable<Scene>;
  34786. /**
  34787. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34788. * @param flag defines which part of the materials must be marked as dirty
  34789. * @param predicate defines a predicate used to filter which materials should be affected
  34790. */
  34791. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34792. /**
  34793. * Method called to create the default loading screen.
  34794. * This can be overriden in your own app.
  34795. * @param canvas The rendering canvas element
  34796. * @returns The loading screen
  34797. */
  34798. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34799. /**
  34800. * Method called to create the default rescale post process on each engine.
  34801. */
  34802. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34803. /**
  34804. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34805. **/
  34806. enableOfflineSupport: boolean;
  34807. /**
  34808. * 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)
  34809. **/
  34810. disableManifestCheck: boolean;
  34811. /**
  34812. * Gets the list of created scenes
  34813. */
  34814. scenes: Scene[];
  34815. /**
  34816. * Event raised when a new scene is created
  34817. */
  34818. onNewSceneAddedObservable: Observable<Scene>;
  34819. /**
  34820. * Gets the list of created postprocesses
  34821. */
  34822. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34823. /**
  34824. * Gets a boolean indicating if the pointer is currently locked
  34825. */
  34826. isPointerLock: boolean;
  34827. /**
  34828. * Observable event triggered each time the rendering canvas is resized
  34829. */
  34830. onResizeObservable: Observable<Engine>;
  34831. /**
  34832. * Observable event triggered each time the canvas loses focus
  34833. */
  34834. onCanvasBlurObservable: Observable<Engine>;
  34835. /**
  34836. * Observable event triggered each time the canvas gains focus
  34837. */
  34838. onCanvasFocusObservable: Observable<Engine>;
  34839. /**
  34840. * Observable event triggered each time the canvas receives pointerout event
  34841. */
  34842. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34843. /**
  34844. * Observable raised when the engine begins a new frame
  34845. */
  34846. onBeginFrameObservable: Observable<Engine>;
  34847. /**
  34848. * If set, will be used to request the next animation frame for the render loop
  34849. */
  34850. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34851. /**
  34852. * Observable raised when the engine ends the current frame
  34853. */
  34854. onEndFrameObservable: Observable<Engine>;
  34855. /**
  34856. * Observable raised when the engine is about to compile a shader
  34857. */
  34858. onBeforeShaderCompilationObservable: Observable<Engine>;
  34859. /**
  34860. * Observable raised when the engine has jsut compiled a shader
  34861. */
  34862. onAfterShaderCompilationObservable: Observable<Engine>;
  34863. /**
  34864. * Gets the audio engine
  34865. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34866. * @ignorenaming
  34867. */
  34868. static audioEngine: IAudioEngine;
  34869. /**
  34870. * Default AudioEngine factory responsible of creating the Audio Engine.
  34871. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34872. */
  34873. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34874. /**
  34875. * Default offline support factory responsible of creating a tool used to store data locally.
  34876. * By default, this will create a Database object if the workload has been embedded.
  34877. */
  34878. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34879. private _loadingScreen;
  34880. private _pointerLockRequested;
  34881. private _dummyFramebuffer;
  34882. private _rescalePostProcess;
  34883. private _deterministicLockstep;
  34884. private _lockstepMaxSteps;
  34885. private _timeStep;
  34886. protected get _supportsHardwareTextureRescaling(): boolean;
  34887. private _fps;
  34888. private _deltaTime;
  34889. /** @hidden */
  34890. _drawCalls: PerfCounter;
  34891. /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
  34892. canvasTabIndex: number;
  34893. /**
  34894. * Turn this value on if you want to pause FPS computation when in background
  34895. */
  34896. disablePerformanceMonitorInBackground: boolean;
  34897. private _performanceMonitor;
  34898. /**
  34899. * Gets the performance monitor attached to this engine
  34900. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34901. */
  34902. get performanceMonitor(): PerformanceMonitor;
  34903. private _onFocus;
  34904. private _onBlur;
  34905. private _onCanvasPointerOut;
  34906. private _onCanvasBlur;
  34907. private _onCanvasFocus;
  34908. private _onFullscreenChange;
  34909. private _onPointerLockChange;
  34910. /**
  34911. * Gets the HTML element used to attach event listeners
  34912. * @returns a HTML element
  34913. */
  34914. getInputElement(): Nullable<HTMLElement>;
  34915. /**
  34916. * Creates a new engine
  34917. * @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
  34918. * @param antialias defines enable antialiasing (default: false)
  34919. * @param options defines further options to be sent to the getContext() function
  34920. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34921. */
  34922. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34923. /**
  34924. * Gets current aspect ratio
  34925. * @param viewportOwner defines the camera to use to get the aspect ratio
  34926. * @param useScreen defines if screen size must be used (or the current render target if any)
  34927. * @returns a number defining the aspect ratio
  34928. */
  34929. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34930. /**
  34931. * Gets current screen aspect ratio
  34932. * @returns a number defining the aspect ratio
  34933. */
  34934. getScreenAspectRatio(): number;
  34935. /**
  34936. * Gets the client rect of the HTML canvas attached with the current webGL context
  34937. * @returns a client rectanglee
  34938. */
  34939. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34940. /**
  34941. * Gets the client rect of the HTML element used for events
  34942. * @returns a client rectanglee
  34943. */
  34944. getInputElementClientRect(): Nullable<ClientRect>;
  34945. /**
  34946. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34947. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34948. * @returns true if engine is in deterministic lock step mode
  34949. */
  34950. isDeterministicLockStep(): boolean;
  34951. /**
  34952. * Gets the max steps when engine is running in deterministic lock step
  34953. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34954. * @returns the max steps
  34955. */
  34956. getLockstepMaxSteps(): number;
  34957. /**
  34958. * Returns the time in ms between steps when using deterministic lock step.
  34959. * @returns time step in (ms)
  34960. */
  34961. getTimeStep(): number;
  34962. /**
  34963. * Force the mipmap generation for the given render target texture
  34964. * @param texture defines the render target texture to use
  34965. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34966. */
  34967. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34968. /** States */
  34969. /**
  34970. * Set various states to the webGL context
  34971. * @param culling defines backface culling state
  34972. * @param zOffset defines the value to apply to zOffset (0 by default)
  34973. * @param force defines if states must be applied even if cache is up to date
  34974. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34975. */
  34976. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34977. /**
  34978. * Set the z offset to apply to current rendering
  34979. * @param value defines the offset to apply
  34980. */
  34981. setZOffset(value: number): void;
  34982. /**
  34983. * Gets the current value of the zOffset
  34984. * @returns the current zOffset state
  34985. */
  34986. getZOffset(): number;
  34987. /**
  34988. * Enable or disable depth buffering
  34989. * @param enable defines the state to set
  34990. */
  34991. setDepthBuffer(enable: boolean): void;
  34992. /**
  34993. * Gets a boolean indicating if depth writing is enabled
  34994. * @returns the current depth writing state
  34995. */
  34996. getDepthWrite(): boolean;
  34997. /**
  34998. * Enable or disable depth writing
  34999. * @param enable defines the state to set
  35000. */
  35001. setDepthWrite(enable: boolean): void;
  35002. /**
  35003. * Gets a boolean indicating if stencil buffer is enabled
  35004. * @returns the current stencil buffer state
  35005. */
  35006. getStencilBuffer(): boolean;
  35007. /**
  35008. * Enable or disable the stencil buffer
  35009. * @param enable defines if the stencil buffer must be enabled or disabled
  35010. */
  35011. setStencilBuffer(enable: boolean): void;
  35012. /**
  35013. * Gets the current stencil mask
  35014. * @returns a number defining the new stencil mask to use
  35015. */
  35016. getStencilMask(): number;
  35017. /**
  35018. * Sets the current stencil mask
  35019. * @param mask defines the new stencil mask to use
  35020. */
  35021. setStencilMask(mask: number): void;
  35022. /**
  35023. * Gets the current stencil function
  35024. * @returns a number defining the stencil function to use
  35025. */
  35026. getStencilFunction(): number;
  35027. /**
  35028. * Gets the current stencil reference value
  35029. * @returns a number defining the stencil reference value to use
  35030. */
  35031. getStencilFunctionReference(): number;
  35032. /**
  35033. * Gets the current stencil mask
  35034. * @returns a number defining the stencil mask to use
  35035. */
  35036. getStencilFunctionMask(): number;
  35037. /**
  35038. * Sets the current stencil function
  35039. * @param stencilFunc defines the new stencil function to use
  35040. */
  35041. setStencilFunction(stencilFunc: number): void;
  35042. /**
  35043. * Sets the current stencil reference
  35044. * @param reference defines the new stencil reference to use
  35045. */
  35046. setStencilFunctionReference(reference: number): void;
  35047. /**
  35048. * Sets the current stencil mask
  35049. * @param mask defines the new stencil mask to use
  35050. */
  35051. setStencilFunctionMask(mask: number): void;
  35052. /**
  35053. * Gets the current stencil operation when stencil fails
  35054. * @returns a number defining stencil operation to use when stencil fails
  35055. */
  35056. getStencilOperationFail(): number;
  35057. /**
  35058. * Gets the current stencil operation when depth fails
  35059. * @returns a number defining stencil operation to use when depth fails
  35060. */
  35061. getStencilOperationDepthFail(): number;
  35062. /**
  35063. * Gets the current stencil operation when stencil passes
  35064. * @returns a number defining stencil operation to use when stencil passes
  35065. */
  35066. getStencilOperationPass(): number;
  35067. /**
  35068. * Sets the stencil operation to use when stencil fails
  35069. * @param operation defines the stencil operation to use when stencil fails
  35070. */
  35071. setStencilOperationFail(operation: number): void;
  35072. /**
  35073. * Sets the stencil operation to use when depth fails
  35074. * @param operation defines the stencil operation to use when depth fails
  35075. */
  35076. setStencilOperationDepthFail(operation: number): void;
  35077. /**
  35078. * Sets the stencil operation to use when stencil passes
  35079. * @param operation defines the stencil operation to use when stencil passes
  35080. */
  35081. setStencilOperationPass(operation: number): void;
  35082. /**
  35083. * Sets a boolean indicating if the dithering state is enabled or disabled
  35084. * @param value defines the dithering state
  35085. */
  35086. setDitheringState(value: boolean): void;
  35087. /**
  35088. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  35089. * @param value defines the rasterizer state
  35090. */
  35091. setRasterizerState(value: boolean): void;
  35092. /**
  35093. * Gets the current depth function
  35094. * @returns a number defining the depth function
  35095. */
  35096. getDepthFunction(): Nullable<number>;
  35097. /**
  35098. * Sets the current depth function
  35099. * @param depthFunc defines the function to use
  35100. */
  35101. setDepthFunction(depthFunc: number): void;
  35102. /**
  35103. * Sets the current depth function to GREATER
  35104. */
  35105. setDepthFunctionToGreater(): void;
  35106. /**
  35107. * Sets the current depth function to GEQUAL
  35108. */
  35109. setDepthFunctionToGreaterOrEqual(): void;
  35110. /**
  35111. * Sets the current depth function to LESS
  35112. */
  35113. setDepthFunctionToLess(): void;
  35114. /**
  35115. * Sets the current depth function to LEQUAL
  35116. */
  35117. setDepthFunctionToLessOrEqual(): void;
  35118. private _cachedStencilBuffer;
  35119. private _cachedStencilFunction;
  35120. private _cachedStencilMask;
  35121. private _cachedStencilOperationPass;
  35122. private _cachedStencilOperationFail;
  35123. private _cachedStencilOperationDepthFail;
  35124. private _cachedStencilReference;
  35125. /**
  35126. * Caches the the state of the stencil buffer
  35127. */
  35128. cacheStencilState(): void;
  35129. /**
  35130. * Restores the state of the stencil buffer
  35131. */
  35132. restoreStencilState(): void;
  35133. /**
  35134. * Directly set the WebGL Viewport
  35135. * @param x defines the x coordinate of the viewport (in screen space)
  35136. * @param y defines the y coordinate of the viewport (in screen space)
  35137. * @param width defines the width of the viewport (in screen space)
  35138. * @param height defines the height of the viewport (in screen space)
  35139. * @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
  35140. */
  35141. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  35142. /**
  35143. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  35144. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  35145. * @param y defines the y-coordinate of the corner of the clear rectangle
  35146. * @param width defines the width of the clear rectangle
  35147. * @param height defines the height of the clear rectangle
  35148. * @param clearColor defines the clear color
  35149. */
  35150. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  35151. /**
  35152. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  35153. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  35154. * @param y defines the y-coordinate of the corner of the clear rectangle
  35155. * @param width defines the width of the clear rectangle
  35156. * @param height defines the height of the clear rectangle
  35157. */
  35158. enableScissor(x: number, y: number, width: number, height: number): void;
  35159. /**
  35160. * Disable previously set scissor test rectangle
  35161. */
  35162. disableScissor(): void;
  35163. protected _reportDrawCall(): void;
  35164. /**
  35165. * Initializes a webVR display and starts listening to display change events
  35166. * The onVRDisplayChangedObservable will be notified upon these changes
  35167. * @returns The onVRDisplayChangedObservable
  35168. */
  35169. initWebVR(): Observable<IDisplayChangedEventArgs>;
  35170. /** @hidden */
  35171. _prepareVRComponent(): void;
  35172. /** @hidden */
  35173. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  35174. /** @hidden */
  35175. _submitVRFrame(): void;
  35176. /**
  35177. * Call this function to leave webVR mode
  35178. * Will do nothing if webVR is not supported or if there is no webVR device
  35179. * @see http://doc.babylonjs.com/how_to/webvr_camera
  35180. */
  35181. disableVR(): void;
  35182. /**
  35183. * Gets a boolean indicating that the system is in VR mode and is presenting
  35184. * @returns true if VR mode is engaged
  35185. */
  35186. isVRPresenting(): boolean;
  35187. /** @hidden */
  35188. _requestVRFrame(): void;
  35189. /** @hidden */
  35190. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35191. /**
  35192. * Gets the source code of the vertex shader associated with a specific webGL program
  35193. * @param program defines the program to use
  35194. * @returns a string containing the source code of the vertex shader associated with the program
  35195. */
  35196. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  35197. /**
  35198. * Gets the source code of the fragment shader associated with a specific webGL program
  35199. * @param program defines the program to use
  35200. * @returns a string containing the source code of the fragment shader associated with the program
  35201. */
  35202. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  35203. /**
  35204. * Sets a depth stencil texture from a render target to the according uniform.
  35205. * @param channel The texture channel
  35206. * @param uniform The uniform to set
  35207. * @param texture The render target texture containing the depth stencil texture to apply
  35208. */
  35209. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  35210. /**
  35211. * Sets a texture to the webGL context from a postprocess
  35212. * @param channel defines the channel to use
  35213. * @param postProcess defines the source postprocess
  35214. */
  35215. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  35216. /**
  35217. * Binds the output of the passed in post process to the texture channel specified
  35218. * @param channel The channel the texture should be bound to
  35219. * @param postProcess The post process which's output should be bound
  35220. */
  35221. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  35222. protected _rebuildBuffers(): void;
  35223. /** @hidden */
  35224. _renderFrame(): void;
  35225. _renderLoop(): void;
  35226. /** @hidden */
  35227. _renderViews(): boolean;
  35228. /**
  35229. * Toggle full screen mode
  35230. * @param requestPointerLock defines if a pointer lock should be requested from the user
  35231. */
  35232. switchFullscreen(requestPointerLock: boolean): void;
  35233. /**
  35234. * Enters full screen mode
  35235. * @param requestPointerLock defines if a pointer lock should be requested from the user
  35236. */
  35237. enterFullscreen(requestPointerLock: boolean): void;
  35238. /**
  35239. * Exits full screen mode
  35240. */
  35241. exitFullscreen(): void;
  35242. /**
  35243. * Enters Pointerlock mode
  35244. */
  35245. enterPointerlock(): void;
  35246. /**
  35247. * Exits Pointerlock mode
  35248. */
  35249. exitPointerlock(): void;
  35250. /**
  35251. * Begin a new frame
  35252. */
  35253. beginFrame(): void;
  35254. /**
  35255. * Enf the current frame
  35256. */
  35257. endFrame(): void;
  35258. resize(): void;
  35259. /**
  35260. * Force a specific size of the canvas
  35261. * @param width defines the new canvas' width
  35262. * @param height defines the new canvas' height
  35263. */
  35264. setSize(width: number, height: number): void;
  35265. /**
  35266. * Updates a dynamic vertex buffer.
  35267. * @param vertexBuffer the vertex buffer to update
  35268. * @param data the data used to update the vertex buffer
  35269. * @param byteOffset the byte offset of the data
  35270. * @param byteLength the byte length of the data
  35271. */
  35272. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  35273. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35274. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35275. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35276. _releaseTexture(texture: InternalTexture): void;
  35277. /**
  35278. * @hidden
  35279. * Rescales a texture
  35280. * @param source input texutre
  35281. * @param destination destination texture
  35282. * @param scene scene to use to render the resize
  35283. * @param internalFormat format to use when resizing
  35284. * @param onComplete callback to be called when resize has completed
  35285. */
  35286. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  35287. /**
  35288. * Gets the current framerate
  35289. * @returns a number representing the framerate
  35290. */
  35291. getFps(): number;
  35292. /**
  35293. * Gets the time spent between current and previous frame
  35294. * @returns a number representing the delta time in ms
  35295. */
  35296. getDeltaTime(): number;
  35297. private _measureFps;
  35298. /** @hidden */
  35299. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  35300. /**
  35301. * Update a dynamic index buffer
  35302. * @param indexBuffer defines the target index buffer
  35303. * @param indices defines the data to update
  35304. * @param offset defines the offset in the target index buffer where update should start
  35305. */
  35306. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  35307. /**
  35308. * Updates the sample count of a render target texture
  35309. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  35310. * @param texture defines the texture to update
  35311. * @param samples defines the sample count to set
  35312. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  35313. */
  35314. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  35315. /**
  35316. * Updates a depth texture Comparison Mode and Function.
  35317. * If the comparison Function is equal to 0, the mode will be set to none.
  35318. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  35319. * @param texture The texture to set the comparison function for
  35320. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  35321. */
  35322. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  35323. /**
  35324. * Creates a webGL buffer to use with instanciation
  35325. * @param capacity defines the size of the buffer
  35326. * @returns the webGL buffer
  35327. */
  35328. createInstancesBuffer(capacity: number): DataBuffer;
  35329. /**
  35330. * Delete a webGL buffer used with instanciation
  35331. * @param buffer defines the webGL buffer to delete
  35332. */
  35333. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  35334. private _clientWaitAsync;
  35335. /** @hidden */
  35336. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  35337. /** @hidden */
  35338. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  35339. dispose(): void;
  35340. private _disableTouchAction;
  35341. /**
  35342. * Display the loading screen
  35343. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35344. */
  35345. displayLoadingUI(): void;
  35346. /**
  35347. * Hide the loading screen
  35348. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35349. */
  35350. hideLoadingUI(): void;
  35351. /**
  35352. * Gets the current loading screen object
  35353. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35354. */
  35355. get loadingScreen(): ILoadingScreen;
  35356. /**
  35357. * Sets the current loading screen object
  35358. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35359. */
  35360. set loadingScreen(loadingScreen: ILoadingScreen);
  35361. /**
  35362. * Sets the current loading screen text
  35363. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35364. */
  35365. set loadingUIText(text: string);
  35366. /**
  35367. * Sets the current loading screen background color
  35368. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35369. */
  35370. set loadingUIBackgroundColor(color: string);
  35371. /** Pointerlock and fullscreen */
  35372. /**
  35373. * Ask the browser to promote the current element to pointerlock mode
  35374. * @param element defines the DOM element to promote
  35375. */
  35376. static _RequestPointerlock(element: HTMLElement): void;
  35377. /**
  35378. * Asks the browser to exit pointerlock mode
  35379. */
  35380. static _ExitPointerlock(): void;
  35381. /**
  35382. * Ask the browser to promote the current element to fullscreen rendering mode
  35383. * @param element defines the DOM element to promote
  35384. */
  35385. static _RequestFullscreen(element: HTMLElement): void;
  35386. /**
  35387. * Asks the browser to exit fullscreen mode
  35388. */
  35389. static _ExitFullscreen(): void;
  35390. }
  35391. }
  35392. declare module "babylonjs/Engines/engineStore" {
  35393. import { Nullable } from "babylonjs/types";
  35394. import { Engine } from "babylonjs/Engines/engine";
  35395. import { Scene } from "babylonjs/scene";
  35396. /**
  35397. * The engine store class is responsible to hold all the instances of Engine and Scene created
  35398. * during the life time of the application.
  35399. */
  35400. export class EngineStore {
  35401. /** Gets the list of created engines */
  35402. static Instances: import("babylonjs/Engines/engine").Engine[];
  35403. /** @hidden */
  35404. static _LastCreatedScene: Nullable<Scene>;
  35405. /**
  35406. * Gets the latest created engine
  35407. */
  35408. static get LastCreatedEngine(): Nullable<Engine>;
  35409. /**
  35410. * Gets the latest created scene
  35411. */
  35412. static get LastCreatedScene(): Nullable<Scene>;
  35413. /**
  35414. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35415. * @ignorenaming
  35416. */
  35417. static UseFallbackTexture: boolean;
  35418. /**
  35419. * Texture content used if a texture cannot loaded
  35420. * @ignorenaming
  35421. */
  35422. static FallbackTexture: string;
  35423. }
  35424. }
  35425. declare module "babylonjs/Misc/promise" {
  35426. /**
  35427. * Helper class that provides a small promise polyfill
  35428. */
  35429. export class PromisePolyfill {
  35430. /**
  35431. * Static function used to check if the polyfill is required
  35432. * If this is the case then the function will inject the polyfill to window.Promise
  35433. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  35434. */
  35435. static Apply(force?: boolean): void;
  35436. }
  35437. }
  35438. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  35439. /**
  35440. * Interface for screenshot methods with describe argument called `size` as object with options
  35441. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  35442. */
  35443. export interface IScreenshotSize {
  35444. /**
  35445. * number in pixels for canvas height
  35446. */
  35447. height?: number;
  35448. /**
  35449. * multiplier allowing render at a higher or lower resolution
  35450. * If value is defined then height and width will be ignored and taken from camera
  35451. */
  35452. precision?: number;
  35453. /**
  35454. * number in pixels for canvas width
  35455. */
  35456. width?: number;
  35457. }
  35458. }
  35459. declare module "babylonjs/Misc/tools" {
  35460. import { Nullable, float } from "babylonjs/types";
  35461. import { DomManagement } from "babylonjs/Misc/domManagement";
  35462. import { WebRequest } from "babylonjs/Misc/webRequest";
  35463. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35464. import { ReadFileError } from "babylonjs/Misc/fileTools";
  35465. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35466. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  35467. import { Camera } from "babylonjs/Cameras/camera";
  35468. import { Engine } from "babylonjs/Engines/engine";
  35469. interface IColor4Like {
  35470. r: float;
  35471. g: float;
  35472. b: float;
  35473. a: float;
  35474. }
  35475. /**
  35476. * Class containing a set of static utilities functions
  35477. */
  35478. export class Tools {
  35479. /**
  35480. * Gets or sets the base URL to use to load assets
  35481. */
  35482. static get BaseUrl(): string;
  35483. static set BaseUrl(value: string);
  35484. /**
  35485. * Enable/Disable Custom HTTP Request Headers globally.
  35486. * default = false
  35487. * @see CustomRequestHeaders
  35488. */
  35489. static UseCustomRequestHeaders: boolean;
  35490. /**
  35491. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  35492. * i.e. when loading files, where the server/service expects an Authorization header
  35493. */
  35494. static CustomRequestHeaders: {
  35495. [key: string]: string;
  35496. };
  35497. /**
  35498. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  35499. */
  35500. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  35501. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  35502. /**
  35503. * Default behaviour for cors in the application.
  35504. * It can be a string if the expected behavior is identical in the entire app.
  35505. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  35506. */
  35507. static get CorsBehavior(): string | ((url: string | string[]) => string);
  35508. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  35509. /**
  35510. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35511. * @ignorenaming
  35512. */
  35513. static get UseFallbackTexture(): boolean;
  35514. static set UseFallbackTexture(value: boolean);
  35515. /**
  35516. * Use this object to register external classes like custom textures or material
  35517. * to allow the laoders to instantiate them
  35518. */
  35519. static get RegisteredExternalClasses(): {
  35520. [key: string]: Object;
  35521. };
  35522. static set RegisteredExternalClasses(classes: {
  35523. [key: string]: Object;
  35524. });
  35525. /**
  35526. * Texture content used if a texture cannot loaded
  35527. * @ignorenaming
  35528. */
  35529. static get fallbackTexture(): string;
  35530. static set fallbackTexture(value: string);
  35531. /**
  35532. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  35533. * @param u defines the coordinate on X axis
  35534. * @param v defines the coordinate on Y axis
  35535. * @param width defines the width of the source data
  35536. * @param height defines the height of the source data
  35537. * @param pixels defines the source byte array
  35538. * @param color defines the output color
  35539. */
  35540. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  35541. /**
  35542. * Interpolates between a and b via alpha
  35543. * @param a The lower value (returned when alpha = 0)
  35544. * @param b The upper value (returned when alpha = 1)
  35545. * @param alpha The interpolation-factor
  35546. * @return The mixed value
  35547. */
  35548. static Mix(a: number, b: number, alpha: number): number;
  35549. /**
  35550. * Tries to instantiate a new object from a given class name
  35551. * @param className defines the class name to instantiate
  35552. * @returns the new object or null if the system was not able to do the instantiation
  35553. */
  35554. static Instantiate(className: string): any;
  35555. /**
  35556. * Provides a slice function that will work even on IE
  35557. * @param data defines the array to slice
  35558. * @param start defines the start of the data (optional)
  35559. * @param end defines the end of the data (optional)
  35560. * @returns the new sliced array
  35561. */
  35562. static Slice<T>(data: T, start?: number, end?: number): T;
  35563. /**
  35564. * Polyfill for setImmediate
  35565. * @param action defines the action to execute after the current execution block
  35566. */
  35567. static SetImmediate(action: () => void): void;
  35568. /**
  35569. * Function indicating if a number is an exponent of 2
  35570. * @param value defines the value to test
  35571. * @returns true if the value is an exponent of 2
  35572. */
  35573. static IsExponentOfTwo(value: number): boolean;
  35574. private static _tmpFloatArray;
  35575. /**
  35576. * Returns the nearest 32-bit single precision float representation of a Number
  35577. * @param value A Number. If the parameter is of a different type, it will get converted
  35578. * to a number or to NaN if it cannot be converted
  35579. * @returns number
  35580. */
  35581. static FloatRound(value: number): number;
  35582. /**
  35583. * Extracts the filename from a path
  35584. * @param path defines the path to use
  35585. * @returns the filename
  35586. */
  35587. static GetFilename(path: string): string;
  35588. /**
  35589. * Extracts the "folder" part of a path (everything before the filename).
  35590. * @param uri The URI to extract the info from
  35591. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35592. * @returns The "folder" part of the path
  35593. */
  35594. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35595. /**
  35596. * Extracts text content from a DOM element hierarchy
  35597. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35598. */
  35599. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35600. /**
  35601. * Convert an angle in radians to degrees
  35602. * @param angle defines the angle to convert
  35603. * @returns the angle in degrees
  35604. */
  35605. static ToDegrees(angle: number): number;
  35606. /**
  35607. * Convert an angle in degrees to radians
  35608. * @param angle defines the angle to convert
  35609. * @returns the angle in radians
  35610. */
  35611. static ToRadians(angle: number): number;
  35612. /**
  35613. * Returns an array if obj is not an array
  35614. * @param obj defines the object to evaluate as an array
  35615. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35616. * @returns either obj directly if obj is an array or a new array containing obj
  35617. */
  35618. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35619. /**
  35620. * Gets the pointer prefix to use
  35621. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35622. */
  35623. static GetPointerPrefix(): string;
  35624. /**
  35625. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35626. * @param url define the url we are trying
  35627. * @param element define the dom element where to configure the cors policy
  35628. */
  35629. static SetCorsBehavior(url: string | string[], element: {
  35630. crossOrigin: string | null;
  35631. }): void;
  35632. /**
  35633. * Removes unwanted characters from an url
  35634. * @param url defines the url to clean
  35635. * @returns the cleaned url
  35636. */
  35637. static CleanUrl(url: string): string;
  35638. /**
  35639. * Gets or sets a function used to pre-process url before using them to load assets
  35640. */
  35641. static get PreprocessUrl(): (url: string) => string;
  35642. static set PreprocessUrl(processor: (url: string) => string);
  35643. /**
  35644. * Loads an image as an HTMLImageElement.
  35645. * @param input url string, ArrayBuffer, or Blob to load
  35646. * @param onLoad callback called when the image successfully loads
  35647. * @param onError callback called when the image fails to load
  35648. * @param offlineProvider offline provider for caching
  35649. * @param mimeType optional mime type
  35650. * @returns the HTMLImageElement of the loaded image
  35651. */
  35652. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35653. /**
  35654. * Loads a file from a url
  35655. * @param url url string, ArrayBuffer, or Blob to load
  35656. * @param onSuccess callback called when the file successfully loads
  35657. * @param onProgress callback called while file is loading (if the server supports this mode)
  35658. * @param offlineProvider defines the offline provider for caching
  35659. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35660. * @param onError callback called when the file fails to load
  35661. * @returns a file request object
  35662. */
  35663. 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;
  35664. /**
  35665. * Loads a file from a url
  35666. * @param url the file url to load
  35667. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35668. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35669. */
  35670. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35671. /**
  35672. * Load a script (identified by an url). When the url returns, the
  35673. * content of this file is added into a new script element, attached to the DOM (body element)
  35674. * @param scriptUrl defines the url of the script to laod
  35675. * @param onSuccess defines the callback called when the script is loaded
  35676. * @param onError defines the callback to call if an error occurs
  35677. * @param scriptId defines the id of the script element
  35678. */
  35679. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35680. /**
  35681. * Load an asynchronous script (identified by an url). When the url returns, the
  35682. * content of this file is added into a new script element, attached to the DOM (body element)
  35683. * @param scriptUrl defines the url of the script to laod
  35684. * @param scriptId defines the id of the script element
  35685. * @returns a promise request object
  35686. */
  35687. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35688. /**
  35689. * Loads a file from a blob
  35690. * @param fileToLoad defines the blob to use
  35691. * @param callback defines the callback to call when data is loaded
  35692. * @param progressCallback defines the callback to call during loading process
  35693. * @returns a file request object
  35694. */
  35695. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35696. /**
  35697. * Reads a file from a File object
  35698. * @param file defines the file to load
  35699. * @param onSuccess defines the callback to call when data is loaded
  35700. * @param onProgress defines the callback to call during loading process
  35701. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35702. * @param onError defines the callback to call when an error occurs
  35703. * @returns a file request object
  35704. */
  35705. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35706. /**
  35707. * Creates a data url from a given string content
  35708. * @param content defines the content to convert
  35709. * @returns the new data url link
  35710. */
  35711. static FileAsURL(content: string): string;
  35712. /**
  35713. * Format the given number to a specific decimal format
  35714. * @param value defines the number to format
  35715. * @param decimals defines the number of decimals to use
  35716. * @returns the formatted string
  35717. */
  35718. static Format(value: number, decimals?: number): string;
  35719. /**
  35720. * Tries to copy an object by duplicating every property
  35721. * @param source defines the source object
  35722. * @param destination defines the target object
  35723. * @param doNotCopyList defines a list of properties to avoid
  35724. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35725. */
  35726. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35727. /**
  35728. * Gets a boolean indicating if the given object has no own property
  35729. * @param obj defines the object to test
  35730. * @returns true if object has no own property
  35731. */
  35732. static IsEmpty(obj: any): boolean;
  35733. /**
  35734. * Function used to register events at window level
  35735. * @param windowElement defines the Window object to use
  35736. * @param events defines the events to register
  35737. */
  35738. static RegisterTopRootEvents(windowElement: Window, events: {
  35739. name: string;
  35740. handler: Nullable<(e: FocusEvent) => any>;
  35741. }[]): void;
  35742. /**
  35743. * Function used to unregister events from window level
  35744. * @param windowElement defines the Window object to use
  35745. * @param events defines the events to unregister
  35746. */
  35747. static UnregisterTopRootEvents(windowElement: Window, events: {
  35748. name: string;
  35749. handler: Nullable<(e: FocusEvent) => any>;
  35750. }[]): void;
  35751. /**
  35752. * @ignore
  35753. */
  35754. static _ScreenshotCanvas: HTMLCanvasElement;
  35755. /**
  35756. * Dumps the current bound framebuffer
  35757. * @param width defines the rendering width
  35758. * @param height defines the rendering height
  35759. * @param engine defines the hosting engine
  35760. * @param successCallback defines the callback triggered once the data are available
  35761. * @param mimeType defines the mime type of the result
  35762. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35763. */
  35764. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35765. /**
  35766. * Converts the canvas data to blob.
  35767. * This acts as a polyfill for browsers not supporting the to blob function.
  35768. * @param canvas Defines the canvas to extract the data from
  35769. * @param successCallback Defines the callback triggered once the data are available
  35770. * @param mimeType Defines the mime type of the result
  35771. */
  35772. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35773. /**
  35774. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35775. * @param successCallback defines the callback triggered once the data are available
  35776. * @param mimeType defines the mime type of the result
  35777. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35778. */
  35779. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35780. /**
  35781. * Downloads a blob in the browser
  35782. * @param blob defines the blob to download
  35783. * @param fileName defines the name of the downloaded file
  35784. */
  35785. static Download(blob: Blob, fileName: string): void;
  35786. /**
  35787. * Captures a screenshot of the current rendering
  35788. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35789. * @param engine defines the rendering engine
  35790. * @param camera defines the source camera
  35791. * @param size This parameter can be set to a single number or to an object with the
  35792. * following (optional) properties: precision, width, height. If a single number is passed,
  35793. * it will be used for both width and height. If an object is passed, the screenshot size
  35794. * will be derived from the parameters. The precision property is a multiplier allowing
  35795. * rendering at a higher or lower resolution
  35796. * @param successCallback defines the callback receives a single parameter which contains the
  35797. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35798. * src parameter of an <img> to display it
  35799. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35800. * Check your browser for supported MIME types
  35801. */
  35802. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35803. /**
  35804. * Captures a screenshot of the current rendering
  35805. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35806. * @param engine defines the rendering engine
  35807. * @param camera defines the source camera
  35808. * @param size This parameter can be set to a single number or to an object with the
  35809. * following (optional) properties: precision, width, height. If a single number is passed,
  35810. * it will be used for both width and height. If an object is passed, the screenshot size
  35811. * will be derived from the parameters. The precision property is a multiplier allowing
  35812. * rendering at a higher or lower resolution
  35813. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35814. * Check your browser for supported MIME types
  35815. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35816. * to the src parameter of an <img> to display it
  35817. */
  35818. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35819. /**
  35820. * Generates an image screenshot from the specified camera.
  35821. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35822. * @param engine The engine to use for rendering
  35823. * @param camera The camera to use for rendering
  35824. * @param size This parameter can be set to a single number or to an object with the
  35825. * following (optional) properties: precision, width, height. If a single number is passed,
  35826. * it will be used for both width and height. If an object is passed, the screenshot size
  35827. * will be derived from the parameters. The precision property is a multiplier allowing
  35828. * rendering at a higher or lower resolution
  35829. * @param successCallback The callback receives a single parameter which contains the
  35830. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35831. * src parameter of an <img> to display it
  35832. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35833. * Check your browser for supported MIME types
  35834. * @param samples Texture samples (default: 1)
  35835. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35836. * @param fileName A name for for the downloaded file.
  35837. */
  35838. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35839. /**
  35840. * Generates an image screenshot from the specified camera.
  35841. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35842. * @param engine The engine to use for rendering
  35843. * @param camera The camera to use for rendering
  35844. * @param size This parameter can be set to a single number or to an object with the
  35845. * following (optional) properties: precision, width, height. If a single number is passed,
  35846. * it will be used for both width and height. If an object is passed, the screenshot size
  35847. * will be derived from the parameters. The precision property is a multiplier allowing
  35848. * rendering at a higher or lower resolution
  35849. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35850. * Check your browser for supported MIME types
  35851. * @param samples Texture samples (default: 1)
  35852. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35853. * @param fileName A name for for the downloaded file.
  35854. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35855. * to the src parameter of an <img> to display it
  35856. */
  35857. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35858. /**
  35859. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35860. * Be aware Math.random() could cause collisions, but:
  35861. * "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"
  35862. * @returns a pseudo random id
  35863. */
  35864. static RandomId(): string;
  35865. /**
  35866. * Test if the given uri is a base64 string
  35867. * @param uri The uri to test
  35868. * @return True if the uri is a base64 string or false otherwise
  35869. */
  35870. static IsBase64(uri: string): boolean;
  35871. /**
  35872. * Decode the given base64 uri.
  35873. * @param uri The uri to decode
  35874. * @return The decoded base64 data.
  35875. */
  35876. static DecodeBase64(uri: string): ArrayBuffer;
  35877. /**
  35878. * Gets the absolute url.
  35879. * @param url the input url
  35880. * @return the absolute url
  35881. */
  35882. static GetAbsoluteUrl(url: string): string;
  35883. /**
  35884. * No log
  35885. */
  35886. static readonly NoneLogLevel: number;
  35887. /**
  35888. * Only message logs
  35889. */
  35890. static readonly MessageLogLevel: number;
  35891. /**
  35892. * Only warning logs
  35893. */
  35894. static readonly WarningLogLevel: number;
  35895. /**
  35896. * Only error logs
  35897. */
  35898. static readonly ErrorLogLevel: number;
  35899. /**
  35900. * All logs
  35901. */
  35902. static readonly AllLogLevel: number;
  35903. /**
  35904. * Gets a value indicating the number of loading errors
  35905. * @ignorenaming
  35906. */
  35907. static get errorsCount(): number;
  35908. /**
  35909. * Callback called when a new log is added
  35910. */
  35911. static OnNewCacheEntry: (entry: string) => void;
  35912. /**
  35913. * Log a message to the console
  35914. * @param message defines the message to log
  35915. */
  35916. static Log(message: string): void;
  35917. /**
  35918. * Write a warning message to the console
  35919. * @param message defines the message to log
  35920. */
  35921. static Warn(message: string): void;
  35922. /**
  35923. * Write an error message to the console
  35924. * @param message defines the message to log
  35925. */
  35926. static Error(message: string): void;
  35927. /**
  35928. * Gets current log cache (list of logs)
  35929. */
  35930. static get LogCache(): string;
  35931. /**
  35932. * Clears the log cache
  35933. */
  35934. static ClearLogCache(): void;
  35935. /**
  35936. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35937. */
  35938. static set LogLevels(level: number);
  35939. /**
  35940. * Checks if the window object exists
  35941. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35942. */
  35943. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35944. /**
  35945. * No performance log
  35946. */
  35947. static readonly PerformanceNoneLogLevel: number;
  35948. /**
  35949. * Use user marks to log performance
  35950. */
  35951. static readonly PerformanceUserMarkLogLevel: number;
  35952. /**
  35953. * Log performance to the console
  35954. */
  35955. static readonly PerformanceConsoleLogLevel: number;
  35956. private static _performance;
  35957. /**
  35958. * Sets the current performance log level
  35959. */
  35960. static set PerformanceLogLevel(level: number);
  35961. private static _StartPerformanceCounterDisabled;
  35962. private static _EndPerformanceCounterDisabled;
  35963. private static _StartUserMark;
  35964. private static _EndUserMark;
  35965. private static _StartPerformanceConsole;
  35966. private static _EndPerformanceConsole;
  35967. /**
  35968. * Starts a performance counter
  35969. */
  35970. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35971. /**
  35972. * Ends a specific performance coutner
  35973. */
  35974. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35975. /**
  35976. * Gets either window.performance.now() if supported or Date.now() else
  35977. */
  35978. static get Now(): number;
  35979. /**
  35980. * This method will return the name of the class used to create the instance of the given object.
  35981. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35982. * @param object the object to get the class name from
  35983. * @param isType defines if the object is actually a type
  35984. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35985. */
  35986. static GetClassName(object: any, isType?: boolean): string;
  35987. /**
  35988. * Gets the first element of an array satisfying a given predicate
  35989. * @param array defines the array to browse
  35990. * @param predicate defines the predicate to use
  35991. * @returns null if not found or the element
  35992. */
  35993. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35994. /**
  35995. * This method will return the name of the full name of the class, including its owning module (if any).
  35996. * 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).
  35997. * @param object the object to get the class name from
  35998. * @param isType defines if the object is actually a type
  35999. * @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.
  36000. * @ignorenaming
  36001. */
  36002. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  36003. /**
  36004. * Returns a promise that resolves after the given amount of time.
  36005. * @param delay Number of milliseconds to delay
  36006. * @returns Promise that resolves after the given amount of time
  36007. */
  36008. static DelayAsync(delay: number): Promise<void>;
  36009. /**
  36010. * Utility function to detect if the current user agent is Safari
  36011. * @returns whether or not the current user agent is safari
  36012. */
  36013. static IsSafari(): boolean;
  36014. }
  36015. /**
  36016. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  36017. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  36018. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  36019. * @param name The name of the class, case should be preserved
  36020. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  36021. */
  36022. export function className(name: string, module?: string): (target: Object) => void;
  36023. /**
  36024. * An implementation of a loop for asynchronous functions.
  36025. */
  36026. export class AsyncLoop {
  36027. /**
  36028. * Defines the number of iterations for the loop
  36029. */
  36030. iterations: number;
  36031. /**
  36032. * Defines the current index of the loop.
  36033. */
  36034. index: number;
  36035. private _done;
  36036. private _fn;
  36037. private _successCallback;
  36038. /**
  36039. * Constructor.
  36040. * @param iterations the number of iterations.
  36041. * @param func the function to run each iteration
  36042. * @param successCallback the callback that will be called upon succesful execution
  36043. * @param offset starting offset.
  36044. */
  36045. constructor(
  36046. /**
  36047. * Defines the number of iterations for the loop
  36048. */
  36049. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  36050. /**
  36051. * Execute the next iteration. Must be called after the last iteration was finished.
  36052. */
  36053. executeNext(): void;
  36054. /**
  36055. * Break the loop and run the success callback.
  36056. */
  36057. breakLoop(): void;
  36058. /**
  36059. * Create and run an async loop.
  36060. * @param iterations the number of iterations.
  36061. * @param fn the function to run each iteration
  36062. * @param successCallback the callback that will be called upon succesful execution
  36063. * @param offset starting offset.
  36064. * @returns the created async loop object
  36065. */
  36066. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  36067. /**
  36068. * A for-loop that will run a given number of iterations synchronous and the rest async.
  36069. * @param iterations total number of iterations
  36070. * @param syncedIterations number of synchronous iterations in each async iteration.
  36071. * @param fn the function to call each iteration.
  36072. * @param callback a success call back that will be called when iterating stops.
  36073. * @param breakFunction a break condition (optional)
  36074. * @param timeout timeout settings for the setTimeout function. default - 0.
  36075. * @returns the created async loop object
  36076. */
  36077. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  36078. }
  36079. }
  36080. declare module "babylonjs/Misc/stringDictionary" {
  36081. import { Nullable } from "babylonjs/types";
  36082. /**
  36083. * This class implement a typical dictionary using a string as key and the generic type T as value.
  36084. * The underlying implementation relies on an associative array to ensure the best performances.
  36085. * The value can be anything including 'null' but except 'undefined'
  36086. */
  36087. export class StringDictionary<T> {
  36088. /**
  36089. * This will clear this dictionary and copy the content from the 'source' one.
  36090. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  36091. * @param source the dictionary to take the content from and copy to this dictionary
  36092. */
  36093. copyFrom(source: StringDictionary<T>): void;
  36094. /**
  36095. * Get a value based from its key
  36096. * @param key the given key to get the matching value from
  36097. * @return the value if found, otherwise undefined is returned
  36098. */
  36099. get(key: string): T | undefined;
  36100. /**
  36101. * Get a value from its key or add it if it doesn't exist.
  36102. * This method will ensure you that a given key/data will be present in the dictionary.
  36103. * @param key the given key to get the matching value from
  36104. * @param factory the factory that will create the value if the key is not present in the dictionary.
  36105. * The factory will only be invoked if there's no data for the given key.
  36106. * @return the value corresponding to the key.
  36107. */
  36108. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  36109. /**
  36110. * Get a value from its key if present in the dictionary otherwise add it
  36111. * @param key the key to get the value from
  36112. * @param val if there's no such key/value pair in the dictionary add it with this value
  36113. * @return the value corresponding to the key
  36114. */
  36115. getOrAdd(key: string, val: T): T;
  36116. /**
  36117. * Check if there's a given key in the dictionary
  36118. * @param key the key to check for
  36119. * @return true if the key is present, false otherwise
  36120. */
  36121. contains(key: string): boolean;
  36122. /**
  36123. * Add a new key and its corresponding value
  36124. * @param key the key to add
  36125. * @param value the value corresponding to the key
  36126. * @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
  36127. */
  36128. add(key: string, value: T): boolean;
  36129. /**
  36130. * Update a specific value associated to a key
  36131. * @param key defines the key to use
  36132. * @param value defines the value to store
  36133. * @returns true if the value was updated (or false if the key was not found)
  36134. */
  36135. set(key: string, value: T): boolean;
  36136. /**
  36137. * Get the element of the given key and remove it from the dictionary
  36138. * @param key defines the key to search
  36139. * @returns the value associated with the key or null if not found
  36140. */
  36141. getAndRemove(key: string): Nullable<T>;
  36142. /**
  36143. * Remove a key/value from the dictionary.
  36144. * @param key the key to remove
  36145. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  36146. */
  36147. remove(key: string): boolean;
  36148. /**
  36149. * Clear the whole content of the dictionary
  36150. */
  36151. clear(): void;
  36152. /**
  36153. * Gets the current count
  36154. */
  36155. get count(): number;
  36156. /**
  36157. * Execute a callback on each key/val of the dictionary.
  36158. * Note that you can remove any element in this dictionary in the callback implementation
  36159. * @param callback the callback to execute on a given key/value pair
  36160. */
  36161. forEach(callback: (key: string, val: T) => void): void;
  36162. /**
  36163. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  36164. * If the callback returns null or undefined the method will iterate to the next key/value pair
  36165. * Note that you can remove any element in this dictionary in the callback implementation
  36166. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  36167. * @returns the first item
  36168. */
  36169. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  36170. private _count;
  36171. private _data;
  36172. }
  36173. }
  36174. declare module "babylonjs/Collisions/collisionCoordinator" {
  36175. import { Nullable } from "babylonjs/types";
  36176. import { Scene } from "babylonjs/scene";
  36177. import { Vector3 } from "babylonjs/Maths/math.vector";
  36178. import { Collider } from "babylonjs/Collisions/collider";
  36179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36180. /** @hidden */
  36181. export interface ICollisionCoordinator {
  36182. createCollider(): Collider;
  36183. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  36184. init(scene: Scene): void;
  36185. }
  36186. /** @hidden */
  36187. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  36188. private _scene;
  36189. private _scaledPosition;
  36190. private _scaledVelocity;
  36191. private _finalPosition;
  36192. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  36193. createCollider(): Collider;
  36194. init(scene: Scene): void;
  36195. private _collideWithWorld;
  36196. }
  36197. }
  36198. declare module "babylonjs/Inputs/scene.inputManager" {
  36199. import { Nullable } from "babylonjs/types";
  36200. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36201. import { Vector2 } from "babylonjs/Maths/math.vector";
  36202. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36203. import { Scene } from "babylonjs/scene";
  36204. /**
  36205. * Class used to manage all inputs for the scene.
  36206. */
  36207. export class InputManager {
  36208. /** The distance in pixel that you have to move to prevent some events */
  36209. static DragMovementThreshold: number;
  36210. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  36211. static LongPressDelay: number;
  36212. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  36213. static DoubleClickDelay: number;
  36214. /** If you need to check double click without raising a single click at first click, enable this flag */
  36215. static ExclusiveDoubleClickMode: boolean;
  36216. private _wheelEventName;
  36217. private _onPointerMove;
  36218. private _onPointerDown;
  36219. private _onPointerUp;
  36220. private _initClickEvent;
  36221. private _initActionManager;
  36222. private _delayedSimpleClick;
  36223. private _delayedSimpleClickTimeout;
  36224. private _previousDelayedSimpleClickTimeout;
  36225. private _meshPickProceed;
  36226. private _previousButtonPressed;
  36227. private _currentPickResult;
  36228. private _previousPickResult;
  36229. private _totalPointersPressed;
  36230. private _doubleClickOccured;
  36231. private _pointerOverMesh;
  36232. private _pickedDownMesh;
  36233. private _pickedUpMesh;
  36234. private _pointerX;
  36235. private _pointerY;
  36236. private _unTranslatedPointerX;
  36237. private _unTranslatedPointerY;
  36238. private _startingPointerPosition;
  36239. private _previousStartingPointerPosition;
  36240. private _startingPointerTime;
  36241. private _previousStartingPointerTime;
  36242. private _pointerCaptures;
  36243. private _onKeyDown;
  36244. private _onKeyUp;
  36245. private _onCanvasFocusObserver;
  36246. private _onCanvasBlurObserver;
  36247. private _scene;
  36248. /**
  36249. * Creates a new InputManager
  36250. * @param scene defines the hosting scene
  36251. */
  36252. constructor(scene: Scene);
  36253. /**
  36254. * Gets the mesh that is currently under the pointer
  36255. */
  36256. get meshUnderPointer(): Nullable<AbstractMesh>;
  36257. /**
  36258. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  36259. */
  36260. get unTranslatedPointer(): Vector2;
  36261. /**
  36262. * Gets or sets the current on-screen X position of the pointer
  36263. */
  36264. get pointerX(): number;
  36265. set pointerX(value: number);
  36266. /**
  36267. * Gets or sets the current on-screen Y position of the pointer
  36268. */
  36269. get pointerY(): number;
  36270. set pointerY(value: number);
  36271. private _updatePointerPosition;
  36272. private _processPointerMove;
  36273. private _setRayOnPointerInfo;
  36274. private _checkPrePointerObservable;
  36275. /**
  36276. * Use this method to simulate a pointer move on a mesh
  36277. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36278. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36279. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36280. */
  36281. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  36282. /**
  36283. * Use this method to simulate a pointer down on a mesh
  36284. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36285. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36286. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36287. */
  36288. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  36289. private _processPointerDown;
  36290. /** @hidden */
  36291. _isPointerSwiping(): boolean;
  36292. /**
  36293. * Use this method to simulate a pointer up on a mesh
  36294. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36295. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36296. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36297. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36298. */
  36299. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  36300. private _processPointerUp;
  36301. /**
  36302. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36303. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36304. * @returns true if the pointer was captured
  36305. */
  36306. isPointerCaptured(pointerId?: number): boolean;
  36307. /**
  36308. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36309. * @param attachUp defines if you want to attach events to pointerup
  36310. * @param attachDown defines if you want to attach events to pointerdown
  36311. * @param attachMove defines if you want to attach events to pointermove
  36312. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  36313. */
  36314. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  36315. /**
  36316. * Detaches all event handlers
  36317. */
  36318. detachControl(): void;
  36319. /**
  36320. * Force the value of meshUnderPointer
  36321. * @param mesh defines the mesh to use
  36322. */
  36323. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36324. /**
  36325. * Gets the mesh under the pointer
  36326. * @returns a Mesh or null if no mesh is under the pointer
  36327. */
  36328. getPointerOverMesh(): Nullable<AbstractMesh>;
  36329. }
  36330. }
  36331. declare module "babylonjs/Misc/uniqueIdGenerator" {
  36332. /**
  36333. * Helper class used to generate session unique ID
  36334. */
  36335. export class UniqueIdGenerator {
  36336. private static _UniqueIdCounter;
  36337. /**
  36338. * Gets an unique (relatively to the current scene) Id
  36339. */
  36340. static get UniqueId(): number;
  36341. }
  36342. }
  36343. declare module "babylonjs/Animations/animationGroup" {
  36344. import { Animatable } from "babylonjs/Animations/animatable";
  36345. import { Animation } from "babylonjs/Animations/animation";
  36346. import { Scene, IDisposable } from "babylonjs/scene";
  36347. import { Observable } from "babylonjs/Misc/observable";
  36348. import { Nullable } from "babylonjs/types";
  36349. import "babylonjs/Animations/animatable";
  36350. /**
  36351. * This class defines the direct association between an animation and a target
  36352. */
  36353. export class TargetedAnimation {
  36354. /**
  36355. * Animation to perform
  36356. */
  36357. animation: Animation;
  36358. /**
  36359. * Target to animate
  36360. */
  36361. target: any;
  36362. /**
  36363. * Serialize the object
  36364. * @returns the JSON object representing the current entity
  36365. */
  36366. serialize(): any;
  36367. }
  36368. /**
  36369. * Use this class to create coordinated animations on multiple targets
  36370. */
  36371. export class AnimationGroup implements IDisposable {
  36372. /** The name of the animation group */
  36373. name: string;
  36374. private _scene;
  36375. private _targetedAnimations;
  36376. private _animatables;
  36377. private _from;
  36378. private _to;
  36379. private _isStarted;
  36380. private _isPaused;
  36381. private _speedRatio;
  36382. private _loopAnimation;
  36383. private _isAdditive;
  36384. /**
  36385. * Gets or sets the unique id of the node
  36386. */
  36387. uniqueId: number;
  36388. /**
  36389. * This observable will notify when one animation have ended
  36390. */
  36391. onAnimationEndObservable: Observable<TargetedAnimation>;
  36392. /**
  36393. * Observer raised when one animation loops
  36394. */
  36395. onAnimationLoopObservable: Observable<TargetedAnimation>;
  36396. /**
  36397. * Observer raised when all animations have looped
  36398. */
  36399. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  36400. /**
  36401. * This observable will notify when all animations have ended.
  36402. */
  36403. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  36404. /**
  36405. * This observable will notify when all animations have paused.
  36406. */
  36407. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  36408. /**
  36409. * This observable will notify when all animations are playing.
  36410. */
  36411. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  36412. /**
  36413. * Gets the first frame
  36414. */
  36415. get from(): number;
  36416. /**
  36417. * Gets the last frame
  36418. */
  36419. get to(): number;
  36420. /**
  36421. * Define if the animations are started
  36422. */
  36423. get isStarted(): boolean;
  36424. /**
  36425. * Gets a value indicating that the current group is playing
  36426. */
  36427. get isPlaying(): boolean;
  36428. /**
  36429. * Gets or sets the speed ratio to use for all animations
  36430. */
  36431. get speedRatio(): number;
  36432. /**
  36433. * Gets or sets the speed ratio to use for all animations
  36434. */
  36435. set speedRatio(value: number);
  36436. /**
  36437. * Gets or sets if all animations should loop or not
  36438. */
  36439. get loopAnimation(): boolean;
  36440. set loopAnimation(value: boolean);
  36441. /**
  36442. * Gets or sets if all animations should be evaluated additively
  36443. */
  36444. get isAdditive(): boolean;
  36445. set isAdditive(value: boolean);
  36446. /**
  36447. * Gets the targeted animations for this animation group
  36448. */
  36449. get targetedAnimations(): Array<TargetedAnimation>;
  36450. /**
  36451. * returning the list of animatables controlled by this animation group.
  36452. */
  36453. get animatables(): Array<Animatable>;
  36454. /**
  36455. * Instantiates a new Animation Group.
  36456. * This helps managing several animations at once.
  36457. * @see http://doc.babylonjs.com/how_to/group
  36458. * @param name Defines the name of the group
  36459. * @param scene Defines the scene the group belongs to
  36460. */
  36461. constructor(
  36462. /** The name of the animation group */
  36463. name: string, scene?: Nullable<Scene>);
  36464. /**
  36465. * Add an animation (with its target) in the group
  36466. * @param animation defines the animation we want to add
  36467. * @param target defines the target of the animation
  36468. * @returns the TargetedAnimation object
  36469. */
  36470. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  36471. /**
  36472. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  36473. * It can add constant keys at begin or end
  36474. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  36475. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  36476. * @returns the animation group
  36477. */
  36478. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  36479. private _animationLoopCount;
  36480. private _animationLoopFlags;
  36481. private _processLoop;
  36482. /**
  36483. * Start all animations on given targets
  36484. * @param loop defines if animations must loop
  36485. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  36486. * @param from defines the from key (optional)
  36487. * @param to defines the to key (optional)
  36488. * @param isAdditive defines the additive state for the resulting animatables (optional)
  36489. * @returns the current animation group
  36490. */
  36491. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  36492. /**
  36493. * Pause all animations
  36494. * @returns the animation group
  36495. */
  36496. pause(): AnimationGroup;
  36497. /**
  36498. * Play all animations to initial state
  36499. * This function will start() the animations if they were not started or will restart() them if they were paused
  36500. * @param loop defines if animations must loop
  36501. * @returns the animation group
  36502. */
  36503. play(loop?: boolean): AnimationGroup;
  36504. /**
  36505. * Reset all animations to initial state
  36506. * @returns the animation group
  36507. */
  36508. reset(): AnimationGroup;
  36509. /**
  36510. * Restart animations from key 0
  36511. * @returns the animation group
  36512. */
  36513. restart(): AnimationGroup;
  36514. /**
  36515. * Stop all animations
  36516. * @returns the animation group
  36517. */
  36518. stop(): AnimationGroup;
  36519. /**
  36520. * Set animation weight for all animatables
  36521. * @param weight defines the weight to use
  36522. * @return the animationGroup
  36523. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36524. */
  36525. setWeightForAllAnimatables(weight: number): AnimationGroup;
  36526. /**
  36527. * Synchronize and normalize all animatables with a source animatable
  36528. * @param root defines the root animatable to synchronize with
  36529. * @return the animationGroup
  36530. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36531. */
  36532. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  36533. /**
  36534. * Goes to a specific frame in this animation group
  36535. * @param frame the frame number to go to
  36536. * @return the animationGroup
  36537. */
  36538. goToFrame(frame: number): AnimationGroup;
  36539. /**
  36540. * Dispose all associated resources
  36541. */
  36542. dispose(): void;
  36543. private _checkAnimationGroupEnded;
  36544. /**
  36545. * Clone the current animation group and returns a copy
  36546. * @param newName defines the name of the new group
  36547. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  36548. * @returns the new aniamtion group
  36549. */
  36550. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  36551. /**
  36552. * Serializes the animationGroup to an object
  36553. * @returns Serialized object
  36554. */
  36555. serialize(): any;
  36556. /**
  36557. * Returns a new AnimationGroup object parsed from the source provided.
  36558. * @param parsedAnimationGroup defines the source
  36559. * @param scene defines the scene that will receive the animationGroup
  36560. * @returns a new AnimationGroup
  36561. */
  36562. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  36563. /**
  36564. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36565. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  36566. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36567. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  36568. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  36569. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  36570. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  36571. */
  36572. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  36573. /**
  36574. * Returns the string "AnimationGroup"
  36575. * @returns "AnimationGroup"
  36576. */
  36577. getClassName(): string;
  36578. /**
  36579. * Creates a detailled string about the object
  36580. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  36581. * @returns a string representing the object
  36582. */
  36583. toString(fullDetails?: boolean): string;
  36584. }
  36585. }
  36586. declare module "babylonjs/scene" {
  36587. import { Nullable } from "babylonjs/types";
  36588. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  36589. import { Observable } from "babylonjs/Misc/observable";
  36590. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  36591. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  36592. import { Geometry } from "babylonjs/Meshes/geometry";
  36593. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36594. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36595. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36596. import { Mesh } from "babylonjs/Meshes/mesh";
  36597. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36598. import { Bone } from "babylonjs/Bones/bone";
  36599. import { Skeleton } from "babylonjs/Bones/skeleton";
  36600. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36601. import { Camera } from "babylonjs/Cameras/camera";
  36602. import { AbstractScene } from "babylonjs/abstractScene";
  36603. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36604. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36605. import { Material } from "babylonjs/Materials/material";
  36606. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36607. import { Effect } from "babylonjs/Materials/effect";
  36608. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36609. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36610. import { Light } from "babylonjs/Lights/light";
  36611. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36612. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36613. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36614. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36615. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36616. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36617. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36618. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36619. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36620. import { Engine } from "babylonjs/Engines/engine";
  36621. import { Node } from "babylonjs/node";
  36622. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36623. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36624. import { WebRequest } from "babylonjs/Misc/webRequest";
  36625. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36626. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36627. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36628. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36629. import { Plane } from "babylonjs/Maths/math.plane";
  36630. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36631. import { Ray } from "babylonjs/Culling/ray";
  36632. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36633. import { Animation } from "babylonjs/Animations/animation";
  36634. import { Animatable } from "babylonjs/Animations/animatable";
  36635. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36636. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36637. import { Collider } from "babylonjs/Collisions/collider";
  36638. /**
  36639. * Define an interface for all classes that will hold resources
  36640. */
  36641. export interface IDisposable {
  36642. /**
  36643. * Releases all held resources
  36644. */
  36645. dispose(): void;
  36646. }
  36647. /** Interface defining initialization parameters for Scene class */
  36648. export interface SceneOptions {
  36649. /**
  36650. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36651. * It will improve performance when the number of geometries becomes important.
  36652. */
  36653. useGeometryUniqueIdsMap?: boolean;
  36654. /**
  36655. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36656. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36657. */
  36658. useMaterialMeshMap?: boolean;
  36659. /**
  36660. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36661. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36662. */
  36663. useClonedMeshMap?: boolean;
  36664. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36665. virtual?: boolean;
  36666. }
  36667. /**
  36668. * Represents a scene to be rendered by the engine.
  36669. * @see http://doc.babylonjs.com/features/scene
  36670. */
  36671. export class Scene extends AbstractScene implements IAnimatable {
  36672. /** The fog is deactivated */
  36673. static readonly FOGMODE_NONE: number;
  36674. /** The fog density is following an exponential function */
  36675. static readonly FOGMODE_EXP: number;
  36676. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36677. static readonly FOGMODE_EXP2: number;
  36678. /** The fog density is following a linear function. */
  36679. static readonly FOGMODE_LINEAR: number;
  36680. /**
  36681. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36682. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36683. */
  36684. static MinDeltaTime: number;
  36685. /**
  36686. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36687. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36688. */
  36689. static MaxDeltaTime: number;
  36690. /**
  36691. * Factory used to create the default material.
  36692. * @param name The name of the material to create
  36693. * @param scene The scene to create the material for
  36694. * @returns The default material
  36695. */
  36696. static DefaultMaterialFactory(scene: Scene): Material;
  36697. /**
  36698. * Factory used to create the a collision coordinator.
  36699. * @returns The collision coordinator
  36700. */
  36701. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36702. /** @hidden */
  36703. _inputManager: InputManager;
  36704. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36705. cameraToUseForPointers: Nullable<Camera>;
  36706. /** @hidden */
  36707. readonly _isScene: boolean;
  36708. /** @hidden */
  36709. _blockEntityCollection: boolean;
  36710. /**
  36711. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36712. */
  36713. autoClear: boolean;
  36714. /**
  36715. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36716. */
  36717. autoClearDepthAndStencil: boolean;
  36718. /**
  36719. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36720. */
  36721. clearColor: Color4;
  36722. /**
  36723. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36724. */
  36725. ambientColor: Color3;
  36726. /**
  36727. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36728. * It should only be one of the following (if not the default embedded one):
  36729. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36730. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36731. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36732. * The material properties need to be setup according to the type of texture in use.
  36733. */
  36734. environmentBRDFTexture: BaseTexture;
  36735. /** @hidden */
  36736. protected _environmentTexture: Nullable<BaseTexture>;
  36737. /**
  36738. * Texture used in all pbr material as the reflection texture.
  36739. * As in the majority of the scene they are the same (exception for multi room and so on),
  36740. * this is easier to reference from here than from all the materials.
  36741. */
  36742. get environmentTexture(): Nullable<BaseTexture>;
  36743. /**
  36744. * Texture used in all pbr material as the reflection texture.
  36745. * As in the majority of the scene they are the same (exception for multi room and so on),
  36746. * this is easier to set here than in all the materials.
  36747. */
  36748. set environmentTexture(value: Nullable<BaseTexture>);
  36749. /** @hidden */
  36750. protected _environmentIntensity: number;
  36751. /**
  36752. * Intensity of the environment in all pbr material.
  36753. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36754. * As in the majority of the scene they are the same (exception for multi room and so on),
  36755. * this is easier to reference from here than from all the materials.
  36756. */
  36757. get environmentIntensity(): number;
  36758. /**
  36759. * Intensity of the environment in all pbr material.
  36760. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36761. * As in the majority of the scene they are the same (exception for multi room and so on),
  36762. * this is easier to set here than in all the materials.
  36763. */
  36764. set environmentIntensity(value: number);
  36765. /** @hidden */
  36766. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36767. /**
  36768. * Default image processing configuration used either in the rendering
  36769. * Forward main pass or through the imageProcessingPostProcess if present.
  36770. * As in the majority of the scene they are the same (exception for multi camera),
  36771. * this is easier to reference from here than from all the materials and post process.
  36772. *
  36773. * No setter as we it is a shared configuration, you can set the values instead.
  36774. */
  36775. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36776. private _forceWireframe;
  36777. /**
  36778. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36779. */
  36780. set forceWireframe(value: boolean);
  36781. get forceWireframe(): boolean;
  36782. private _skipFrustumClipping;
  36783. /**
  36784. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36785. */
  36786. set skipFrustumClipping(value: boolean);
  36787. get skipFrustumClipping(): boolean;
  36788. private _forcePointsCloud;
  36789. /**
  36790. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36791. */
  36792. set forcePointsCloud(value: boolean);
  36793. get forcePointsCloud(): boolean;
  36794. /**
  36795. * Gets or sets the active clipplane 1
  36796. */
  36797. clipPlane: Nullable<Plane>;
  36798. /**
  36799. * Gets or sets the active clipplane 2
  36800. */
  36801. clipPlane2: Nullable<Plane>;
  36802. /**
  36803. * Gets or sets the active clipplane 3
  36804. */
  36805. clipPlane3: Nullable<Plane>;
  36806. /**
  36807. * Gets or sets the active clipplane 4
  36808. */
  36809. clipPlane4: Nullable<Plane>;
  36810. /**
  36811. * Gets or sets the active clipplane 5
  36812. */
  36813. clipPlane5: Nullable<Plane>;
  36814. /**
  36815. * Gets or sets the active clipplane 6
  36816. */
  36817. clipPlane6: Nullable<Plane>;
  36818. /**
  36819. * Gets or sets a boolean indicating if animations are enabled
  36820. */
  36821. animationsEnabled: boolean;
  36822. private _animationPropertiesOverride;
  36823. /**
  36824. * Gets or sets the animation properties override
  36825. */
  36826. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36827. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36828. /**
  36829. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36830. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36831. */
  36832. useConstantAnimationDeltaTime: boolean;
  36833. /**
  36834. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36835. * Please note that it requires to run a ray cast through the scene on every frame
  36836. */
  36837. constantlyUpdateMeshUnderPointer: boolean;
  36838. /**
  36839. * Defines the HTML cursor to use when hovering over interactive elements
  36840. */
  36841. hoverCursor: string;
  36842. /**
  36843. * Defines the HTML default cursor to use (empty by default)
  36844. */
  36845. defaultCursor: string;
  36846. /**
  36847. * Defines whether cursors are handled by the scene.
  36848. */
  36849. doNotHandleCursors: boolean;
  36850. /**
  36851. * This is used to call preventDefault() on pointer down
  36852. * in order to block unwanted artifacts like system double clicks
  36853. */
  36854. preventDefaultOnPointerDown: boolean;
  36855. /**
  36856. * This is used to call preventDefault() on pointer up
  36857. * in order to block unwanted artifacts like system double clicks
  36858. */
  36859. preventDefaultOnPointerUp: boolean;
  36860. /**
  36861. * Gets or sets user defined metadata
  36862. */
  36863. metadata: any;
  36864. /**
  36865. * For internal use only. Please do not use.
  36866. */
  36867. reservedDataStore: any;
  36868. /**
  36869. * Gets the name of the plugin used to load this scene (null by default)
  36870. */
  36871. loadingPluginName: string;
  36872. /**
  36873. * Use this array to add regular expressions used to disable offline support for specific urls
  36874. */
  36875. disableOfflineSupportExceptionRules: RegExp[];
  36876. /**
  36877. * An event triggered when the scene is disposed.
  36878. */
  36879. onDisposeObservable: Observable<Scene>;
  36880. private _onDisposeObserver;
  36881. /** Sets a function to be executed when this scene is disposed. */
  36882. set onDispose(callback: () => void);
  36883. /**
  36884. * An event triggered before rendering the scene (right after animations and physics)
  36885. */
  36886. onBeforeRenderObservable: Observable<Scene>;
  36887. private _onBeforeRenderObserver;
  36888. /** Sets a function to be executed before rendering this scene */
  36889. set beforeRender(callback: Nullable<() => void>);
  36890. /**
  36891. * An event triggered after rendering the scene
  36892. */
  36893. onAfterRenderObservable: Observable<Scene>;
  36894. /**
  36895. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36896. */
  36897. onAfterRenderCameraObservable: Observable<Camera>;
  36898. private _onAfterRenderObserver;
  36899. /** Sets a function to be executed after rendering this scene */
  36900. set afterRender(callback: Nullable<() => void>);
  36901. /**
  36902. * An event triggered before animating the scene
  36903. */
  36904. onBeforeAnimationsObservable: Observable<Scene>;
  36905. /**
  36906. * An event triggered after animations processing
  36907. */
  36908. onAfterAnimationsObservable: Observable<Scene>;
  36909. /**
  36910. * An event triggered before draw calls are ready to be sent
  36911. */
  36912. onBeforeDrawPhaseObservable: Observable<Scene>;
  36913. /**
  36914. * An event triggered after draw calls have been sent
  36915. */
  36916. onAfterDrawPhaseObservable: Observable<Scene>;
  36917. /**
  36918. * An event triggered when the scene is ready
  36919. */
  36920. onReadyObservable: Observable<Scene>;
  36921. /**
  36922. * An event triggered before rendering a camera
  36923. */
  36924. onBeforeCameraRenderObservable: Observable<Camera>;
  36925. private _onBeforeCameraRenderObserver;
  36926. /** Sets a function to be executed before rendering a camera*/
  36927. set beforeCameraRender(callback: () => void);
  36928. /**
  36929. * An event triggered after rendering a camera
  36930. */
  36931. onAfterCameraRenderObservable: Observable<Camera>;
  36932. private _onAfterCameraRenderObserver;
  36933. /** Sets a function to be executed after rendering a camera*/
  36934. set afterCameraRender(callback: () => void);
  36935. /**
  36936. * An event triggered when active meshes evaluation is about to start
  36937. */
  36938. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36939. /**
  36940. * An event triggered when active meshes evaluation is done
  36941. */
  36942. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36943. /**
  36944. * An event triggered when particles rendering is about to start
  36945. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36946. */
  36947. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36948. /**
  36949. * An event triggered when particles rendering is done
  36950. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36951. */
  36952. onAfterParticlesRenderingObservable: Observable<Scene>;
  36953. /**
  36954. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36955. */
  36956. onDataLoadedObservable: Observable<Scene>;
  36957. /**
  36958. * An event triggered when a camera is created
  36959. */
  36960. onNewCameraAddedObservable: Observable<Camera>;
  36961. /**
  36962. * An event triggered when a camera is removed
  36963. */
  36964. onCameraRemovedObservable: Observable<Camera>;
  36965. /**
  36966. * An event triggered when a light is created
  36967. */
  36968. onNewLightAddedObservable: Observable<Light>;
  36969. /**
  36970. * An event triggered when a light is removed
  36971. */
  36972. onLightRemovedObservable: Observable<Light>;
  36973. /**
  36974. * An event triggered when a geometry is created
  36975. */
  36976. onNewGeometryAddedObservable: Observable<Geometry>;
  36977. /**
  36978. * An event triggered when a geometry is removed
  36979. */
  36980. onGeometryRemovedObservable: Observable<Geometry>;
  36981. /**
  36982. * An event triggered when a transform node is created
  36983. */
  36984. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36985. /**
  36986. * An event triggered when a transform node is removed
  36987. */
  36988. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36989. /**
  36990. * An event triggered when a mesh is created
  36991. */
  36992. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36993. /**
  36994. * An event triggered when a mesh is removed
  36995. */
  36996. onMeshRemovedObservable: Observable<AbstractMesh>;
  36997. /**
  36998. * An event triggered when a skeleton is created
  36999. */
  37000. onNewSkeletonAddedObservable: Observable<Skeleton>;
  37001. /**
  37002. * An event triggered when a skeleton is removed
  37003. */
  37004. onSkeletonRemovedObservable: Observable<Skeleton>;
  37005. /**
  37006. * An event triggered when a material is created
  37007. */
  37008. onNewMaterialAddedObservable: Observable<Material>;
  37009. /**
  37010. * An event triggered when a material is removed
  37011. */
  37012. onMaterialRemovedObservable: Observable<Material>;
  37013. /**
  37014. * An event triggered when a texture is created
  37015. */
  37016. onNewTextureAddedObservable: Observable<BaseTexture>;
  37017. /**
  37018. * An event triggered when a texture is removed
  37019. */
  37020. onTextureRemovedObservable: Observable<BaseTexture>;
  37021. /**
  37022. * An event triggered when render targets are about to be rendered
  37023. * Can happen multiple times per frame.
  37024. */
  37025. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  37026. /**
  37027. * An event triggered when render targets were rendered.
  37028. * Can happen multiple times per frame.
  37029. */
  37030. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  37031. /**
  37032. * An event triggered before calculating deterministic simulation step
  37033. */
  37034. onBeforeStepObservable: Observable<Scene>;
  37035. /**
  37036. * An event triggered after calculating deterministic simulation step
  37037. */
  37038. onAfterStepObservable: Observable<Scene>;
  37039. /**
  37040. * An event triggered when the activeCamera property is updated
  37041. */
  37042. onActiveCameraChanged: Observable<Scene>;
  37043. /**
  37044. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  37045. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  37046. * 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)
  37047. */
  37048. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  37049. /**
  37050. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  37051. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  37052. * 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)
  37053. */
  37054. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  37055. /**
  37056. * This Observable will when a mesh has been imported into the scene.
  37057. */
  37058. onMeshImportedObservable: Observable<AbstractMesh>;
  37059. /**
  37060. * This Observable will when an animation file has been imported into the scene.
  37061. */
  37062. onAnimationFileImportedObservable: Observable<Scene>;
  37063. /**
  37064. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  37065. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  37066. */
  37067. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  37068. /** @hidden */
  37069. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  37070. /**
  37071. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  37072. */
  37073. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  37074. /**
  37075. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  37076. */
  37077. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  37078. /**
  37079. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  37080. */
  37081. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  37082. /** Callback called when a pointer move is detected */
  37083. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  37084. /** Callback called when a pointer down is detected */
  37085. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  37086. /** Callback called when a pointer up is detected */
  37087. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  37088. /** Callback called when a pointer pick is detected */
  37089. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  37090. /**
  37091. * 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).
  37092. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  37093. */
  37094. onPrePointerObservable: Observable<PointerInfoPre>;
  37095. /**
  37096. * Observable event triggered each time an input event is received from the rendering canvas
  37097. */
  37098. onPointerObservable: Observable<PointerInfo>;
  37099. /**
  37100. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  37101. */
  37102. get unTranslatedPointer(): Vector2;
  37103. /**
  37104. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  37105. */
  37106. static get DragMovementThreshold(): number;
  37107. static set DragMovementThreshold(value: number);
  37108. /**
  37109. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  37110. */
  37111. static get LongPressDelay(): number;
  37112. static set LongPressDelay(value: number);
  37113. /**
  37114. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  37115. */
  37116. static get DoubleClickDelay(): number;
  37117. static set DoubleClickDelay(value: number);
  37118. /** If you need to check double click without raising a single click at first click, enable this flag */
  37119. static get ExclusiveDoubleClickMode(): boolean;
  37120. static set ExclusiveDoubleClickMode(value: boolean);
  37121. /** @hidden */
  37122. _mirroredCameraPosition: Nullable<Vector3>;
  37123. /**
  37124. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  37125. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  37126. */
  37127. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  37128. /**
  37129. * Observable event triggered each time an keyboard event is received from the hosting window
  37130. */
  37131. onKeyboardObservable: Observable<KeyboardInfo>;
  37132. private _useRightHandedSystem;
  37133. /**
  37134. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  37135. */
  37136. set useRightHandedSystem(value: boolean);
  37137. get useRightHandedSystem(): boolean;
  37138. private _timeAccumulator;
  37139. private _currentStepId;
  37140. private _currentInternalStep;
  37141. /**
  37142. * Sets the step Id used by deterministic lock step
  37143. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37144. * @param newStepId defines the step Id
  37145. */
  37146. setStepId(newStepId: number): void;
  37147. /**
  37148. * Gets the step Id used by deterministic lock step
  37149. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37150. * @returns the step Id
  37151. */
  37152. getStepId(): number;
  37153. /**
  37154. * Gets the internal step used by deterministic lock step
  37155. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37156. * @returns the internal step
  37157. */
  37158. getInternalStep(): number;
  37159. private _fogEnabled;
  37160. /**
  37161. * Gets or sets a boolean indicating if fog is enabled on this scene
  37162. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37163. * (Default is true)
  37164. */
  37165. set fogEnabled(value: boolean);
  37166. get fogEnabled(): boolean;
  37167. private _fogMode;
  37168. /**
  37169. * Gets or sets the fog mode to use
  37170. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37171. * | mode | value |
  37172. * | --- | --- |
  37173. * | FOGMODE_NONE | 0 |
  37174. * | FOGMODE_EXP | 1 |
  37175. * | FOGMODE_EXP2 | 2 |
  37176. * | FOGMODE_LINEAR | 3 |
  37177. */
  37178. set fogMode(value: number);
  37179. get fogMode(): number;
  37180. /**
  37181. * Gets or sets the fog color to use
  37182. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37183. * (Default is Color3(0.2, 0.2, 0.3))
  37184. */
  37185. fogColor: Color3;
  37186. /**
  37187. * Gets or sets the fog density to use
  37188. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37189. * (Default is 0.1)
  37190. */
  37191. fogDensity: number;
  37192. /**
  37193. * Gets or sets the fog start distance to use
  37194. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37195. * (Default is 0)
  37196. */
  37197. fogStart: number;
  37198. /**
  37199. * Gets or sets the fog end distance to use
  37200. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37201. * (Default is 1000)
  37202. */
  37203. fogEnd: number;
  37204. private _shadowsEnabled;
  37205. /**
  37206. * Gets or sets a boolean indicating if shadows are enabled on this scene
  37207. */
  37208. set shadowsEnabled(value: boolean);
  37209. get shadowsEnabled(): boolean;
  37210. private _lightsEnabled;
  37211. /**
  37212. * Gets or sets a boolean indicating if lights are enabled on this scene
  37213. */
  37214. set lightsEnabled(value: boolean);
  37215. get lightsEnabled(): boolean;
  37216. /** All of the active cameras added to this scene. */
  37217. activeCameras: Camera[];
  37218. /** @hidden */
  37219. _activeCamera: Nullable<Camera>;
  37220. /** Gets or sets the current active camera */
  37221. get activeCamera(): Nullable<Camera>;
  37222. set activeCamera(value: Nullable<Camera>);
  37223. private _defaultMaterial;
  37224. /** The default material used on meshes when no material is affected */
  37225. get defaultMaterial(): Material;
  37226. /** The default material used on meshes when no material is affected */
  37227. set defaultMaterial(value: Material);
  37228. private _texturesEnabled;
  37229. /**
  37230. * Gets or sets a boolean indicating if textures are enabled on this scene
  37231. */
  37232. set texturesEnabled(value: boolean);
  37233. get texturesEnabled(): boolean;
  37234. /**
  37235. * Gets or sets a boolean indicating if particles are enabled on this scene
  37236. */
  37237. particlesEnabled: boolean;
  37238. /**
  37239. * Gets or sets a boolean indicating if sprites are enabled on this scene
  37240. */
  37241. spritesEnabled: boolean;
  37242. private _skeletonsEnabled;
  37243. /**
  37244. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  37245. */
  37246. set skeletonsEnabled(value: boolean);
  37247. get skeletonsEnabled(): boolean;
  37248. /**
  37249. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  37250. */
  37251. lensFlaresEnabled: boolean;
  37252. /**
  37253. * Gets or sets a boolean indicating if collisions are enabled on this scene
  37254. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37255. */
  37256. collisionsEnabled: boolean;
  37257. private _collisionCoordinator;
  37258. /** @hidden */
  37259. get collisionCoordinator(): ICollisionCoordinator;
  37260. /**
  37261. * Defines the gravity applied to this scene (used only for collisions)
  37262. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37263. */
  37264. gravity: Vector3;
  37265. /**
  37266. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  37267. */
  37268. postProcessesEnabled: boolean;
  37269. /**
  37270. * The list of postprocesses added to the scene
  37271. */
  37272. postProcesses: PostProcess[];
  37273. /**
  37274. * Gets the current postprocess manager
  37275. */
  37276. postProcessManager: PostProcessManager;
  37277. /**
  37278. * Gets or sets a boolean indicating if render targets are enabled on this scene
  37279. */
  37280. renderTargetsEnabled: boolean;
  37281. /**
  37282. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  37283. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  37284. */
  37285. dumpNextRenderTargets: boolean;
  37286. /**
  37287. * The list of user defined render targets added to the scene
  37288. */
  37289. customRenderTargets: RenderTargetTexture[];
  37290. /**
  37291. * Defines if texture loading must be delayed
  37292. * If true, textures will only be loaded when they need to be rendered
  37293. */
  37294. useDelayedTextureLoading: boolean;
  37295. /**
  37296. * Gets the list of meshes imported to the scene through SceneLoader
  37297. */
  37298. importedMeshesFiles: String[];
  37299. /**
  37300. * Gets or sets a boolean indicating if probes are enabled on this scene
  37301. */
  37302. probesEnabled: boolean;
  37303. /**
  37304. * Gets or sets the current offline provider to use to store scene data
  37305. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  37306. */
  37307. offlineProvider: IOfflineProvider;
  37308. /**
  37309. * Gets or sets the action manager associated with the scene
  37310. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37311. */
  37312. actionManager: AbstractActionManager;
  37313. private _meshesForIntersections;
  37314. /**
  37315. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  37316. */
  37317. proceduralTexturesEnabled: boolean;
  37318. private _engine;
  37319. private _totalVertices;
  37320. /** @hidden */
  37321. _activeIndices: PerfCounter;
  37322. /** @hidden */
  37323. _activeParticles: PerfCounter;
  37324. /** @hidden */
  37325. _activeBones: PerfCounter;
  37326. private _animationRatio;
  37327. /** @hidden */
  37328. _animationTimeLast: number;
  37329. /** @hidden */
  37330. _animationTime: number;
  37331. /**
  37332. * Gets or sets a general scale for animation speed
  37333. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  37334. */
  37335. animationTimeScale: number;
  37336. /** @hidden */
  37337. _cachedMaterial: Nullable<Material>;
  37338. /** @hidden */
  37339. _cachedEffect: Nullable<Effect>;
  37340. /** @hidden */
  37341. _cachedVisibility: Nullable<number>;
  37342. private _renderId;
  37343. private _frameId;
  37344. private _executeWhenReadyTimeoutId;
  37345. private _intermediateRendering;
  37346. private _viewUpdateFlag;
  37347. private _projectionUpdateFlag;
  37348. /** @hidden */
  37349. _toBeDisposed: Nullable<IDisposable>[];
  37350. private _activeRequests;
  37351. /** @hidden */
  37352. _pendingData: any[];
  37353. private _isDisposed;
  37354. /**
  37355. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  37356. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  37357. */
  37358. dispatchAllSubMeshesOfActiveMeshes: boolean;
  37359. private _activeMeshes;
  37360. private _processedMaterials;
  37361. private _renderTargets;
  37362. /** @hidden */
  37363. _activeParticleSystems: SmartArray<IParticleSystem>;
  37364. private _activeSkeletons;
  37365. private _softwareSkinnedMeshes;
  37366. private _renderingManager;
  37367. /** @hidden */
  37368. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  37369. private _transformMatrix;
  37370. private _sceneUbo;
  37371. /** @hidden */
  37372. _viewMatrix: Matrix;
  37373. private _projectionMatrix;
  37374. /** @hidden */
  37375. _forcedViewPosition: Nullable<Vector3>;
  37376. /** @hidden */
  37377. _frustumPlanes: Plane[];
  37378. /**
  37379. * Gets the list of frustum planes (built from the active camera)
  37380. */
  37381. get frustumPlanes(): Plane[];
  37382. /**
  37383. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  37384. * This is useful if there are more lights that the maximum simulteanous authorized
  37385. */
  37386. requireLightSorting: boolean;
  37387. /** @hidden */
  37388. readonly useMaterialMeshMap: boolean;
  37389. /** @hidden */
  37390. readonly useClonedMeshMap: boolean;
  37391. private _externalData;
  37392. private _uid;
  37393. /**
  37394. * @hidden
  37395. * Backing store of defined scene components.
  37396. */
  37397. _components: ISceneComponent[];
  37398. /**
  37399. * @hidden
  37400. * Backing store of defined scene components.
  37401. */
  37402. _serializableComponents: ISceneSerializableComponent[];
  37403. /**
  37404. * List of components to register on the next registration step.
  37405. */
  37406. private _transientComponents;
  37407. /**
  37408. * Registers the transient components if needed.
  37409. */
  37410. private _registerTransientComponents;
  37411. /**
  37412. * @hidden
  37413. * Add a component to the scene.
  37414. * Note that the ccomponent could be registered on th next frame if this is called after
  37415. * the register component stage.
  37416. * @param component Defines the component to add to the scene
  37417. */
  37418. _addComponent(component: ISceneComponent): void;
  37419. /**
  37420. * @hidden
  37421. * Gets a component from the scene.
  37422. * @param name defines the name of the component to retrieve
  37423. * @returns the component or null if not present
  37424. */
  37425. _getComponent(name: string): Nullable<ISceneComponent>;
  37426. /**
  37427. * @hidden
  37428. * Defines the actions happening before camera updates.
  37429. */
  37430. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  37431. /**
  37432. * @hidden
  37433. * Defines the actions happening before clear the canvas.
  37434. */
  37435. _beforeClearStage: Stage<SimpleStageAction>;
  37436. /**
  37437. * @hidden
  37438. * Defines the actions when collecting render targets for the frame.
  37439. */
  37440. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  37441. /**
  37442. * @hidden
  37443. * Defines the actions happening for one camera in the frame.
  37444. */
  37445. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  37446. /**
  37447. * @hidden
  37448. * Defines the actions happening during the per mesh ready checks.
  37449. */
  37450. _isReadyForMeshStage: Stage<MeshStageAction>;
  37451. /**
  37452. * @hidden
  37453. * Defines the actions happening before evaluate active mesh checks.
  37454. */
  37455. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  37456. /**
  37457. * @hidden
  37458. * Defines the actions happening during the evaluate sub mesh checks.
  37459. */
  37460. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  37461. /**
  37462. * @hidden
  37463. * Defines the actions happening during the active mesh stage.
  37464. */
  37465. _activeMeshStage: Stage<ActiveMeshStageAction>;
  37466. /**
  37467. * @hidden
  37468. * Defines the actions happening during the per camera render target step.
  37469. */
  37470. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  37471. /**
  37472. * @hidden
  37473. * Defines the actions happening just before the active camera is drawing.
  37474. */
  37475. _beforeCameraDrawStage: Stage<CameraStageAction>;
  37476. /**
  37477. * @hidden
  37478. * Defines the actions happening just before a render target is drawing.
  37479. */
  37480. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37481. /**
  37482. * @hidden
  37483. * Defines the actions happening just before a rendering group is drawing.
  37484. */
  37485. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37486. /**
  37487. * @hidden
  37488. * Defines the actions happening just before a mesh is drawing.
  37489. */
  37490. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37491. /**
  37492. * @hidden
  37493. * Defines the actions happening just after a mesh has been drawn.
  37494. */
  37495. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37496. /**
  37497. * @hidden
  37498. * Defines the actions happening just after a rendering group has been drawn.
  37499. */
  37500. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37501. /**
  37502. * @hidden
  37503. * Defines the actions happening just after the active camera has been drawn.
  37504. */
  37505. _afterCameraDrawStage: Stage<CameraStageAction>;
  37506. /**
  37507. * @hidden
  37508. * Defines the actions happening just after a render target has been drawn.
  37509. */
  37510. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37511. /**
  37512. * @hidden
  37513. * Defines the actions happening just after rendering all cameras and computing intersections.
  37514. */
  37515. _afterRenderStage: Stage<SimpleStageAction>;
  37516. /**
  37517. * @hidden
  37518. * Defines the actions happening when a pointer move event happens.
  37519. */
  37520. _pointerMoveStage: Stage<PointerMoveStageAction>;
  37521. /**
  37522. * @hidden
  37523. * Defines the actions happening when a pointer down event happens.
  37524. */
  37525. _pointerDownStage: Stage<PointerUpDownStageAction>;
  37526. /**
  37527. * @hidden
  37528. * Defines the actions happening when a pointer up event happens.
  37529. */
  37530. _pointerUpStage: Stage<PointerUpDownStageAction>;
  37531. /**
  37532. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  37533. */
  37534. private geometriesByUniqueId;
  37535. /**
  37536. * Creates a new Scene
  37537. * @param engine defines the engine to use to render this scene
  37538. * @param options defines the scene options
  37539. */
  37540. constructor(engine: Engine, options?: SceneOptions);
  37541. /**
  37542. * Gets a string idenfifying the name of the class
  37543. * @returns "Scene" string
  37544. */
  37545. getClassName(): string;
  37546. private _defaultMeshCandidates;
  37547. /**
  37548. * @hidden
  37549. */
  37550. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  37551. private _defaultSubMeshCandidates;
  37552. /**
  37553. * @hidden
  37554. */
  37555. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  37556. /**
  37557. * Sets the default candidate providers for the scene.
  37558. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  37559. * and getCollidingSubMeshCandidates to their default function
  37560. */
  37561. setDefaultCandidateProviders(): void;
  37562. /**
  37563. * Gets the mesh that is currently under the pointer
  37564. */
  37565. get meshUnderPointer(): Nullable<AbstractMesh>;
  37566. /**
  37567. * Gets or sets the current on-screen X position of the pointer
  37568. */
  37569. get pointerX(): number;
  37570. set pointerX(value: number);
  37571. /**
  37572. * Gets or sets the current on-screen Y position of the pointer
  37573. */
  37574. get pointerY(): number;
  37575. set pointerY(value: number);
  37576. /**
  37577. * Gets the cached material (ie. the latest rendered one)
  37578. * @returns the cached material
  37579. */
  37580. getCachedMaterial(): Nullable<Material>;
  37581. /**
  37582. * Gets the cached effect (ie. the latest rendered one)
  37583. * @returns the cached effect
  37584. */
  37585. getCachedEffect(): Nullable<Effect>;
  37586. /**
  37587. * Gets the cached visibility state (ie. the latest rendered one)
  37588. * @returns the cached visibility state
  37589. */
  37590. getCachedVisibility(): Nullable<number>;
  37591. /**
  37592. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  37593. * @param material defines the current material
  37594. * @param effect defines the current effect
  37595. * @param visibility defines the current visibility state
  37596. * @returns true if one parameter is not cached
  37597. */
  37598. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  37599. /**
  37600. * Gets the engine associated with the scene
  37601. * @returns an Engine
  37602. */
  37603. getEngine(): Engine;
  37604. /**
  37605. * Gets the total number of vertices rendered per frame
  37606. * @returns the total number of vertices rendered per frame
  37607. */
  37608. getTotalVertices(): number;
  37609. /**
  37610. * Gets the performance counter for total vertices
  37611. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37612. */
  37613. get totalVerticesPerfCounter(): PerfCounter;
  37614. /**
  37615. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37616. * @returns the total number of active indices rendered per frame
  37617. */
  37618. getActiveIndices(): number;
  37619. /**
  37620. * Gets the performance counter for active indices
  37621. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37622. */
  37623. get totalActiveIndicesPerfCounter(): PerfCounter;
  37624. /**
  37625. * Gets the total number of active particles rendered per frame
  37626. * @returns the total number of active particles rendered per frame
  37627. */
  37628. getActiveParticles(): number;
  37629. /**
  37630. * Gets the performance counter for active particles
  37631. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37632. */
  37633. get activeParticlesPerfCounter(): PerfCounter;
  37634. /**
  37635. * Gets the total number of active bones rendered per frame
  37636. * @returns the total number of active bones rendered per frame
  37637. */
  37638. getActiveBones(): number;
  37639. /**
  37640. * Gets the performance counter for active bones
  37641. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37642. */
  37643. get activeBonesPerfCounter(): PerfCounter;
  37644. /**
  37645. * Gets the array of active meshes
  37646. * @returns an array of AbstractMesh
  37647. */
  37648. getActiveMeshes(): SmartArray<AbstractMesh>;
  37649. /**
  37650. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37651. * @returns a number
  37652. */
  37653. getAnimationRatio(): number;
  37654. /**
  37655. * Gets an unique Id for the current render phase
  37656. * @returns a number
  37657. */
  37658. getRenderId(): number;
  37659. /**
  37660. * Gets an unique Id for the current frame
  37661. * @returns a number
  37662. */
  37663. getFrameId(): number;
  37664. /** Call this function if you want to manually increment the render Id*/
  37665. incrementRenderId(): void;
  37666. private _createUbo;
  37667. /**
  37668. * Use this method to simulate a pointer move on a mesh
  37669. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37670. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37671. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37672. * @returns the current scene
  37673. */
  37674. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37675. /**
  37676. * Use this method to simulate a pointer down on a mesh
  37677. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37678. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37679. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37680. * @returns the current scene
  37681. */
  37682. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37683. /**
  37684. * Use this method to simulate a pointer up on a mesh
  37685. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37686. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37687. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37688. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37689. * @returns the current scene
  37690. */
  37691. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37692. /**
  37693. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37694. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37695. * @returns true if the pointer was captured
  37696. */
  37697. isPointerCaptured(pointerId?: number): boolean;
  37698. /**
  37699. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37700. * @param attachUp defines if you want to attach events to pointerup
  37701. * @param attachDown defines if you want to attach events to pointerdown
  37702. * @param attachMove defines if you want to attach events to pointermove
  37703. */
  37704. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37705. /** Detaches all event handlers*/
  37706. detachControl(): void;
  37707. /**
  37708. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37709. * Delay loaded resources are not taking in account
  37710. * @return true if all required resources are ready
  37711. */
  37712. isReady(): boolean;
  37713. /** Resets all cached information relative to material (including effect and visibility) */
  37714. resetCachedMaterial(): void;
  37715. /**
  37716. * Registers a function to be called before every frame render
  37717. * @param func defines the function to register
  37718. */
  37719. registerBeforeRender(func: () => void): void;
  37720. /**
  37721. * Unregisters a function called before every frame render
  37722. * @param func defines the function to unregister
  37723. */
  37724. unregisterBeforeRender(func: () => void): void;
  37725. /**
  37726. * Registers a function to be called after every frame render
  37727. * @param func defines the function to register
  37728. */
  37729. registerAfterRender(func: () => void): void;
  37730. /**
  37731. * Unregisters a function called after every frame render
  37732. * @param func defines the function to unregister
  37733. */
  37734. unregisterAfterRender(func: () => void): void;
  37735. private _executeOnceBeforeRender;
  37736. /**
  37737. * The provided function will run before render once and will be disposed afterwards.
  37738. * A timeout delay can be provided so that the function will be executed in N ms.
  37739. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37740. * @param func The function to be executed.
  37741. * @param timeout optional delay in ms
  37742. */
  37743. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37744. /** @hidden */
  37745. _addPendingData(data: any): void;
  37746. /** @hidden */
  37747. _removePendingData(data: any): void;
  37748. /**
  37749. * Returns the number of items waiting to be loaded
  37750. * @returns the number of items waiting to be loaded
  37751. */
  37752. getWaitingItemsCount(): number;
  37753. /**
  37754. * Returns a boolean indicating if the scene is still loading data
  37755. */
  37756. get isLoading(): boolean;
  37757. /**
  37758. * Registers a function to be executed when the scene is ready
  37759. * @param {Function} func - the function to be executed
  37760. */
  37761. executeWhenReady(func: () => void): void;
  37762. /**
  37763. * Returns a promise that resolves when the scene is ready
  37764. * @returns A promise that resolves when the scene is ready
  37765. */
  37766. whenReadyAsync(): Promise<void>;
  37767. /** @hidden */
  37768. _checkIsReady(): void;
  37769. /**
  37770. * Gets all animatable attached to the scene
  37771. */
  37772. get animatables(): Animatable[];
  37773. /**
  37774. * Resets the last animation time frame.
  37775. * Useful to override when animations start running when loading a scene for the first time.
  37776. */
  37777. resetLastAnimationTimeFrame(): void;
  37778. /**
  37779. * Gets the current view matrix
  37780. * @returns a Matrix
  37781. */
  37782. getViewMatrix(): Matrix;
  37783. /**
  37784. * Gets the current projection matrix
  37785. * @returns a Matrix
  37786. */
  37787. getProjectionMatrix(): Matrix;
  37788. /**
  37789. * Gets the current transform matrix
  37790. * @returns a Matrix made of View * Projection
  37791. */
  37792. getTransformMatrix(): Matrix;
  37793. /**
  37794. * Sets the current transform matrix
  37795. * @param viewL defines the View matrix to use
  37796. * @param projectionL defines the Projection matrix to use
  37797. * @param viewR defines the right View matrix to use (if provided)
  37798. * @param projectionR defines the right Projection matrix to use (if provided)
  37799. */
  37800. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37801. /**
  37802. * Gets the uniform buffer used to store scene data
  37803. * @returns a UniformBuffer
  37804. */
  37805. getSceneUniformBuffer(): UniformBuffer;
  37806. /**
  37807. * Gets an unique (relatively to the current scene) Id
  37808. * @returns an unique number for the scene
  37809. */
  37810. getUniqueId(): number;
  37811. /**
  37812. * Add a mesh to the list of scene's meshes
  37813. * @param newMesh defines the mesh to add
  37814. * @param recursive if all child meshes should also be added to the scene
  37815. */
  37816. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37817. /**
  37818. * Remove a mesh for the list of scene's meshes
  37819. * @param toRemove defines the mesh to remove
  37820. * @param recursive if all child meshes should also be removed from the scene
  37821. * @returns the index where the mesh was in the mesh list
  37822. */
  37823. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37824. /**
  37825. * Add a transform node to the list of scene's transform nodes
  37826. * @param newTransformNode defines the transform node to add
  37827. */
  37828. addTransformNode(newTransformNode: TransformNode): void;
  37829. /**
  37830. * Remove a transform node for the list of scene's transform nodes
  37831. * @param toRemove defines the transform node to remove
  37832. * @returns the index where the transform node was in the transform node list
  37833. */
  37834. removeTransformNode(toRemove: TransformNode): number;
  37835. /**
  37836. * Remove a skeleton for the list of scene's skeletons
  37837. * @param toRemove defines the skeleton to remove
  37838. * @returns the index where the skeleton was in the skeleton list
  37839. */
  37840. removeSkeleton(toRemove: Skeleton): number;
  37841. /**
  37842. * Remove a morph target for the list of scene's morph targets
  37843. * @param toRemove defines the morph target to remove
  37844. * @returns the index where the morph target was in the morph target list
  37845. */
  37846. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37847. /**
  37848. * Remove a light for the list of scene's lights
  37849. * @param toRemove defines the light to remove
  37850. * @returns the index where the light was in the light list
  37851. */
  37852. removeLight(toRemove: Light): number;
  37853. /**
  37854. * Remove a camera for the list of scene's cameras
  37855. * @param toRemove defines the camera to remove
  37856. * @returns the index where the camera was in the camera list
  37857. */
  37858. removeCamera(toRemove: Camera): number;
  37859. /**
  37860. * Remove a particle system for the list of scene's particle systems
  37861. * @param toRemove defines the particle system to remove
  37862. * @returns the index where the particle system was in the particle system list
  37863. */
  37864. removeParticleSystem(toRemove: IParticleSystem): number;
  37865. /**
  37866. * Remove a animation for the list of scene's animations
  37867. * @param toRemove defines the animation to remove
  37868. * @returns the index where the animation was in the animation list
  37869. */
  37870. removeAnimation(toRemove: Animation): number;
  37871. /**
  37872. * Will stop the animation of the given target
  37873. * @param target - the target
  37874. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37875. * @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)
  37876. */
  37877. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37878. /**
  37879. * Removes the given animation group from this scene.
  37880. * @param toRemove The animation group to remove
  37881. * @returns The index of the removed animation group
  37882. */
  37883. removeAnimationGroup(toRemove: AnimationGroup): number;
  37884. /**
  37885. * Removes the given multi-material from this scene.
  37886. * @param toRemove The multi-material to remove
  37887. * @returns The index of the removed multi-material
  37888. */
  37889. removeMultiMaterial(toRemove: MultiMaterial): number;
  37890. /**
  37891. * Removes the given material from this scene.
  37892. * @param toRemove The material to remove
  37893. * @returns The index of the removed material
  37894. */
  37895. removeMaterial(toRemove: Material): number;
  37896. /**
  37897. * Removes the given action manager from this scene.
  37898. * @param toRemove The action manager to remove
  37899. * @returns The index of the removed action manager
  37900. */
  37901. removeActionManager(toRemove: AbstractActionManager): number;
  37902. /**
  37903. * Removes the given texture from this scene.
  37904. * @param toRemove The texture to remove
  37905. * @returns The index of the removed texture
  37906. */
  37907. removeTexture(toRemove: BaseTexture): number;
  37908. /**
  37909. * Adds the given light to this scene
  37910. * @param newLight The light to add
  37911. */
  37912. addLight(newLight: Light): void;
  37913. /**
  37914. * Sorts the list list based on light priorities
  37915. */
  37916. sortLightsByPriority(): void;
  37917. /**
  37918. * Adds the given camera to this scene
  37919. * @param newCamera The camera to add
  37920. */
  37921. addCamera(newCamera: Camera): void;
  37922. /**
  37923. * Adds the given skeleton to this scene
  37924. * @param newSkeleton The skeleton to add
  37925. */
  37926. addSkeleton(newSkeleton: Skeleton): void;
  37927. /**
  37928. * Adds the given particle system to this scene
  37929. * @param newParticleSystem The particle system to add
  37930. */
  37931. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37932. /**
  37933. * Adds the given animation to this scene
  37934. * @param newAnimation The animation to add
  37935. */
  37936. addAnimation(newAnimation: Animation): void;
  37937. /**
  37938. * Adds the given animation group to this scene.
  37939. * @param newAnimationGroup The animation group to add
  37940. */
  37941. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37942. /**
  37943. * Adds the given multi-material to this scene
  37944. * @param newMultiMaterial The multi-material to add
  37945. */
  37946. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37947. /**
  37948. * Adds the given material to this scene
  37949. * @param newMaterial The material to add
  37950. */
  37951. addMaterial(newMaterial: Material): void;
  37952. /**
  37953. * Adds the given morph target to this scene
  37954. * @param newMorphTargetManager The morph target to add
  37955. */
  37956. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37957. /**
  37958. * Adds the given geometry to this scene
  37959. * @param newGeometry The geometry to add
  37960. */
  37961. addGeometry(newGeometry: Geometry): void;
  37962. /**
  37963. * Adds the given action manager to this scene
  37964. * @param newActionManager The action manager to add
  37965. */
  37966. addActionManager(newActionManager: AbstractActionManager): void;
  37967. /**
  37968. * Adds the given texture to this scene.
  37969. * @param newTexture The texture to add
  37970. */
  37971. addTexture(newTexture: BaseTexture): void;
  37972. /**
  37973. * Switch active camera
  37974. * @param newCamera defines the new active camera
  37975. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37976. */
  37977. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37978. /**
  37979. * sets the active camera of the scene using its ID
  37980. * @param id defines the camera's ID
  37981. * @return the new active camera or null if none found.
  37982. */
  37983. setActiveCameraByID(id: string): Nullable<Camera>;
  37984. /**
  37985. * sets the active camera of the scene using its name
  37986. * @param name defines the camera's name
  37987. * @returns the new active camera or null if none found.
  37988. */
  37989. setActiveCameraByName(name: string): Nullable<Camera>;
  37990. /**
  37991. * get an animation group using its name
  37992. * @param name defines the material's name
  37993. * @return the animation group or null if none found.
  37994. */
  37995. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37996. /**
  37997. * Get a material using its unique id
  37998. * @param uniqueId defines the material's unique id
  37999. * @return the material or null if none found.
  38000. */
  38001. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  38002. /**
  38003. * get a material using its id
  38004. * @param id defines the material's ID
  38005. * @return the material or null if none found.
  38006. */
  38007. getMaterialByID(id: string): Nullable<Material>;
  38008. /**
  38009. * Gets a the last added material using a given id
  38010. * @param id defines the material's ID
  38011. * @return the last material with the given id or null if none found.
  38012. */
  38013. getLastMaterialByID(id: string): Nullable<Material>;
  38014. /**
  38015. * Gets a material using its name
  38016. * @param name defines the material's name
  38017. * @return the material or null if none found.
  38018. */
  38019. getMaterialByName(name: string): Nullable<Material>;
  38020. /**
  38021. * Get a texture using its unique id
  38022. * @param uniqueId defines the texture's unique id
  38023. * @return the texture or null if none found.
  38024. */
  38025. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  38026. /**
  38027. * Gets a camera using its id
  38028. * @param id defines the id to look for
  38029. * @returns the camera or null if not found
  38030. */
  38031. getCameraByID(id: string): Nullable<Camera>;
  38032. /**
  38033. * Gets a camera using its unique id
  38034. * @param uniqueId defines the unique id to look for
  38035. * @returns the camera or null if not found
  38036. */
  38037. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  38038. /**
  38039. * Gets a camera using its name
  38040. * @param name defines the camera's name
  38041. * @return the camera or null if none found.
  38042. */
  38043. getCameraByName(name: string): Nullable<Camera>;
  38044. /**
  38045. * Gets a bone using its id
  38046. * @param id defines the bone's id
  38047. * @return the bone or null if not found
  38048. */
  38049. getBoneByID(id: string): Nullable<Bone>;
  38050. /**
  38051. * Gets a bone using its id
  38052. * @param name defines the bone's name
  38053. * @return the bone or null if not found
  38054. */
  38055. getBoneByName(name: string): Nullable<Bone>;
  38056. /**
  38057. * Gets a light node using its name
  38058. * @param name defines the the light's name
  38059. * @return the light or null if none found.
  38060. */
  38061. getLightByName(name: string): Nullable<Light>;
  38062. /**
  38063. * Gets a light node using its id
  38064. * @param id defines the light's id
  38065. * @return the light or null if none found.
  38066. */
  38067. getLightByID(id: string): Nullable<Light>;
  38068. /**
  38069. * Gets a light node using its scene-generated unique ID
  38070. * @param uniqueId defines the light's unique id
  38071. * @return the light or null if none found.
  38072. */
  38073. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  38074. /**
  38075. * Gets a particle system by id
  38076. * @param id defines the particle system id
  38077. * @return the corresponding system or null if none found
  38078. */
  38079. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  38080. /**
  38081. * Gets a geometry using its ID
  38082. * @param id defines the geometry's id
  38083. * @return the geometry or null if none found.
  38084. */
  38085. getGeometryByID(id: string): Nullable<Geometry>;
  38086. private _getGeometryByUniqueID;
  38087. /**
  38088. * Add a new geometry to this scene
  38089. * @param geometry defines the geometry to be added to the scene.
  38090. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  38091. * @return a boolean defining if the geometry was added or not
  38092. */
  38093. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  38094. /**
  38095. * Removes an existing geometry
  38096. * @param geometry defines the geometry to be removed from the scene
  38097. * @return a boolean defining if the geometry was removed or not
  38098. */
  38099. removeGeometry(geometry: Geometry): boolean;
  38100. /**
  38101. * Gets the list of geometries attached to the scene
  38102. * @returns an array of Geometry
  38103. */
  38104. getGeometries(): Geometry[];
  38105. /**
  38106. * Gets the first added mesh found of a given ID
  38107. * @param id defines the id to search for
  38108. * @return the mesh found or null if not found at all
  38109. */
  38110. getMeshByID(id: string): Nullable<AbstractMesh>;
  38111. /**
  38112. * Gets a list of meshes using their id
  38113. * @param id defines the id to search for
  38114. * @returns a list of meshes
  38115. */
  38116. getMeshesByID(id: string): Array<AbstractMesh>;
  38117. /**
  38118. * Gets the first added transform node found of a given ID
  38119. * @param id defines the id to search for
  38120. * @return the found transform node or null if not found at all.
  38121. */
  38122. getTransformNodeByID(id: string): Nullable<TransformNode>;
  38123. /**
  38124. * Gets a transform node with its auto-generated unique id
  38125. * @param uniqueId efines the unique id to search for
  38126. * @return the found transform node or null if not found at all.
  38127. */
  38128. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  38129. /**
  38130. * Gets a list of transform nodes using their id
  38131. * @param id defines the id to search for
  38132. * @returns a list of transform nodes
  38133. */
  38134. getTransformNodesByID(id: string): Array<TransformNode>;
  38135. /**
  38136. * Gets a mesh with its auto-generated unique id
  38137. * @param uniqueId defines the unique id to search for
  38138. * @return the found mesh or null if not found at all.
  38139. */
  38140. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  38141. /**
  38142. * Gets a the last added mesh using a given id
  38143. * @param id defines the id to search for
  38144. * @return the found mesh or null if not found at all.
  38145. */
  38146. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  38147. /**
  38148. * Gets a the last added node (Mesh, Camera, Light) using a given id
  38149. * @param id defines the id to search for
  38150. * @return the found node or null if not found at all
  38151. */
  38152. getLastEntryByID(id: string): Nullable<Node>;
  38153. /**
  38154. * Gets a node (Mesh, Camera, Light) using a given id
  38155. * @param id defines the id to search for
  38156. * @return the found node or null if not found at all
  38157. */
  38158. getNodeByID(id: string): Nullable<Node>;
  38159. /**
  38160. * Gets a node (Mesh, Camera, Light) using a given name
  38161. * @param name defines the name to search for
  38162. * @return the found node or null if not found at all.
  38163. */
  38164. getNodeByName(name: string): Nullable<Node>;
  38165. /**
  38166. * Gets a mesh using a given name
  38167. * @param name defines the name to search for
  38168. * @return the found mesh or null if not found at all.
  38169. */
  38170. getMeshByName(name: string): Nullable<AbstractMesh>;
  38171. /**
  38172. * Gets a transform node using a given name
  38173. * @param name defines the name to search for
  38174. * @return the found transform node or null if not found at all.
  38175. */
  38176. getTransformNodeByName(name: string): Nullable<TransformNode>;
  38177. /**
  38178. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  38179. * @param id defines the id to search for
  38180. * @return the found skeleton or null if not found at all.
  38181. */
  38182. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  38183. /**
  38184. * Gets a skeleton using a given auto generated unique id
  38185. * @param uniqueId defines the unique id to search for
  38186. * @return the found skeleton or null if not found at all.
  38187. */
  38188. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  38189. /**
  38190. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  38191. * @param id defines the id to search for
  38192. * @return the found skeleton or null if not found at all.
  38193. */
  38194. getSkeletonById(id: string): Nullable<Skeleton>;
  38195. /**
  38196. * Gets a skeleton using a given name
  38197. * @param name defines the name to search for
  38198. * @return the found skeleton or null if not found at all.
  38199. */
  38200. getSkeletonByName(name: string): Nullable<Skeleton>;
  38201. /**
  38202. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  38203. * @param id defines the id to search for
  38204. * @return the found morph target manager or null if not found at all.
  38205. */
  38206. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  38207. /**
  38208. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  38209. * @param id defines the id to search for
  38210. * @return the found morph target or null if not found at all.
  38211. */
  38212. getMorphTargetById(id: string): Nullable<MorphTarget>;
  38213. /**
  38214. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  38215. * @param name defines the name to search for
  38216. * @return the found morph target or null if not found at all.
  38217. */
  38218. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  38219. /**
  38220. * Gets a boolean indicating if the given mesh is active
  38221. * @param mesh defines the mesh to look for
  38222. * @returns true if the mesh is in the active list
  38223. */
  38224. isActiveMesh(mesh: AbstractMesh): boolean;
  38225. /**
  38226. * Return a unique id as a string which can serve as an identifier for the scene
  38227. */
  38228. get uid(): string;
  38229. /**
  38230. * Add an externaly attached data from its key.
  38231. * This method call will fail and return false, if such key already exists.
  38232. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  38233. * @param key the unique key that identifies the data
  38234. * @param data the data object to associate to the key for this Engine instance
  38235. * @return true if no such key were already present and the data was added successfully, false otherwise
  38236. */
  38237. addExternalData<T>(key: string, data: T): boolean;
  38238. /**
  38239. * Get an externaly attached data from its key
  38240. * @param key the unique key that identifies the data
  38241. * @return the associated data, if present (can be null), or undefined if not present
  38242. */
  38243. getExternalData<T>(key: string): Nullable<T>;
  38244. /**
  38245. * Get an externaly attached data from its key, create it using a factory if it's not already present
  38246. * @param key the unique key that identifies the data
  38247. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  38248. * @return the associated data, can be null if the factory returned null.
  38249. */
  38250. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  38251. /**
  38252. * Remove an externaly attached data from the Engine instance
  38253. * @param key the unique key that identifies the data
  38254. * @return true if the data was successfully removed, false if it doesn't exist
  38255. */
  38256. removeExternalData(key: string): boolean;
  38257. private _evaluateSubMesh;
  38258. /**
  38259. * Clear the processed materials smart array preventing retention point in material dispose.
  38260. */
  38261. freeProcessedMaterials(): void;
  38262. private _preventFreeActiveMeshesAndRenderingGroups;
  38263. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  38264. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  38265. * when disposing several meshes in a row or a hierarchy of meshes.
  38266. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  38267. */
  38268. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  38269. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  38270. /**
  38271. * Clear the active meshes smart array preventing retention point in mesh dispose.
  38272. */
  38273. freeActiveMeshes(): void;
  38274. /**
  38275. * Clear the info related to rendering groups preventing retention points during dispose.
  38276. */
  38277. freeRenderingGroups(): void;
  38278. /** @hidden */
  38279. _isInIntermediateRendering(): boolean;
  38280. /**
  38281. * Lambda returning the list of potentially active meshes.
  38282. */
  38283. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  38284. /**
  38285. * Lambda returning the list of potentially active sub meshes.
  38286. */
  38287. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  38288. /**
  38289. * Lambda returning the list of potentially intersecting sub meshes.
  38290. */
  38291. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  38292. /**
  38293. * Lambda returning the list of potentially colliding sub meshes.
  38294. */
  38295. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  38296. private _activeMeshesFrozen;
  38297. private _skipEvaluateActiveMeshesCompletely;
  38298. /**
  38299. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  38300. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  38301. * @returns the current scene
  38302. */
  38303. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  38304. /**
  38305. * Use this function to restart evaluating active meshes on every frame
  38306. * @returns the current scene
  38307. */
  38308. unfreezeActiveMeshes(): Scene;
  38309. private _evaluateActiveMeshes;
  38310. private _activeMesh;
  38311. /**
  38312. * Update the transform matrix to update from the current active camera
  38313. * @param force defines a boolean used to force the update even if cache is up to date
  38314. */
  38315. updateTransformMatrix(force?: boolean): void;
  38316. private _bindFrameBuffer;
  38317. /** @hidden */
  38318. _allowPostProcessClearColor: boolean;
  38319. /** @hidden */
  38320. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  38321. private _processSubCameras;
  38322. private _checkIntersections;
  38323. /** @hidden */
  38324. _advancePhysicsEngineStep(step: number): void;
  38325. /**
  38326. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  38327. */
  38328. getDeterministicFrameTime: () => number;
  38329. /** @hidden */
  38330. _animate(): void;
  38331. /** Execute all animations (for a frame) */
  38332. animate(): void;
  38333. /**
  38334. * Render the scene
  38335. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  38336. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  38337. */
  38338. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  38339. /**
  38340. * Freeze all materials
  38341. * A frozen material will not be updatable but should be faster to render
  38342. */
  38343. freezeMaterials(): void;
  38344. /**
  38345. * Unfreeze all materials
  38346. * A frozen material will not be updatable but should be faster to render
  38347. */
  38348. unfreezeMaterials(): void;
  38349. /**
  38350. * Releases all held ressources
  38351. */
  38352. dispose(): void;
  38353. /**
  38354. * Gets if the scene is already disposed
  38355. */
  38356. get isDisposed(): boolean;
  38357. /**
  38358. * Call this function to reduce memory footprint of the scene.
  38359. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  38360. */
  38361. clearCachedVertexData(): void;
  38362. /**
  38363. * This function will remove the local cached buffer data from texture.
  38364. * It will save memory but will prevent the texture from being rebuilt
  38365. */
  38366. cleanCachedTextureBuffer(): void;
  38367. /**
  38368. * Get the world extend vectors with an optional filter
  38369. *
  38370. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  38371. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  38372. */
  38373. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  38374. min: Vector3;
  38375. max: Vector3;
  38376. };
  38377. /**
  38378. * Creates a ray that can be used to pick in the scene
  38379. * @param x defines the x coordinate of the origin (on-screen)
  38380. * @param y defines the y coordinate of the origin (on-screen)
  38381. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  38382. * @param camera defines the camera to use for the picking
  38383. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  38384. * @returns a Ray
  38385. */
  38386. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  38387. /**
  38388. * Creates a ray that can be used to pick in the scene
  38389. * @param x defines the x coordinate of the origin (on-screen)
  38390. * @param y defines the y coordinate of the origin (on-screen)
  38391. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  38392. * @param result defines the ray where to store the picking ray
  38393. * @param camera defines the camera to use for the picking
  38394. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  38395. * @returns the current scene
  38396. */
  38397. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  38398. /**
  38399. * Creates a ray that can be used to pick in the scene
  38400. * @param x defines the x coordinate of the origin (on-screen)
  38401. * @param y defines the y coordinate of the origin (on-screen)
  38402. * @param camera defines the camera to use for the picking
  38403. * @returns a Ray
  38404. */
  38405. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  38406. /**
  38407. * Creates a ray that can be used to pick in the scene
  38408. * @param x defines the x coordinate of the origin (on-screen)
  38409. * @param y defines the y coordinate of the origin (on-screen)
  38410. * @param result defines the ray where to store the picking ray
  38411. * @param camera defines the camera to use for the picking
  38412. * @returns the current scene
  38413. */
  38414. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  38415. /** Launch a ray to try to pick a mesh in the scene
  38416. * @param x position on screen
  38417. * @param y position on screen
  38418. * @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
  38419. * @param fastCheck defines if the first intersection will be used (and not the closest)
  38420. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38421. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38422. * @returns a PickingInfo
  38423. */
  38424. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  38425. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  38426. * @param x position on screen
  38427. * @param y position on screen
  38428. * @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
  38429. * @param fastCheck defines if the first intersection will be used (and not the closest)
  38430. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38431. * @returns a PickingInfo (Please note that some info will not be set like distance, bv, bu and everything that cannot be capture by only using bounding infos)
  38432. */
  38433. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  38434. /** Use the given ray to pick a mesh in the scene
  38435. * @param ray The ray to use to pick meshes
  38436. * @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
  38437. * @param fastCheck defines if the first intersection will be used (and not the closest)
  38438. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38439. * @returns a PickingInfo
  38440. */
  38441. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  38442. /**
  38443. * Launch a ray to try to pick a mesh in the scene
  38444. * @param x X position on screen
  38445. * @param y Y position on screen
  38446. * @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
  38447. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38448. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38449. * @returns an array of PickingInfo
  38450. */
  38451. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  38452. /**
  38453. * Launch a ray to try to pick a mesh in the scene
  38454. * @param ray Ray to use
  38455. * @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
  38456. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38457. * @returns an array of PickingInfo
  38458. */
  38459. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  38460. /**
  38461. * Force the value of meshUnderPointer
  38462. * @param mesh defines the mesh to use
  38463. */
  38464. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38465. /**
  38466. * Gets the mesh under the pointer
  38467. * @returns a Mesh or null if no mesh is under the pointer
  38468. */
  38469. getPointerOverMesh(): Nullable<AbstractMesh>;
  38470. /** @hidden */
  38471. _rebuildGeometries(): void;
  38472. /** @hidden */
  38473. _rebuildTextures(): void;
  38474. private _getByTags;
  38475. /**
  38476. * Get a list of meshes by tags
  38477. * @param tagsQuery defines the tags query to use
  38478. * @param forEach defines a predicate used to filter results
  38479. * @returns an array of Mesh
  38480. */
  38481. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  38482. /**
  38483. * Get a list of cameras by tags
  38484. * @param tagsQuery defines the tags query to use
  38485. * @param forEach defines a predicate used to filter results
  38486. * @returns an array of Camera
  38487. */
  38488. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  38489. /**
  38490. * Get a list of lights by tags
  38491. * @param tagsQuery defines the tags query to use
  38492. * @param forEach defines a predicate used to filter results
  38493. * @returns an array of Light
  38494. */
  38495. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  38496. /**
  38497. * Get a list of materials by tags
  38498. * @param tagsQuery defines the tags query to use
  38499. * @param forEach defines a predicate used to filter results
  38500. * @returns an array of Material
  38501. */
  38502. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  38503. /**
  38504. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  38505. * This allowed control for front to back rendering or reversly depending of the special needs.
  38506. *
  38507. * @param renderingGroupId The rendering group id corresponding to its index
  38508. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38509. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38510. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38511. */
  38512. 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;
  38513. /**
  38514. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38515. *
  38516. * @param renderingGroupId The rendering group id corresponding to its index
  38517. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38518. * @param depth Automatically clears depth between groups if true and autoClear is true.
  38519. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  38520. */
  38521. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  38522. /**
  38523. * Gets the current auto clear configuration for one rendering group of the rendering
  38524. * manager.
  38525. * @param index the rendering group index to get the information for
  38526. * @returns The auto clear setup for the requested rendering group
  38527. */
  38528. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  38529. private _blockMaterialDirtyMechanism;
  38530. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  38531. get blockMaterialDirtyMechanism(): boolean;
  38532. set blockMaterialDirtyMechanism(value: boolean);
  38533. /**
  38534. * Will flag all materials as dirty to trigger new shader compilation
  38535. * @param flag defines the flag used to specify which material part must be marked as dirty
  38536. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  38537. */
  38538. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38539. /** @hidden */
  38540. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  38541. /** @hidden */
  38542. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38543. /** @hidden */
  38544. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  38545. /** @hidden */
  38546. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  38547. /** @hidden */
  38548. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38549. /** @hidden */
  38550. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38551. }
  38552. }
  38553. declare module "babylonjs/assetContainer" {
  38554. import { AbstractScene } from "babylonjs/abstractScene";
  38555. import { Scene } from "babylonjs/scene";
  38556. import { Mesh } from "babylonjs/Meshes/mesh";
  38557. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38558. import { Skeleton } from "babylonjs/Bones/skeleton";
  38559. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38560. import { Animatable } from "babylonjs/Animations/animatable";
  38561. import { Nullable } from "babylonjs/types";
  38562. import { Node } from "babylonjs/node";
  38563. /**
  38564. * Set of assets to keep when moving a scene into an asset container.
  38565. */
  38566. export class KeepAssets extends AbstractScene {
  38567. }
  38568. /**
  38569. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  38570. */
  38571. export class InstantiatedEntries {
  38572. /**
  38573. * List of new root nodes (eg. nodes with no parent)
  38574. */
  38575. rootNodes: TransformNode[];
  38576. /**
  38577. * List of new skeletons
  38578. */
  38579. skeletons: Skeleton[];
  38580. /**
  38581. * List of new animation groups
  38582. */
  38583. animationGroups: AnimationGroup[];
  38584. }
  38585. /**
  38586. * Container with a set of assets that can be added or removed from a scene.
  38587. */
  38588. export class AssetContainer extends AbstractScene {
  38589. private _wasAddedToScene;
  38590. /**
  38591. * The scene the AssetContainer belongs to.
  38592. */
  38593. scene: Scene;
  38594. /**
  38595. * Instantiates an AssetContainer.
  38596. * @param scene The scene the AssetContainer belongs to.
  38597. */
  38598. constructor(scene: Scene);
  38599. /**
  38600. * Instantiate or clone all meshes and add the new ones to the scene.
  38601. * Skeletons and animation groups will all be cloned
  38602. * @param nameFunction defines an optional function used to get new names for clones
  38603. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  38604. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  38605. */
  38606. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  38607. /**
  38608. * Adds all the assets from the container to the scene.
  38609. */
  38610. addAllToScene(): void;
  38611. /**
  38612. * Removes all the assets in the container from the scene
  38613. */
  38614. removeAllFromScene(): void;
  38615. /**
  38616. * Disposes all the assets in the container
  38617. */
  38618. dispose(): void;
  38619. private _moveAssets;
  38620. /**
  38621. * Removes all the assets contained in the scene and adds them to the container.
  38622. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38623. */
  38624. moveAllFromScene(keepAssets?: KeepAssets): void;
  38625. /**
  38626. * 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.
  38627. * @returns the root mesh
  38628. */
  38629. createRootMesh(): Mesh;
  38630. /**
  38631. * Merge animations from this asset container into a scene
  38632. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38633. * @param animatables set of animatables to retarget to a node from the scene
  38634. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38635. */
  38636. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  38637. }
  38638. }
  38639. declare module "babylonjs/abstractScene" {
  38640. import { Scene } from "babylonjs/scene";
  38641. import { Nullable } from "babylonjs/types";
  38642. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38643. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38644. import { Geometry } from "babylonjs/Meshes/geometry";
  38645. import { Skeleton } from "babylonjs/Bones/skeleton";
  38646. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38647. import { AssetContainer } from "babylonjs/assetContainer";
  38648. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38649. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38650. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38651. import { Material } from "babylonjs/Materials/material";
  38652. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38653. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38654. import { Camera } from "babylonjs/Cameras/camera";
  38655. import { Light } from "babylonjs/Lights/light";
  38656. import { Node } from "babylonjs/node";
  38657. import { Animation } from "babylonjs/Animations/animation";
  38658. /**
  38659. * Defines how the parser contract is defined.
  38660. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38661. */
  38662. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38663. /**
  38664. * Defines how the individual parser contract is defined.
  38665. * These parser can parse an individual asset
  38666. */
  38667. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38668. /**
  38669. * Base class of the scene acting as a container for the different elements composing a scene.
  38670. * This class is dynamically extended by the different components of the scene increasing
  38671. * flexibility and reducing coupling
  38672. */
  38673. export abstract class AbstractScene {
  38674. /**
  38675. * Stores the list of available parsers in the application.
  38676. */
  38677. private static _BabylonFileParsers;
  38678. /**
  38679. * Stores the list of available individual parsers in the application.
  38680. */
  38681. private static _IndividualBabylonFileParsers;
  38682. /**
  38683. * Adds a parser in the list of available ones
  38684. * @param name Defines the name of the parser
  38685. * @param parser Defines the parser to add
  38686. */
  38687. static AddParser(name: string, parser: BabylonFileParser): void;
  38688. /**
  38689. * Gets a general parser from the list of avaialble ones
  38690. * @param name Defines the name of the parser
  38691. * @returns the requested parser or null
  38692. */
  38693. static GetParser(name: string): Nullable<BabylonFileParser>;
  38694. /**
  38695. * Adds n individual parser in the list of available ones
  38696. * @param name Defines the name of the parser
  38697. * @param parser Defines the parser to add
  38698. */
  38699. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38700. /**
  38701. * Gets an individual parser from the list of avaialble ones
  38702. * @param name Defines the name of the parser
  38703. * @returns the requested parser or null
  38704. */
  38705. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38706. /**
  38707. * Parser json data and populate both a scene and its associated container object
  38708. * @param jsonData Defines the data to parse
  38709. * @param scene Defines the scene to parse the data for
  38710. * @param container Defines the container attached to the parsing sequence
  38711. * @param rootUrl Defines the root url of the data
  38712. */
  38713. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38714. /**
  38715. * Gets the list of root nodes (ie. nodes with no parent)
  38716. */
  38717. rootNodes: Node[];
  38718. /** All of the cameras added to this scene
  38719. * @see http://doc.babylonjs.com/babylon101/cameras
  38720. */
  38721. cameras: Camera[];
  38722. /**
  38723. * All of the lights added to this scene
  38724. * @see http://doc.babylonjs.com/babylon101/lights
  38725. */
  38726. lights: Light[];
  38727. /**
  38728. * All of the (abstract) meshes added to this scene
  38729. */
  38730. meshes: AbstractMesh[];
  38731. /**
  38732. * The list of skeletons added to the scene
  38733. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38734. */
  38735. skeletons: Skeleton[];
  38736. /**
  38737. * All of the particle systems added to this scene
  38738. * @see http://doc.babylonjs.com/babylon101/particles
  38739. */
  38740. particleSystems: IParticleSystem[];
  38741. /**
  38742. * Gets a list of Animations associated with the scene
  38743. */
  38744. animations: Animation[];
  38745. /**
  38746. * All of the animation groups added to this scene
  38747. * @see http://doc.babylonjs.com/how_to/group
  38748. */
  38749. animationGroups: AnimationGroup[];
  38750. /**
  38751. * All of the multi-materials added to this scene
  38752. * @see http://doc.babylonjs.com/how_to/multi_materials
  38753. */
  38754. multiMaterials: MultiMaterial[];
  38755. /**
  38756. * All of the materials added to this scene
  38757. * In the context of a Scene, it is not supposed to be modified manually.
  38758. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38759. * Note also that the order of the Material within the array is not significant and might change.
  38760. * @see http://doc.babylonjs.com/babylon101/materials
  38761. */
  38762. materials: Material[];
  38763. /**
  38764. * The list of morph target managers added to the scene
  38765. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38766. */
  38767. morphTargetManagers: MorphTargetManager[];
  38768. /**
  38769. * The list of geometries used in the scene.
  38770. */
  38771. geometries: Geometry[];
  38772. /**
  38773. * All of the tranform nodes added to this scene
  38774. * In the context of a Scene, it is not supposed to be modified manually.
  38775. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38776. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38777. * @see http://doc.babylonjs.com/how_to/transformnode
  38778. */
  38779. transformNodes: TransformNode[];
  38780. /**
  38781. * ActionManagers available on the scene.
  38782. */
  38783. actionManagers: AbstractActionManager[];
  38784. /**
  38785. * Textures to keep.
  38786. */
  38787. textures: BaseTexture[];
  38788. /**
  38789. * Environment texture for the scene
  38790. */
  38791. environmentTexture: Nullable<BaseTexture>;
  38792. /**
  38793. * @returns all meshes, lights, cameras, transformNodes and bones
  38794. */
  38795. getNodes(): Array<Node>;
  38796. }
  38797. }
  38798. declare module "babylonjs/Audio/sound" {
  38799. import { Observable } from "babylonjs/Misc/observable";
  38800. import { Vector3 } from "babylonjs/Maths/math.vector";
  38801. import { Nullable } from "babylonjs/types";
  38802. import { Scene } from "babylonjs/scene";
  38803. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38804. /**
  38805. * Interface used to define options for Sound class
  38806. */
  38807. export interface ISoundOptions {
  38808. /**
  38809. * Does the sound autoplay once loaded.
  38810. */
  38811. autoplay?: boolean;
  38812. /**
  38813. * Does the sound loop after it finishes playing once.
  38814. */
  38815. loop?: boolean;
  38816. /**
  38817. * Sound's volume
  38818. */
  38819. volume?: number;
  38820. /**
  38821. * Is it a spatial sound?
  38822. */
  38823. spatialSound?: boolean;
  38824. /**
  38825. * Maximum distance to hear that sound
  38826. */
  38827. maxDistance?: number;
  38828. /**
  38829. * Uses user defined attenuation function
  38830. */
  38831. useCustomAttenuation?: boolean;
  38832. /**
  38833. * Define the roll off factor of spatial sounds.
  38834. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38835. */
  38836. rolloffFactor?: number;
  38837. /**
  38838. * Define the reference distance the sound should be heard perfectly.
  38839. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38840. */
  38841. refDistance?: number;
  38842. /**
  38843. * Define the distance attenuation model the sound will follow.
  38844. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38845. */
  38846. distanceModel?: string;
  38847. /**
  38848. * Defines the playback speed (1 by default)
  38849. */
  38850. playbackRate?: number;
  38851. /**
  38852. * Defines if the sound is from a streaming source
  38853. */
  38854. streaming?: boolean;
  38855. /**
  38856. * Defines an optional length (in seconds) inside the sound file
  38857. */
  38858. length?: number;
  38859. /**
  38860. * Defines an optional offset (in seconds) inside the sound file
  38861. */
  38862. offset?: number;
  38863. /**
  38864. * If true, URLs will not be required to state the audio file codec to use.
  38865. */
  38866. skipCodecCheck?: boolean;
  38867. }
  38868. /**
  38869. * Defines a sound that can be played in the application.
  38870. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38871. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38872. */
  38873. export class Sound {
  38874. /**
  38875. * The name of the sound in the scene.
  38876. */
  38877. name: string;
  38878. /**
  38879. * Does the sound autoplay once loaded.
  38880. */
  38881. autoplay: boolean;
  38882. /**
  38883. * Does the sound loop after it finishes playing once.
  38884. */
  38885. loop: boolean;
  38886. /**
  38887. * Does the sound use a custom attenuation curve to simulate the falloff
  38888. * happening when the source gets further away from the camera.
  38889. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38890. */
  38891. useCustomAttenuation: boolean;
  38892. /**
  38893. * The sound track id this sound belongs to.
  38894. */
  38895. soundTrackId: number;
  38896. /**
  38897. * Is this sound currently played.
  38898. */
  38899. isPlaying: boolean;
  38900. /**
  38901. * Is this sound currently paused.
  38902. */
  38903. isPaused: boolean;
  38904. /**
  38905. * Does this sound enables spatial sound.
  38906. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38907. */
  38908. spatialSound: boolean;
  38909. /**
  38910. * Define the reference distance the sound should be heard perfectly.
  38911. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38912. */
  38913. refDistance: number;
  38914. /**
  38915. * Define the roll off factor of spatial sounds.
  38916. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38917. */
  38918. rolloffFactor: number;
  38919. /**
  38920. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38921. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38922. */
  38923. maxDistance: number;
  38924. /**
  38925. * Define the distance attenuation model the sound will follow.
  38926. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38927. */
  38928. distanceModel: string;
  38929. /**
  38930. * @hidden
  38931. * Back Compat
  38932. **/
  38933. onended: () => any;
  38934. /**
  38935. * Observable event when the current playing sound finishes.
  38936. */
  38937. onEndedObservable: Observable<Sound>;
  38938. private _panningModel;
  38939. private _playbackRate;
  38940. private _streaming;
  38941. private _startTime;
  38942. private _startOffset;
  38943. private _position;
  38944. /** @hidden */
  38945. _positionInEmitterSpace: boolean;
  38946. private _localDirection;
  38947. private _volume;
  38948. private _isReadyToPlay;
  38949. private _isDirectional;
  38950. private _readyToPlayCallback;
  38951. private _audioBuffer;
  38952. private _soundSource;
  38953. private _streamingSource;
  38954. private _soundPanner;
  38955. private _soundGain;
  38956. private _inputAudioNode;
  38957. private _outputAudioNode;
  38958. private _coneInnerAngle;
  38959. private _coneOuterAngle;
  38960. private _coneOuterGain;
  38961. private _scene;
  38962. private _connectedTransformNode;
  38963. private _customAttenuationFunction;
  38964. private _registerFunc;
  38965. private _isOutputConnected;
  38966. private _htmlAudioElement;
  38967. private _urlType;
  38968. private _length?;
  38969. private _offset?;
  38970. /** @hidden */
  38971. static _SceneComponentInitialization: (scene: Scene) => void;
  38972. /**
  38973. * Create a sound and attach it to a scene
  38974. * @param name Name of your sound
  38975. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38976. * @param scene defines the scene the sound belongs to
  38977. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38978. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38979. */
  38980. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38981. /**
  38982. * Release the sound and its associated resources
  38983. */
  38984. dispose(): void;
  38985. /**
  38986. * Gets if the sounds is ready to be played or not.
  38987. * @returns true if ready, otherwise false
  38988. */
  38989. isReady(): boolean;
  38990. private _soundLoaded;
  38991. /**
  38992. * Sets the data of the sound from an audiobuffer
  38993. * @param audioBuffer The audioBuffer containing the data
  38994. */
  38995. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38996. /**
  38997. * Updates the current sounds options such as maxdistance, loop...
  38998. * @param options A JSON object containing values named as the object properties
  38999. */
  39000. updateOptions(options: ISoundOptions): void;
  39001. private _createSpatialParameters;
  39002. private _updateSpatialParameters;
  39003. /**
  39004. * Switch the panning model to HRTF:
  39005. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  39006. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39007. */
  39008. switchPanningModelToHRTF(): void;
  39009. /**
  39010. * Switch the panning model to Equal Power:
  39011. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  39012. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39013. */
  39014. switchPanningModelToEqualPower(): void;
  39015. private _switchPanningModel;
  39016. /**
  39017. * Connect this sound to a sound track audio node like gain...
  39018. * @param soundTrackAudioNode the sound track audio node to connect to
  39019. */
  39020. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  39021. /**
  39022. * Transform this sound into a directional source
  39023. * @param coneInnerAngle Size of the inner cone in degree
  39024. * @param coneOuterAngle Size of the outer cone in degree
  39025. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  39026. */
  39027. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  39028. /**
  39029. * Gets or sets the inner angle for the directional cone.
  39030. */
  39031. get directionalConeInnerAngle(): number;
  39032. /**
  39033. * Gets or sets the inner angle for the directional cone.
  39034. */
  39035. set directionalConeInnerAngle(value: number);
  39036. /**
  39037. * Gets or sets the outer angle for the directional cone.
  39038. */
  39039. get directionalConeOuterAngle(): number;
  39040. /**
  39041. * Gets or sets the outer angle for the directional cone.
  39042. */
  39043. set directionalConeOuterAngle(value: number);
  39044. /**
  39045. * Sets the position of the emitter if spatial sound is enabled
  39046. * @param newPosition Defines the new posisiton
  39047. */
  39048. setPosition(newPosition: Vector3): void;
  39049. /**
  39050. * Sets the local direction of the emitter if spatial sound is enabled
  39051. * @param newLocalDirection Defines the new local direction
  39052. */
  39053. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  39054. private _updateDirection;
  39055. /** @hidden */
  39056. updateDistanceFromListener(): void;
  39057. /**
  39058. * Sets a new custom attenuation function for the sound.
  39059. * @param callback Defines the function used for the attenuation
  39060. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  39061. */
  39062. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  39063. /**
  39064. * Play the sound
  39065. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  39066. * @param offset (optional) Start the sound at a specific time in seconds
  39067. * @param length (optional) Sound duration (in seconds)
  39068. */
  39069. play(time?: number, offset?: number, length?: number): void;
  39070. private _onended;
  39071. /**
  39072. * Stop the sound
  39073. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  39074. */
  39075. stop(time?: number): void;
  39076. /**
  39077. * Put the sound in pause
  39078. */
  39079. pause(): void;
  39080. /**
  39081. * Sets a dedicated volume for this sounds
  39082. * @param newVolume Define the new volume of the sound
  39083. * @param time Define time for gradual change to new volume
  39084. */
  39085. setVolume(newVolume: number, time?: number): void;
  39086. /**
  39087. * Set the sound play back rate
  39088. * @param newPlaybackRate Define the playback rate the sound should be played at
  39089. */
  39090. setPlaybackRate(newPlaybackRate: number): void;
  39091. /**
  39092. * Gets the volume of the sound.
  39093. * @returns the volume of the sound
  39094. */
  39095. getVolume(): number;
  39096. /**
  39097. * Attach the sound to a dedicated mesh
  39098. * @param transformNode The transform node to connect the sound with
  39099. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  39100. */
  39101. attachToMesh(transformNode: TransformNode): void;
  39102. /**
  39103. * Detach the sound from the previously attached mesh
  39104. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  39105. */
  39106. detachFromMesh(): void;
  39107. private _onRegisterAfterWorldMatrixUpdate;
  39108. /**
  39109. * Clone the current sound in the scene.
  39110. * @returns the new sound clone
  39111. */
  39112. clone(): Nullable<Sound>;
  39113. /**
  39114. * Gets the current underlying audio buffer containing the data
  39115. * @returns the audio buffer
  39116. */
  39117. getAudioBuffer(): Nullable<AudioBuffer>;
  39118. /**
  39119. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  39120. * @returns the source node
  39121. */
  39122. getSoundSource(): Nullable<AudioBufferSourceNode>;
  39123. /**
  39124. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  39125. * @returns the gain node
  39126. */
  39127. getSoundGain(): Nullable<GainNode>;
  39128. /**
  39129. * Serializes the Sound in a JSON representation
  39130. * @returns the JSON representation of the sound
  39131. */
  39132. serialize(): any;
  39133. /**
  39134. * Parse a JSON representation of a sound to innstantiate in a given scene
  39135. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  39136. * @param scene Define the scene the new parsed sound should be created in
  39137. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  39138. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  39139. * @returns the newly parsed sound
  39140. */
  39141. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  39142. }
  39143. }
  39144. declare module "babylonjs/Actions/directAudioActions" {
  39145. import { Action } from "babylonjs/Actions/action";
  39146. import { Condition } from "babylonjs/Actions/condition";
  39147. import { Sound } from "babylonjs/Audio/sound";
  39148. /**
  39149. * This defines an action helpful to play a defined sound on a triggered action.
  39150. */
  39151. export class PlaySoundAction extends Action {
  39152. private _sound;
  39153. /**
  39154. * Instantiate the action
  39155. * @param triggerOptions defines the trigger options
  39156. * @param sound defines the sound to play
  39157. * @param condition defines the trigger related conditions
  39158. */
  39159. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  39160. /** @hidden */
  39161. _prepare(): void;
  39162. /**
  39163. * Execute the action and play the sound.
  39164. */
  39165. execute(): void;
  39166. /**
  39167. * Serializes the actions and its related information.
  39168. * @param parent defines the object to serialize in
  39169. * @returns the serialized object
  39170. */
  39171. serialize(parent: any): any;
  39172. }
  39173. /**
  39174. * This defines an action helpful to stop a defined sound on a triggered action.
  39175. */
  39176. export class StopSoundAction extends Action {
  39177. private _sound;
  39178. /**
  39179. * Instantiate the action
  39180. * @param triggerOptions defines the trigger options
  39181. * @param sound defines the sound to stop
  39182. * @param condition defines the trigger related conditions
  39183. */
  39184. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  39185. /** @hidden */
  39186. _prepare(): void;
  39187. /**
  39188. * Execute the action and stop the sound.
  39189. */
  39190. execute(): void;
  39191. /**
  39192. * Serializes the actions and its related information.
  39193. * @param parent defines the object to serialize in
  39194. * @returns the serialized object
  39195. */
  39196. serialize(parent: any): any;
  39197. }
  39198. }
  39199. declare module "babylonjs/Actions/interpolateValueAction" {
  39200. import { Action } from "babylonjs/Actions/action";
  39201. import { Condition } from "babylonjs/Actions/condition";
  39202. import { Observable } from "babylonjs/Misc/observable";
  39203. /**
  39204. * This defines an action responsible to change the value of a property
  39205. * by interpolating between its current value and the newly set one once triggered.
  39206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  39207. */
  39208. export class InterpolateValueAction extends Action {
  39209. /**
  39210. * Defines the path of the property where the value should be interpolated
  39211. */
  39212. propertyPath: string;
  39213. /**
  39214. * Defines the target value at the end of the interpolation.
  39215. */
  39216. value: any;
  39217. /**
  39218. * Defines the time it will take for the property to interpolate to the value.
  39219. */
  39220. duration: number;
  39221. /**
  39222. * Defines if the other scene animations should be stopped when the action has been triggered
  39223. */
  39224. stopOtherAnimations?: boolean;
  39225. /**
  39226. * Defines a callback raised once the interpolation animation has been done.
  39227. */
  39228. onInterpolationDone?: () => void;
  39229. /**
  39230. * Observable triggered once the interpolation animation has been done.
  39231. */
  39232. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  39233. private _target;
  39234. private _effectiveTarget;
  39235. private _property;
  39236. /**
  39237. * Instantiate the action
  39238. * @param triggerOptions defines the trigger options
  39239. * @param target defines the object containing the value to interpolate
  39240. * @param propertyPath defines the path to the property in the target object
  39241. * @param value defines the target value at the end of the interpolation
  39242. * @param duration deines the time it will take for the property to interpolate to the value.
  39243. * @param condition defines the trigger related conditions
  39244. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  39245. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  39246. */
  39247. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  39248. /** @hidden */
  39249. _prepare(): void;
  39250. /**
  39251. * Execute the action starts the value interpolation.
  39252. */
  39253. execute(): void;
  39254. /**
  39255. * Serializes the actions and its related information.
  39256. * @param parent defines the object to serialize in
  39257. * @returns the serialized object
  39258. */
  39259. serialize(parent: any): any;
  39260. }
  39261. }
  39262. declare module "babylonjs/Actions/index" {
  39263. export * from "babylonjs/Actions/abstractActionManager";
  39264. export * from "babylonjs/Actions/action";
  39265. export * from "babylonjs/Actions/actionEvent";
  39266. export * from "babylonjs/Actions/actionManager";
  39267. export * from "babylonjs/Actions/condition";
  39268. export * from "babylonjs/Actions/directActions";
  39269. export * from "babylonjs/Actions/directAudioActions";
  39270. export * from "babylonjs/Actions/interpolateValueAction";
  39271. }
  39272. declare module "babylonjs/Animations/index" {
  39273. export * from "babylonjs/Animations/animatable";
  39274. export * from "babylonjs/Animations/animation";
  39275. export * from "babylonjs/Animations/animationGroup";
  39276. export * from "babylonjs/Animations/animationPropertiesOverride";
  39277. export * from "babylonjs/Animations/easing";
  39278. export * from "babylonjs/Animations/runtimeAnimation";
  39279. export * from "babylonjs/Animations/animationEvent";
  39280. export * from "babylonjs/Animations/animationGroup";
  39281. export * from "babylonjs/Animations/animationKey";
  39282. export * from "babylonjs/Animations/animationRange";
  39283. export * from "babylonjs/Animations/animatable.interface";
  39284. }
  39285. declare module "babylonjs/Audio/soundTrack" {
  39286. import { Sound } from "babylonjs/Audio/sound";
  39287. import { Analyser } from "babylonjs/Audio/analyser";
  39288. import { Scene } from "babylonjs/scene";
  39289. /**
  39290. * Options allowed during the creation of a sound track.
  39291. */
  39292. export interface ISoundTrackOptions {
  39293. /**
  39294. * The volume the sound track should take during creation
  39295. */
  39296. volume?: number;
  39297. /**
  39298. * Define if the sound track is the main sound track of the scene
  39299. */
  39300. mainTrack?: boolean;
  39301. }
  39302. /**
  39303. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  39304. * It will be also used in a future release to apply effects on a specific track.
  39305. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  39306. */
  39307. export class SoundTrack {
  39308. /**
  39309. * The unique identifier of the sound track in the scene.
  39310. */
  39311. id: number;
  39312. /**
  39313. * The list of sounds included in the sound track.
  39314. */
  39315. soundCollection: Array<Sound>;
  39316. private _outputAudioNode;
  39317. private _scene;
  39318. private _connectedAnalyser;
  39319. private _options;
  39320. private _isInitialized;
  39321. /**
  39322. * Creates a new sound track.
  39323. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  39324. * @param scene Define the scene the sound track belongs to
  39325. * @param options
  39326. */
  39327. constructor(scene: Scene, options?: ISoundTrackOptions);
  39328. private _initializeSoundTrackAudioGraph;
  39329. /**
  39330. * Release the sound track and its associated resources
  39331. */
  39332. dispose(): void;
  39333. /**
  39334. * Adds a sound to this sound track
  39335. * @param sound define the cound to add
  39336. * @ignoreNaming
  39337. */
  39338. AddSound(sound: Sound): void;
  39339. /**
  39340. * Removes a sound to this sound track
  39341. * @param sound define the cound to remove
  39342. * @ignoreNaming
  39343. */
  39344. RemoveSound(sound: Sound): void;
  39345. /**
  39346. * Set a global volume for the full sound track.
  39347. * @param newVolume Define the new volume of the sound track
  39348. */
  39349. setVolume(newVolume: number): void;
  39350. /**
  39351. * Switch the panning model to HRTF:
  39352. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  39353. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39354. */
  39355. switchPanningModelToHRTF(): void;
  39356. /**
  39357. * Switch the panning model to Equal Power:
  39358. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  39359. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39360. */
  39361. switchPanningModelToEqualPower(): void;
  39362. /**
  39363. * Connect the sound track to an audio analyser allowing some amazing
  39364. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  39365. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  39366. * @param analyser The analyser to connect to the engine
  39367. */
  39368. connectToAnalyser(analyser: Analyser): void;
  39369. }
  39370. }
  39371. declare module "babylonjs/Audio/audioSceneComponent" {
  39372. import { Sound } from "babylonjs/Audio/sound";
  39373. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  39374. import { Nullable } from "babylonjs/types";
  39375. import { Vector3 } from "babylonjs/Maths/math.vector";
  39376. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  39377. import { Scene } from "babylonjs/scene";
  39378. import { AbstractScene } from "babylonjs/abstractScene";
  39379. import "babylonjs/Audio/audioEngine";
  39380. module "babylonjs/abstractScene" {
  39381. interface AbstractScene {
  39382. /**
  39383. * The list of sounds used in the scene.
  39384. */
  39385. sounds: Nullable<Array<Sound>>;
  39386. }
  39387. }
  39388. module "babylonjs/scene" {
  39389. interface Scene {
  39390. /**
  39391. * @hidden
  39392. * Backing field
  39393. */
  39394. _mainSoundTrack: SoundTrack;
  39395. /**
  39396. * The main sound track played by the scene.
  39397. * It cotains your primary collection of sounds.
  39398. */
  39399. mainSoundTrack: SoundTrack;
  39400. /**
  39401. * The list of sound tracks added to the scene
  39402. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39403. */
  39404. soundTracks: Nullable<Array<SoundTrack>>;
  39405. /**
  39406. * Gets a sound using a given name
  39407. * @param name defines the name to search for
  39408. * @return the found sound or null if not found at all.
  39409. */
  39410. getSoundByName(name: string): Nullable<Sound>;
  39411. /**
  39412. * Gets or sets if audio support is enabled
  39413. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39414. */
  39415. audioEnabled: boolean;
  39416. /**
  39417. * Gets or sets if audio will be output to headphones
  39418. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39419. */
  39420. headphone: boolean;
  39421. /**
  39422. * Gets or sets custom audio listener position provider
  39423. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39424. */
  39425. audioListenerPositionProvider: Nullable<() => Vector3>;
  39426. /**
  39427. * Gets or sets a refresh rate when using 3D audio positioning
  39428. */
  39429. audioPositioningRefreshRate: number;
  39430. }
  39431. }
  39432. /**
  39433. * Defines the sound scene component responsible to manage any sounds
  39434. * in a given scene.
  39435. */
  39436. export class AudioSceneComponent implements ISceneSerializableComponent {
  39437. /**
  39438. * The component name helpfull to identify the component in the list of scene components.
  39439. */
  39440. readonly name: string;
  39441. /**
  39442. * The scene the component belongs to.
  39443. */
  39444. scene: Scene;
  39445. private _audioEnabled;
  39446. /**
  39447. * Gets whether audio is enabled or not.
  39448. * Please use related enable/disable method to switch state.
  39449. */
  39450. get audioEnabled(): boolean;
  39451. private _headphone;
  39452. /**
  39453. * Gets whether audio is outputing to headphone or not.
  39454. * Please use the according Switch methods to change output.
  39455. */
  39456. get headphone(): boolean;
  39457. /**
  39458. * Gets or sets a refresh rate when using 3D audio positioning
  39459. */
  39460. audioPositioningRefreshRate: number;
  39461. private _audioListenerPositionProvider;
  39462. /**
  39463. * Gets the current audio listener position provider
  39464. */
  39465. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  39466. /**
  39467. * Sets a custom listener position for all sounds in the scene
  39468. * By default, this is the position of the first active camera
  39469. */
  39470. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  39471. /**
  39472. * Creates a new instance of the component for the given scene
  39473. * @param scene Defines the scene to register the component in
  39474. */
  39475. constructor(scene: Scene);
  39476. /**
  39477. * Registers the component in a given scene
  39478. */
  39479. register(): void;
  39480. /**
  39481. * Rebuilds the elements related to this component in case of
  39482. * context lost for instance.
  39483. */
  39484. rebuild(): void;
  39485. /**
  39486. * Serializes the component data to the specified json object
  39487. * @param serializationObject The object to serialize to
  39488. */
  39489. serialize(serializationObject: any): void;
  39490. /**
  39491. * Adds all the elements from the container to the scene
  39492. * @param container the container holding the elements
  39493. */
  39494. addFromContainer(container: AbstractScene): void;
  39495. /**
  39496. * Removes all the elements in the container from the scene
  39497. * @param container contains the elements to remove
  39498. * @param dispose if the removed element should be disposed (default: false)
  39499. */
  39500. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  39501. /**
  39502. * Disposes the component and the associated ressources.
  39503. */
  39504. dispose(): void;
  39505. /**
  39506. * Disables audio in the associated scene.
  39507. */
  39508. disableAudio(): void;
  39509. /**
  39510. * Enables audio in the associated scene.
  39511. */
  39512. enableAudio(): void;
  39513. /**
  39514. * Switch audio to headphone output.
  39515. */
  39516. switchAudioModeForHeadphones(): void;
  39517. /**
  39518. * Switch audio to normal speakers.
  39519. */
  39520. switchAudioModeForNormalSpeakers(): void;
  39521. private _cachedCameraDirection;
  39522. private _cachedCameraPosition;
  39523. private _lastCheck;
  39524. private _afterRender;
  39525. }
  39526. }
  39527. declare module "babylonjs/Audio/weightedsound" {
  39528. import { Sound } from "babylonjs/Audio/sound";
  39529. /**
  39530. * Wraps one or more Sound objects and selects one with random weight for playback.
  39531. */
  39532. export class WeightedSound {
  39533. /** When true a Sound will be selected and played when the current playing Sound completes. */
  39534. loop: boolean;
  39535. private _coneInnerAngle;
  39536. private _coneOuterAngle;
  39537. private _volume;
  39538. /** A Sound is currently playing. */
  39539. isPlaying: boolean;
  39540. /** A Sound is currently paused. */
  39541. isPaused: boolean;
  39542. private _sounds;
  39543. private _weights;
  39544. private _currentIndex?;
  39545. /**
  39546. * Creates a new WeightedSound from the list of sounds given.
  39547. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  39548. * @param sounds Array of Sounds that will be selected from.
  39549. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  39550. */
  39551. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  39552. /**
  39553. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  39554. */
  39555. get directionalConeInnerAngle(): number;
  39556. /**
  39557. * The size of cone in degress for a directional sound in which there will be no attenuation.
  39558. */
  39559. set directionalConeInnerAngle(value: number);
  39560. /**
  39561. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39562. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39563. */
  39564. get directionalConeOuterAngle(): number;
  39565. /**
  39566. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39567. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39568. */
  39569. set directionalConeOuterAngle(value: number);
  39570. /**
  39571. * Playback volume.
  39572. */
  39573. get volume(): number;
  39574. /**
  39575. * Playback volume.
  39576. */
  39577. set volume(value: number);
  39578. private _onended;
  39579. /**
  39580. * Suspend playback
  39581. */
  39582. pause(): void;
  39583. /**
  39584. * Stop playback
  39585. */
  39586. stop(): void;
  39587. /**
  39588. * Start playback.
  39589. * @param startOffset Position the clip head at a specific time in seconds.
  39590. */
  39591. play(startOffset?: number): void;
  39592. }
  39593. }
  39594. declare module "babylonjs/Audio/index" {
  39595. export * from "babylonjs/Audio/analyser";
  39596. export * from "babylonjs/Audio/audioEngine";
  39597. export * from "babylonjs/Audio/audioSceneComponent";
  39598. export * from "babylonjs/Audio/sound";
  39599. export * from "babylonjs/Audio/soundTrack";
  39600. export * from "babylonjs/Audio/weightedsound";
  39601. }
  39602. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  39603. import { Behavior } from "babylonjs/Behaviors/behavior";
  39604. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39605. import { BackEase } from "babylonjs/Animations/easing";
  39606. /**
  39607. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39608. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39609. */
  39610. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39611. /**
  39612. * Gets the name of the behavior.
  39613. */
  39614. get name(): string;
  39615. /**
  39616. * The easing function used by animations
  39617. */
  39618. static EasingFunction: BackEase;
  39619. /**
  39620. * The easing mode used by animations
  39621. */
  39622. static EasingMode: number;
  39623. /**
  39624. * The duration of the animation, in milliseconds
  39625. */
  39626. transitionDuration: number;
  39627. /**
  39628. * Length of the distance animated by the transition when lower radius is reached
  39629. */
  39630. lowerRadiusTransitionRange: number;
  39631. /**
  39632. * Length of the distance animated by the transition when upper radius is reached
  39633. */
  39634. upperRadiusTransitionRange: number;
  39635. private _autoTransitionRange;
  39636. /**
  39637. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39638. */
  39639. get autoTransitionRange(): boolean;
  39640. /**
  39641. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39642. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39643. */
  39644. set autoTransitionRange(value: boolean);
  39645. private _attachedCamera;
  39646. private _onAfterCheckInputsObserver;
  39647. private _onMeshTargetChangedObserver;
  39648. /**
  39649. * Initializes the behavior.
  39650. */
  39651. init(): void;
  39652. /**
  39653. * Attaches the behavior to its arc rotate camera.
  39654. * @param camera Defines the camera to attach the behavior to
  39655. */
  39656. attach(camera: ArcRotateCamera): void;
  39657. /**
  39658. * Detaches the behavior from its current arc rotate camera.
  39659. */
  39660. detach(): void;
  39661. private _radiusIsAnimating;
  39662. private _radiusBounceTransition;
  39663. private _animatables;
  39664. private _cachedWheelPrecision;
  39665. /**
  39666. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39667. * @param radiusLimit The limit to check against.
  39668. * @return Bool to indicate if at limit.
  39669. */
  39670. private _isRadiusAtLimit;
  39671. /**
  39672. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39673. * @param radiusDelta The delta by which to animate to. Can be negative.
  39674. */
  39675. private _applyBoundRadiusAnimation;
  39676. /**
  39677. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39678. */
  39679. protected _clearAnimationLocks(): void;
  39680. /**
  39681. * Stops and removes all animations that have been applied to the camera
  39682. */
  39683. stopAllAnimations(): void;
  39684. }
  39685. }
  39686. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39687. import { Behavior } from "babylonjs/Behaviors/behavior";
  39688. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39689. import { ExponentialEase } from "babylonjs/Animations/easing";
  39690. import { Nullable } from "babylonjs/types";
  39691. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39692. import { Vector3 } from "babylonjs/Maths/math.vector";
  39693. /**
  39694. * 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.
  39695. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39696. */
  39697. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39698. /**
  39699. * Gets the name of the behavior.
  39700. */
  39701. get name(): string;
  39702. private _mode;
  39703. private _radiusScale;
  39704. private _positionScale;
  39705. private _defaultElevation;
  39706. private _elevationReturnTime;
  39707. private _elevationReturnWaitTime;
  39708. private _zoomStopsAnimation;
  39709. private _framingTime;
  39710. /**
  39711. * The easing function used by animations
  39712. */
  39713. static EasingFunction: ExponentialEase;
  39714. /**
  39715. * The easing mode used by animations
  39716. */
  39717. static EasingMode: number;
  39718. /**
  39719. * Sets the current mode used by the behavior
  39720. */
  39721. set mode(mode: number);
  39722. /**
  39723. * Gets current mode used by the behavior.
  39724. */
  39725. get mode(): number;
  39726. /**
  39727. * Sets the scale applied to the radius (1 by default)
  39728. */
  39729. set radiusScale(radius: number);
  39730. /**
  39731. * Gets the scale applied to the radius
  39732. */
  39733. get radiusScale(): number;
  39734. /**
  39735. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39736. */
  39737. set positionScale(scale: number);
  39738. /**
  39739. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39740. */
  39741. get positionScale(): number;
  39742. /**
  39743. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39744. * behaviour is triggered, in radians.
  39745. */
  39746. set defaultElevation(elevation: number);
  39747. /**
  39748. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39749. * behaviour is triggered, in radians.
  39750. */
  39751. get defaultElevation(): number;
  39752. /**
  39753. * Sets the time (in milliseconds) taken to return to the default beta position.
  39754. * Negative value indicates camera should not return to default.
  39755. */
  39756. set elevationReturnTime(speed: number);
  39757. /**
  39758. * Gets the time (in milliseconds) taken to return to the default beta position.
  39759. * Negative value indicates camera should not return to default.
  39760. */
  39761. get elevationReturnTime(): number;
  39762. /**
  39763. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39764. */
  39765. set elevationReturnWaitTime(time: number);
  39766. /**
  39767. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39768. */
  39769. get elevationReturnWaitTime(): number;
  39770. /**
  39771. * Sets the flag that indicates if user zooming should stop animation.
  39772. */
  39773. set zoomStopsAnimation(flag: boolean);
  39774. /**
  39775. * Gets the flag that indicates if user zooming should stop animation.
  39776. */
  39777. get zoomStopsAnimation(): boolean;
  39778. /**
  39779. * Sets the transition time when framing the mesh, in milliseconds
  39780. */
  39781. set framingTime(time: number);
  39782. /**
  39783. * Gets the transition time when framing the mesh, in milliseconds
  39784. */
  39785. get framingTime(): number;
  39786. /**
  39787. * Define if the behavior should automatically change the configured
  39788. * camera limits and sensibilities.
  39789. */
  39790. autoCorrectCameraLimitsAndSensibility: boolean;
  39791. private _onPrePointerObservableObserver;
  39792. private _onAfterCheckInputsObserver;
  39793. private _onMeshTargetChangedObserver;
  39794. private _attachedCamera;
  39795. private _isPointerDown;
  39796. private _lastInteractionTime;
  39797. /**
  39798. * Initializes the behavior.
  39799. */
  39800. init(): void;
  39801. /**
  39802. * Attaches the behavior to its arc rotate camera.
  39803. * @param camera Defines the camera to attach the behavior to
  39804. */
  39805. attach(camera: ArcRotateCamera): void;
  39806. /**
  39807. * Detaches the behavior from its current arc rotate camera.
  39808. */
  39809. detach(): void;
  39810. private _animatables;
  39811. private _betaIsAnimating;
  39812. private _betaTransition;
  39813. private _radiusTransition;
  39814. private _vectorTransition;
  39815. /**
  39816. * Targets the given mesh and updates zoom level accordingly.
  39817. * @param mesh The mesh to target.
  39818. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39819. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39820. */
  39821. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39822. /**
  39823. * Targets the given mesh with its children and updates zoom level accordingly.
  39824. * @param mesh The mesh to target.
  39825. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39826. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39827. */
  39828. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39829. /**
  39830. * Targets the given meshes with their children and updates zoom level accordingly.
  39831. * @param meshes The mesh to target.
  39832. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39833. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39834. */
  39835. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39836. /**
  39837. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39838. * @param minimumWorld Determines the smaller position of the bounding box extend
  39839. * @param maximumWorld Determines the bigger position of the bounding box extend
  39840. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39841. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39842. */
  39843. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39844. /**
  39845. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39846. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39847. * frustum width.
  39848. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39849. * to fully enclose the mesh in the viewing frustum.
  39850. */
  39851. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39852. /**
  39853. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39854. * is automatically returned to its default position (expected to be above ground plane).
  39855. */
  39856. private _maintainCameraAboveGround;
  39857. /**
  39858. * Returns the frustum slope based on the canvas ratio and camera FOV
  39859. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39860. */
  39861. private _getFrustumSlope;
  39862. /**
  39863. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39864. */
  39865. private _clearAnimationLocks;
  39866. /**
  39867. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39868. */
  39869. private _applyUserInteraction;
  39870. /**
  39871. * Stops and removes all animations that have been applied to the camera
  39872. */
  39873. stopAllAnimations(): void;
  39874. /**
  39875. * Gets a value indicating if the user is moving the camera
  39876. */
  39877. get isUserIsMoving(): boolean;
  39878. /**
  39879. * The camera can move all the way towards the mesh.
  39880. */
  39881. static IgnoreBoundsSizeMode: number;
  39882. /**
  39883. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39884. */
  39885. static FitFrustumSidesMode: number;
  39886. }
  39887. }
  39888. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39889. import { Nullable } from "babylonjs/types";
  39890. import { Camera } from "babylonjs/Cameras/camera";
  39891. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39892. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39893. /**
  39894. * Base class for Camera Pointer Inputs.
  39895. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39896. * for example usage.
  39897. */
  39898. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39899. /**
  39900. * Defines the camera the input is attached to.
  39901. */
  39902. abstract camera: Camera;
  39903. /**
  39904. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39905. */
  39906. protected _altKey: boolean;
  39907. protected _ctrlKey: boolean;
  39908. protected _metaKey: boolean;
  39909. protected _shiftKey: boolean;
  39910. /**
  39911. * Which mouse buttons were pressed at time of last mouse event.
  39912. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39913. */
  39914. protected _buttonsPressed: number;
  39915. /**
  39916. * Defines the buttons associated with the input to handle camera move.
  39917. */
  39918. buttons: number[];
  39919. /**
  39920. * Attach the input controls to a specific dom element to get the input from.
  39921. * @param element Defines the element the controls should be listened from
  39922. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39923. */
  39924. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39925. /**
  39926. * Detach the current controls from the specified dom element.
  39927. * @param element Defines the element to stop listening the inputs from
  39928. */
  39929. detachControl(element: Nullable<HTMLElement>): void;
  39930. /**
  39931. * Gets the class name of the current input.
  39932. * @returns the class name
  39933. */
  39934. getClassName(): string;
  39935. /**
  39936. * Get the friendly name associated with the input class.
  39937. * @returns the input friendly name
  39938. */
  39939. getSimpleName(): string;
  39940. /**
  39941. * Called on pointer POINTERDOUBLETAP event.
  39942. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39943. */
  39944. protected onDoubleTap(type: string): void;
  39945. /**
  39946. * Called on pointer POINTERMOVE event if only a single touch is active.
  39947. * Override this method to provide functionality.
  39948. */
  39949. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39950. /**
  39951. * Called on pointer POINTERMOVE event if multiple touches are active.
  39952. * Override this method to provide functionality.
  39953. */
  39954. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39955. /**
  39956. * Called on JS contextmenu event.
  39957. * Override this method to provide functionality.
  39958. */
  39959. protected onContextMenu(evt: PointerEvent): void;
  39960. /**
  39961. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39962. * press.
  39963. * Override this method to provide functionality.
  39964. */
  39965. protected onButtonDown(evt: PointerEvent): void;
  39966. /**
  39967. * Called each time a new POINTERUP event occurs. Ie, for each button
  39968. * release.
  39969. * Override this method to provide functionality.
  39970. */
  39971. protected onButtonUp(evt: PointerEvent): void;
  39972. /**
  39973. * Called when window becomes inactive.
  39974. * Override this method to provide functionality.
  39975. */
  39976. protected onLostFocus(): void;
  39977. private _pointerInput;
  39978. private _observer;
  39979. private _onLostFocus;
  39980. private pointA;
  39981. private pointB;
  39982. }
  39983. }
  39984. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39985. import { Nullable } from "babylonjs/types";
  39986. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39987. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39988. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39989. /**
  39990. * Manage the pointers inputs to control an arc rotate camera.
  39991. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39992. */
  39993. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39994. /**
  39995. * Defines the camera the input is attached to.
  39996. */
  39997. camera: ArcRotateCamera;
  39998. /**
  39999. * Gets the class name of the current input.
  40000. * @returns the class name
  40001. */
  40002. getClassName(): string;
  40003. /**
  40004. * Defines the buttons associated with the input to handle camera move.
  40005. */
  40006. buttons: number[];
  40007. /**
  40008. * Defines the pointer angular sensibility along the X axis or how fast is
  40009. * the camera rotating.
  40010. */
  40011. angularSensibilityX: number;
  40012. /**
  40013. * Defines the pointer angular sensibility along the Y axis or how fast is
  40014. * the camera rotating.
  40015. */
  40016. angularSensibilityY: number;
  40017. /**
  40018. * Defines the pointer pinch precision or how fast is the camera zooming.
  40019. */
  40020. pinchPrecision: number;
  40021. /**
  40022. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40023. * from 0.
  40024. * It defines the percentage of current camera.radius to use as delta when
  40025. * pinch zoom is used.
  40026. */
  40027. pinchDeltaPercentage: number;
  40028. /**
  40029. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  40030. * that any object in the plane at the camera's target point will scale
  40031. * perfectly with finger motion.
  40032. * Overrides pinchDeltaPercentage and pinchPrecision.
  40033. */
  40034. useNaturalPinchZoom: boolean;
  40035. /**
  40036. * Defines the pointer panning sensibility or how fast is the camera moving.
  40037. */
  40038. panningSensibility: number;
  40039. /**
  40040. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  40041. */
  40042. multiTouchPanning: boolean;
  40043. /**
  40044. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  40045. * zoom (pinch) through multitouch.
  40046. */
  40047. multiTouchPanAndZoom: boolean;
  40048. /**
  40049. * Revers pinch action direction.
  40050. */
  40051. pinchInwards: boolean;
  40052. private _isPanClick;
  40053. private _twoFingerActivityCount;
  40054. private _isPinching;
  40055. /**
  40056. * Called on pointer POINTERMOVE event if only a single touch is active.
  40057. */
  40058. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40059. /**
  40060. * Called on pointer POINTERDOUBLETAP event.
  40061. */
  40062. protected onDoubleTap(type: string): void;
  40063. /**
  40064. * Called on pointer POINTERMOVE event if multiple touches are active.
  40065. */
  40066. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40067. /**
  40068. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  40069. * press.
  40070. */
  40071. protected onButtonDown(evt: PointerEvent): void;
  40072. /**
  40073. * Called each time a new POINTERUP event occurs. Ie, for each button
  40074. * release.
  40075. */
  40076. protected onButtonUp(evt: PointerEvent): void;
  40077. /**
  40078. * Called when window becomes inactive.
  40079. */
  40080. protected onLostFocus(): void;
  40081. }
  40082. }
  40083. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  40084. import { Nullable } from "babylonjs/types";
  40085. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40086. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40087. /**
  40088. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  40089. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40090. */
  40091. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  40092. /**
  40093. * Defines the camera the input is attached to.
  40094. */
  40095. camera: ArcRotateCamera;
  40096. /**
  40097. * Defines the list of key codes associated with the up action (increase alpha)
  40098. */
  40099. keysUp: number[];
  40100. /**
  40101. * Defines the list of key codes associated with the down action (decrease alpha)
  40102. */
  40103. keysDown: number[];
  40104. /**
  40105. * Defines the list of key codes associated with the left action (increase beta)
  40106. */
  40107. keysLeft: number[];
  40108. /**
  40109. * Defines the list of key codes associated with the right action (decrease beta)
  40110. */
  40111. keysRight: number[];
  40112. /**
  40113. * Defines the list of key codes associated with the reset action.
  40114. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  40115. */
  40116. keysReset: number[];
  40117. /**
  40118. * Defines the panning sensibility of the inputs.
  40119. * (How fast is the camera panning)
  40120. */
  40121. panningSensibility: number;
  40122. /**
  40123. * Defines the zooming sensibility of the inputs.
  40124. * (How fast is the camera zooming)
  40125. */
  40126. zoomingSensibility: number;
  40127. /**
  40128. * Defines whether maintaining the alt key down switch the movement mode from
  40129. * orientation to zoom.
  40130. */
  40131. useAltToZoom: boolean;
  40132. /**
  40133. * Rotation speed of the camera
  40134. */
  40135. angularSpeed: number;
  40136. private _keys;
  40137. private _ctrlPressed;
  40138. private _altPressed;
  40139. private _onCanvasBlurObserver;
  40140. private _onKeyboardObserver;
  40141. private _engine;
  40142. private _scene;
  40143. /**
  40144. * Attach the input controls to a specific dom element to get the input from.
  40145. * @param element Defines the element the controls should be listened from
  40146. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40147. */
  40148. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40149. /**
  40150. * Detach the current controls from the specified dom element.
  40151. * @param element Defines the element to stop listening the inputs from
  40152. */
  40153. detachControl(element: Nullable<HTMLElement>): void;
  40154. /**
  40155. * Update the current camera state depending on the inputs that have been used this frame.
  40156. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40157. */
  40158. checkInputs(): void;
  40159. /**
  40160. * Gets the class name of the current intput.
  40161. * @returns the class name
  40162. */
  40163. getClassName(): string;
  40164. /**
  40165. * Get the friendly name associated with the input class.
  40166. * @returns the input friendly name
  40167. */
  40168. getSimpleName(): string;
  40169. }
  40170. }
  40171. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  40172. import { Nullable } from "babylonjs/types";
  40173. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40174. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40175. /**
  40176. * Manage the mouse wheel inputs to control an arc rotate camera.
  40177. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40178. */
  40179. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  40180. /**
  40181. * Defines the camera the input is attached to.
  40182. */
  40183. camera: ArcRotateCamera;
  40184. /**
  40185. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40186. */
  40187. wheelPrecision: number;
  40188. /**
  40189. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40190. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40191. */
  40192. wheelDeltaPercentage: number;
  40193. private _wheel;
  40194. private _observer;
  40195. private computeDeltaFromMouseWheelLegacyEvent;
  40196. /**
  40197. * Attach the input controls to a specific dom element to get the input from.
  40198. * @param element Defines the element the controls should be listened from
  40199. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40200. */
  40201. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40202. /**
  40203. * Detach the current controls from the specified dom element.
  40204. * @param element Defines the element to stop listening the inputs from
  40205. */
  40206. detachControl(element: Nullable<HTMLElement>): void;
  40207. /**
  40208. * Gets the class name of the current intput.
  40209. * @returns the class name
  40210. */
  40211. getClassName(): string;
  40212. /**
  40213. * Get the friendly name associated with the input class.
  40214. * @returns the input friendly name
  40215. */
  40216. getSimpleName(): string;
  40217. }
  40218. }
  40219. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40220. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40221. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40222. /**
  40223. * Default Inputs manager for the ArcRotateCamera.
  40224. * It groups all the default supported inputs for ease of use.
  40225. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40226. */
  40227. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  40228. /**
  40229. * Instantiates a new ArcRotateCameraInputsManager.
  40230. * @param camera Defines the camera the inputs belong to
  40231. */
  40232. constructor(camera: ArcRotateCamera);
  40233. /**
  40234. * Add mouse wheel input support to the input manager.
  40235. * @returns the current input manager
  40236. */
  40237. addMouseWheel(): ArcRotateCameraInputsManager;
  40238. /**
  40239. * Add pointers input support to the input manager.
  40240. * @returns the current input manager
  40241. */
  40242. addPointers(): ArcRotateCameraInputsManager;
  40243. /**
  40244. * Add keyboard input support to the input manager.
  40245. * @returns the current input manager
  40246. */
  40247. addKeyboard(): ArcRotateCameraInputsManager;
  40248. }
  40249. }
  40250. declare module "babylonjs/Cameras/arcRotateCamera" {
  40251. import { Observable } from "babylonjs/Misc/observable";
  40252. import { Nullable } from "babylonjs/types";
  40253. import { Scene } from "babylonjs/scene";
  40254. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  40255. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40256. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40257. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40258. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  40259. import { Camera } from "babylonjs/Cameras/camera";
  40260. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40261. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40262. import { Collider } from "babylonjs/Collisions/collider";
  40263. /**
  40264. * This represents an orbital type of camera.
  40265. *
  40266. * 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.
  40267. * 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.
  40268. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  40269. */
  40270. export class ArcRotateCamera extends TargetCamera {
  40271. /**
  40272. * Defines the rotation angle of the camera along the longitudinal axis.
  40273. */
  40274. alpha: number;
  40275. /**
  40276. * Defines the rotation angle of the camera along the latitudinal axis.
  40277. */
  40278. beta: number;
  40279. /**
  40280. * Defines the radius of the camera from it s target point.
  40281. */
  40282. radius: number;
  40283. protected _target: Vector3;
  40284. protected _targetHost: Nullable<AbstractMesh>;
  40285. /**
  40286. * Defines the target point of the camera.
  40287. * The camera looks towards it form the radius distance.
  40288. */
  40289. get target(): Vector3;
  40290. set target(value: Vector3);
  40291. /**
  40292. * Define the current local position of the camera in the scene
  40293. */
  40294. get position(): Vector3;
  40295. set position(newPosition: Vector3);
  40296. protected _upVector: Vector3;
  40297. protected _upToYMatrix: Matrix;
  40298. protected _YToUpMatrix: Matrix;
  40299. /**
  40300. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  40301. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  40302. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  40303. */
  40304. set upVector(vec: Vector3);
  40305. get upVector(): Vector3;
  40306. /**
  40307. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  40308. */
  40309. setMatUp(): void;
  40310. /**
  40311. * Current inertia value on the longitudinal axis.
  40312. * The bigger this number the longer it will take for the camera to stop.
  40313. */
  40314. inertialAlphaOffset: number;
  40315. /**
  40316. * Current inertia value on the latitudinal axis.
  40317. * The bigger this number the longer it will take for the camera to stop.
  40318. */
  40319. inertialBetaOffset: number;
  40320. /**
  40321. * Current inertia value on the radius axis.
  40322. * The bigger this number the longer it will take for the camera to stop.
  40323. */
  40324. inertialRadiusOffset: number;
  40325. /**
  40326. * Minimum allowed angle on the longitudinal axis.
  40327. * This can help limiting how the Camera is able to move in the scene.
  40328. */
  40329. lowerAlphaLimit: Nullable<number>;
  40330. /**
  40331. * Maximum allowed angle on the longitudinal axis.
  40332. * This can help limiting how the Camera is able to move in the scene.
  40333. */
  40334. upperAlphaLimit: Nullable<number>;
  40335. /**
  40336. * Minimum allowed angle on the latitudinal axis.
  40337. * This can help limiting how the Camera is able to move in the scene.
  40338. */
  40339. lowerBetaLimit: number;
  40340. /**
  40341. * Maximum allowed angle on the latitudinal axis.
  40342. * This can help limiting how the Camera is able to move in the scene.
  40343. */
  40344. upperBetaLimit: number;
  40345. /**
  40346. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  40347. * This can help limiting how the Camera is able to move in the scene.
  40348. */
  40349. lowerRadiusLimit: Nullable<number>;
  40350. /**
  40351. * Maximum allowed distance of the camera to the target (The camera can not get further).
  40352. * This can help limiting how the Camera is able to move in the scene.
  40353. */
  40354. upperRadiusLimit: Nullable<number>;
  40355. /**
  40356. * Defines the current inertia value used during panning of the camera along the X axis.
  40357. */
  40358. inertialPanningX: number;
  40359. /**
  40360. * Defines the current inertia value used during panning of the camera along the Y axis.
  40361. */
  40362. inertialPanningY: number;
  40363. /**
  40364. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  40365. * Basically if your fingers moves away from more than this distance you will be considered
  40366. * in pinch mode.
  40367. */
  40368. pinchToPanMaxDistance: number;
  40369. /**
  40370. * Defines the maximum distance the camera can pan.
  40371. * This could help keeping the cammera always in your scene.
  40372. */
  40373. panningDistanceLimit: Nullable<number>;
  40374. /**
  40375. * Defines the target of the camera before paning.
  40376. */
  40377. panningOriginTarget: Vector3;
  40378. /**
  40379. * Defines the value of the inertia used during panning.
  40380. * 0 would mean stop inertia and one would mean no decelleration at all.
  40381. */
  40382. panningInertia: number;
  40383. /**
  40384. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  40385. */
  40386. get angularSensibilityX(): number;
  40387. set angularSensibilityX(value: number);
  40388. /**
  40389. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  40390. */
  40391. get angularSensibilityY(): number;
  40392. set angularSensibilityY(value: number);
  40393. /**
  40394. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  40395. */
  40396. get pinchPrecision(): number;
  40397. set pinchPrecision(value: number);
  40398. /**
  40399. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  40400. * It will be used instead of pinchDeltaPrecision if different from 0.
  40401. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40402. */
  40403. get pinchDeltaPercentage(): number;
  40404. set pinchDeltaPercentage(value: number);
  40405. /**
  40406. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  40407. * and pinch delta percentage.
  40408. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  40409. * that any object in the plane at the camera's target point will scale
  40410. * perfectly with finger motion.
  40411. */
  40412. get useNaturalPinchZoom(): boolean;
  40413. set useNaturalPinchZoom(value: boolean);
  40414. /**
  40415. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  40416. */
  40417. get panningSensibility(): number;
  40418. set panningSensibility(value: number);
  40419. /**
  40420. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  40421. */
  40422. get keysUp(): number[];
  40423. set keysUp(value: number[]);
  40424. /**
  40425. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  40426. */
  40427. get keysDown(): number[];
  40428. set keysDown(value: number[]);
  40429. /**
  40430. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  40431. */
  40432. get keysLeft(): number[];
  40433. set keysLeft(value: number[]);
  40434. /**
  40435. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  40436. */
  40437. get keysRight(): number[];
  40438. set keysRight(value: number[]);
  40439. /**
  40440. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40441. */
  40442. get wheelPrecision(): number;
  40443. set wheelPrecision(value: number);
  40444. /**
  40445. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  40446. * It will be used instead of pinchDeltaPrecision if different from 0.
  40447. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40448. */
  40449. get wheelDeltaPercentage(): number;
  40450. set wheelDeltaPercentage(value: number);
  40451. /**
  40452. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  40453. */
  40454. zoomOnFactor: number;
  40455. /**
  40456. * Defines a screen offset for the camera position.
  40457. */
  40458. targetScreenOffset: Vector2;
  40459. /**
  40460. * Allows the camera to be completely reversed.
  40461. * If false the camera can not arrive upside down.
  40462. */
  40463. allowUpsideDown: boolean;
  40464. /**
  40465. * Define if double tap/click is used to restore the previously saved state of the camera.
  40466. */
  40467. useInputToRestoreState: boolean;
  40468. /** @hidden */
  40469. _viewMatrix: Matrix;
  40470. /** @hidden */
  40471. _useCtrlForPanning: boolean;
  40472. /** @hidden */
  40473. _panningMouseButton: number;
  40474. /**
  40475. * Defines the input associated to the camera.
  40476. */
  40477. inputs: ArcRotateCameraInputsManager;
  40478. /** @hidden */
  40479. _reset: () => void;
  40480. /**
  40481. * Defines the allowed panning axis.
  40482. */
  40483. panningAxis: Vector3;
  40484. protected _localDirection: Vector3;
  40485. protected _transformedDirection: Vector3;
  40486. private _bouncingBehavior;
  40487. /**
  40488. * Gets the bouncing behavior of the camera if it has been enabled.
  40489. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40490. */
  40491. get bouncingBehavior(): Nullable<BouncingBehavior>;
  40492. /**
  40493. * Defines if the bouncing behavior of the camera is enabled on the camera.
  40494. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40495. */
  40496. get useBouncingBehavior(): boolean;
  40497. set useBouncingBehavior(value: boolean);
  40498. private _framingBehavior;
  40499. /**
  40500. * Gets the framing behavior of the camera if it has been enabled.
  40501. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40502. */
  40503. get framingBehavior(): Nullable<FramingBehavior>;
  40504. /**
  40505. * Defines if the framing behavior of the camera is enabled on the camera.
  40506. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40507. */
  40508. get useFramingBehavior(): boolean;
  40509. set useFramingBehavior(value: boolean);
  40510. private _autoRotationBehavior;
  40511. /**
  40512. * Gets the auto rotation behavior of the camera if it has been enabled.
  40513. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40514. */
  40515. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  40516. /**
  40517. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  40518. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40519. */
  40520. get useAutoRotationBehavior(): boolean;
  40521. set useAutoRotationBehavior(value: boolean);
  40522. /**
  40523. * Observable triggered when the mesh target has been changed on the camera.
  40524. */
  40525. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  40526. /**
  40527. * Event raised when the camera is colliding with a mesh.
  40528. */
  40529. onCollide: (collidedMesh: AbstractMesh) => void;
  40530. /**
  40531. * Defines whether the camera should check collision with the objects oh the scene.
  40532. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  40533. */
  40534. checkCollisions: boolean;
  40535. /**
  40536. * Defines the collision radius of the camera.
  40537. * This simulates a sphere around the camera.
  40538. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40539. */
  40540. collisionRadius: Vector3;
  40541. protected _collider: Collider;
  40542. protected _previousPosition: Vector3;
  40543. protected _collisionVelocity: Vector3;
  40544. protected _newPosition: Vector3;
  40545. protected _previousAlpha: number;
  40546. protected _previousBeta: number;
  40547. protected _previousRadius: number;
  40548. protected _collisionTriggered: boolean;
  40549. protected _targetBoundingCenter: Nullable<Vector3>;
  40550. private _computationVector;
  40551. /**
  40552. * Instantiates a new ArcRotateCamera in a given scene
  40553. * @param name Defines the name of the camera
  40554. * @param alpha Defines the camera rotation along the logitudinal axis
  40555. * @param beta Defines the camera rotation along the latitudinal axis
  40556. * @param radius Defines the camera distance from its target
  40557. * @param target Defines the camera target
  40558. * @param scene Defines the scene the camera belongs to
  40559. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  40560. */
  40561. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40562. /** @hidden */
  40563. _initCache(): void;
  40564. /** @hidden */
  40565. _updateCache(ignoreParentClass?: boolean): void;
  40566. protected _getTargetPosition(): Vector3;
  40567. private _storedAlpha;
  40568. private _storedBeta;
  40569. private _storedRadius;
  40570. private _storedTarget;
  40571. private _storedTargetScreenOffset;
  40572. /**
  40573. * Stores the current state of the camera (alpha, beta, radius and target)
  40574. * @returns the camera itself
  40575. */
  40576. storeState(): Camera;
  40577. /**
  40578. * @hidden
  40579. * Restored camera state. You must call storeState() first
  40580. */
  40581. _restoreStateValues(): boolean;
  40582. /** @hidden */
  40583. _isSynchronizedViewMatrix(): boolean;
  40584. /**
  40585. * Attached controls to the current camera.
  40586. * @param element Defines the element the controls should be listened from
  40587. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40588. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  40589. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  40590. */
  40591. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  40592. /**
  40593. * Detach the current controls from the camera.
  40594. * The camera will stop reacting to inputs.
  40595. * @param element Defines the element to stop listening the inputs from
  40596. */
  40597. detachControl(element: HTMLElement): void;
  40598. /** @hidden */
  40599. _checkInputs(): void;
  40600. protected _checkLimits(): void;
  40601. /**
  40602. * Rebuilds angles (alpha, beta) and radius from the give position and target
  40603. */
  40604. rebuildAnglesAndRadius(): void;
  40605. /**
  40606. * Use a position to define the current camera related information like alpha, beta and radius
  40607. * @param position Defines the position to set the camera at
  40608. */
  40609. setPosition(position: Vector3): void;
  40610. /**
  40611. * Defines the target the camera should look at.
  40612. * This will automatically adapt alpha beta and radius to fit within the new target.
  40613. * @param target Defines the new target as a Vector or a mesh
  40614. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  40615. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  40616. */
  40617. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  40618. /** @hidden */
  40619. _getViewMatrix(): Matrix;
  40620. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  40621. /**
  40622. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  40623. * @param meshes Defines the mesh to zoom on
  40624. * @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)
  40625. */
  40626. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  40627. /**
  40628. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  40629. * The target will be changed but the radius
  40630. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  40631. * @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)
  40632. */
  40633. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  40634. min: Vector3;
  40635. max: Vector3;
  40636. distance: number;
  40637. }, doNotUpdateMaxZ?: boolean): void;
  40638. /**
  40639. * @override
  40640. * Override Camera.createRigCamera
  40641. */
  40642. createRigCamera(name: string, cameraIndex: number): Camera;
  40643. /**
  40644. * @hidden
  40645. * @override
  40646. * Override Camera._updateRigCameras
  40647. */
  40648. _updateRigCameras(): void;
  40649. /**
  40650. * Destroy the camera and release the current resources hold by it.
  40651. */
  40652. dispose(): void;
  40653. /**
  40654. * Gets the current object class name.
  40655. * @return the class name
  40656. */
  40657. getClassName(): string;
  40658. }
  40659. }
  40660. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40661. import { Behavior } from "babylonjs/Behaviors/behavior";
  40662. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40663. /**
  40664. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40665. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40666. */
  40667. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40668. /**
  40669. * Gets the name of the behavior.
  40670. */
  40671. get name(): string;
  40672. private _zoomStopsAnimation;
  40673. private _idleRotationSpeed;
  40674. private _idleRotationWaitTime;
  40675. private _idleRotationSpinupTime;
  40676. /**
  40677. * Sets the flag that indicates if user zooming should stop animation.
  40678. */
  40679. set zoomStopsAnimation(flag: boolean);
  40680. /**
  40681. * Gets the flag that indicates if user zooming should stop animation.
  40682. */
  40683. get zoomStopsAnimation(): boolean;
  40684. /**
  40685. * Sets the default speed at which the camera rotates around the model.
  40686. */
  40687. set idleRotationSpeed(speed: number);
  40688. /**
  40689. * Gets the default speed at which the camera rotates around the model.
  40690. */
  40691. get idleRotationSpeed(): number;
  40692. /**
  40693. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40694. */
  40695. set idleRotationWaitTime(time: number);
  40696. /**
  40697. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40698. */
  40699. get idleRotationWaitTime(): number;
  40700. /**
  40701. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40702. */
  40703. set idleRotationSpinupTime(time: number);
  40704. /**
  40705. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40706. */
  40707. get idleRotationSpinupTime(): number;
  40708. /**
  40709. * Gets a value indicating if the camera is currently rotating because of this behavior
  40710. */
  40711. get rotationInProgress(): boolean;
  40712. private _onPrePointerObservableObserver;
  40713. private _onAfterCheckInputsObserver;
  40714. private _attachedCamera;
  40715. private _isPointerDown;
  40716. private _lastFrameTime;
  40717. private _lastInteractionTime;
  40718. private _cameraRotationSpeed;
  40719. /**
  40720. * Initializes the behavior.
  40721. */
  40722. init(): void;
  40723. /**
  40724. * Attaches the behavior to its arc rotate camera.
  40725. * @param camera Defines the camera to attach the behavior to
  40726. */
  40727. attach(camera: ArcRotateCamera): void;
  40728. /**
  40729. * Detaches the behavior from its current arc rotate camera.
  40730. */
  40731. detach(): void;
  40732. /**
  40733. * Returns true if user is scrolling.
  40734. * @return true if user is scrolling.
  40735. */
  40736. private _userIsZooming;
  40737. private _lastFrameRadius;
  40738. private _shouldAnimationStopForInteraction;
  40739. /**
  40740. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40741. */
  40742. private _applyUserInteraction;
  40743. private _userIsMoving;
  40744. }
  40745. }
  40746. declare module "babylonjs/Behaviors/Cameras/index" {
  40747. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40748. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40749. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40750. }
  40751. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40752. import { Mesh } from "babylonjs/Meshes/mesh";
  40753. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40754. import { Behavior } from "babylonjs/Behaviors/behavior";
  40755. /**
  40756. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40757. */
  40758. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40759. private ui;
  40760. /**
  40761. * The name of the behavior
  40762. */
  40763. name: string;
  40764. /**
  40765. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40766. */
  40767. distanceAwayFromFace: number;
  40768. /**
  40769. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40770. */
  40771. distanceAwayFromBottomOfFace: number;
  40772. private _faceVectors;
  40773. private _target;
  40774. private _scene;
  40775. private _onRenderObserver;
  40776. private _tmpMatrix;
  40777. private _tmpVector;
  40778. /**
  40779. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40780. * @param ui The transform node that should be attched to the mesh
  40781. */
  40782. constructor(ui: TransformNode);
  40783. /**
  40784. * Initializes the behavior
  40785. */
  40786. init(): void;
  40787. private _closestFace;
  40788. private _zeroVector;
  40789. private _lookAtTmpMatrix;
  40790. private _lookAtToRef;
  40791. /**
  40792. * Attaches the AttachToBoxBehavior to the passed in mesh
  40793. * @param target The mesh that the specified node will be attached to
  40794. */
  40795. attach(target: Mesh): void;
  40796. /**
  40797. * Detaches the behavior from the mesh
  40798. */
  40799. detach(): void;
  40800. }
  40801. }
  40802. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40803. import { Behavior } from "babylonjs/Behaviors/behavior";
  40804. import { Mesh } from "babylonjs/Meshes/mesh";
  40805. /**
  40806. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40807. */
  40808. export class FadeInOutBehavior implements Behavior<Mesh> {
  40809. /**
  40810. * Time in milliseconds to delay before fading in (Default: 0)
  40811. */
  40812. delay: number;
  40813. /**
  40814. * Time in milliseconds for the mesh to fade in (Default: 300)
  40815. */
  40816. fadeInTime: number;
  40817. private _millisecondsPerFrame;
  40818. private _hovered;
  40819. private _hoverValue;
  40820. private _ownerNode;
  40821. /**
  40822. * Instatiates the FadeInOutBehavior
  40823. */
  40824. constructor();
  40825. /**
  40826. * The name of the behavior
  40827. */
  40828. get name(): string;
  40829. /**
  40830. * Initializes the behavior
  40831. */
  40832. init(): void;
  40833. /**
  40834. * Attaches the fade behavior on the passed in mesh
  40835. * @param ownerNode The mesh that will be faded in/out once attached
  40836. */
  40837. attach(ownerNode: Mesh): void;
  40838. /**
  40839. * Detaches the behavior from the mesh
  40840. */
  40841. detach(): void;
  40842. /**
  40843. * Triggers the mesh to begin fading in or out
  40844. * @param value if the object should fade in or out (true to fade in)
  40845. */
  40846. fadeIn(value: boolean): void;
  40847. private _update;
  40848. private _setAllVisibility;
  40849. }
  40850. }
  40851. declare module "babylonjs/Misc/pivotTools" {
  40852. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40853. /**
  40854. * Class containing a set of static utilities functions for managing Pivots
  40855. * @hidden
  40856. */
  40857. export class PivotTools {
  40858. private static _PivotCached;
  40859. private static _OldPivotPoint;
  40860. private static _PivotTranslation;
  40861. private static _PivotTmpVector;
  40862. /** @hidden */
  40863. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40864. /** @hidden */
  40865. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40866. }
  40867. }
  40868. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40869. import { Scene } from "babylonjs/scene";
  40870. import { Vector4 } from "babylonjs/Maths/math.vector";
  40871. import { Mesh } from "babylonjs/Meshes/mesh";
  40872. import { Nullable } from "babylonjs/types";
  40873. import { Plane } from "babylonjs/Maths/math.plane";
  40874. /**
  40875. * Class containing static functions to help procedurally build meshes
  40876. */
  40877. export class PlaneBuilder {
  40878. /**
  40879. * Creates a plane mesh
  40880. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40881. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40882. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40883. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40884. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40886. * @param name defines the name of the mesh
  40887. * @param options defines the options used to create the mesh
  40888. * @param scene defines the hosting scene
  40889. * @returns the plane mesh
  40890. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40891. */
  40892. static CreatePlane(name: string, options: {
  40893. size?: number;
  40894. width?: number;
  40895. height?: number;
  40896. sideOrientation?: number;
  40897. frontUVs?: Vector4;
  40898. backUVs?: Vector4;
  40899. updatable?: boolean;
  40900. sourcePlane?: Plane;
  40901. }, scene?: Nullable<Scene>): Mesh;
  40902. }
  40903. }
  40904. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40905. import { Behavior } from "babylonjs/Behaviors/behavior";
  40906. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40907. import { Observable } from "babylonjs/Misc/observable";
  40908. import { Vector3 } from "babylonjs/Maths/math.vector";
  40909. import { Ray } from "babylonjs/Culling/ray";
  40910. import "babylonjs/Meshes/Builders/planeBuilder";
  40911. /**
  40912. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40913. */
  40914. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40915. private static _AnyMouseID;
  40916. /**
  40917. * Abstract mesh the behavior is set on
  40918. */
  40919. attachedNode: AbstractMesh;
  40920. private _dragPlane;
  40921. private _scene;
  40922. private _pointerObserver;
  40923. private _beforeRenderObserver;
  40924. private static _planeScene;
  40925. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40926. /**
  40927. * 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)
  40928. */
  40929. maxDragAngle: number;
  40930. /**
  40931. * @hidden
  40932. */
  40933. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40934. /**
  40935. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40936. */
  40937. currentDraggingPointerID: number;
  40938. /**
  40939. * The last position where the pointer hit the drag plane in world space
  40940. */
  40941. lastDragPosition: Vector3;
  40942. /**
  40943. * If the behavior is currently in a dragging state
  40944. */
  40945. dragging: boolean;
  40946. /**
  40947. * 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)
  40948. */
  40949. dragDeltaRatio: number;
  40950. /**
  40951. * If the drag plane orientation should be updated during the dragging (Default: true)
  40952. */
  40953. updateDragPlane: boolean;
  40954. private _debugMode;
  40955. private _moving;
  40956. /**
  40957. * Fires each time the attached mesh is dragged with the pointer
  40958. * * delta between last drag position and current drag position in world space
  40959. * * dragDistance along the drag axis
  40960. * * dragPlaneNormal normal of the current drag plane used during the drag
  40961. * * dragPlanePoint in world space where the drag intersects the drag plane
  40962. */
  40963. onDragObservable: Observable<{
  40964. delta: Vector3;
  40965. dragPlanePoint: Vector3;
  40966. dragPlaneNormal: Vector3;
  40967. dragDistance: number;
  40968. pointerId: number;
  40969. }>;
  40970. /**
  40971. * Fires each time a drag begins (eg. mouse down on mesh)
  40972. */
  40973. onDragStartObservable: Observable<{
  40974. dragPlanePoint: Vector3;
  40975. pointerId: number;
  40976. }>;
  40977. /**
  40978. * Fires each time a drag ends (eg. mouse release after drag)
  40979. */
  40980. onDragEndObservable: Observable<{
  40981. dragPlanePoint: Vector3;
  40982. pointerId: number;
  40983. }>;
  40984. /**
  40985. * If the attached mesh should be moved when dragged
  40986. */
  40987. moveAttached: boolean;
  40988. /**
  40989. * If the drag behavior will react to drag events (Default: true)
  40990. */
  40991. enabled: boolean;
  40992. /**
  40993. * If pointer events should start and release the drag (Default: true)
  40994. */
  40995. startAndReleaseDragOnPointerEvents: boolean;
  40996. /**
  40997. * If camera controls should be detached during the drag
  40998. */
  40999. detachCameraControls: boolean;
  41000. /**
  41001. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  41002. */
  41003. useObjectOrientationForDragging: boolean;
  41004. private _options;
  41005. /**
  41006. * Gets the options used by the behavior
  41007. */
  41008. get options(): {
  41009. dragAxis?: Vector3;
  41010. dragPlaneNormal?: Vector3;
  41011. };
  41012. /**
  41013. * Sets the options used by the behavior
  41014. */
  41015. set options(options: {
  41016. dragAxis?: Vector3;
  41017. dragPlaneNormal?: Vector3;
  41018. });
  41019. /**
  41020. * Creates a pointer drag behavior that can be attached to a mesh
  41021. * @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)
  41022. */
  41023. constructor(options?: {
  41024. dragAxis?: Vector3;
  41025. dragPlaneNormal?: Vector3;
  41026. });
  41027. /**
  41028. * Predicate to determine if it is valid to move the object to a new position when it is moved
  41029. */
  41030. validateDrag: (targetPosition: Vector3) => boolean;
  41031. /**
  41032. * The name of the behavior
  41033. */
  41034. get name(): string;
  41035. /**
  41036. * Initializes the behavior
  41037. */
  41038. init(): void;
  41039. private _tmpVector;
  41040. private _alternatePickedPoint;
  41041. private _worldDragAxis;
  41042. private _targetPosition;
  41043. private _attachedElement;
  41044. /**
  41045. * Attaches the drag behavior the passed in mesh
  41046. * @param ownerNode The mesh that will be dragged around once attached
  41047. * @param predicate Predicate to use for pick filtering
  41048. */
  41049. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  41050. /**
  41051. * Force relase the drag action by code.
  41052. */
  41053. releaseDrag(): void;
  41054. private _startDragRay;
  41055. private _lastPointerRay;
  41056. /**
  41057. * Simulates the start of a pointer drag event on the behavior
  41058. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  41059. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  41060. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  41061. */
  41062. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  41063. private _startDrag;
  41064. private _dragDelta;
  41065. private _moveDrag;
  41066. private _pickWithRayOnDragPlane;
  41067. private _pointA;
  41068. private _pointB;
  41069. private _pointC;
  41070. private _lineA;
  41071. private _lineB;
  41072. private _localAxis;
  41073. private _lookAt;
  41074. private _updateDragPlanePosition;
  41075. /**
  41076. * Detaches the behavior from the mesh
  41077. */
  41078. detach(): void;
  41079. }
  41080. }
  41081. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  41082. import { Mesh } from "babylonjs/Meshes/mesh";
  41083. import { Behavior } from "babylonjs/Behaviors/behavior";
  41084. /**
  41085. * A behavior that when attached to a mesh will allow the mesh to be scaled
  41086. */
  41087. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  41088. private _dragBehaviorA;
  41089. private _dragBehaviorB;
  41090. private _startDistance;
  41091. private _initialScale;
  41092. private _targetScale;
  41093. private _ownerNode;
  41094. private _sceneRenderObserver;
  41095. /**
  41096. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  41097. */
  41098. constructor();
  41099. /**
  41100. * The name of the behavior
  41101. */
  41102. get name(): string;
  41103. /**
  41104. * Initializes the behavior
  41105. */
  41106. init(): void;
  41107. private _getCurrentDistance;
  41108. /**
  41109. * Attaches the scale behavior the passed in mesh
  41110. * @param ownerNode The mesh that will be scaled around once attached
  41111. */
  41112. attach(ownerNode: Mesh): void;
  41113. /**
  41114. * Detaches the behavior from the mesh
  41115. */
  41116. detach(): void;
  41117. }
  41118. }
  41119. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  41120. import { Behavior } from "babylonjs/Behaviors/behavior";
  41121. import { Mesh } from "babylonjs/Meshes/mesh";
  41122. import { Observable } from "babylonjs/Misc/observable";
  41123. /**
  41124. * 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
  41125. */
  41126. export class SixDofDragBehavior implements Behavior<Mesh> {
  41127. private static _virtualScene;
  41128. private _ownerNode;
  41129. private _sceneRenderObserver;
  41130. private _scene;
  41131. private _targetPosition;
  41132. private _virtualOriginMesh;
  41133. private _virtualDragMesh;
  41134. private _pointerObserver;
  41135. private _moving;
  41136. private _startingOrientation;
  41137. private _attachedElement;
  41138. /**
  41139. * 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)
  41140. */
  41141. private zDragFactor;
  41142. /**
  41143. * If the object should rotate to face the drag origin
  41144. */
  41145. rotateDraggedObject: boolean;
  41146. /**
  41147. * If the behavior is currently in a dragging state
  41148. */
  41149. dragging: boolean;
  41150. /**
  41151. * 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)
  41152. */
  41153. dragDeltaRatio: number;
  41154. /**
  41155. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41156. */
  41157. currentDraggingPointerID: number;
  41158. /**
  41159. * If camera controls should be detached during the drag
  41160. */
  41161. detachCameraControls: boolean;
  41162. /**
  41163. * Fires each time a drag starts
  41164. */
  41165. onDragStartObservable: Observable<{}>;
  41166. /**
  41167. * Fires each time a drag ends (eg. mouse release after drag)
  41168. */
  41169. onDragEndObservable: Observable<{}>;
  41170. /**
  41171. * 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
  41172. */
  41173. constructor();
  41174. /**
  41175. * The name of the behavior
  41176. */
  41177. get name(): string;
  41178. /**
  41179. * Initializes the behavior
  41180. */
  41181. init(): void;
  41182. /**
  41183. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  41184. */
  41185. private get _pointerCamera();
  41186. /**
  41187. * Attaches the scale behavior the passed in mesh
  41188. * @param ownerNode The mesh that will be scaled around once attached
  41189. */
  41190. attach(ownerNode: Mesh): void;
  41191. /**
  41192. * Detaches the behavior from the mesh
  41193. */
  41194. detach(): void;
  41195. }
  41196. }
  41197. declare module "babylonjs/Behaviors/Meshes/index" {
  41198. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  41199. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  41200. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  41201. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41202. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  41203. }
  41204. declare module "babylonjs/Behaviors/index" {
  41205. export * from "babylonjs/Behaviors/behavior";
  41206. export * from "babylonjs/Behaviors/Cameras/index";
  41207. export * from "babylonjs/Behaviors/Meshes/index";
  41208. }
  41209. declare module "babylonjs/Bones/boneIKController" {
  41210. import { Bone } from "babylonjs/Bones/bone";
  41211. import { Vector3 } from "babylonjs/Maths/math.vector";
  41212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41213. import { Nullable } from "babylonjs/types";
  41214. /**
  41215. * Class used to apply inverse kinematics to bones
  41216. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  41217. */
  41218. export class BoneIKController {
  41219. private static _tmpVecs;
  41220. private static _tmpQuat;
  41221. private static _tmpMats;
  41222. /**
  41223. * Gets or sets the target mesh
  41224. */
  41225. targetMesh: AbstractMesh;
  41226. /** Gets or sets the mesh used as pole */
  41227. poleTargetMesh: AbstractMesh;
  41228. /**
  41229. * Gets or sets the bone used as pole
  41230. */
  41231. poleTargetBone: Nullable<Bone>;
  41232. /**
  41233. * Gets or sets the target position
  41234. */
  41235. targetPosition: Vector3;
  41236. /**
  41237. * Gets or sets the pole target position
  41238. */
  41239. poleTargetPosition: Vector3;
  41240. /**
  41241. * Gets or sets the pole target local offset
  41242. */
  41243. poleTargetLocalOffset: Vector3;
  41244. /**
  41245. * Gets or sets the pole angle
  41246. */
  41247. poleAngle: number;
  41248. /**
  41249. * Gets or sets the mesh associated with the controller
  41250. */
  41251. mesh: AbstractMesh;
  41252. /**
  41253. * 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)
  41254. */
  41255. slerpAmount: number;
  41256. private _bone1Quat;
  41257. private _bone1Mat;
  41258. private _bone2Ang;
  41259. private _bone1;
  41260. private _bone2;
  41261. private _bone1Length;
  41262. private _bone2Length;
  41263. private _maxAngle;
  41264. private _maxReach;
  41265. private _rightHandedSystem;
  41266. private _bendAxis;
  41267. private _slerping;
  41268. private _adjustRoll;
  41269. /**
  41270. * Gets or sets maximum allowed angle
  41271. */
  41272. get maxAngle(): number;
  41273. set maxAngle(value: number);
  41274. /**
  41275. * Creates a new BoneIKController
  41276. * @param mesh defines the mesh to control
  41277. * @param bone defines the bone to control
  41278. * @param options defines options to set up the controller
  41279. */
  41280. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  41281. targetMesh?: AbstractMesh;
  41282. poleTargetMesh?: AbstractMesh;
  41283. poleTargetBone?: Bone;
  41284. poleTargetLocalOffset?: Vector3;
  41285. poleAngle?: number;
  41286. bendAxis?: Vector3;
  41287. maxAngle?: number;
  41288. slerpAmount?: number;
  41289. });
  41290. private _setMaxAngle;
  41291. /**
  41292. * Force the controller to update the bones
  41293. */
  41294. update(): void;
  41295. }
  41296. }
  41297. declare module "babylonjs/Bones/boneLookController" {
  41298. import { Vector3 } from "babylonjs/Maths/math.vector";
  41299. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41300. import { Bone } from "babylonjs/Bones/bone";
  41301. import { Space } from "babylonjs/Maths/math.axis";
  41302. /**
  41303. * Class used to make a bone look toward a point in space
  41304. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  41305. */
  41306. export class BoneLookController {
  41307. private static _tmpVecs;
  41308. private static _tmpQuat;
  41309. private static _tmpMats;
  41310. /**
  41311. * The target Vector3 that the bone will look at
  41312. */
  41313. target: Vector3;
  41314. /**
  41315. * The mesh that the bone is attached to
  41316. */
  41317. mesh: AbstractMesh;
  41318. /**
  41319. * The bone that will be looking to the target
  41320. */
  41321. bone: Bone;
  41322. /**
  41323. * The up axis of the coordinate system that is used when the bone is rotated
  41324. */
  41325. upAxis: Vector3;
  41326. /**
  41327. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  41328. */
  41329. upAxisSpace: Space;
  41330. /**
  41331. * Used to make an adjustment to the yaw of the bone
  41332. */
  41333. adjustYaw: number;
  41334. /**
  41335. * Used to make an adjustment to the pitch of the bone
  41336. */
  41337. adjustPitch: number;
  41338. /**
  41339. * Used to make an adjustment to the roll of the bone
  41340. */
  41341. adjustRoll: number;
  41342. /**
  41343. * 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)
  41344. */
  41345. slerpAmount: number;
  41346. private _minYaw;
  41347. private _maxYaw;
  41348. private _minPitch;
  41349. private _maxPitch;
  41350. private _minYawSin;
  41351. private _minYawCos;
  41352. private _maxYawSin;
  41353. private _maxYawCos;
  41354. private _midYawConstraint;
  41355. private _minPitchTan;
  41356. private _maxPitchTan;
  41357. private _boneQuat;
  41358. private _slerping;
  41359. private _transformYawPitch;
  41360. private _transformYawPitchInv;
  41361. private _firstFrameSkipped;
  41362. private _yawRange;
  41363. private _fowardAxis;
  41364. /**
  41365. * Gets or sets the minimum yaw angle that the bone can look to
  41366. */
  41367. get minYaw(): number;
  41368. set minYaw(value: number);
  41369. /**
  41370. * Gets or sets the maximum yaw angle that the bone can look to
  41371. */
  41372. get maxYaw(): number;
  41373. set maxYaw(value: number);
  41374. /**
  41375. * Gets or sets the minimum pitch angle that the bone can look to
  41376. */
  41377. get minPitch(): number;
  41378. set minPitch(value: number);
  41379. /**
  41380. * Gets or sets the maximum pitch angle that the bone can look to
  41381. */
  41382. get maxPitch(): number;
  41383. set maxPitch(value: number);
  41384. /**
  41385. * Create a BoneLookController
  41386. * @param mesh the mesh that the bone belongs to
  41387. * @param bone the bone that will be looking to the target
  41388. * @param target the target Vector3 to look at
  41389. * @param options optional settings:
  41390. * * maxYaw: the maximum angle the bone will yaw to
  41391. * * minYaw: the minimum angle the bone will yaw to
  41392. * * maxPitch: the maximum angle the bone will pitch to
  41393. * * minPitch: the minimum angle the bone will yaw to
  41394. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  41395. * * upAxis: the up axis of the coordinate system
  41396. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  41397. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  41398. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  41399. * * adjustYaw: used to make an adjustment to the yaw of the bone
  41400. * * adjustPitch: used to make an adjustment to the pitch of the bone
  41401. * * adjustRoll: used to make an adjustment to the roll of the bone
  41402. **/
  41403. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  41404. maxYaw?: number;
  41405. minYaw?: number;
  41406. maxPitch?: number;
  41407. minPitch?: number;
  41408. slerpAmount?: number;
  41409. upAxis?: Vector3;
  41410. upAxisSpace?: Space;
  41411. yawAxis?: Vector3;
  41412. pitchAxis?: Vector3;
  41413. adjustYaw?: number;
  41414. adjustPitch?: number;
  41415. adjustRoll?: number;
  41416. });
  41417. /**
  41418. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  41419. */
  41420. update(): void;
  41421. private _getAngleDiff;
  41422. private _getAngleBetween;
  41423. private _isAngleBetween;
  41424. }
  41425. }
  41426. declare module "babylonjs/Bones/index" {
  41427. export * from "babylonjs/Bones/bone";
  41428. export * from "babylonjs/Bones/boneIKController";
  41429. export * from "babylonjs/Bones/boneLookController";
  41430. export * from "babylonjs/Bones/skeleton";
  41431. }
  41432. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  41433. import { Nullable } from "babylonjs/types";
  41434. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41435. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41436. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41437. /**
  41438. * Manage the gamepad inputs to control an arc rotate camera.
  41439. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41440. */
  41441. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  41442. /**
  41443. * Defines the camera the input is attached to.
  41444. */
  41445. camera: ArcRotateCamera;
  41446. /**
  41447. * Defines the gamepad the input is gathering event from.
  41448. */
  41449. gamepad: Nullable<Gamepad>;
  41450. /**
  41451. * Defines the gamepad rotation sensiblity.
  41452. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41453. */
  41454. gamepadRotationSensibility: number;
  41455. /**
  41456. * Defines the gamepad move sensiblity.
  41457. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41458. */
  41459. gamepadMoveSensibility: number;
  41460. private _yAxisScale;
  41461. /**
  41462. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41463. */
  41464. get invertYAxis(): boolean;
  41465. set invertYAxis(value: boolean);
  41466. private _onGamepadConnectedObserver;
  41467. private _onGamepadDisconnectedObserver;
  41468. /**
  41469. * Attach the input controls to a specific dom element to get the input from.
  41470. * @param element Defines the element the controls should be listened from
  41471. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41472. */
  41473. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41474. /**
  41475. * Detach the current controls from the specified dom element.
  41476. * @param element Defines the element to stop listening the inputs from
  41477. */
  41478. detachControl(element: Nullable<HTMLElement>): void;
  41479. /**
  41480. * Update the current camera state depending on the inputs that have been used this frame.
  41481. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41482. */
  41483. checkInputs(): void;
  41484. /**
  41485. * Gets the class name of the current intput.
  41486. * @returns the class name
  41487. */
  41488. getClassName(): string;
  41489. /**
  41490. * Get the friendly name associated with the input class.
  41491. * @returns the input friendly name
  41492. */
  41493. getSimpleName(): string;
  41494. }
  41495. }
  41496. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  41497. import { Nullable } from "babylonjs/types";
  41498. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41499. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41500. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  41501. interface ArcRotateCameraInputsManager {
  41502. /**
  41503. * Add orientation input support to the input manager.
  41504. * @returns the current input manager
  41505. */
  41506. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  41507. }
  41508. }
  41509. /**
  41510. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41511. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41512. */
  41513. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41514. /**
  41515. * Defines the camera the input is attached to.
  41516. */
  41517. camera: ArcRotateCamera;
  41518. /**
  41519. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41520. */
  41521. alphaCorrection: number;
  41522. /**
  41523. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41524. */
  41525. gammaCorrection: number;
  41526. private _alpha;
  41527. private _gamma;
  41528. private _dirty;
  41529. private _deviceOrientationHandler;
  41530. /**
  41531. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41532. */
  41533. constructor();
  41534. /**
  41535. * Attach the input controls to a specific dom element to get the input from.
  41536. * @param element Defines the element the controls should be listened from
  41537. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41538. */
  41539. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41540. /** @hidden */
  41541. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41542. /**
  41543. * Update the current camera state depending on the inputs that have been used this frame.
  41544. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41545. */
  41546. checkInputs(): void;
  41547. /**
  41548. * Detach the current controls from the specified dom element.
  41549. * @param element Defines the element to stop listening the inputs from
  41550. */
  41551. detachControl(element: Nullable<HTMLElement>): void;
  41552. /**
  41553. * Gets the class name of the current intput.
  41554. * @returns the class name
  41555. */
  41556. getClassName(): string;
  41557. /**
  41558. * Get the friendly name associated with the input class.
  41559. * @returns the input friendly name
  41560. */
  41561. getSimpleName(): string;
  41562. }
  41563. }
  41564. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  41565. import { Nullable } from "babylonjs/types";
  41566. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41567. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41568. /**
  41569. * Listen to mouse events to control the camera.
  41570. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41571. */
  41572. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41573. /**
  41574. * Defines the camera the input is attached to.
  41575. */
  41576. camera: FlyCamera;
  41577. /**
  41578. * Defines if touch is enabled. (Default is true.)
  41579. */
  41580. touchEnabled: boolean;
  41581. /**
  41582. * Defines the buttons associated with the input to handle camera rotation.
  41583. */
  41584. buttons: number[];
  41585. /**
  41586. * Assign buttons for Yaw control.
  41587. */
  41588. buttonsYaw: number[];
  41589. /**
  41590. * Assign buttons for Pitch control.
  41591. */
  41592. buttonsPitch: number[];
  41593. /**
  41594. * Assign buttons for Roll control.
  41595. */
  41596. buttonsRoll: number[];
  41597. /**
  41598. * Detect if any button is being pressed while mouse is moved.
  41599. * -1 = Mouse locked.
  41600. * 0 = Left button.
  41601. * 1 = Middle Button.
  41602. * 2 = Right Button.
  41603. */
  41604. activeButton: number;
  41605. /**
  41606. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41607. * Higher values reduce its sensitivity.
  41608. */
  41609. angularSensibility: number;
  41610. private _mousemoveCallback;
  41611. private _observer;
  41612. private _rollObserver;
  41613. private previousPosition;
  41614. private noPreventDefault;
  41615. private element;
  41616. /**
  41617. * Listen to mouse events to control the camera.
  41618. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41619. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41620. */
  41621. constructor(touchEnabled?: boolean);
  41622. /**
  41623. * Attach the mouse control to the HTML DOM element.
  41624. * @param element Defines the element that listens to the input events.
  41625. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41626. */
  41627. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41628. /**
  41629. * Detach the current controls from the specified dom element.
  41630. * @param element Defines the element to stop listening the inputs from
  41631. */
  41632. detachControl(element: Nullable<HTMLElement>): void;
  41633. /**
  41634. * Gets the class name of the current input.
  41635. * @returns the class name.
  41636. */
  41637. getClassName(): string;
  41638. /**
  41639. * Get the friendly name associated with the input class.
  41640. * @returns the input's friendly name.
  41641. */
  41642. getSimpleName(): string;
  41643. private _pointerInput;
  41644. private _onMouseMove;
  41645. /**
  41646. * Rotate camera by mouse offset.
  41647. */
  41648. private rotateCamera;
  41649. }
  41650. }
  41651. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41652. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41653. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41654. /**
  41655. * Default Inputs manager for the FlyCamera.
  41656. * It groups all the default supported inputs for ease of use.
  41657. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41658. */
  41659. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41660. /**
  41661. * Instantiates a new FlyCameraInputsManager.
  41662. * @param camera Defines the camera the inputs belong to.
  41663. */
  41664. constructor(camera: FlyCamera);
  41665. /**
  41666. * Add keyboard input support to the input manager.
  41667. * @returns the new FlyCameraKeyboardMoveInput().
  41668. */
  41669. addKeyboard(): FlyCameraInputsManager;
  41670. /**
  41671. * Add mouse input support to the input manager.
  41672. * @param touchEnabled Enable touch screen support.
  41673. * @returns the new FlyCameraMouseInput().
  41674. */
  41675. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41676. }
  41677. }
  41678. declare module "babylonjs/Cameras/flyCamera" {
  41679. import { Scene } from "babylonjs/scene";
  41680. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41681. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41682. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41683. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41684. /**
  41685. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41686. * such as in a 3D Space Shooter or a Flight Simulator.
  41687. */
  41688. export class FlyCamera extends TargetCamera {
  41689. /**
  41690. * Define the collision ellipsoid of the camera.
  41691. * This is helpful for simulating a camera body, like a player's body.
  41692. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41693. */
  41694. ellipsoid: Vector3;
  41695. /**
  41696. * Define an offset for the position of the ellipsoid around the camera.
  41697. * This can be helpful if the camera is attached away from the player's body center,
  41698. * such as at its head.
  41699. */
  41700. ellipsoidOffset: Vector3;
  41701. /**
  41702. * Enable or disable collisions of the camera with the rest of the scene objects.
  41703. */
  41704. checkCollisions: boolean;
  41705. /**
  41706. * Enable or disable gravity on the camera.
  41707. */
  41708. applyGravity: boolean;
  41709. /**
  41710. * Define the current direction the camera is moving to.
  41711. */
  41712. cameraDirection: Vector3;
  41713. /**
  41714. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41715. * This overrides and empties cameraRotation.
  41716. */
  41717. rotationQuaternion: Quaternion;
  41718. /**
  41719. * Track Roll to maintain the wanted Rolling when looking around.
  41720. */
  41721. _trackRoll: number;
  41722. /**
  41723. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41724. */
  41725. rollCorrect: number;
  41726. /**
  41727. * Mimic a banked turn, Rolling the camera when Yawing.
  41728. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41729. */
  41730. bankedTurn: boolean;
  41731. /**
  41732. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41733. */
  41734. bankedTurnLimit: number;
  41735. /**
  41736. * Value of 0 disables the banked Roll.
  41737. * Value of 1 is equal to the Yaw angle in radians.
  41738. */
  41739. bankedTurnMultiplier: number;
  41740. /**
  41741. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41742. */
  41743. inputs: FlyCameraInputsManager;
  41744. /**
  41745. * Gets the input sensibility for mouse input.
  41746. * Higher values reduce sensitivity.
  41747. */
  41748. get angularSensibility(): number;
  41749. /**
  41750. * Sets the input sensibility for a mouse input.
  41751. * Higher values reduce sensitivity.
  41752. */
  41753. set angularSensibility(value: number);
  41754. /**
  41755. * Get the keys for camera movement forward.
  41756. */
  41757. get keysForward(): number[];
  41758. /**
  41759. * Set the keys for camera movement forward.
  41760. */
  41761. set keysForward(value: number[]);
  41762. /**
  41763. * Get the keys for camera movement backward.
  41764. */
  41765. get keysBackward(): number[];
  41766. set keysBackward(value: number[]);
  41767. /**
  41768. * Get the keys for camera movement up.
  41769. */
  41770. get keysUp(): number[];
  41771. /**
  41772. * Set the keys for camera movement up.
  41773. */
  41774. set keysUp(value: number[]);
  41775. /**
  41776. * Get the keys for camera movement down.
  41777. */
  41778. get keysDown(): number[];
  41779. /**
  41780. * Set the keys for camera movement down.
  41781. */
  41782. set keysDown(value: number[]);
  41783. /**
  41784. * Get the keys for camera movement left.
  41785. */
  41786. get keysLeft(): number[];
  41787. /**
  41788. * Set the keys for camera movement left.
  41789. */
  41790. set keysLeft(value: number[]);
  41791. /**
  41792. * Set the keys for camera movement right.
  41793. */
  41794. get keysRight(): number[];
  41795. /**
  41796. * Set the keys for camera movement right.
  41797. */
  41798. set keysRight(value: number[]);
  41799. /**
  41800. * Event raised when the camera collides with a mesh in the scene.
  41801. */
  41802. onCollide: (collidedMesh: AbstractMesh) => void;
  41803. private _collider;
  41804. private _needMoveForGravity;
  41805. private _oldPosition;
  41806. private _diffPosition;
  41807. private _newPosition;
  41808. /** @hidden */
  41809. _localDirection: Vector3;
  41810. /** @hidden */
  41811. _transformedDirection: Vector3;
  41812. /**
  41813. * Instantiates a FlyCamera.
  41814. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41815. * such as in a 3D Space Shooter or a Flight Simulator.
  41816. * @param name Define the name of the camera in the scene.
  41817. * @param position Define the starting position of the camera in the scene.
  41818. * @param scene Define the scene the camera belongs to.
  41819. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41820. */
  41821. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41822. /**
  41823. * Attach a control to the HTML DOM element.
  41824. * @param element Defines the element that listens to the input events.
  41825. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41826. */
  41827. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41828. /**
  41829. * Detach a control from the HTML DOM element.
  41830. * The camera will stop reacting to that input.
  41831. * @param element Defines the element that listens to the input events.
  41832. */
  41833. detachControl(element: HTMLElement): void;
  41834. private _collisionMask;
  41835. /**
  41836. * Get the mask that the camera ignores in collision events.
  41837. */
  41838. get collisionMask(): number;
  41839. /**
  41840. * Set the mask that the camera ignores in collision events.
  41841. */
  41842. set collisionMask(mask: number);
  41843. /** @hidden */
  41844. _collideWithWorld(displacement: Vector3): void;
  41845. /** @hidden */
  41846. private _onCollisionPositionChange;
  41847. /** @hidden */
  41848. _checkInputs(): void;
  41849. /** @hidden */
  41850. _decideIfNeedsToMove(): boolean;
  41851. /** @hidden */
  41852. _updatePosition(): void;
  41853. /**
  41854. * Restore the Roll to its target value at the rate specified.
  41855. * @param rate - Higher means slower restoring.
  41856. * @hidden
  41857. */
  41858. restoreRoll(rate: number): void;
  41859. /**
  41860. * Destroy the camera and release the current resources held by it.
  41861. */
  41862. dispose(): void;
  41863. /**
  41864. * Get the current object class name.
  41865. * @returns the class name.
  41866. */
  41867. getClassName(): string;
  41868. }
  41869. }
  41870. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41871. import { Nullable } from "babylonjs/types";
  41872. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41873. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41874. /**
  41875. * Listen to keyboard events to control the camera.
  41876. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41877. */
  41878. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41879. /**
  41880. * Defines the camera the input is attached to.
  41881. */
  41882. camera: FlyCamera;
  41883. /**
  41884. * The list of keyboard keys used to control the forward move of the camera.
  41885. */
  41886. keysForward: number[];
  41887. /**
  41888. * The list of keyboard keys used to control the backward move of the camera.
  41889. */
  41890. keysBackward: number[];
  41891. /**
  41892. * The list of keyboard keys used to control the forward move of the camera.
  41893. */
  41894. keysUp: number[];
  41895. /**
  41896. * The list of keyboard keys used to control the backward move of the camera.
  41897. */
  41898. keysDown: number[];
  41899. /**
  41900. * The list of keyboard keys used to control the right strafe move of the camera.
  41901. */
  41902. keysRight: number[];
  41903. /**
  41904. * The list of keyboard keys used to control the left strafe move of the camera.
  41905. */
  41906. keysLeft: number[];
  41907. private _keys;
  41908. private _onCanvasBlurObserver;
  41909. private _onKeyboardObserver;
  41910. private _engine;
  41911. private _scene;
  41912. /**
  41913. * Attach the input controls to a specific dom element to get the input from.
  41914. * @param element Defines the element the controls should be listened from
  41915. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41916. */
  41917. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41918. /**
  41919. * Detach the current controls from the specified dom element.
  41920. * @param element Defines the element to stop listening the inputs from
  41921. */
  41922. detachControl(element: Nullable<HTMLElement>): void;
  41923. /**
  41924. * Gets the class name of the current intput.
  41925. * @returns the class name
  41926. */
  41927. getClassName(): string;
  41928. /** @hidden */
  41929. _onLostFocus(e: FocusEvent): void;
  41930. /**
  41931. * Get the friendly name associated with the input class.
  41932. * @returns the input friendly name
  41933. */
  41934. getSimpleName(): string;
  41935. /**
  41936. * Update the current camera state depending on the inputs that have been used this frame.
  41937. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41938. */
  41939. checkInputs(): void;
  41940. }
  41941. }
  41942. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41943. import { Nullable } from "babylonjs/types";
  41944. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41945. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41946. /**
  41947. * Manage the mouse wheel inputs to control a follow camera.
  41948. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41949. */
  41950. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41951. /**
  41952. * Defines the camera the input is attached to.
  41953. */
  41954. camera: FollowCamera;
  41955. /**
  41956. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41957. */
  41958. axisControlRadius: boolean;
  41959. /**
  41960. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41961. */
  41962. axisControlHeight: boolean;
  41963. /**
  41964. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41965. */
  41966. axisControlRotation: boolean;
  41967. /**
  41968. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41969. * relation to mouseWheel events.
  41970. */
  41971. wheelPrecision: number;
  41972. /**
  41973. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41974. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41975. */
  41976. wheelDeltaPercentage: number;
  41977. private _wheel;
  41978. private _observer;
  41979. /**
  41980. * Attach the input controls to a specific dom element to get the input from.
  41981. * @param element Defines the element the controls should be listened from
  41982. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41983. */
  41984. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41985. /**
  41986. * Detach the current controls from the specified dom element.
  41987. * @param element Defines the element to stop listening the inputs from
  41988. */
  41989. detachControl(element: Nullable<HTMLElement>): void;
  41990. /**
  41991. * Gets the class name of the current intput.
  41992. * @returns the class name
  41993. */
  41994. getClassName(): string;
  41995. /**
  41996. * Get the friendly name associated with the input class.
  41997. * @returns the input friendly name
  41998. */
  41999. getSimpleName(): string;
  42000. }
  42001. }
  42002. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  42003. import { Nullable } from "babylonjs/types";
  42004. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42005. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  42006. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  42007. /**
  42008. * Manage the pointers inputs to control an follow camera.
  42009. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42010. */
  42011. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  42012. /**
  42013. * Defines the camera the input is attached to.
  42014. */
  42015. camera: FollowCamera;
  42016. /**
  42017. * Gets the class name of the current input.
  42018. * @returns the class name
  42019. */
  42020. getClassName(): string;
  42021. /**
  42022. * Defines the pointer angular sensibility along the X axis or how fast is
  42023. * the camera rotating.
  42024. * A negative number will reverse the axis direction.
  42025. */
  42026. angularSensibilityX: number;
  42027. /**
  42028. * Defines the pointer angular sensibility along the Y axis or how fast is
  42029. * the camera rotating.
  42030. * A negative number will reverse the axis direction.
  42031. */
  42032. angularSensibilityY: number;
  42033. /**
  42034. * Defines the pointer pinch precision or how fast is the camera zooming.
  42035. * A negative number will reverse the axis direction.
  42036. */
  42037. pinchPrecision: number;
  42038. /**
  42039. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42040. * from 0.
  42041. * It defines the percentage of current camera.radius to use as delta when
  42042. * pinch zoom is used.
  42043. */
  42044. pinchDeltaPercentage: number;
  42045. /**
  42046. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  42047. */
  42048. axisXControlRadius: boolean;
  42049. /**
  42050. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  42051. */
  42052. axisXControlHeight: boolean;
  42053. /**
  42054. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  42055. */
  42056. axisXControlRotation: boolean;
  42057. /**
  42058. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  42059. */
  42060. axisYControlRadius: boolean;
  42061. /**
  42062. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  42063. */
  42064. axisYControlHeight: boolean;
  42065. /**
  42066. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  42067. */
  42068. axisYControlRotation: boolean;
  42069. /**
  42070. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  42071. */
  42072. axisPinchControlRadius: boolean;
  42073. /**
  42074. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  42075. */
  42076. axisPinchControlHeight: boolean;
  42077. /**
  42078. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  42079. */
  42080. axisPinchControlRotation: boolean;
  42081. /**
  42082. * Log error messages if basic misconfiguration has occurred.
  42083. */
  42084. warningEnable: boolean;
  42085. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42086. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42087. private _warningCounter;
  42088. private _warning;
  42089. }
  42090. }
  42091. declare module "babylonjs/Cameras/followCameraInputsManager" {
  42092. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  42093. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42094. /**
  42095. * Default Inputs manager for the FollowCamera.
  42096. * It groups all the default supported inputs for ease of use.
  42097. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42098. */
  42099. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  42100. /**
  42101. * Instantiates a new FollowCameraInputsManager.
  42102. * @param camera Defines the camera the inputs belong to
  42103. */
  42104. constructor(camera: FollowCamera);
  42105. /**
  42106. * Add keyboard input support to the input manager.
  42107. * @returns the current input manager
  42108. */
  42109. addKeyboard(): FollowCameraInputsManager;
  42110. /**
  42111. * Add mouse wheel input support to the input manager.
  42112. * @returns the current input manager
  42113. */
  42114. addMouseWheel(): FollowCameraInputsManager;
  42115. /**
  42116. * Add pointers input support to the input manager.
  42117. * @returns the current input manager
  42118. */
  42119. addPointers(): FollowCameraInputsManager;
  42120. /**
  42121. * Add orientation input support to the input manager.
  42122. * @returns the current input manager
  42123. */
  42124. addVRDeviceOrientation(): FollowCameraInputsManager;
  42125. }
  42126. }
  42127. declare module "babylonjs/Cameras/followCamera" {
  42128. import { Nullable } from "babylonjs/types";
  42129. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  42130. import { Scene } from "babylonjs/scene";
  42131. import { Vector3 } from "babylonjs/Maths/math.vector";
  42132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42133. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  42134. /**
  42135. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  42136. * an arc rotate version arcFollowCamera are available.
  42137. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42138. */
  42139. export class FollowCamera extends TargetCamera {
  42140. /**
  42141. * Distance the follow camera should follow an object at
  42142. */
  42143. radius: number;
  42144. /**
  42145. * Minimum allowed distance of the camera to the axis of rotation
  42146. * (The camera can not get closer).
  42147. * This can help limiting how the Camera is able to move in the scene.
  42148. */
  42149. lowerRadiusLimit: Nullable<number>;
  42150. /**
  42151. * Maximum allowed distance of the camera to the axis of rotation
  42152. * (The camera can not get further).
  42153. * This can help limiting how the Camera is able to move in the scene.
  42154. */
  42155. upperRadiusLimit: Nullable<number>;
  42156. /**
  42157. * Define a rotation offset between the camera and the object it follows
  42158. */
  42159. rotationOffset: number;
  42160. /**
  42161. * Minimum allowed angle to camera position relative to target object.
  42162. * This can help limiting how the Camera is able to move in the scene.
  42163. */
  42164. lowerRotationOffsetLimit: Nullable<number>;
  42165. /**
  42166. * Maximum allowed angle to camera position relative to target object.
  42167. * This can help limiting how the Camera is able to move in the scene.
  42168. */
  42169. upperRotationOffsetLimit: Nullable<number>;
  42170. /**
  42171. * Define a height offset between the camera and the object it follows.
  42172. * It can help following an object from the top (like a car chaing a plane)
  42173. */
  42174. heightOffset: number;
  42175. /**
  42176. * Minimum allowed height of camera position relative to target object.
  42177. * This can help limiting how the Camera is able to move in the scene.
  42178. */
  42179. lowerHeightOffsetLimit: Nullable<number>;
  42180. /**
  42181. * Maximum allowed height of camera position relative to target object.
  42182. * This can help limiting how the Camera is able to move in the scene.
  42183. */
  42184. upperHeightOffsetLimit: Nullable<number>;
  42185. /**
  42186. * Define how fast the camera can accelerate to follow it s target.
  42187. */
  42188. cameraAcceleration: number;
  42189. /**
  42190. * Define the speed limit of the camera following an object.
  42191. */
  42192. maxCameraSpeed: number;
  42193. /**
  42194. * Define the target of the camera.
  42195. */
  42196. lockedTarget: Nullable<AbstractMesh>;
  42197. /**
  42198. * Defines the input associated with the camera.
  42199. */
  42200. inputs: FollowCameraInputsManager;
  42201. /**
  42202. * Instantiates the follow camera.
  42203. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42204. * @param name Define the name of the camera in the scene
  42205. * @param position Define the position of the camera
  42206. * @param scene Define the scene the camera belong to
  42207. * @param lockedTarget Define the target of the camera
  42208. */
  42209. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  42210. private _follow;
  42211. /**
  42212. * Attached controls to the current camera.
  42213. * @param element Defines the element the controls should be listened from
  42214. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42215. */
  42216. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42217. /**
  42218. * Detach the current controls from the camera.
  42219. * The camera will stop reacting to inputs.
  42220. * @param element Defines the element to stop listening the inputs from
  42221. */
  42222. detachControl(element: HTMLElement): void;
  42223. /** @hidden */
  42224. _checkInputs(): void;
  42225. private _checkLimits;
  42226. /**
  42227. * Gets the camera class name.
  42228. * @returns the class name
  42229. */
  42230. getClassName(): string;
  42231. }
  42232. /**
  42233. * Arc Rotate version of the follow camera.
  42234. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  42235. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42236. */
  42237. export class ArcFollowCamera extends TargetCamera {
  42238. /** The longitudinal angle of the camera */
  42239. alpha: number;
  42240. /** The latitudinal angle of the camera */
  42241. beta: number;
  42242. /** The radius of the camera from its target */
  42243. radius: number;
  42244. /** Define the camera target (the messh it should follow) */
  42245. target: Nullable<AbstractMesh>;
  42246. private _cartesianCoordinates;
  42247. /**
  42248. * Instantiates a new ArcFollowCamera
  42249. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42250. * @param name Define the name of the camera
  42251. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  42252. * @param beta Define the rotation angle of the camera around the elevation axis
  42253. * @param radius Define the radius of the camera from its target point
  42254. * @param target Define the target of the camera
  42255. * @param scene Define the scene the camera belongs to
  42256. */
  42257. constructor(name: string,
  42258. /** The longitudinal angle of the camera */
  42259. alpha: number,
  42260. /** The latitudinal angle of the camera */
  42261. beta: number,
  42262. /** The radius of the camera from its target */
  42263. radius: number,
  42264. /** Define the camera target (the messh it should follow) */
  42265. target: Nullable<AbstractMesh>, scene: Scene);
  42266. private _follow;
  42267. /** @hidden */
  42268. _checkInputs(): void;
  42269. /**
  42270. * Returns the class name of the object.
  42271. * It is mostly used internally for serialization purposes.
  42272. */
  42273. getClassName(): string;
  42274. }
  42275. }
  42276. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  42277. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42278. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42279. import { Nullable } from "babylonjs/types";
  42280. /**
  42281. * Manage the keyboard inputs to control the movement of a follow camera.
  42282. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42283. */
  42284. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  42285. /**
  42286. * Defines the camera the input is attached to.
  42287. */
  42288. camera: FollowCamera;
  42289. /**
  42290. * Defines the list of key codes associated with the up action (increase heightOffset)
  42291. */
  42292. keysHeightOffsetIncr: number[];
  42293. /**
  42294. * Defines the list of key codes associated with the down action (decrease heightOffset)
  42295. */
  42296. keysHeightOffsetDecr: number[];
  42297. /**
  42298. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  42299. */
  42300. keysHeightOffsetModifierAlt: boolean;
  42301. /**
  42302. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  42303. */
  42304. keysHeightOffsetModifierCtrl: boolean;
  42305. /**
  42306. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  42307. */
  42308. keysHeightOffsetModifierShift: boolean;
  42309. /**
  42310. * Defines the list of key codes associated with the left action (increase rotationOffset)
  42311. */
  42312. keysRotationOffsetIncr: number[];
  42313. /**
  42314. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  42315. */
  42316. keysRotationOffsetDecr: number[];
  42317. /**
  42318. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  42319. */
  42320. keysRotationOffsetModifierAlt: boolean;
  42321. /**
  42322. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  42323. */
  42324. keysRotationOffsetModifierCtrl: boolean;
  42325. /**
  42326. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  42327. */
  42328. keysRotationOffsetModifierShift: boolean;
  42329. /**
  42330. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  42331. */
  42332. keysRadiusIncr: number[];
  42333. /**
  42334. * Defines the list of key codes associated with the zoom-out action (increase radius)
  42335. */
  42336. keysRadiusDecr: number[];
  42337. /**
  42338. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  42339. */
  42340. keysRadiusModifierAlt: boolean;
  42341. /**
  42342. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  42343. */
  42344. keysRadiusModifierCtrl: boolean;
  42345. /**
  42346. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  42347. */
  42348. keysRadiusModifierShift: boolean;
  42349. /**
  42350. * Defines the rate of change of heightOffset.
  42351. */
  42352. heightSensibility: number;
  42353. /**
  42354. * Defines the rate of change of rotationOffset.
  42355. */
  42356. rotationSensibility: number;
  42357. /**
  42358. * Defines the rate of change of radius.
  42359. */
  42360. radiusSensibility: number;
  42361. private _keys;
  42362. private _ctrlPressed;
  42363. private _altPressed;
  42364. private _shiftPressed;
  42365. private _onCanvasBlurObserver;
  42366. private _onKeyboardObserver;
  42367. private _engine;
  42368. private _scene;
  42369. /**
  42370. * Attach the input controls to a specific dom element to get the input from.
  42371. * @param element Defines the element the controls should be listened from
  42372. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42373. */
  42374. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42375. /**
  42376. * Detach the current controls from the specified dom element.
  42377. * @param element Defines the element to stop listening the inputs from
  42378. */
  42379. detachControl(element: Nullable<HTMLElement>): void;
  42380. /**
  42381. * Update the current camera state depending on the inputs that have been used this frame.
  42382. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42383. */
  42384. checkInputs(): void;
  42385. /**
  42386. * Gets the class name of the current input.
  42387. * @returns the class name
  42388. */
  42389. getClassName(): string;
  42390. /**
  42391. * Get the friendly name associated with the input class.
  42392. * @returns the input friendly name
  42393. */
  42394. getSimpleName(): string;
  42395. /**
  42396. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42397. * allow modification of the heightOffset value.
  42398. */
  42399. private _modifierHeightOffset;
  42400. /**
  42401. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42402. * allow modification of the rotationOffset value.
  42403. */
  42404. private _modifierRotationOffset;
  42405. /**
  42406. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42407. * allow modification of the radius value.
  42408. */
  42409. private _modifierRadius;
  42410. }
  42411. }
  42412. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  42413. import { Nullable } from "babylonjs/types";
  42414. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42415. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42416. import { Observable } from "babylonjs/Misc/observable";
  42417. module "babylonjs/Cameras/freeCameraInputsManager" {
  42418. interface FreeCameraInputsManager {
  42419. /**
  42420. * @hidden
  42421. */
  42422. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  42423. /**
  42424. * Add orientation input support to the input manager.
  42425. * @returns the current input manager
  42426. */
  42427. addDeviceOrientation(): FreeCameraInputsManager;
  42428. }
  42429. }
  42430. /**
  42431. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  42432. * Screen rotation is taken into account.
  42433. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42434. */
  42435. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  42436. private _camera;
  42437. private _screenOrientationAngle;
  42438. private _constantTranform;
  42439. private _screenQuaternion;
  42440. private _alpha;
  42441. private _beta;
  42442. private _gamma;
  42443. /**
  42444. * Can be used to detect if a device orientation sensor is available on a device
  42445. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  42446. * @returns a promise that will resolve on orientation change
  42447. */
  42448. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  42449. /**
  42450. * @hidden
  42451. */
  42452. _onDeviceOrientationChangedObservable: Observable<void>;
  42453. /**
  42454. * Instantiates a new input
  42455. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42456. */
  42457. constructor();
  42458. /**
  42459. * Define the camera controlled by the input.
  42460. */
  42461. get camera(): FreeCamera;
  42462. set camera(camera: FreeCamera);
  42463. /**
  42464. * Attach the input controls to a specific dom element to get the input from.
  42465. * @param element Defines the element the controls should be listened from
  42466. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42467. */
  42468. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42469. private _orientationChanged;
  42470. private _deviceOrientation;
  42471. /**
  42472. * Detach the current controls from the specified dom element.
  42473. * @param element Defines the element to stop listening the inputs from
  42474. */
  42475. detachControl(element: Nullable<HTMLElement>): void;
  42476. /**
  42477. * Update the current camera state depending on the inputs that have been used this frame.
  42478. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42479. */
  42480. checkInputs(): void;
  42481. /**
  42482. * Gets the class name of the current intput.
  42483. * @returns the class name
  42484. */
  42485. getClassName(): string;
  42486. /**
  42487. * Get the friendly name associated with the input class.
  42488. * @returns the input friendly name
  42489. */
  42490. getSimpleName(): string;
  42491. }
  42492. }
  42493. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  42494. import { Nullable } from "babylonjs/types";
  42495. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42496. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42497. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42498. /**
  42499. * Manage the gamepad inputs to control a free camera.
  42500. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42501. */
  42502. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  42503. /**
  42504. * Define the camera the input is attached to.
  42505. */
  42506. camera: FreeCamera;
  42507. /**
  42508. * Define the Gamepad controlling the input
  42509. */
  42510. gamepad: Nullable<Gamepad>;
  42511. /**
  42512. * Defines the gamepad rotation sensiblity.
  42513. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42514. */
  42515. gamepadAngularSensibility: number;
  42516. /**
  42517. * Defines the gamepad move sensiblity.
  42518. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42519. */
  42520. gamepadMoveSensibility: number;
  42521. private _yAxisScale;
  42522. /**
  42523. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42524. */
  42525. get invertYAxis(): boolean;
  42526. set invertYAxis(value: boolean);
  42527. private _onGamepadConnectedObserver;
  42528. private _onGamepadDisconnectedObserver;
  42529. private _cameraTransform;
  42530. private _deltaTransform;
  42531. private _vector3;
  42532. private _vector2;
  42533. /**
  42534. * Attach the input controls to a specific dom element to get the input from.
  42535. * @param element Defines the element the controls should be listened from
  42536. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42537. */
  42538. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42539. /**
  42540. * Detach the current controls from the specified dom element.
  42541. * @param element Defines the element to stop listening the inputs from
  42542. */
  42543. detachControl(element: Nullable<HTMLElement>): void;
  42544. /**
  42545. * Update the current camera state depending on the inputs that have been used this frame.
  42546. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42547. */
  42548. checkInputs(): void;
  42549. /**
  42550. * Gets the class name of the current intput.
  42551. * @returns the class name
  42552. */
  42553. getClassName(): string;
  42554. /**
  42555. * Get the friendly name associated with the input class.
  42556. * @returns the input friendly name
  42557. */
  42558. getSimpleName(): string;
  42559. }
  42560. }
  42561. declare module "babylonjs/Misc/virtualJoystick" {
  42562. import { Nullable } from "babylonjs/types";
  42563. import { Vector3 } from "babylonjs/Maths/math.vector";
  42564. /**
  42565. * Defines the potential axis of a Joystick
  42566. */
  42567. export enum JoystickAxis {
  42568. /** X axis */
  42569. X = 0,
  42570. /** Y axis */
  42571. Y = 1,
  42572. /** Z axis */
  42573. Z = 2
  42574. }
  42575. /**
  42576. * Class used to define virtual joystick (used in touch mode)
  42577. */
  42578. export class VirtualJoystick {
  42579. /**
  42580. * Gets or sets a boolean indicating that left and right values must be inverted
  42581. */
  42582. reverseLeftRight: boolean;
  42583. /**
  42584. * Gets or sets a boolean indicating that up and down values must be inverted
  42585. */
  42586. reverseUpDown: boolean;
  42587. /**
  42588. * Gets the offset value for the position (ie. the change of the position value)
  42589. */
  42590. deltaPosition: Vector3;
  42591. /**
  42592. * Gets a boolean indicating if the virtual joystick was pressed
  42593. */
  42594. pressed: boolean;
  42595. /**
  42596. * Canvas the virtual joystick will render onto, default z-index of this is 5
  42597. */
  42598. static Canvas: Nullable<HTMLCanvasElement>;
  42599. private static _globalJoystickIndex;
  42600. private static vjCanvasContext;
  42601. private static vjCanvasWidth;
  42602. private static vjCanvasHeight;
  42603. private static halfWidth;
  42604. private _action;
  42605. private _axisTargetedByLeftAndRight;
  42606. private _axisTargetedByUpAndDown;
  42607. private _joystickSensibility;
  42608. private _inversedSensibility;
  42609. private _joystickPointerID;
  42610. private _joystickColor;
  42611. private _joystickPointerPos;
  42612. private _joystickPreviousPointerPos;
  42613. private _joystickPointerStartPos;
  42614. private _deltaJoystickVector;
  42615. private _leftJoystick;
  42616. private _touches;
  42617. private _onPointerDownHandlerRef;
  42618. private _onPointerMoveHandlerRef;
  42619. private _onPointerUpHandlerRef;
  42620. private _onResize;
  42621. /**
  42622. * Creates a new virtual joystick
  42623. * @param leftJoystick defines that the joystick is for left hand (false by default)
  42624. */
  42625. constructor(leftJoystick?: boolean);
  42626. /**
  42627. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  42628. * @param newJoystickSensibility defines the new sensibility
  42629. */
  42630. setJoystickSensibility(newJoystickSensibility: number): void;
  42631. private _onPointerDown;
  42632. private _onPointerMove;
  42633. private _onPointerUp;
  42634. /**
  42635. * Change the color of the virtual joystick
  42636. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  42637. */
  42638. setJoystickColor(newColor: string): void;
  42639. /**
  42640. * Defines a callback to call when the joystick is touched
  42641. * @param action defines the callback
  42642. */
  42643. setActionOnTouch(action: () => any): void;
  42644. /**
  42645. * Defines which axis you'd like to control for left & right
  42646. * @param axis defines the axis to use
  42647. */
  42648. setAxisForLeftRight(axis: JoystickAxis): void;
  42649. /**
  42650. * Defines which axis you'd like to control for up & down
  42651. * @param axis defines the axis to use
  42652. */
  42653. setAxisForUpDown(axis: JoystickAxis): void;
  42654. private _drawVirtualJoystick;
  42655. /**
  42656. * Release internal HTML canvas
  42657. */
  42658. releaseCanvas(): void;
  42659. }
  42660. }
  42661. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42662. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42663. import { Nullable } from "babylonjs/types";
  42664. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42665. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42666. module "babylonjs/Cameras/freeCameraInputsManager" {
  42667. interface FreeCameraInputsManager {
  42668. /**
  42669. * Add virtual joystick input support to the input manager.
  42670. * @returns the current input manager
  42671. */
  42672. addVirtualJoystick(): FreeCameraInputsManager;
  42673. }
  42674. }
  42675. /**
  42676. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42677. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42678. */
  42679. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42680. /**
  42681. * Defines the camera the input is attached to.
  42682. */
  42683. camera: FreeCamera;
  42684. private _leftjoystick;
  42685. private _rightjoystick;
  42686. /**
  42687. * Gets the left stick of the virtual joystick.
  42688. * @returns The virtual Joystick
  42689. */
  42690. getLeftJoystick(): VirtualJoystick;
  42691. /**
  42692. * Gets the right stick of the virtual joystick.
  42693. * @returns The virtual Joystick
  42694. */
  42695. getRightJoystick(): VirtualJoystick;
  42696. /**
  42697. * Update the current camera state depending on the inputs that have been used this frame.
  42698. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42699. */
  42700. checkInputs(): void;
  42701. /**
  42702. * Attach the input controls to a specific dom element to get the input from.
  42703. * @param element Defines the element the controls should be listened from
  42704. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42705. */
  42706. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42707. /**
  42708. * Detach the current controls from the specified dom element.
  42709. * @param element Defines the element to stop listening the inputs from
  42710. */
  42711. detachControl(element: Nullable<HTMLElement>): void;
  42712. /**
  42713. * Gets the class name of the current intput.
  42714. * @returns the class name
  42715. */
  42716. getClassName(): string;
  42717. /**
  42718. * Get the friendly name associated with the input class.
  42719. * @returns the input friendly name
  42720. */
  42721. getSimpleName(): string;
  42722. }
  42723. }
  42724. declare module "babylonjs/Cameras/Inputs/index" {
  42725. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42726. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42727. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42728. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42729. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42730. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42731. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42732. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42733. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42734. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42735. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42736. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42737. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42738. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42739. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42740. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42741. }
  42742. declare module "babylonjs/Cameras/touchCamera" {
  42743. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42744. import { Scene } from "babylonjs/scene";
  42745. import { Vector3 } from "babylonjs/Maths/math.vector";
  42746. /**
  42747. * This represents a FPS type of camera controlled by touch.
  42748. * This is like a universal camera minus the Gamepad controls.
  42749. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42750. */
  42751. export class TouchCamera extends FreeCamera {
  42752. /**
  42753. * Defines the touch sensibility for rotation.
  42754. * The higher the faster.
  42755. */
  42756. get touchAngularSensibility(): number;
  42757. set touchAngularSensibility(value: number);
  42758. /**
  42759. * Defines the touch sensibility for move.
  42760. * The higher the faster.
  42761. */
  42762. get touchMoveSensibility(): number;
  42763. set touchMoveSensibility(value: number);
  42764. /**
  42765. * Instantiates a new touch camera.
  42766. * This represents a FPS type of camera controlled by touch.
  42767. * This is like a universal camera minus the Gamepad controls.
  42768. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42769. * @param name Define the name of the camera in the scene
  42770. * @param position Define the start position of the camera in the scene
  42771. * @param scene Define the scene the camera belongs to
  42772. */
  42773. constructor(name: string, position: Vector3, scene: Scene);
  42774. /**
  42775. * Gets the current object class name.
  42776. * @return the class name
  42777. */
  42778. getClassName(): string;
  42779. /** @hidden */
  42780. _setupInputs(): void;
  42781. }
  42782. }
  42783. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42784. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42785. import { Scene } from "babylonjs/scene";
  42786. import { Vector3 } from "babylonjs/Maths/math.vector";
  42787. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42788. import { Axis } from "babylonjs/Maths/math.axis";
  42789. /**
  42790. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42791. * being tilted forward or back and left or right.
  42792. */
  42793. export class DeviceOrientationCamera extends FreeCamera {
  42794. private _initialQuaternion;
  42795. private _quaternionCache;
  42796. private _tmpDragQuaternion;
  42797. private _disablePointerInputWhenUsingDeviceOrientation;
  42798. /**
  42799. * Creates a new device orientation camera
  42800. * @param name The name of the camera
  42801. * @param position The start position camera
  42802. * @param scene The scene the camera belongs to
  42803. */
  42804. constructor(name: string, position: Vector3, scene: Scene);
  42805. /**
  42806. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42807. */
  42808. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42809. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42810. private _dragFactor;
  42811. /**
  42812. * Enabled turning on the y axis when the orientation sensor is active
  42813. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42814. */
  42815. enableHorizontalDragging(dragFactor?: number): void;
  42816. /**
  42817. * Gets the current instance class name ("DeviceOrientationCamera").
  42818. * This helps avoiding instanceof at run time.
  42819. * @returns the class name
  42820. */
  42821. getClassName(): string;
  42822. /**
  42823. * @hidden
  42824. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42825. */
  42826. _checkInputs(): void;
  42827. /**
  42828. * Reset the camera to its default orientation on the specified axis only.
  42829. * @param axis The axis to reset
  42830. */
  42831. resetToCurrentRotation(axis?: Axis): void;
  42832. }
  42833. }
  42834. declare module "babylonjs/Gamepads/xboxGamepad" {
  42835. import { Observable } from "babylonjs/Misc/observable";
  42836. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42837. /**
  42838. * Defines supported buttons for XBox360 compatible gamepads
  42839. */
  42840. export enum Xbox360Button {
  42841. /** A */
  42842. A = 0,
  42843. /** B */
  42844. B = 1,
  42845. /** X */
  42846. X = 2,
  42847. /** Y */
  42848. Y = 3,
  42849. /** Left button */
  42850. LB = 4,
  42851. /** Right button */
  42852. RB = 5,
  42853. /** Back */
  42854. Back = 8,
  42855. /** Start */
  42856. Start = 9,
  42857. /** Left stick */
  42858. LeftStick = 10,
  42859. /** Right stick */
  42860. RightStick = 11
  42861. }
  42862. /** Defines values for XBox360 DPad */
  42863. export enum Xbox360Dpad {
  42864. /** Up */
  42865. Up = 12,
  42866. /** Down */
  42867. Down = 13,
  42868. /** Left */
  42869. Left = 14,
  42870. /** Right */
  42871. Right = 15
  42872. }
  42873. /**
  42874. * Defines a XBox360 gamepad
  42875. */
  42876. export class Xbox360Pad extends Gamepad {
  42877. private _leftTrigger;
  42878. private _rightTrigger;
  42879. private _onlefttriggerchanged;
  42880. private _onrighttriggerchanged;
  42881. private _onbuttondown;
  42882. private _onbuttonup;
  42883. private _ondpaddown;
  42884. private _ondpadup;
  42885. /** Observable raised when a button is pressed */
  42886. onButtonDownObservable: Observable<Xbox360Button>;
  42887. /** Observable raised when a button is released */
  42888. onButtonUpObservable: Observable<Xbox360Button>;
  42889. /** Observable raised when a pad is pressed */
  42890. onPadDownObservable: Observable<Xbox360Dpad>;
  42891. /** Observable raised when a pad is released */
  42892. onPadUpObservable: Observable<Xbox360Dpad>;
  42893. private _buttonA;
  42894. private _buttonB;
  42895. private _buttonX;
  42896. private _buttonY;
  42897. private _buttonBack;
  42898. private _buttonStart;
  42899. private _buttonLB;
  42900. private _buttonRB;
  42901. private _buttonLeftStick;
  42902. private _buttonRightStick;
  42903. private _dPadUp;
  42904. private _dPadDown;
  42905. private _dPadLeft;
  42906. private _dPadRight;
  42907. private _isXboxOnePad;
  42908. /**
  42909. * Creates a new XBox360 gamepad object
  42910. * @param id defines the id of this gamepad
  42911. * @param index defines its index
  42912. * @param gamepad defines the internal HTML gamepad object
  42913. * @param xboxOne defines if it is a XBox One gamepad
  42914. */
  42915. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42916. /**
  42917. * Defines the callback to call when left trigger is pressed
  42918. * @param callback defines the callback to use
  42919. */
  42920. onlefttriggerchanged(callback: (value: number) => void): void;
  42921. /**
  42922. * Defines the callback to call when right trigger is pressed
  42923. * @param callback defines the callback to use
  42924. */
  42925. onrighttriggerchanged(callback: (value: number) => void): void;
  42926. /**
  42927. * Gets the left trigger value
  42928. */
  42929. get leftTrigger(): number;
  42930. /**
  42931. * Sets the left trigger value
  42932. */
  42933. set leftTrigger(newValue: number);
  42934. /**
  42935. * Gets the right trigger value
  42936. */
  42937. get rightTrigger(): number;
  42938. /**
  42939. * Sets the right trigger value
  42940. */
  42941. set rightTrigger(newValue: number);
  42942. /**
  42943. * Defines the callback to call when a button is pressed
  42944. * @param callback defines the callback to use
  42945. */
  42946. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42947. /**
  42948. * Defines the callback to call when a button is released
  42949. * @param callback defines the callback to use
  42950. */
  42951. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42952. /**
  42953. * Defines the callback to call when a pad is pressed
  42954. * @param callback defines the callback to use
  42955. */
  42956. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42957. /**
  42958. * Defines the callback to call when a pad is released
  42959. * @param callback defines the callback to use
  42960. */
  42961. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42962. private _setButtonValue;
  42963. private _setDPadValue;
  42964. /**
  42965. * Gets the value of the `A` button
  42966. */
  42967. get buttonA(): number;
  42968. /**
  42969. * Sets the value of the `A` button
  42970. */
  42971. set buttonA(value: number);
  42972. /**
  42973. * Gets the value of the `B` button
  42974. */
  42975. get buttonB(): number;
  42976. /**
  42977. * Sets the value of the `B` button
  42978. */
  42979. set buttonB(value: number);
  42980. /**
  42981. * Gets the value of the `X` button
  42982. */
  42983. get buttonX(): number;
  42984. /**
  42985. * Sets the value of the `X` button
  42986. */
  42987. set buttonX(value: number);
  42988. /**
  42989. * Gets the value of the `Y` button
  42990. */
  42991. get buttonY(): number;
  42992. /**
  42993. * Sets the value of the `Y` button
  42994. */
  42995. set buttonY(value: number);
  42996. /**
  42997. * Gets the value of the `Start` button
  42998. */
  42999. get buttonStart(): number;
  43000. /**
  43001. * Sets the value of the `Start` button
  43002. */
  43003. set buttonStart(value: number);
  43004. /**
  43005. * Gets the value of the `Back` button
  43006. */
  43007. get buttonBack(): number;
  43008. /**
  43009. * Sets the value of the `Back` button
  43010. */
  43011. set buttonBack(value: number);
  43012. /**
  43013. * Gets the value of the `Left` button
  43014. */
  43015. get buttonLB(): number;
  43016. /**
  43017. * Sets the value of the `Left` button
  43018. */
  43019. set buttonLB(value: number);
  43020. /**
  43021. * Gets the value of the `Right` button
  43022. */
  43023. get buttonRB(): number;
  43024. /**
  43025. * Sets the value of the `Right` button
  43026. */
  43027. set buttonRB(value: number);
  43028. /**
  43029. * Gets the value of the Left joystick
  43030. */
  43031. get buttonLeftStick(): number;
  43032. /**
  43033. * Sets the value of the Left joystick
  43034. */
  43035. set buttonLeftStick(value: number);
  43036. /**
  43037. * Gets the value of the Right joystick
  43038. */
  43039. get buttonRightStick(): number;
  43040. /**
  43041. * Sets the value of the Right joystick
  43042. */
  43043. set buttonRightStick(value: number);
  43044. /**
  43045. * Gets the value of D-pad up
  43046. */
  43047. get dPadUp(): number;
  43048. /**
  43049. * Sets the value of D-pad up
  43050. */
  43051. set dPadUp(value: number);
  43052. /**
  43053. * Gets the value of D-pad down
  43054. */
  43055. get dPadDown(): number;
  43056. /**
  43057. * Sets the value of D-pad down
  43058. */
  43059. set dPadDown(value: number);
  43060. /**
  43061. * Gets the value of D-pad left
  43062. */
  43063. get dPadLeft(): number;
  43064. /**
  43065. * Sets the value of D-pad left
  43066. */
  43067. set dPadLeft(value: number);
  43068. /**
  43069. * Gets the value of D-pad right
  43070. */
  43071. get dPadRight(): number;
  43072. /**
  43073. * Sets the value of D-pad right
  43074. */
  43075. set dPadRight(value: number);
  43076. /**
  43077. * Force the gamepad to synchronize with device values
  43078. */
  43079. update(): void;
  43080. /**
  43081. * Disposes the gamepad
  43082. */
  43083. dispose(): void;
  43084. }
  43085. }
  43086. declare module "babylonjs/Gamepads/dualShockGamepad" {
  43087. import { Observable } from "babylonjs/Misc/observable";
  43088. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  43089. /**
  43090. * Defines supported buttons for DualShock compatible gamepads
  43091. */
  43092. export enum DualShockButton {
  43093. /** Cross */
  43094. Cross = 0,
  43095. /** Circle */
  43096. Circle = 1,
  43097. /** Square */
  43098. Square = 2,
  43099. /** Triangle */
  43100. Triangle = 3,
  43101. /** L1 */
  43102. L1 = 4,
  43103. /** R1 */
  43104. R1 = 5,
  43105. /** Share */
  43106. Share = 8,
  43107. /** Options */
  43108. Options = 9,
  43109. /** Left stick */
  43110. LeftStick = 10,
  43111. /** Right stick */
  43112. RightStick = 11
  43113. }
  43114. /** Defines values for DualShock DPad */
  43115. export enum DualShockDpad {
  43116. /** Up */
  43117. Up = 12,
  43118. /** Down */
  43119. Down = 13,
  43120. /** Left */
  43121. Left = 14,
  43122. /** Right */
  43123. Right = 15
  43124. }
  43125. /**
  43126. * Defines a DualShock gamepad
  43127. */
  43128. export class DualShockPad extends Gamepad {
  43129. private _leftTrigger;
  43130. private _rightTrigger;
  43131. private _onlefttriggerchanged;
  43132. private _onrighttriggerchanged;
  43133. private _onbuttondown;
  43134. private _onbuttonup;
  43135. private _ondpaddown;
  43136. private _ondpadup;
  43137. /** Observable raised when a button is pressed */
  43138. onButtonDownObservable: Observable<DualShockButton>;
  43139. /** Observable raised when a button is released */
  43140. onButtonUpObservable: Observable<DualShockButton>;
  43141. /** Observable raised when a pad is pressed */
  43142. onPadDownObservable: Observable<DualShockDpad>;
  43143. /** Observable raised when a pad is released */
  43144. onPadUpObservable: Observable<DualShockDpad>;
  43145. private _buttonCross;
  43146. private _buttonCircle;
  43147. private _buttonSquare;
  43148. private _buttonTriangle;
  43149. private _buttonShare;
  43150. private _buttonOptions;
  43151. private _buttonL1;
  43152. private _buttonR1;
  43153. private _buttonLeftStick;
  43154. private _buttonRightStick;
  43155. private _dPadUp;
  43156. private _dPadDown;
  43157. private _dPadLeft;
  43158. private _dPadRight;
  43159. /**
  43160. * Creates a new DualShock gamepad object
  43161. * @param id defines the id of this gamepad
  43162. * @param index defines its index
  43163. * @param gamepad defines the internal HTML gamepad object
  43164. */
  43165. constructor(id: string, index: number, gamepad: any);
  43166. /**
  43167. * Defines the callback to call when left trigger is pressed
  43168. * @param callback defines the callback to use
  43169. */
  43170. onlefttriggerchanged(callback: (value: number) => void): void;
  43171. /**
  43172. * Defines the callback to call when right trigger is pressed
  43173. * @param callback defines the callback to use
  43174. */
  43175. onrighttriggerchanged(callback: (value: number) => void): void;
  43176. /**
  43177. * Gets the left trigger value
  43178. */
  43179. get leftTrigger(): number;
  43180. /**
  43181. * Sets the left trigger value
  43182. */
  43183. set leftTrigger(newValue: number);
  43184. /**
  43185. * Gets the right trigger value
  43186. */
  43187. get rightTrigger(): number;
  43188. /**
  43189. * Sets the right trigger value
  43190. */
  43191. set rightTrigger(newValue: number);
  43192. /**
  43193. * Defines the callback to call when a button is pressed
  43194. * @param callback defines the callback to use
  43195. */
  43196. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  43197. /**
  43198. * Defines the callback to call when a button is released
  43199. * @param callback defines the callback to use
  43200. */
  43201. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  43202. /**
  43203. * Defines the callback to call when a pad is pressed
  43204. * @param callback defines the callback to use
  43205. */
  43206. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  43207. /**
  43208. * Defines the callback to call when a pad is released
  43209. * @param callback defines the callback to use
  43210. */
  43211. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  43212. private _setButtonValue;
  43213. private _setDPadValue;
  43214. /**
  43215. * Gets the value of the `Cross` button
  43216. */
  43217. get buttonCross(): number;
  43218. /**
  43219. * Sets the value of the `Cross` button
  43220. */
  43221. set buttonCross(value: number);
  43222. /**
  43223. * Gets the value of the `Circle` button
  43224. */
  43225. get buttonCircle(): number;
  43226. /**
  43227. * Sets the value of the `Circle` button
  43228. */
  43229. set buttonCircle(value: number);
  43230. /**
  43231. * Gets the value of the `Square` button
  43232. */
  43233. get buttonSquare(): number;
  43234. /**
  43235. * Sets the value of the `Square` button
  43236. */
  43237. set buttonSquare(value: number);
  43238. /**
  43239. * Gets the value of the `Triangle` button
  43240. */
  43241. get buttonTriangle(): number;
  43242. /**
  43243. * Sets the value of the `Triangle` button
  43244. */
  43245. set buttonTriangle(value: number);
  43246. /**
  43247. * Gets the value of the `Options` button
  43248. */
  43249. get buttonOptions(): number;
  43250. /**
  43251. * Sets the value of the `Options` button
  43252. */
  43253. set buttonOptions(value: number);
  43254. /**
  43255. * Gets the value of the `Share` button
  43256. */
  43257. get buttonShare(): number;
  43258. /**
  43259. * Sets the value of the `Share` button
  43260. */
  43261. set buttonShare(value: number);
  43262. /**
  43263. * Gets the value of the `L1` button
  43264. */
  43265. get buttonL1(): number;
  43266. /**
  43267. * Sets the value of the `L1` button
  43268. */
  43269. set buttonL1(value: number);
  43270. /**
  43271. * Gets the value of the `R1` button
  43272. */
  43273. get buttonR1(): number;
  43274. /**
  43275. * Sets the value of the `R1` button
  43276. */
  43277. set buttonR1(value: number);
  43278. /**
  43279. * Gets the value of the Left joystick
  43280. */
  43281. get buttonLeftStick(): number;
  43282. /**
  43283. * Sets the value of the Left joystick
  43284. */
  43285. set buttonLeftStick(value: number);
  43286. /**
  43287. * Gets the value of the Right joystick
  43288. */
  43289. get buttonRightStick(): number;
  43290. /**
  43291. * Sets the value of the Right joystick
  43292. */
  43293. set buttonRightStick(value: number);
  43294. /**
  43295. * Gets the value of D-pad up
  43296. */
  43297. get dPadUp(): number;
  43298. /**
  43299. * Sets the value of D-pad up
  43300. */
  43301. set dPadUp(value: number);
  43302. /**
  43303. * Gets the value of D-pad down
  43304. */
  43305. get dPadDown(): number;
  43306. /**
  43307. * Sets the value of D-pad down
  43308. */
  43309. set dPadDown(value: number);
  43310. /**
  43311. * Gets the value of D-pad left
  43312. */
  43313. get dPadLeft(): number;
  43314. /**
  43315. * Sets the value of D-pad left
  43316. */
  43317. set dPadLeft(value: number);
  43318. /**
  43319. * Gets the value of D-pad right
  43320. */
  43321. get dPadRight(): number;
  43322. /**
  43323. * Sets the value of D-pad right
  43324. */
  43325. set dPadRight(value: number);
  43326. /**
  43327. * Force the gamepad to synchronize with device values
  43328. */
  43329. update(): void;
  43330. /**
  43331. * Disposes the gamepad
  43332. */
  43333. dispose(): void;
  43334. }
  43335. }
  43336. declare module "babylonjs/Gamepads/gamepadManager" {
  43337. import { Observable } from "babylonjs/Misc/observable";
  43338. import { Nullable } from "babylonjs/types";
  43339. import { Scene } from "babylonjs/scene";
  43340. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  43341. /**
  43342. * Manager for handling gamepads
  43343. */
  43344. export class GamepadManager {
  43345. private _scene?;
  43346. private _babylonGamepads;
  43347. private _oneGamepadConnected;
  43348. /** @hidden */
  43349. _isMonitoring: boolean;
  43350. private _gamepadEventSupported;
  43351. private _gamepadSupport?;
  43352. /**
  43353. * observable to be triggered when the gamepad controller has been connected
  43354. */
  43355. onGamepadConnectedObservable: Observable<Gamepad>;
  43356. /**
  43357. * observable to be triggered when the gamepad controller has been disconnected
  43358. */
  43359. onGamepadDisconnectedObservable: Observable<Gamepad>;
  43360. private _onGamepadConnectedEvent;
  43361. private _onGamepadDisconnectedEvent;
  43362. /**
  43363. * Initializes the gamepad manager
  43364. * @param _scene BabylonJS scene
  43365. */
  43366. constructor(_scene?: Scene | undefined);
  43367. /**
  43368. * The gamepads in the game pad manager
  43369. */
  43370. get gamepads(): Gamepad[];
  43371. /**
  43372. * Get the gamepad controllers based on type
  43373. * @param type The type of gamepad controller
  43374. * @returns Nullable gamepad
  43375. */
  43376. getGamepadByType(type?: number): Nullable<Gamepad>;
  43377. /**
  43378. * Disposes the gamepad manager
  43379. */
  43380. dispose(): void;
  43381. private _addNewGamepad;
  43382. private _startMonitoringGamepads;
  43383. private _stopMonitoringGamepads;
  43384. /** @hidden */
  43385. _checkGamepadsStatus(): void;
  43386. private _updateGamepadObjects;
  43387. }
  43388. }
  43389. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  43390. import { Nullable } from "babylonjs/types";
  43391. import { Scene } from "babylonjs/scene";
  43392. import { ISceneComponent } from "babylonjs/sceneComponent";
  43393. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  43394. module "babylonjs/scene" {
  43395. interface Scene {
  43396. /** @hidden */
  43397. _gamepadManager: Nullable<GamepadManager>;
  43398. /**
  43399. * Gets the gamepad manager associated with the scene
  43400. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  43401. */
  43402. gamepadManager: GamepadManager;
  43403. }
  43404. }
  43405. module "babylonjs/Cameras/freeCameraInputsManager" {
  43406. /**
  43407. * Interface representing a free camera inputs manager
  43408. */
  43409. interface FreeCameraInputsManager {
  43410. /**
  43411. * Adds gamepad input support to the FreeCameraInputsManager.
  43412. * @returns the FreeCameraInputsManager
  43413. */
  43414. addGamepad(): FreeCameraInputsManager;
  43415. }
  43416. }
  43417. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  43418. /**
  43419. * Interface representing an arc rotate camera inputs manager
  43420. */
  43421. interface ArcRotateCameraInputsManager {
  43422. /**
  43423. * Adds gamepad input support to the ArcRotateCamera InputManager.
  43424. * @returns the camera inputs manager
  43425. */
  43426. addGamepad(): ArcRotateCameraInputsManager;
  43427. }
  43428. }
  43429. /**
  43430. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  43431. */
  43432. export class GamepadSystemSceneComponent implements ISceneComponent {
  43433. /**
  43434. * The component name helpfull to identify the component in the list of scene components.
  43435. */
  43436. readonly name: string;
  43437. /**
  43438. * The scene the component belongs to.
  43439. */
  43440. scene: Scene;
  43441. /**
  43442. * Creates a new instance of the component for the given scene
  43443. * @param scene Defines the scene to register the component in
  43444. */
  43445. constructor(scene: Scene);
  43446. /**
  43447. * Registers the component in a given scene
  43448. */
  43449. register(): void;
  43450. /**
  43451. * Rebuilds the elements related to this component in case of
  43452. * context lost for instance.
  43453. */
  43454. rebuild(): void;
  43455. /**
  43456. * Disposes the component and the associated ressources
  43457. */
  43458. dispose(): void;
  43459. private _beforeCameraUpdate;
  43460. }
  43461. }
  43462. declare module "babylonjs/Cameras/universalCamera" {
  43463. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  43464. import { Scene } from "babylonjs/scene";
  43465. import { Vector3 } from "babylonjs/Maths/math.vector";
  43466. import "babylonjs/Gamepads/gamepadSceneComponent";
  43467. /**
  43468. * 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,
  43469. * which still works and will still be found in many Playgrounds.
  43470. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43471. */
  43472. export class UniversalCamera extends TouchCamera {
  43473. /**
  43474. * Defines the gamepad rotation sensiblity.
  43475. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43476. */
  43477. get gamepadAngularSensibility(): number;
  43478. set gamepadAngularSensibility(value: number);
  43479. /**
  43480. * Defines the gamepad move sensiblity.
  43481. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43482. */
  43483. get gamepadMoveSensibility(): number;
  43484. set gamepadMoveSensibility(value: number);
  43485. /**
  43486. * 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,
  43487. * which still works and will still be found in many Playgrounds.
  43488. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43489. * @param name Define the name of the camera in the scene
  43490. * @param position Define the start position of the camera in the scene
  43491. * @param scene Define the scene the camera belongs to
  43492. */
  43493. constructor(name: string, position: Vector3, scene: Scene);
  43494. /**
  43495. * Gets the current object class name.
  43496. * @return the class name
  43497. */
  43498. getClassName(): string;
  43499. }
  43500. }
  43501. declare module "babylonjs/Cameras/gamepadCamera" {
  43502. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43503. import { Scene } from "babylonjs/scene";
  43504. import { Vector3 } from "babylonjs/Maths/math.vector";
  43505. /**
  43506. * This represents a FPS type of camera. This is only here for back compat purpose.
  43507. * Please use the UniversalCamera instead as both are identical.
  43508. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43509. */
  43510. export class GamepadCamera extends UniversalCamera {
  43511. /**
  43512. * Instantiates a new Gamepad Camera
  43513. * This represents a FPS type of camera. This is only here for back compat purpose.
  43514. * Please use the UniversalCamera instead as both are identical.
  43515. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43516. * @param name Define the name of the camera in the scene
  43517. * @param position Define the start position of the camera in the scene
  43518. * @param scene Define the scene the camera belongs to
  43519. */
  43520. constructor(name: string, position: Vector3, scene: Scene);
  43521. /**
  43522. * Gets the current object class name.
  43523. * @return the class name
  43524. */
  43525. getClassName(): string;
  43526. }
  43527. }
  43528. declare module "babylonjs/Shaders/pass.fragment" {
  43529. /** @hidden */
  43530. export var passPixelShader: {
  43531. name: string;
  43532. shader: string;
  43533. };
  43534. }
  43535. declare module "babylonjs/Shaders/passCube.fragment" {
  43536. /** @hidden */
  43537. export var passCubePixelShader: {
  43538. name: string;
  43539. shader: string;
  43540. };
  43541. }
  43542. declare module "babylonjs/PostProcesses/passPostProcess" {
  43543. import { Nullable } from "babylonjs/types";
  43544. import { Camera } from "babylonjs/Cameras/camera";
  43545. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43546. import { Engine } from "babylonjs/Engines/engine";
  43547. import "babylonjs/Shaders/pass.fragment";
  43548. import "babylonjs/Shaders/passCube.fragment";
  43549. /**
  43550. * PassPostProcess which produces an output the same as it's input
  43551. */
  43552. export class PassPostProcess extends PostProcess {
  43553. /**
  43554. * Creates the PassPostProcess
  43555. * @param name The name of the effect.
  43556. * @param options The required width/height ratio to downsize to before computing the render pass.
  43557. * @param camera The camera to apply the render pass to.
  43558. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43559. * @param engine The engine which the post process will be applied. (default: current engine)
  43560. * @param reusable If the post process can be reused on the same frame. (default: false)
  43561. * @param textureType The type of texture to be used when performing the post processing.
  43562. * @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)
  43563. */
  43564. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43565. }
  43566. /**
  43567. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  43568. */
  43569. export class PassCubePostProcess extends PostProcess {
  43570. private _face;
  43571. /**
  43572. * Gets or sets the cube face to display.
  43573. * * 0 is +X
  43574. * * 1 is -X
  43575. * * 2 is +Y
  43576. * * 3 is -Y
  43577. * * 4 is +Z
  43578. * * 5 is -Z
  43579. */
  43580. get face(): number;
  43581. set face(value: number);
  43582. /**
  43583. * Creates the PassCubePostProcess
  43584. * @param name The name of the effect.
  43585. * @param options The required width/height ratio to downsize to before computing the render pass.
  43586. * @param camera The camera to apply the render pass to.
  43587. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43588. * @param engine The engine which the post process will be applied. (default: current engine)
  43589. * @param reusable If the post process can be reused on the same frame. (default: false)
  43590. * @param textureType The type of texture to be used when performing the post processing.
  43591. * @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)
  43592. */
  43593. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43594. }
  43595. }
  43596. declare module "babylonjs/Shaders/anaglyph.fragment" {
  43597. /** @hidden */
  43598. export var anaglyphPixelShader: {
  43599. name: string;
  43600. shader: string;
  43601. };
  43602. }
  43603. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  43604. import { Engine } from "babylonjs/Engines/engine";
  43605. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43606. import { Camera } from "babylonjs/Cameras/camera";
  43607. import "babylonjs/Shaders/anaglyph.fragment";
  43608. /**
  43609. * Postprocess used to generate anaglyphic rendering
  43610. */
  43611. export class AnaglyphPostProcess extends PostProcess {
  43612. private _passedProcess;
  43613. /**
  43614. * Creates a new AnaglyphPostProcess
  43615. * @param name defines postprocess name
  43616. * @param options defines creation options or target ratio scale
  43617. * @param rigCameras defines cameras using this postprocess
  43618. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  43619. * @param engine defines hosting engine
  43620. * @param reusable defines if the postprocess will be reused multiple times per frame
  43621. */
  43622. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  43623. }
  43624. }
  43625. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  43626. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  43627. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43628. import { Scene } from "babylonjs/scene";
  43629. import { Vector3 } from "babylonjs/Maths/math.vector";
  43630. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43631. /**
  43632. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  43633. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43634. */
  43635. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  43636. /**
  43637. * Creates a new AnaglyphArcRotateCamera
  43638. * @param name defines camera name
  43639. * @param alpha defines alpha angle (in radians)
  43640. * @param beta defines beta angle (in radians)
  43641. * @param radius defines radius
  43642. * @param target defines camera target
  43643. * @param interaxialDistance defines distance between each color axis
  43644. * @param scene defines the hosting scene
  43645. */
  43646. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43647. /**
  43648. * Gets camera class name
  43649. * @returns AnaglyphArcRotateCamera
  43650. */
  43651. getClassName(): string;
  43652. }
  43653. }
  43654. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43655. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43656. import { Scene } from "babylonjs/scene";
  43657. import { Vector3 } from "babylonjs/Maths/math.vector";
  43658. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43659. /**
  43660. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43661. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43662. */
  43663. export class AnaglyphFreeCamera extends FreeCamera {
  43664. /**
  43665. * Creates a new AnaglyphFreeCamera
  43666. * @param name defines camera name
  43667. * @param position defines initial position
  43668. * @param interaxialDistance defines distance between each color axis
  43669. * @param scene defines the hosting scene
  43670. */
  43671. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43672. /**
  43673. * Gets camera class name
  43674. * @returns AnaglyphFreeCamera
  43675. */
  43676. getClassName(): string;
  43677. }
  43678. }
  43679. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43680. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43681. import { Scene } from "babylonjs/scene";
  43682. import { Vector3 } from "babylonjs/Maths/math.vector";
  43683. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43684. /**
  43685. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43686. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43687. */
  43688. export class AnaglyphGamepadCamera extends GamepadCamera {
  43689. /**
  43690. * Creates a new AnaglyphGamepadCamera
  43691. * @param name defines camera name
  43692. * @param position defines initial position
  43693. * @param interaxialDistance defines distance between each color axis
  43694. * @param scene defines the hosting scene
  43695. */
  43696. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43697. /**
  43698. * Gets camera class name
  43699. * @returns AnaglyphGamepadCamera
  43700. */
  43701. getClassName(): string;
  43702. }
  43703. }
  43704. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43705. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43706. import { Scene } from "babylonjs/scene";
  43707. import { Vector3 } from "babylonjs/Maths/math.vector";
  43708. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43709. /**
  43710. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43711. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43712. */
  43713. export class AnaglyphUniversalCamera extends UniversalCamera {
  43714. /**
  43715. * Creates a new AnaglyphUniversalCamera
  43716. * @param name defines camera name
  43717. * @param position defines initial position
  43718. * @param interaxialDistance defines distance between each color axis
  43719. * @param scene defines the hosting scene
  43720. */
  43721. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43722. /**
  43723. * Gets camera class name
  43724. * @returns AnaglyphUniversalCamera
  43725. */
  43726. getClassName(): string;
  43727. }
  43728. }
  43729. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43730. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43731. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43732. import { Scene } from "babylonjs/scene";
  43733. import { Vector3 } from "babylonjs/Maths/math.vector";
  43734. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43735. /**
  43736. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43737. * @see http://doc.babylonjs.com/features/cameras
  43738. */
  43739. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43740. /**
  43741. * Creates a new StereoscopicArcRotateCamera
  43742. * @param name defines camera name
  43743. * @param alpha defines alpha angle (in radians)
  43744. * @param beta defines beta angle (in radians)
  43745. * @param radius defines radius
  43746. * @param target defines camera target
  43747. * @param interaxialDistance defines distance between each color axis
  43748. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43749. * @param scene defines the hosting scene
  43750. */
  43751. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43752. /**
  43753. * Gets camera class name
  43754. * @returns StereoscopicArcRotateCamera
  43755. */
  43756. getClassName(): string;
  43757. }
  43758. }
  43759. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43760. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43761. import { Scene } from "babylonjs/scene";
  43762. import { Vector3 } from "babylonjs/Maths/math.vector";
  43763. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43764. /**
  43765. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43766. * @see http://doc.babylonjs.com/features/cameras
  43767. */
  43768. export class StereoscopicFreeCamera extends FreeCamera {
  43769. /**
  43770. * Creates a new StereoscopicFreeCamera
  43771. * @param name defines camera name
  43772. * @param position defines initial position
  43773. * @param interaxialDistance defines distance between each color axis
  43774. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43775. * @param scene defines the hosting scene
  43776. */
  43777. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43778. /**
  43779. * Gets camera class name
  43780. * @returns StereoscopicFreeCamera
  43781. */
  43782. getClassName(): string;
  43783. }
  43784. }
  43785. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43786. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43787. import { Scene } from "babylonjs/scene";
  43788. import { Vector3 } from "babylonjs/Maths/math.vector";
  43789. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43790. /**
  43791. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43792. * @see http://doc.babylonjs.com/features/cameras
  43793. */
  43794. export class StereoscopicGamepadCamera extends GamepadCamera {
  43795. /**
  43796. * Creates a new StereoscopicGamepadCamera
  43797. * @param name defines camera name
  43798. * @param position defines initial position
  43799. * @param interaxialDistance defines distance between each color axis
  43800. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43801. * @param scene defines the hosting scene
  43802. */
  43803. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43804. /**
  43805. * Gets camera class name
  43806. * @returns StereoscopicGamepadCamera
  43807. */
  43808. getClassName(): string;
  43809. }
  43810. }
  43811. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43812. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43813. import { Scene } from "babylonjs/scene";
  43814. import { Vector3 } from "babylonjs/Maths/math.vector";
  43815. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43816. /**
  43817. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43818. * @see http://doc.babylonjs.com/features/cameras
  43819. */
  43820. export class StereoscopicUniversalCamera extends UniversalCamera {
  43821. /**
  43822. * Creates a new StereoscopicUniversalCamera
  43823. * @param name defines camera name
  43824. * @param position defines initial position
  43825. * @param interaxialDistance defines distance between each color axis
  43826. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43827. * @param scene defines the hosting scene
  43828. */
  43829. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43830. /**
  43831. * Gets camera class name
  43832. * @returns StereoscopicUniversalCamera
  43833. */
  43834. getClassName(): string;
  43835. }
  43836. }
  43837. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43838. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43839. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43840. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43841. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43842. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43843. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43844. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43845. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43846. }
  43847. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43848. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43849. import { Scene } from "babylonjs/scene";
  43850. import { Vector3 } from "babylonjs/Maths/math.vector";
  43851. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43852. /**
  43853. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43854. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43855. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43856. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43857. */
  43858. export class VirtualJoysticksCamera extends FreeCamera {
  43859. /**
  43860. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43861. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43862. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43863. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43864. * @param name Define the name of the camera in the scene
  43865. * @param position Define the start position of the camera in the scene
  43866. * @param scene Define the scene the camera belongs to
  43867. */
  43868. constructor(name: string, position: Vector3, scene: Scene);
  43869. /**
  43870. * Gets the current object class name.
  43871. * @return the class name
  43872. */
  43873. getClassName(): string;
  43874. }
  43875. }
  43876. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43877. import { Matrix } from "babylonjs/Maths/math.vector";
  43878. /**
  43879. * This represents all the required metrics to create a VR camera.
  43880. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43881. */
  43882. export class VRCameraMetrics {
  43883. /**
  43884. * Define the horizontal resolution off the screen.
  43885. */
  43886. hResolution: number;
  43887. /**
  43888. * Define the vertical resolution off the screen.
  43889. */
  43890. vResolution: number;
  43891. /**
  43892. * Define the horizontal screen size.
  43893. */
  43894. hScreenSize: number;
  43895. /**
  43896. * Define the vertical screen size.
  43897. */
  43898. vScreenSize: number;
  43899. /**
  43900. * Define the vertical screen center position.
  43901. */
  43902. vScreenCenter: number;
  43903. /**
  43904. * Define the distance of the eyes to the screen.
  43905. */
  43906. eyeToScreenDistance: number;
  43907. /**
  43908. * Define the distance between both lenses
  43909. */
  43910. lensSeparationDistance: number;
  43911. /**
  43912. * Define the distance between both viewer's eyes.
  43913. */
  43914. interpupillaryDistance: number;
  43915. /**
  43916. * Define the distortion factor of the VR postprocess.
  43917. * Please, touch with care.
  43918. */
  43919. distortionK: number[];
  43920. /**
  43921. * Define the chromatic aberration correction factors for the VR post process.
  43922. */
  43923. chromaAbCorrection: number[];
  43924. /**
  43925. * Define the scale factor of the post process.
  43926. * The smaller the better but the slower.
  43927. */
  43928. postProcessScaleFactor: number;
  43929. /**
  43930. * Define an offset for the lens center.
  43931. */
  43932. lensCenterOffset: number;
  43933. /**
  43934. * Define if the current vr camera should compensate the distortion of the lense or not.
  43935. */
  43936. compensateDistortion: boolean;
  43937. /**
  43938. * Defines if multiview should be enabled when rendering (Default: false)
  43939. */
  43940. multiviewEnabled: boolean;
  43941. /**
  43942. * Gets the rendering aspect ratio based on the provided resolutions.
  43943. */
  43944. get aspectRatio(): number;
  43945. /**
  43946. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43947. */
  43948. get aspectRatioFov(): number;
  43949. /**
  43950. * @hidden
  43951. */
  43952. get leftHMatrix(): Matrix;
  43953. /**
  43954. * @hidden
  43955. */
  43956. get rightHMatrix(): Matrix;
  43957. /**
  43958. * @hidden
  43959. */
  43960. get leftPreViewMatrix(): Matrix;
  43961. /**
  43962. * @hidden
  43963. */
  43964. get rightPreViewMatrix(): Matrix;
  43965. /**
  43966. * Get the default VRMetrics based on the most generic setup.
  43967. * @returns the default vr metrics
  43968. */
  43969. static GetDefault(): VRCameraMetrics;
  43970. }
  43971. }
  43972. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43973. /** @hidden */
  43974. export var vrDistortionCorrectionPixelShader: {
  43975. name: string;
  43976. shader: string;
  43977. };
  43978. }
  43979. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43980. import { Camera } from "babylonjs/Cameras/camera";
  43981. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43982. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43983. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43984. /**
  43985. * VRDistortionCorrectionPostProcess used for mobile VR
  43986. */
  43987. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43988. private _isRightEye;
  43989. private _distortionFactors;
  43990. private _postProcessScaleFactor;
  43991. private _lensCenterOffset;
  43992. private _scaleIn;
  43993. private _scaleFactor;
  43994. private _lensCenter;
  43995. /**
  43996. * Initializes the VRDistortionCorrectionPostProcess
  43997. * @param name The name of the effect.
  43998. * @param camera The camera to apply the render pass to.
  43999. * @param isRightEye If this is for the right eye distortion
  44000. * @param vrMetrics All the required metrics for the VR camera
  44001. */
  44002. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  44003. }
  44004. }
  44005. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  44006. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  44007. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44008. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44009. import { Scene } from "babylonjs/scene";
  44010. import { Vector3 } from "babylonjs/Maths/math.vector";
  44011. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  44012. import "babylonjs/Cameras/RigModes/vrRigMode";
  44013. /**
  44014. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  44015. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  44016. */
  44017. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  44018. /**
  44019. * Creates a new VRDeviceOrientationArcRotateCamera
  44020. * @param name defines camera name
  44021. * @param alpha defines the camera rotation along the logitudinal axis
  44022. * @param beta defines the camera rotation along the latitudinal axis
  44023. * @param radius defines the camera distance from its target
  44024. * @param target defines the camera target
  44025. * @param scene defines the scene the camera belongs to
  44026. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  44027. * @param vrCameraMetrics defines the vr metrics associated to the camera
  44028. */
  44029. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  44030. /**
  44031. * Gets camera class name
  44032. * @returns VRDeviceOrientationArcRotateCamera
  44033. */
  44034. getClassName(): string;
  44035. }
  44036. }
  44037. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  44038. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  44039. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44040. import { Scene } from "babylonjs/scene";
  44041. import { Vector3 } from "babylonjs/Maths/math.vector";
  44042. import "babylonjs/Cameras/RigModes/vrRigMode";
  44043. /**
  44044. * Camera used to simulate VR rendering (based on FreeCamera)
  44045. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  44046. */
  44047. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  44048. /**
  44049. * Creates a new VRDeviceOrientationFreeCamera
  44050. * @param name defines camera name
  44051. * @param position defines the start position of the camera
  44052. * @param scene defines the scene the camera belongs to
  44053. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  44054. * @param vrCameraMetrics defines the vr metrics associated to the camera
  44055. */
  44056. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  44057. /**
  44058. * Gets camera class name
  44059. * @returns VRDeviceOrientationFreeCamera
  44060. */
  44061. getClassName(): string;
  44062. }
  44063. }
  44064. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  44065. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  44066. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44067. import { Scene } from "babylonjs/scene";
  44068. import { Vector3 } from "babylonjs/Maths/math.vector";
  44069. import "babylonjs/Gamepads/gamepadSceneComponent";
  44070. /**
  44071. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  44072. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  44073. */
  44074. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  44075. /**
  44076. * Creates a new VRDeviceOrientationGamepadCamera
  44077. * @param name defines camera name
  44078. * @param position defines the start position of the camera
  44079. * @param scene defines the scene the camera belongs to
  44080. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  44081. * @param vrCameraMetrics defines the vr metrics associated to the camera
  44082. */
  44083. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  44084. /**
  44085. * Gets camera class name
  44086. * @returns VRDeviceOrientationGamepadCamera
  44087. */
  44088. getClassName(): string;
  44089. }
  44090. }
  44091. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  44092. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44093. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44094. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44095. /** @hidden */
  44096. export var imageProcessingPixelShader: {
  44097. name: string;
  44098. shader: string;
  44099. };
  44100. }
  44101. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  44102. import { Nullable } from "babylonjs/types";
  44103. import { Color4 } from "babylonjs/Maths/math.color";
  44104. import { Camera } from "babylonjs/Cameras/camera";
  44105. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44106. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44107. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44108. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  44109. import { Engine } from "babylonjs/Engines/engine";
  44110. import "babylonjs/Shaders/imageProcessing.fragment";
  44111. import "babylonjs/Shaders/postprocess.vertex";
  44112. /**
  44113. * ImageProcessingPostProcess
  44114. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  44115. */
  44116. export class ImageProcessingPostProcess extends PostProcess {
  44117. /**
  44118. * Default configuration related to image processing available in the PBR Material.
  44119. */
  44120. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44121. /**
  44122. * Gets the image processing configuration used either in this material.
  44123. */
  44124. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  44125. /**
  44126. * Sets the Default image processing configuration used either in the this material.
  44127. *
  44128. * If sets to null, the scene one is in use.
  44129. */
  44130. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  44131. /**
  44132. * Keep track of the image processing observer to allow dispose and replace.
  44133. */
  44134. private _imageProcessingObserver;
  44135. /**
  44136. * Attaches a new image processing configuration to the PBR Material.
  44137. * @param configuration
  44138. */
  44139. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  44140. /**
  44141. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  44142. */
  44143. get colorCurves(): Nullable<ColorCurves>;
  44144. /**
  44145. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  44146. */
  44147. set colorCurves(value: Nullable<ColorCurves>);
  44148. /**
  44149. * Gets wether the color curves effect is enabled.
  44150. */
  44151. get colorCurvesEnabled(): boolean;
  44152. /**
  44153. * Sets wether the color curves effect is enabled.
  44154. */
  44155. set colorCurvesEnabled(value: boolean);
  44156. /**
  44157. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  44158. */
  44159. get colorGradingTexture(): Nullable<BaseTexture>;
  44160. /**
  44161. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  44162. */
  44163. set colorGradingTexture(value: Nullable<BaseTexture>);
  44164. /**
  44165. * Gets wether the color grading effect is enabled.
  44166. */
  44167. get colorGradingEnabled(): boolean;
  44168. /**
  44169. * Gets wether the color grading effect is enabled.
  44170. */
  44171. set colorGradingEnabled(value: boolean);
  44172. /**
  44173. * Gets exposure used in the effect.
  44174. */
  44175. get exposure(): number;
  44176. /**
  44177. * Sets exposure used in the effect.
  44178. */
  44179. set exposure(value: number);
  44180. /**
  44181. * Gets wether tonemapping is enabled or not.
  44182. */
  44183. get toneMappingEnabled(): boolean;
  44184. /**
  44185. * Sets wether tonemapping is enabled or not
  44186. */
  44187. set toneMappingEnabled(value: boolean);
  44188. /**
  44189. * Gets the type of tone mapping effect.
  44190. */
  44191. get toneMappingType(): number;
  44192. /**
  44193. * Sets the type of tone mapping effect.
  44194. */
  44195. set toneMappingType(value: number);
  44196. /**
  44197. * Gets contrast used in the effect.
  44198. */
  44199. get contrast(): number;
  44200. /**
  44201. * Sets contrast used in the effect.
  44202. */
  44203. set contrast(value: number);
  44204. /**
  44205. * Gets Vignette stretch size.
  44206. */
  44207. get vignetteStretch(): number;
  44208. /**
  44209. * Sets Vignette stretch size.
  44210. */
  44211. set vignetteStretch(value: number);
  44212. /**
  44213. * Gets Vignette centre X Offset.
  44214. */
  44215. get vignetteCentreX(): number;
  44216. /**
  44217. * Sets Vignette centre X Offset.
  44218. */
  44219. set vignetteCentreX(value: number);
  44220. /**
  44221. * Gets Vignette centre Y Offset.
  44222. */
  44223. get vignetteCentreY(): number;
  44224. /**
  44225. * Sets Vignette centre Y Offset.
  44226. */
  44227. set vignetteCentreY(value: number);
  44228. /**
  44229. * Gets Vignette weight or intensity of the vignette effect.
  44230. */
  44231. get vignetteWeight(): number;
  44232. /**
  44233. * Sets Vignette weight or intensity of the vignette effect.
  44234. */
  44235. set vignetteWeight(value: number);
  44236. /**
  44237. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  44238. * if vignetteEnabled is set to true.
  44239. */
  44240. get vignetteColor(): Color4;
  44241. /**
  44242. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  44243. * if vignetteEnabled is set to true.
  44244. */
  44245. set vignetteColor(value: Color4);
  44246. /**
  44247. * Gets Camera field of view used by the Vignette effect.
  44248. */
  44249. get vignetteCameraFov(): number;
  44250. /**
  44251. * Sets Camera field of view used by the Vignette effect.
  44252. */
  44253. set vignetteCameraFov(value: number);
  44254. /**
  44255. * Gets the vignette blend mode allowing different kind of effect.
  44256. */
  44257. get vignetteBlendMode(): number;
  44258. /**
  44259. * Sets the vignette blend mode allowing different kind of effect.
  44260. */
  44261. set vignetteBlendMode(value: number);
  44262. /**
  44263. * Gets wether the vignette effect is enabled.
  44264. */
  44265. get vignetteEnabled(): boolean;
  44266. /**
  44267. * Sets wether the vignette effect is enabled.
  44268. */
  44269. set vignetteEnabled(value: boolean);
  44270. private _fromLinearSpace;
  44271. /**
  44272. * Gets wether the input of the processing is in Gamma or Linear Space.
  44273. */
  44274. get fromLinearSpace(): boolean;
  44275. /**
  44276. * Sets wether the input of the processing is in Gamma or Linear Space.
  44277. */
  44278. set fromLinearSpace(value: boolean);
  44279. /**
  44280. * Defines cache preventing GC.
  44281. */
  44282. private _defines;
  44283. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  44284. /**
  44285. * "ImageProcessingPostProcess"
  44286. * @returns "ImageProcessingPostProcess"
  44287. */
  44288. getClassName(): string;
  44289. protected _updateParameters(): void;
  44290. dispose(camera?: Camera): void;
  44291. }
  44292. }
  44293. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  44294. import { Scene } from "babylonjs/scene";
  44295. import { Color3 } from "babylonjs/Maths/math.color";
  44296. import { Mesh } from "babylonjs/Meshes/mesh";
  44297. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  44298. import { Nullable } from "babylonjs/types";
  44299. /**
  44300. * Class containing static functions to help procedurally build meshes
  44301. */
  44302. export class GroundBuilder {
  44303. /**
  44304. * Creates a ground mesh
  44305. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  44306. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  44307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44308. * @param name defines the name of the mesh
  44309. * @param options defines the options used to create the mesh
  44310. * @param scene defines the hosting scene
  44311. * @returns the ground mesh
  44312. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  44313. */
  44314. static CreateGround(name: string, options: {
  44315. width?: number;
  44316. height?: number;
  44317. subdivisions?: number;
  44318. subdivisionsX?: number;
  44319. subdivisionsY?: number;
  44320. updatable?: boolean;
  44321. }, scene: any): Mesh;
  44322. /**
  44323. * Creates a tiled ground mesh
  44324. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  44325. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  44326. * * 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
  44327. * * 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
  44328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44329. * @param name defines the name of the mesh
  44330. * @param options defines the options used to create the mesh
  44331. * @param scene defines the hosting scene
  44332. * @returns the tiled ground mesh
  44333. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  44334. */
  44335. static CreateTiledGround(name: string, options: {
  44336. xmin: number;
  44337. zmin: number;
  44338. xmax: number;
  44339. zmax: number;
  44340. subdivisions?: {
  44341. w: number;
  44342. h: number;
  44343. };
  44344. precision?: {
  44345. w: number;
  44346. h: number;
  44347. };
  44348. updatable?: boolean;
  44349. }, scene?: Nullable<Scene>): Mesh;
  44350. /**
  44351. * Creates a ground mesh from a height map
  44352. * * The parameter `url` sets the URL of the height map image resource.
  44353. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  44354. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  44355. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  44356. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  44357. * * 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.
  44358. * * 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).
  44359. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  44360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44361. * @param name defines the name of the mesh
  44362. * @param url defines the url to the height map
  44363. * @param options defines the options used to create the mesh
  44364. * @param scene defines the hosting scene
  44365. * @returns the ground mesh
  44366. * @see https://doc.babylonjs.com/babylon101/height_map
  44367. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  44368. */
  44369. static CreateGroundFromHeightMap(name: string, url: string, options: {
  44370. width?: number;
  44371. height?: number;
  44372. subdivisions?: number;
  44373. minHeight?: number;
  44374. maxHeight?: number;
  44375. colorFilter?: Color3;
  44376. alphaFilter?: number;
  44377. updatable?: boolean;
  44378. onReady?: (mesh: GroundMesh) => void;
  44379. }, scene?: Nullable<Scene>): GroundMesh;
  44380. }
  44381. }
  44382. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  44383. import { Vector4 } from "babylonjs/Maths/math.vector";
  44384. import { Mesh } from "babylonjs/Meshes/mesh";
  44385. /**
  44386. * Class containing static functions to help procedurally build meshes
  44387. */
  44388. export class TorusBuilder {
  44389. /**
  44390. * Creates a torus mesh
  44391. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  44392. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  44393. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  44394. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44395. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44396. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44397. * @param name defines the name of the mesh
  44398. * @param options defines the options used to create the mesh
  44399. * @param scene defines the hosting scene
  44400. * @returns the torus mesh
  44401. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  44402. */
  44403. static CreateTorus(name: string, options: {
  44404. diameter?: number;
  44405. thickness?: number;
  44406. tessellation?: number;
  44407. updatable?: boolean;
  44408. sideOrientation?: number;
  44409. frontUVs?: Vector4;
  44410. backUVs?: Vector4;
  44411. }, scene: any): Mesh;
  44412. }
  44413. }
  44414. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  44415. import { Vector4 } from "babylonjs/Maths/math.vector";
  44416. import { Color4 } from "babylonjs/Maths/math.color";
  44417. import { Mesh } from "babylonjs/Meshes/mesh";
  44418. /**
  44419. * Class containing static functions to help procedurally build meshes
  44420. */
  44421. export class CylinderBuilder {
  44422. /**
  44423. * Creates a cylinder or a cone mesh
  44424. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  44425. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  44426. * * 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.
  44427. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  44428. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  44429. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  44430. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  44431. * * 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).
  44432. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  44433. * * 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).
  44434. * * 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
  44435. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  44436. * * 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
  44437. * * 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.
  44438. * * If `enclose` is false, a ring surface is one element.
  44439. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  44440. * * 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
  44441. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44442. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44444. * @param name defines the name of the mesh
  44445. * @param options defines the options used to create the mesh
  44446. * @param scene defines the hosting scene
  44447. * @returns the cylinder mesh
  44448. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  44449. */
  44450. static CreateCylinder(name: string, options: {
  44451. height?: number;
  44452. diameterTop?: number;
  44453. diameterBottom?: number;
  44454. diameter?: number;
  44455. tessellation?: number;
  44456. subdivisions?: number;
  44457. arc?: number;
  44458. faceColors?: Color4[];
  44459. faceUV?: Vector4[];
  44460. updatable?: boolean;
  44461. hasRings?: boolean;
  44462. enclose?: boolean;
  44463. cap?: number;
  44464. sideOrientation?: number;
  44465. frontUVs?: Vector4;
  44466. backUVs?: Vector4;
  44467. }, scene: any): Mesh;
  44468. }
  44469. }
  44470. declare module "babylonjs/XR/webXRTypes" {
  44471. import { Nullable } from "babylonjs/types";
  44472. import { IDisposable } from "babylonjs/scene";
  44473. /**
  44474. * States of the webXR experience
  44475. */
  44476. export enum WebXRState {
  44477. /**
  44478. * Transitioning to being in XR mode
  44479. */
  44480. ENTERING_XR = 0,
  44481. /**
  44482. * Transitioning to non XR mode
  44483. */
  44484. EXITING_XR = 1,
  44485. /**
  44486. * In XR mode and presenting
  44487. */
  44488. IN_XR = 2,
  44489. /**
  44490. * Not entered XR mode
  44491. */
  44492. NOT_IN_XR = 3
  44493. }
  44494. /**
  44495. * Abstraction of the XR render target
  44496. */
  44497. export interface WebXRRenderTarget extends IDisposable {
  44498. /**
  44499. * xrpresent context of the canvas which can be used to display/mirror xr content
  44500. */
  44501. canvasContext: WebGLRenderingContext;
  44502. /**
  44503. * xr layer for the canvas
  44504. */
  44505. xrLayer: Nullable<XRWebGLLayer>;
  44506. /**
  44507. * Initializes the xr layer for the session
  44508. * @param xrSession xr session
  44509. * @returns a promise that will resolve once the XR Layer has been created
  44510. */
  44511. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44512. }
  44513. }
  44514. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  44515. import { Nullable } from "babylonjs/types";
  44516. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44517. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44518. /**
  44519. * COnfiguration object for WebXR output canvas
  44520. */
  44521. export class WebXRManagedOutputCanvasOptions {
  44522. /**
  44523. * An optional canvas in case you wish to create it yourself and provide it here.
  44524. * If not provided, a new canvas will be created
  44525. */
  44526. canvasElement?: HTMLCanvasElement;
  44527. /**
  44528. * Options for this XR Layer output
  44529. */
  44530. canvasOptions?: XRWebGLLayerOptions;
  44531. /**
  44532. * CSS styling for a newly created canvas (if not provided)
  44533. */
  44534. newCanvasCssStyle?: string;
  44535. /**
  44536. * Get the default values of the configuration object
  44537. * @returns default values of this configuration object
  44538. */
  44539. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  44540. }
  44541. /**
  44542. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  44543. */
  44544. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  44545. private _options;
  44546. private _canvas;
  44547. private _engine;
  44548. /**
  44549. * Rendering context of the canvas which can be used to display/mirror xr content
  44550. */
  44551. canvasContext: WebGLRenderingContext;
  44552. /**
  44553. * xr layer for the canvas
  44554. */
  44555. xrLayer: Nullable<XRWebGLLayer>;
  44556. /**
  44557. * Initializes the canvas to be added/removed upon entering/exiting xr
  44558. * @param _xrSessionManager The XR Session manager
  44559. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  44560. */
  44561. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  44562. /**
  44563. * Disposes of the object
  44564. */
  44565. dispose(): void;
  44566. /**
  44567. * Initializes the xr layer for the session
  44568. * @param xrSession xr session
  44569. * @returns a promise that will resolve once the XR Layer has been created
  44570. */
  44571. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44572. private _addCanvas;
  44573. private _removeCanvas;
  44574. private _setManagedOutputCanvas;
  44575. }
  44576. }
  44577. declare module "babylonjs/XR/webXRSessionManager" {
  44578. import { Observable } from "babylonjs/Misc/observable";
  44579. import { Nullable } from "babylonjs/types";
  44580. import { IDisposable, Scene } from "babylonjs/scene";
  44581. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44582. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44583. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  44584. /**
  44585. * Manages an XRSession to work with Babylon's engine
  44586. * @see https://doc.babylonjs.com/how_to/webxr
  44587. */
  44588. export class WebXRSessionManager implements IDisposable {
  44589. /** The scene which the session should be created for */
  44590. scene: Scene;
  44591. private _referenceSpace;
  44592. private _rttProvider;
  44593. private _sessionEnded;
  44594. private _xrNavigator;
  44595. private baseLayer;
  44596. /**
  44597. * The base reference space from which the session started. good if you want to reset your
  44598. * reference space
  44599. */
  44600. baseReferenceSpace: XRReferenceSpace;
  44601. /**
  44602. * Current XR frame
  44603. */
  44604. currentFrame: Nullable<XRFrame>;
  44605. /** WebXR timestamp updated every frame */
  44606. currentTimestamp: number;
  44607. /**
  44608. * Used just in case of a failure to initialize an immersive session.
  44609. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44610. */
  44611. defaultHeightCompensation: number;
  44612. /**
  44613. * Fires every time a new xrFrame arrives which can be used to update the camera
  44614. */
  44615. onXRFrameObservable: Observable<XRFrame>;
  44616. /**
  44617. * Fires when the reference space changed
  44618. */
  44619. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44620. /**
  44621. * Fires when the xr session is ended either by the device or manually done
  44622. */
  44623. onXRSessionEnded: Observable<any>;
  44624. /**
  44625. * Fires when the xr session is ended either by the device or manually done
  44626. */
  44627. onXRSessionInit: Observable<XRSession>;
  44628. /**
  44629. * Underlying xr session
  44630. */
  44631. session: XRSession;
  44632. /**
  44633. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44634. * or get the offset the player is currently at.
  44635. */
  44636. viewerReferenceSpace: XRReferenceSpace;
  44637. /**
  44638. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44639. * @param scene The scene which the session should be created for
  44640. */
  44641. constructor(
  44642. /** The scene which the session should be created for */
  44643. scene: Scene);
  44644. /**
  44645. * The current reference space used in this session. This reference space can constantly change!
  44646. * It is mainly used to offset the camera's position.
  44647. */
  44648. get referenceSpace(): XRReferenceSpace;
  44649. /**
  44650. * Set a new reference space and triggers the observable
  44651. */
  44652. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44653. /**
  44654. * Disposes of the session manager
  44655. */
  44656. dispose(): void;
  44657. /**
  44658. * Stops the xrSession and restores the render loop
  44659. * @returns Promise which resolves after it exits XR
  44660. */
  44661. exitXRAsync(): Promise<void>;
  44662. /**
  44663. * Gets the correct render target texture to be rendered this frame for this eye
  44664. * @param eye the eye for which to get the render target
  44665. * @returns the render target for the specified eye
  44666. */
  44667. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44668. /**
  44669. * Creates a WebXRRenderTarget object for the XR session
  44670. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44671. * @param options optional options to provide when creating a new render target
  44672. * @returns a WebXR render target to which the session can render
  44673. */
  44674. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44675. /**
  44676. * Initializes the manager
  44677. * After initialization enterXR can be called to start an XR session
  44678. * @returns Promise which resolves after it is initialized
  44679. */
  44680. initializeAsync(): Promise<void>;
  44681. /**
  44682. * Initializes an xr session
  44683. * @param xrSessionMode mode to initialize
  44684. * @param xrSessionInit defines optional and required values to pass to the session builder
  44685. * @returns a promise which will resolve once the session has been initialized
  44686. */
  44687. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44688. /**
  44689. * Checks if a session would be supported for the creation options specified
  44690. * @param sessionMode session mode to check if supported eg. immersive-vr
  44691. * @returns A Promise that resolves to true if supported and false if not
  44692. */
  44693. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44694. /**
  44695. * Resets the reference space to the one started the session
  44696. */
  44697. resetReferenceSpace(): void;
  44698. /**
  44699. * Starts rendering to the xr layer
  44700. */
  44701. runXRRenderLoop(): void;
  44702. /**
  44703. * Sets the reference space on the xr session
  44704. * @param referenceSpaceType space to set
  44705. * @returns a promise that will resolve once the reference space has been set
  44706. */
  44707. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44708. /**
  44709. * Updates the render state of the session
  44710. * @param state state to set
  44711. * @returns a promise that resolves once the render state has been updated
  44712. */
  44713. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44714. /**
  44715. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44716. * @param sessionMode defines the session to test
  44717. * @returns a promise with boolean as final value
  44718. */
  44719. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44720. private _createRenderTargetTexture;
  44721. }
  44722. }
  44723. declare module "babylonjs/XR/webXRCamera" {
  44724. import { Scene } from "babylonjs/scene";
  44725. import { Camera } from "babylonjs/Cameras/camera";
  44726. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44727. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44728. /**
  44729. * WebXR Camera which holds the views for the xrSession
  44730. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44731. */
  44732. export class WebXRCamera extends FreeCamera {
  44733. private _xrSessionManager;
  44734. private _firstFrame;
  44735. private _referenceQuaternion;
  44736. private _referencedPosition;
  44737. private _xrInvPositionCache;
  44738. private _xrInvQuaternionCache;
  44739. /**
  44740. * Should position compensation execute on first frame.
  44741. * This is used when copying the position from a native (non XR) camera
  44742. */
  44743. compensateOnFirstFrame: boolean;
  44744. /**
  44745. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44746. * @param name the name of the camera
  44747. * @param scene the scene to add the camera to
  44748. * @param _xrSessionManager a constructed xr session manager
  44749. */
  44750. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44751. /**
  44752. * Return the user's height, unrelated to the current ground.
  44753. * This will be the y position of this camera, when ground level is 0.
  44754. */
  44755. get realWorldHeight(): number;
  44756. /** @hidden */
  44757. _updateForDualEyeDebugging(): void;
  44758. /**
  44759. * Sets this camera's transformation based on a non-vr camera
  44760. * @param otherCamera the non-vr camera to copy the transformation from
  44761. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44762. */
  44763. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44764. /**
  44765. * Gets the current instance class name ("WebXRCamera").
  44766. * @returns the class name
  44767. */
  44768. getClassName(): string;
  44769. private _updateFromXRSession;
  44770. private _updateNumberOfRigCameras;
  44771. private _updateReferenceSpace;
  44772. private _updateReferenceSpaceOffset;
  44773. }
  44774. }
  44775. declare module "babylonjs/XR/webXRFeaturesManager" {
  44776. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44777. import { IDisposable } from "babylonjs/scene";
  44778. /**
  44779. * Defining the interface required for a (webxr) feature
  44780. */
  44781. export interface IWebXRFeature extends IDisposable {
  44782. /**
  44783. * Is this feature attached
  44784. */
  44785. attached: boolean;
  44786. /**
  44787. * Should auto-attach be disabled?
  44788. */
  44789. disableAutoAttach: boolean;
  44790. /**
  44791. * Attach the feature to the session
  44792. * Will usually be called by the features manager
  44793. *
  44794. * @param force should attachment be forced (even when already attached)
  44795. * @returns true if successful.
  44796. */
  44797. attach(force?: boolean): boolean;
  44798. /**
  44799. * Detach the feature from the session
  44800. * Will usually be called by the features manager
  44801. *
  44802. * @returns true if successful.
  44803. */
  44804. detach(): boolean;
  44805. }
  44806. /**
  44807. * A list of the currently available features without referencing them
  44808. */
  44809. export class WebXRFeatureName {
  44810. /**
  44811. * The name of the anchor system feature
  44812. */
  44813. static ANCHOR_SYSTEM: string;
  44814. /**
  44815. * The name of the background remover feature
  44816. */
  44817. static BACKGROUND_REMOVER: string;
  44818. /**
  44819. * The name of the hit test feature
  44820. */
  44821. static HIT_TEST: string;
  44822. /**
  44823. * physics impostors for xr controllers feature
  44824. */
  44825. static PHYSICS_CONTROLLERS: string;
  44826. /**
  44827. * The name of the plane detection feature
  44828. */
  44829. static PLANE_DETECTION: string;
  44830. /**
  44831. * The name of the pointer selection feature
  44832. */
  44833. static POINTER_SELECTION: string;
  44834. /**
  44835. * The name of the teleportation feature
  44836. */
  44837. static TELEPORTATION: string;
  44838. }
  44839. /**
  44840. * Defining the constructor of a feature. Used to register the modules.
  44841. */
  44842. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44843. /**
  44844. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44845. * It is mainly used in AR sessions.
  44846. *
  44847. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44848. */
  44849. export class WebXRFeaturesManager implements IDisposable {
  44850. private _xrSessionManager;
  44851. private static readonly _AvailableFeatures;
  44852. private _features;
  44853. /**
  44854. * constructs a new features manages.
  44855. *
  44856. * @param _xrSessionManager an instance of WebXRSessionManager
  44857. */
  44858. constructor(_xrSessionManager: WebXRSessionManager);
  44859. /**
  44860. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44861. * Mainly used internally.
  44862. *
  44863. * @param featureName the name of the feature to register
  44864. * @param constructorFunction the function used to construct the module
  44865. * @param version the (babylon) version of the module
  44866. * @param stable is that a stable version of this module
  44867. */
  44868. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44869. /**
  44870. * Returns a constructor of a specific feature.
  44871. *
  44872. * @param featureName the name of the feature to construct
  44873. * @param version the version of the feature to load
  44874. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44875. * @param options optional options provided to the module.
  44876. * @returns a function that, when called, will return a new instance of this feature
  44877. */
  44878. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44879. /**
  44880. * Can be used to return the list of features currently registered
  44881. *
  44882. * @returns an Array of available features
  44883. */
  44884. static GetAvailableFeatures(): string[];
  44885. /**
  44886. * Gets the versions available for a specific feature
  44887. * @param featureName the name of the feature
  44888. * @returns an array with the available versions
  44889. */
  44890. static GetAvailableVersions(featureName: string): string[];
  44891. /**
  44892. * Return the latest unstable version of this feature
  44893. * @param featureName the name of the feature to search
  44894. * @returns the version number. if not found will return -1
  44895. */
  44896. static GetLatestVersionOfFeature(featureName: string): number;
  44897. /**
  44898. * Return the latest stable version of this feature
  44899. * @param featureName the name of the feature to search
  44900. * @returns the version number. if not found will return -1
  44901. */
  44902. static GetStableVersionOfFeature(featureName: string): number;
  44903. /**
  44904. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44905. * Can be used during a session to start a feature
  44906. * @param featureName the name of feature to attach
  44907. */
  44908. attachFeature(featureName: string): void;
  44909. /**
  44910. * Can be used inside a session or when the session ends to detach a specific feature
  44911. * @param featureName the name of the feature to detach
  44912. */
  44913. detachFeature(featureName: string): void;
  44914. /**
  44915. * Used to disable an already-enabled feature
  44916. * The feature will be disposed and will be recreated once enabled.
  44917. * @param featureName the feature to disable
  44918. * @returns true if disable was successful
  44919. */
  44920. disableFeature(featureName: string | {
  44921. Name: string;
  44922. }): boolean;
  44923. /**
  44924. * dispose this features manager
  44925. */
  44926. dispose(): void;
  44927. /**
  44928. * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.
  44929. * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.
  44930. *
  44931. * @param featureName the name of the feature to load or the class of the feature
  44932. * @param version optional version to load. if not provided the latest version will be enabled
  44933. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44934. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44935. * @returns a new constructed feature or throws an error if feature not found.
  44936. */
  44937. enableFeature(featureName: string | {
  44938. Name: string;
  44939. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44940. /**
  44941. * get the implementation of an enabled feature.
  44942. * @param featureName the name of the feature to load
  44943. * @returns the feature class, if found
  44944. */
  44945. getEnabledFeature(featureName: string): IWebXRFeature;
  44946. /**
  44947. * Get the list of enabled features
  44948. * @returns an array of enabled features
  44949. */
  44950. getEnabledFeatures(): string[];
  44951. }
  44952. }
  44953. declare module "babylonjs/XR/webXRExperienceHelper" {
  44954. import { Observable } from "babylonjs/Misc/observable";
  44955. import { IDisposable, Scene } from "babylonjs/scene";
  44956. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44957. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  44958. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44959. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  44960. /**
  44961. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  44962. * @see https://doc.babylonjs.com/how_to/webxr
  44963. */
  44964. export class WebXRExperienceHelper implements IDisposable {
  44965. private scene;
  44966. private _nonVRCamera;
  44967. private _originalSceneAutoClear;
  44968. private _supported;
  44969. /**
  44970. * Camera used to render xr content
  44971. */
  44972. camera: WebXRCamera;
  44973. /** A features manager for this xr session */
  44974. featuresManager: WebXRFeaturesManager;
  44975. /**
  44976. * Observers registered here will be triggered after the camera's initial transformation is set
  44977. * This can be used to set a different ground level or an extra rotation.
  44978. *
  44979. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44980. * to the position set after this observable is done executing.
  44981. */
  44982. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44983. /**
  44984. * Fires when the state of the experience helper has changed
  44985. */
  44986. onStateChangedObservable: Observable<WebXRState>;
  44987. /** Session manager used to keep track of xr session */
  44988. sessionManager: WebXRSessionManager;
  44989. /**
  44990. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44991. */
  44992. state: WebXRState;
  44993. /**
  44994. * Creates a WebXRExperienceHelper
  44995. * @param scene The scene the helper should be created in
  44996. */
  44997. private constructor();
  44998. /**
  44999. * Creates the experience helper
  45000. * @param scene the scene to attach the experience helper to
  45001. * @returns a promise for the experience helper
  45002. */
  45003. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  45004. /**
  45005. * Disposes of the experience helper
  45006. */
  45007. dispose(): void;
  45008. /**
  45009. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  45010. * @param sessionMode options for the XR session
  45011. * @param referenceSpaceType frame of reference of the XR session
  45012. * @param renderTarget the output canvas that will be used to enter XR mode
  45013. * @returns promise that resolves after xr mode has entered
  45014. */
  45015. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  45016. /**
  45017. * Exits XR mode and returns the scene to its original state
  45018. * @returns promise that resolves after xr mode has exited
  45019. */
  45020. exitXRAsync(): Promise<void>;
  45021. private _nonXRToXRCamera;
  45022. private _setState;
  45023. }
  45024. }
  45025. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  45026. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45027. import { Observable } from "babylonjs/Misc/observable";
  45028. import { IDisposable } from "babylonjs/scene";
  45029. /**
  45030. * X-Y values for axes in WebXR
  45031. */
  45032. export interface IWebXRMotionControllerAxesValue {
  45033. /**
  45034. * The value of the x axis
  45035. */
  45036. x: number;
  45037. /**
  45038. * The value of the y-axis
  45039. */
  45040. y: number;
  45041. }
  45042. /**
  45043. * changed / previous values for the values of this component
  45044. */
  45045. export interface IWebXRMotionControllerComponentChangesValues<T> {
  45046. /**
  45047. * current (this frame) value
  45048. */
  45049. current: T;
  45050. /**
  45051. * previous (last change) value
  45052. */
  45053. previous: T;
  45054. }
  45055. /**
  45056. * Represents changes in the component between current frame and last values recorded
  45057. */
  45058. export interface IWebXRMotionControllerComponentChanges {
  45059. /**
  45060. * will be populated with previous and current values if axes changed
  45061. */
  45062. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  45063. /**
  45064. * will be populated with previous and current values if pressed changed
  45065. */
  45066. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  45067. /**
  45068. * will be populated with previous and current values if touched changed
  45069. */
  45070. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  45071. /**
  45072. * will be populated with previous and current values if value changed
  45073. */
  45074. value?: IWebXRMotionControllerComponentChangesValues<number>;
  45075. }
  45076. /**
  45077. * This class represents a single component (for example button or thumbstick) of a motion controller
  45078. */
  45079. export class WebXRControllerComponent implements IDisposable {
  45080. /**
  45081. * the id of this component
  45082. */
  45083. id: string;
  45084. /**
  45085. * the type of the component
  45086. */
  45087. type: MotionControllerComponentType;
  45088. private _buttonIndex;
  45089. private _axesIndices;
  45090. private _axes;
  45091. private _changes;
  45092. private _currentValue;
  45093. private _hasChanges;
  45094. private _pressed;
  45095. private _touched;
  45096. /**
  45097. * button component type
  45098. */
  45099. static BUTTON_TYPE: MotionControllerComponentType;
  45100. /**
  45101. * squeeze component type
  45102. */
  45103. static SQUEEZE_TYPE: MotionControllerComponentType;
  45104. /**
  45105. * Thumbstick component type
  45106. */
  45107. static THUMBSTICK_TYPE: MotionControllerComponentType;
  45108. /**
  45109. * Touchpad component type
  45110. */
  45111. static TOUCHPAD_TYPE: MotionControllerComponentType;
  45112. /**
  45113. * trigger component type
  45114. */
  45115. static TRIGGER_TYPE: MotionControllerComponentType;
  45116. /**
  45117. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  45118. * the axes data changes
  45119. */
  45120. onAxisValueChangedObservable: Observable<{
  45121. x: number;
  45122. y: number;
  45123. }>;
  45124. /**
  45125. * Observers registered here will be triggered when the state of a button changes
  45126. * State change is either pressed / touched / value
  45127. */
  45128. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  45129. /**
  45130. * Creates a new component for a motion controller.
  45131. * It is created by the motion controller itself
  45132. *
  45133. * @param id the id of this component
  45134. * @param type the type of the component
  45135. * @param _buttonIndex index in the buttons array of the gamepad
  45136. * @param _axesIndices indices of the values in the axes array of the gamepad
  45137. */
  45138. constructor(
  45139. /**
  45140. * the id of this component
  45141. */
  45142. id: string,
  45143. /**
  45144. * the type of the component
  45145. */
  45146. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  45147. /**
  45148. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  45149. */
  45150. get axes(): IWebXRMotionControllerAxesValue;
  45151. /**
  45152. * Get the changes. Elements will be populated only if they changed with their previous and current value
  45153. */
  45154. get changes(): IWebXRMotionControllerComponentChanges;
  45155. /**
  45156. * Return whether or not the component changed the last frame
  45157. */
  45158. get hasChanges(): boolean;
  45159. /**
  45160. * is the button currently pressed
  45161. */
  45162. get pressed(): boolean;
  45163. /**
  45164. * is the button currently touched
  45165. */
  45166. get touched(): boolean;
  45167. /**
  45168. * Get the current value of this component
  45169. */
  45170. get value(): number;
  45171. /**
  45172. * Dispose this component
  45173. */
  45174. dispose(): void;
  45175. /**
  45176. * Are there axes correlating to this component
  45177. * @return true is axes data is available
  45178. */
  45179. isAxes(): boolean;
  45180. /**
  45181. * Is this component a button (hence - pressable)
  45182. * @returns true if can be pressed
  45183. */
  45184. isButton(): boolean;
  45185. /**
  45186. * update this component using the gamepad object it is in. Called on every frame
  45187. * @param nativeController the native gamepad controller object
  45188. */
  45189. update(nativeController: IMinimalMotionControllerObject): void;
  45190. }
  45191. }
  45192. declare module "babylonjs/Loading/sceneLoader" {
  45193. import { Observable } from "babylonjs/Misc/observable";
  45194. import { Nullable } from "babylonjs/types";
  45195. import { Scene } from "babylonjs/scene";
  45196. import { Engine } from "babylonjs/Engines/engine";
  45197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45198. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  45199. import { AssetContainer } from "babylonjs/assetContainer";
  45200. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  45201. import { Skeleton } from "babylonjs/Bones/skeleton";
  45202. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  45203. import { WebRequest } from "babylonjs/Misc/webRequest";
  45204. /**
  45205. * Class used to represent data loading progression
  45206. */
  45207. export class SceneLoaderProgressEvent {
  45208. /** defines if data length to load can be evaluated */
  45209. readonly lengthComputable: boolean;
  45210. /** defines the loaded data length */
  45211. readonly loaded: number;
  45212. /** defines the data length to load */
  45213. readonly total: number;
  45214. /**
  45215. * Create a new progress event
  45216. * @param lengthComputable defines if data length to load can be evaluated
  45217. * @param loaded defines the loaded data length
  45218. * @param total defines the data length to load
  45219. */
  45220. constructor(
  45221. /** defines if data length to load can be evaluated */
  45222. lengthComputable: boolean,
  45223. /** defines the loaded data length */
  45224. loaded: number,
  45225. /** defines the data length to load */
  45226. total: number);
  45227. /**
  45228. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  45229. * @param event defines the source event
  45230. * @returns a new SceneLoaderProgressEvent
  45231. */
  45232. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  45233. }
  45234. /**
  45235. * Interface used by SceneLoader plugins to define supported file extensions
  45236. */
  45237. export interface ISceneLoaderPluginExtensions {
  45238. /**
  45239. * Defines the list of supported extensions
  45240. */
  45241. [extension: string]: {
  45242. isBinary: boolean;
  45243. };
  45244. }
  45245. /**
  45246. * Interface used by SceneLoader plugin factory
  45247. */
  45248. export interface ISceneLoaderPluginFactory {
  45249. /**
  45250. * Defines the name of the factory
  45251. */
  45252. name: string;
  45253. /**
  45254. * Function called to create a new plugin
  45255. * @return the new plugin
  45256. */
  45257. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  45258. /**
  45259. * The callback that returns true if the data can be directly loaded.
  45260. * @param data string containing the file data
  45261. * @returns if the data can be loaded directly
  45262. */
  45263. canDirectLoad?(data: string): boolean;
  45264. }
  45265. /**
  45266. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  45267. */
  45268. export interface ISceneLoaderPluginBase {
  45269. /**
  45270. * The friendly name of this plugin.
  45271. */
  45272. name: string;
  45273. /**
  45274. * The file extensions supported by this plugin.
  45275. */
  45276. extensions: string | ISceneLoaderPluginExtensions;
  45277. /**
  45278. * The callback called when loading from a url.
  45279. * @param scene scene loading this url
  45280. * @param url url to load
  45281. * @param onSuccess callback called when the file successfully loads
  45282. * @param onProgress callback called while file is loading (if the server supports this mode)
  45283. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  45284. * @param onError callback called when the file fails to load
  45285. * @returns a file request object
  45286. */
  45287. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  45288. /**
  45289. * The callback called when loading from a file object.
  45290. * @param scene scene loading this file
  45291. * @param file defines the file to load
  45292. * @param onSuccess defines the callback to call when data is loaded
  45293. * @param onProgress defines the callback to call during loading process
  45294. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  45295. * @param onError defines the callback to call when an error occurs
  45296. * @returns a file request object
  45297. */
  45298. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  45299. /**
  45300. * The callback that returns true if the data can be directly loaded.
  45301. * @param data string containing the file data
  45302. * @returns if the data can be loaded directly
  45303. */
  45304. canDirectLoad?(data: string): boolean;
  45305. /**
  45306. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  45307. * @param scene scene loading this data
  45308. * @param data string containing the data
  45309. * @returns data to pass to the plugin
  45310. */
  45311. directLoad?(scene: Scene, data: string): any;
  45312. /**
  45313. * The callback that allows custom handling of the root url based on the response url.
  45314. * @param rootUrl the original root url
  45315. * @param responseURL the response url if available
  45316. * @returns the new root url
  45317. */
  45318. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  45319. }
  45320. /**
  45321. * Interface used to define a SceneLoader plugin
  45322. */
  45323. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  45324. /**
  45325. * Import meshes into a scene.
  45326. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45327. * @param scene The scene to import into
  45328. * @param data The data to import
  45329. * @param rootUrl The root url for scene and resources
  45330. * @param meshes The meshes array to import into
  45331. * @param particleSystems The particle systems array to import into
  45332. * @param skeletons The skeletons array to import into
  45333. * @param onError The callback when import fails
  45334. * @returns True if successful or false otherwise
  45335. */
  45336. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  45337. /**
  45338. * Load into a scene.
  45339. * @param scene The scene to load into
  45340. * @param data The data to import
  45341. * @param rootUrl The root url for scene and resources
  45342. * @param onError The callback when import fails
  45343. * @returns True if successful or false otherwise
  45344. */
  45345. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  45346. /**
  45347. * Load into an asset container.
  45348. * @param scene The scene to load into
  45349. * @param data The data to import
  45350. * @param rootUrl The root url for scene and resources
  45351. * @param onError The callback when import fails
  45352. * @returns The loaded asset container
  45353. */
  45354. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  45355. }
  45356. /**
  45357. * Interface used to define an async SceneLoader plugin
  45358. */
  45359. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  45360. /**
  45361. * Import meshes into a scene.
  45362. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45363. * @param scene The scene to import into
  45364. * @param data The data to import
  45365. * @param rootUrl The root url for scene and resources
  45366. * @param onProgress The callback when the load progresses
  45367. * @param fileName Defines the name of the file to load
  45368. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  45369. */
  45370. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  45371. meshes: AbstractMesh[];
  45372. particleSystems: IParticleSystem[];
  45373. skeletons: Skeleton[];
  45374. animationGroups: AnimationGroup[];
  45375. }>;
  45376. /**
  45377. * Load into a scene.
  45378. * @param scene The scene to load into
  45379. * @param data The data to import
  45380. * @param rootUrl The root url for scene and resources
  45381. * @param onProgress The callback when the load progresses
  45382. * @param fileName Defines the name of the file to load
  45383. * @returns Nothing
  45384. */
  45385. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  45386. /**
  45387. * Load into an asset container.
  45388. * @param scene The scene to load into
  45389. * @param data The data to import
  45390. * @param rootUrl The root url for scene and resources
  45391. * @param onProgress The callback when the load progresses
  45392. * @param fileName Defines the name of the file to load
  45393. * @returns The loaded asset container
  45394. */
  45395. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  45396. }
  45397. /**
  45398. * Mode that determines how to handle old animation groups before loading new ones.
  45399. */
  45400. export enum SceneLoaderAnimationGroupLoadingMode {
  45401. /**
  45402. * Reset all old animations to initial state then dispose them.
  45403. */
  45404. Clean = 0,
  45405. /**
  45406. * Stop all old animations.
  45407. */
  45408. Stop = 1,
  45409. /**
  45410. * Restart old animations from first frame.
  45411. */
  45412. Sync = 2,
  45413. /**
  45414. * Old animations remains untouched.
  45415. */
  45416. NoSync = 3
  45417. }
  45418. /**
  45419. * Class used to load scene from various file formats using registered plugins
  45420. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  45421. */
  45422. export class SceneLoader {
  45423. /**
  45424. * No logging while loading
  45425. */
  45426. static readonly NO_LOGGING: number;
  45427. /**
  45428. * Minimal logging while loading
  45429. */
  45430. static readonly MINIMAL_LOGGING: number;
  45431. /**
  45432. * Summary logging while loading
  45433. */
  45434. static readonly SUMMARY_LOGGING: number;
  45435. /**
  45436. * Detailled logging while loading
  45437. */
  45438. static readonly DETAILED_LOGGING: number;
  45439. /**
  45440. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  45441. */
  45442. static get ForceFullSceneLoadingForIncremental(): boolean;
  45443. static set ForceFullSceneLoadingForIncremental(value: boolean);
  45444. /**
  45445. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  45446. */
  45447. static get ShowLoadingScreen(): boolean;
  45448. static set ShowLoadingScreen(value: boolean);
  45449. /**
  45450. * Defines the current logging level (while loading the scene)
  45451. * @ignorenaming
  45452. */
  45453. static get loggingLevel(): number;
  45454. static set loggingLevel(value: number);
  45455. /**
  45456. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  45457. */
  45458. static get CleanBoneMatrixWeights(): boolean;
  45459. static set CleanBoneMatrixWeights(value: boolean);
  45460. /**
  45461. * Event raised when a plugin is used to load a scene
  45462. */
  45463. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  45464. private static _registeredPlugins;
  45465. private static _getDefaultPlugin;
  45466. private static _getPluginForExtension;
  45467. private static _getPluginForDirectLoad;
  45468. private static _getPluginForFilename;
  45469. private static _getDirectLoad;
  45470. private static _loadData;
  45471. private static _getFileInfo;
  45472. /**
  45473. * Gets a plugin that can load the given extension
  45474. * @param extension defines the extension to load
  45475. * @returns a plugin or null if none works
  45476. */
  45477. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  45478. /**
  45479. * Gets a boolean indicating that the given extension can be loaded
  45480. * @param extension defines the extension to load
  45481. * @returns true if the extension is supported
  45482. */
  45483. static IsPluginForExtensionAvailable(extension: string): boolean;
  45484. /**
  45485. * Adds a new plugin to the list of registered plugins
  45486. * @param plugin defines the plugin to add
  45487. */
  45488. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  45489. /**
  45490. * Import meshes into a scene
  45491. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45492. * @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)
  45493. * @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)
  45494. * @param scene the instance of BABYLON.Scene to append to
  45495. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  45496. * @param onProgress a callback with a progress event for each file being loaded
  45497. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45498. * @param pluginExtension the extension used to determine the plugin
  45499. * @returns The loaded plugin
  45500. */
  45501. 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>;
  45502. /**
  45503. * Import meshes into a scene
  45504. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45505. * @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)
  45506. * @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)
  45507. * @param scene the instance of BABYLON.Scene to append to
  45508. * @param onProgress a callback with a progress event for each file being loaded
  45509. * @param pluginExtension the extension used to determine the plugin
  45510. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  45511. */
  45512. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  45513. meshes: AbstractMesh[];
  45514. particleSystems: IParticleSystem[];
  45515. skeletons: Skeleton[];
  45516. animationGroups: AnimationGroup[];
  45517. }>;
  45518. /**
  45519. * Load a scene
  45520. * @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)
  45521. * @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)
  45522. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45523. * @param onSuccess a callback with the scene when import succeeds
  45524. * @param onProgress a callback with a progress event for each file being loaded
  45525. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45526. * @param pluginExtension the extension used to determine the plugin
  45527. * @returns The loaded plugin
  45528. */
  45529. 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>;
  45530. /**
  45531. * Load a scene
  45532. * @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)
  45533. * @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)
  45534. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45535. * @param onProgress a callback with a progress event for each file being loaded
  45536. * @param pluginExtension the extension used to determine the plugin
  45537. * @returns The loaded scene
  45538. */
  45539. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45540. /**
  45541. * Append a scene
  45542. * @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)
  45543. * @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)
  45544. * @param scene is the instance of BABYLON.Scene to append to
  45545. * @param onSuccess a callback with the scene when import succeeds
  45546. * @param onProgress a callback with a progress event for each file being loaded
  45547. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45548. * @param pluginExtension the extension used to determine the plugin
  45549. * @returns The loaded plugin
  45550. */
  45551. 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>;
  45552. /**
  45553. * Append a scene
  45554. * @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)
  45555. * @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)
  45556. * @param scene is the instance of BABYLON.Scene to append to
  45557. * @param onProgress a callback with a progress event for each file being loaded
  45558. * @param pluginExtension the extension used to determine the plugin
  45559. * @returns The given scene
  45560. */
  45561. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45562. /**
  45563. * Load a scene into an asset container
  45564. * @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)
  45565. * @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)
  45566. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45567. * @param onSuccess a callback with the scene when import succeeds
  45568. * @param onProgress a callback with a progress event for each file being loaded
  45569. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45570. * @param pluginExtension the extension used to determine the plugin
  45571. * @returns The loaded plugin
  45572. */
  45573. 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>;
  45574. /**
  45575. * Load a scene into an asset container
  45576. * @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)
  45577. * @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)
  45578. * @param scene is the instance of Scene to append to
  45579. * @param onProgress a callback with a progress event for each file being loaded
  45580. * @param pluginExtension the extension used to determine the plugin
  45581. * @returns The loaded asset container
  45582. */
  45583. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  45584. /**
  45585. * Import animations from a file into a scene
  45586. * @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)
  45587. * @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)
  45588. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45589. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45590. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45591. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45592. * @param onSuccess a callback with the scene when import succeeds
  45593. * @param onProgress a callback with a progress event for each file being loaded
  45594. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45595. */
  45596. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  45597. /**
  45598. * Import animations from a file into a scene
  45599. * @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)
  45600. * @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)
  45601. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45602. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45603. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45604. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45605. * @param onSuccess a callback with the scene when import succeeds
  45606. * @param onProgress a callback with a progress event for each file being loaded
  45607. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45608. * @returns the updated scene with imported animations
  45609. */
  45610. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  45611. }
  45612. }
  45613. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45614. import { IDisposable, Scene } from "babylonjs/scene";
  45615. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45616. import { Observable } from "babylonjs/Misc/observable";
  45617. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45618. import { Nullable } from "babylonjs/types";
  45619. /**
  45620. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45621. */
  45622. export type MotionControllerHandness = "none" | "left" | "right";
  45623. /**
  45624. * The type of components available in motion controllers.
  45625. * This is not the name of the component.
  45626. */
  45627. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45628. /**
  45629. * The state of a controller component
  45630. */
  45631. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45632. /**
  45633. * The schema of motion controller layout.
  45634. * No object will be initialized using this interface
  45635. * This is used just to define the profile.
  45636. */
  45637. export interface IMotionControllerLayout {
  45638. /**
  45639. * Path to load the assets. Usually relative to the base path
  45640. */
  45641. assetPath: string;
  45642. /**
  45643. * Available components (unsorted)
  45644. */
  45645. components: {
  45646. /**
  45647. * A map of component Ids
  45648. */
  45649. [componentId: string]: {
  45650. /**
  45651. * The type of input the component outputs
  45652. */
  45653. type: MotionControllerComponentType;
  45654. /**
  45655. * The indices of this component in the gamepad object
  45656. */
  45657. gamepadIndices: {
  45658. /**
  45659. * Index of button
  45660. */
  45661. button?: number;
  45662. /**
  45663. * If available, index of x-axis
  45664. */
  45665. xAxis?: number;
  45666. /**
  45667. * If available, index of y-axis
  45668. */
  45669. yAxis?: number;
  45670. };
  45671. /**
  45672. * The mesh's root node name
  45673. */
  45674. rootNodeName: string;
  45675. /**
  45676. * Animation definitions for this model
  45677. */
  45678. visualResponses: {
  45679. [stateKey: string]: {
  45680. /**
  45681. * What property will be animated
  45682. */
  45683. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45684. /**
  45685. * What states influence this visual response
  45686. */
  45687. states: MotionControllerComponentStateType[];
  45688. /**
  45689. * Type of animation - movement or visibility
  45690. */
  45691. valueNodeProperty: "transform" | "visibility";
  45692. /**
  45693. * Base node name to move. Its position will be calculated according to the min and max nodes
  45694. */
  45695. valueNodeName?: string;
  45696. /**
  45697. * Minimum movement node
  45698. */
  45699. minNodeName?: string;
  45700. /**
  45701. * Max movement node
  45702. */
  45703. maxNodeName?: string;
  45704. };
  45705. };
  45706. /**
  45707. * If touch enabled, what is the name of node to display user feedback
  45708. */
  45709. touchPointNodeName?: string;
  45710. };
  45711. };
  45712. /**
  45713. * Is it xr standard mapping or not
  45714. */
  45715. gamepadMapping: "" | "xr-standard";
  45716. /**
  45717. * Base root node of this entire model
  45718. */
  45719. rootNodeName: string;
  45720. /**
  45721. * Defines the main button component id
  45722. */
  45723. selectComponentId: string;
  45724. }
  45725. /**
  45726. * A definition for the layout map in the input profile
  45727. */
  45728. export interface IMotionControllerLayoutMap {
  45729. /**
  45730. * Layouts with handness type as a key
  45731. */
  45732. [handness: string]: IMotionControllerLayout;
  45733. }
  45734. /**
  45735. * The XR Input profile schema
  45736. * Profiles can be found here:
  45737. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45738. */
  45739. export interface IMotionControllerProfile {
  45740. /**
  45741. * fallback profiles for this profileId
  45742. */
  45743. fallbackProfileIds: string[];
  45744. /**
  45745. * The layout map, with handness as key
  45746. */
  45747. layouts: IMotionControllerLayoutMap;
  45748. /**
  45749. * The id of this profile
  45750. * correlates to the profile(s) in the xrInput.profiles array
  45751. */
  45752. profileId: string;
  45753. }
  45754. /**
  45755. * A helper-interface for the 3 meshes needed for controller button animation
  45756. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45757. */
  45758. export interface IMotionControllerButtonMeshMap {
  45759. /**
  45760. * the mesh that defines the pressed value mesh position.
  45761. * This is used to find the max-position of this button
  45762. */
  45763. pressedMesh: AbstractMesh;
  45764. /**
  45765. * the mesh that defines the unpressed value mesh position.
  45766. * This is used to find the min (or initial) position of this button
  45767. */
  45768. unpressedMesh: AbstractMesh;
  45769. /**
  45770. * The mesh that will be changed when value changes
  45771. */
  45772. valueMesh: AbstractMesh;
  45773. }
  45774. /**
  45775. * A helper-interface for the 3 meshes needed for controller axis animation.
  45776. * This will be expanded when touchpad animations are fully supported
  45777. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45778. */
  45779. export interface IMotionControllerMeshMap {
  45780. /**
  45781. * the mesh that defines the maximum value mesh position.
  45782. */
  45783. maxMesh?: AbstractMesh;
  45784. /**
  45785. * the mesh that defines the minimum value mesh position.
  45786. */
  45787. minMesh?: AbstractMesh;
  45788. /**
  45789. * The mesh that will be changed when axis value changes
  45790. */
  45791. valueMesh: AbstractMesh;
  45792. }
  45793. /**
  45794. * The elements needed for change-detection of the gamepad objects in motion controllers
  45795. */
  45796. export interface IMinimalMotionControllerObject {
  45797. /**
  45798. * Available axes of this controller
  45799. */
  45800. axes: number[];
  45801. /**
  45802. * An array of available buttons
  45803. */
  45804. buttons: Array<{
  45805. /**
  45806. * Value of the button/trigger
  45807. */
  45808. value: number;
  45809. /**
  45810. * If the button/trigger is currently touched
  45811. */
  45812. touched: boolean;
  45813. /**
  45814. * If the button/trigger is currently pressed
  45815. */
  45816. pressed: boolean;
  45817. }>;
  45818. }
  45819. /**
  45820. * An Abstract Motion controller
  45821. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45822. * Each component has an observable to check for changes in value and state
  45823. */
  45824. export abstract class WebXRAbstractMotionController implements IDisposable {
  45825. protected scene: Scene;
  45826. protected layout: IMotionControllerLayout;
  45827. /**
  45828. * The gamepad object correlating to this controller
  45829. */
  45830. gamepadObject: IMinimalMotionControllerObject;
  45831. /**
  45832. * handness (left/right/none) of this controller
  45833. */
  45834. handness: MotionControllerHandness;
  45835. private _initComponent;
  45836. private _modelReady;
  45837. /**
  45838. * A map of components (WebXRControllerComponent) in this motion controller
  45839. * Components have a ComponentType and can also have both button and axis definitions
  45840. */
  45841. readonly components: {
  45842. [id: string]: WebXRControllerComponent;
  45843. };
  45844. /**
  45845. * Disable the model's animation. Can be set at any time.
  45846. */
  45847. disableAnimation: boolean;
  45848. /**
  45849. * Observers registered here will be triggered when the model of this controller is done loading
  45850. */
  45851. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45852. /**
  45853. * The profile id of this motion controller
  45854. */
  45855. abstract profileId: string;
  45856. /**
  45857. * The root mesh of the model. It is null if the model was not yet initialized
  45858. */
  45859. rootMesh: Nullable<AbstractMesh>;
  45860. /**
  45861. * constructs a new abstract motion controller
  45862. * @param scene the scene to which the model of the controller will be added
  45863. * @param layout The profile layout to load
  45864. * @param gamepadObject The gamepad object correlating to this controller
  45865. * @param handness handness (left/right/none) of this controller
  45866. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45867. */
  45868. constructor(scene: Scene, layout: IMotionControllerLayout,
  45869. /**
  45870. * The gamepad object correlating to this controller
  45871. */
  45872. gamepadObject: IMinimalMotionControllerObject,
  45873. /**
  45874. * handness (left/right/none) of this controller
  45875. */
  45876. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  45877. /**
  45878. * Dispose this controller, the model mesh and all its components
  45879. */
  45880. dispose(): void;
  45881. /**
  45882. * Returns all components of specific type
  45883. * @param type the type to search for
  45884. * @return an array of components with this type
  45885. */
  45886. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  45887. /**
  45888. * get a component based an its component id as defined in layout.components
  45889. * @param id the id of the component
  45890. * @returns the component correlates to the id or undefined if not found
  45891. */
  45892. getComponent(id: string): WebXRControllerComponent;
  45893. /**
  45894. * Get the list of components available in this motion controller
  45895. * @returns an array of strings correlating to available components
  45896. */
  45897. getComponentIds(): string[];
  45898. /**
  45899. * Get the first component of specific type
  45900. * @param type type of component to find
  45901. * @return a controller component or null if not found
  45902. */
  45903. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  45904. /**
  45905. * Get the main (Select) component of this controller as defined in the layout
  45906. * @returns the main component of this controller
  45907. */
  45908. getMainComponent(): WebXRControllerComponent;
  45909. /**
  45910. * Loads the model correlating to this controller
  45911. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45912. * @returns A promise fulfilled with the result of the model loading
  45913. */
  45914. loadModel(): Promise<boolean>;
  45915. /**
  45916. * Update this model using the current XRFrame
  45917. * @param xrFrame the current xr frame to use and update the model
  45918. */
  45919. updateFromXRFrame(xrFrame: XRFrame): void;
  45920. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45921. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45922. /**
  45923. * Moves the axis on the controller mesh based on its current state
  45924. * @param axis the index of the axis
  45925. * @param axisValue the value of the axis which determines the meshes new position
  45926. * @hidden
  45927. */
  45928. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  45929. /**
  45930. * Update the model itself with the current frame data
  45931. * @param xrFrame the frame to use for updating the model mesh
  45932. */
  45933. protected updateModel(xrFrame: XRFrame): void;
  45934. /**
  45935. * Get the filename and path for this controller's model
  45936. * @returns a map of filename and path
  45937. */
  45938. protected abstract _getFilenameAndPath(): {
  45939. filename: string;
  45940. path: string;
  45941. };
  45942. /**
  45943. * This function is called before the mesh is loaded. It checks for loading constraints.
  45944. * For example, this function can check if the GLB loader is available
  45945. * If this function returns false, the generic controller will be loaded instead
  45946. * @returns Is the client ready to load the mesh
  45947. */
  45948. protected abstract _getModelLoadingConstraints(): boolean;
  45949. /**
  45950. * This function will be called after the model was successfully loaded and can be used
  45951. * for mesh transformations before it is available for the user
  45952. * @param meshes the loaded meshes
  45953. */
  45954. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45955. /**
  45956. * Set the root mesh for this controller. Important for the WebXR controller class
  45957. * @param meshes the loaded meshes
  45958. */
  45959. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45960. /**
  45961. * A function executed each frame that updates the mesh (if needed)
  45962. * @param xrFrame the current xrFrame
  45963. */
  45964. protected abstract _updateModel(xrFrame: XRFrame): void;
  45965. private _getGenericFilenameAndPath;
  45966. private _getGenericParentMesh;
  45967. }
  45968. }
  45969. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  45970. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45971. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45972. import { Scene } from "babylonjs/scene";
  45973. /**
  45974. * A generic trigger-only motion controller for WebXR
  45975. */
  45976. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45977. /**
  45978. * Static version of the profile id of this controller
  45979. */
  45980. static ProfileId: string;
  45981. profileId: string;
  45982. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45983. protected _getFilenameAndPath(): {
  45984. filename: string;
  45985. path: string;
  45986. };
  45987. protected _getModelLoadingConstraints(): boolean;
  45988. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45989. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45990. protected _updateModel(): void;
  45991. }
  45992. }
  45993. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45994. import { Vector4 } from "babylonjs/Maths/math.vector";
  45995. import { Mesh } from "babylonjs/Meshes/mesh";
  45996. import { Scene } from "babylonjs/scene";
  45997. import { Nullable } from "babylonjs/types";
  45998. /**
  45999. * Class containing static functions to help procedurally build meshes
  46000. */
  46001. export class SphereBuilder {
  46002. /**
  46003. * Creates a sphere mesh
  46004. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  46005. * * 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`)
  46006. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  46007. * * 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
  46008. * * 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)
  46009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46010. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46012. * @param name defines the name of the mesh
  46013. * @param options defines the options used to create the mesh
  46014. * @param scene defines the hosting scene
  46015. * @returns the sphere mesh
  46016. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  46017. */
  46018. static CreateSphere(name: string, options: {
  46019. segments?: number;
  46020. diameter?: number;
  46021. diameterX?: number;
  46022. diameterY?: number;
  46023. diameterZ?: number;
  46024. arc?: number;
  46025. slice?: number;
  46026. sideOrientation?: number;
  46027. frontUVs?: Vector4;
  46028. backUVs?: Vector4;
  46029. updatable?: boolean;
  46030. }, scene?: Nullable<Scene>): Mesh;
  46031. }
  46032. }
  46033. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  46034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46035. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46036. import { Scene } from "babylonjs/scene";
  46037. /**
  46038. * A profiled motion controller has its profile loaded from an online repository.
  46039. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  46040. */
  46041. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  46042. private _repositoryUrl;
  46043. private _buttonMeshMapping;
  46044. private _touchDots;
  46045. /**
  46046. * The profile ID of this controller. Will be populated when the controller initializes.
  46047. */
  46048. profileId: string;
  46049. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  46050. dispose(): void;
  46051. protected _getFilenameAndPath(): {
  46052. filename: string;
  46053. path: string;
  46054. };
  46055. protected _getModelLoadingConstraints(): boolean;
  46056. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  46057. protected _setRootMesh(meshes: AbstractMesh[]): void;
  46058. protected _updateModel(_xrFrame: XRFrame): void;
  46059. }
  46060. }
  46061. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  46062. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46063. import { Scene } from "babylonjs/scene";
  46064. /**
  46065. * A construction function type to create a new controller based on an xrInput object
  46066. */
  46067. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  46068. /**
  46069. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  46070. *
  46071. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  46072. * it should be replaced with auto-loaded controllers.
  46073. *
  46074. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  46075. */
  46076. export class WebXRMotionControllerManager {
  46077. private static _AvailableControllers;
  46078. private static _Fallbacks;
  46079. private static _ProfileLoadingPromises;
  46080. private static _ProfilesList;
  46081. /**
  46082. * The base URL of the online controller repository. Can be changed at any time.
  46083. */
  46084. static BaseRepositoryUrl: string;
  46085. /**
  46086. * Which repository gets priority - local or online
  46087. */
  46088. static PrioritizeOnlineRepository: boolean;
  46089. /**
  46090. * Use the online repository, or use only locally-defined controllers
  46091. */
  46092. static UseOnlineRepository: boolean;
  46093. /**
  46094. * Clear the cache used for profile loading and reload when requested again
  46095. */
  46096. static ClearProfilesCache(): void;
  46097. /**
  46098. * Register the default fallbacks.
  46099. * This function is called automatically when this file is imported.
  46100. */
  46101. static DefaultFallbacks(): void;
  46102. /**
  46103. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  46104. * @param profileId the profile to which a fallback needs to be found
  46105. * @return an array with corresponding fallback profiles
  46106. */
  46107. static FindFallbackWithProfileId(profileId: string): string[];
  46108. /**
  46109. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  46110. * The order of search:
  46111. *
  46112. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  46113. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  46114. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  46115. * 4) return the generic trigger controller if none were found
  46116. *
  46117. * @param xrInput the xrInput to which a new controller is initialized
  46118. * @param scene the scene to which the model will be added
  46119. * @param forceProfile force a certain profile for this controller
  46120. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  46121. */
  46122. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  46123. /**
  46124. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  46125. *
  46126. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  46127. *
  46128. * @param type the profile type to register
  46129. * @param constructFunction the function to be called when loading this profile
  46130. */
  46131. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  46132. /**
  46133. * Register a fallback to a specific profile.
  46134. * @param profileId the profileId that will receive the fallbacks
  46135. * @param fallbacks A list of fallback profiles
  46136. */
  46137. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  46138. /**
  46139. * Will update the list of profiles available in the repository
  46140. * @return a promise that resolves to a map of profiles available online
  46141. */
  46142. static UpdateProfilesList(): Promise<{
  46143. [profile: string]: string;
  46144. }>;
  46145. private static _LoadProfileFromRepository;
  46146. private static _LoadProfilesFromAvailableControllers;
  46147. }
  46148. }
  46149. declare module "babylonjs/XR/webXRInputSource" {
  46150. import { Observable } from "babylonjs/Misc/observable";
  46151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46152. import { Ray } from "babylonjs/Culling/ray";
  46153. import { Scene } from "babylonjs/scene";
  46154. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46155. /**
  46156. * Configuration options for the WebXR controller creation
  46157. */
  46158. export interface IWebXRControllerOptions {
  46159. /**
  46160. * Should the controller mesh be animated when a user interacts with it
  46161. * The pressed buttons / thumbstick and touchpad animations will be disabled
  46162. */
  46163. disableMotionControllerAnimation?: boolean;
  46164. /**
  46165. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  46166. */
  46167. doNotLoadControllerMesh?: boolean;
  46168. /**
  46169. * Force a specific controller type for this controller.
  46170. * This can be used when creating your own profile or when testing different controllers
  46171. */
  46172. forceControllerProfile?: string;
  46173. }
  46174. /**
  46175. * Represents an XR controller
  46176. */
  46177. export class WebXRInputSource {
  46178. private _scene;
  46179. /** The underlying input source for the controller */
  46180. inputSource: XRInputSource;
  46181. private _options;
  46182. private _tmpQuaternion;
  46183. private _tmpVector;
  46184. private _uniqueId;
  46185. /**
  46186. * 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
  46187. */
  46188. grip?: AbstractMesh;
  46189. /**
  46190. * If available, this is the gamepad object related to this controller.
  46191. * Using this object it is possible to get click events and trackpad changes of the
  46192. * webxr controller that is currently being used.
  46193. */
  46194. motionController?: WebXRAbstractMotionController;
  46195. /**
  46196. * Event that fires when the controller is removed/disposed.
  46197. * The object provided as event data is this controller, after associated assets were disposed.
  46198. * uniqueId is still available.
  46199. */
  46200. onDisposeObservable: Observable<WebXRInputSource>;
  46201. /**
  46202. * Will be triggered when the mesh associated with the motion controller is done loading.
  46203. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  46204. * A shortened version of controller -> motion controller -> on mesh loaded.
  46205. */
  46206. onMeshLoadedObservable: Observable<AbstractMesh>;
  46207. /**
  46208. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  46209. */
  46210. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  46211. /**
  46212. * Pointer which can be used to select objects or attach a visible laser to
  46213. */
  46214. pointer: AbstractMesh;
  46215. /**
  46216. * Creates the controller
  46217. * @see https://doc.babylonjs.com/how_to/webxr
  46218. * @param _scene the scene which the controller should be associated to
  46219. * @param inputSource the underlying input source for the controller
  46220. * @param _options options for this controller creation
  46221. */
  46222. constructor(_scene: Scene,
  46223. /** The underlying input source for the controller */
  46224. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  46225. /**
  46226. * Get this controllers unique id
  46227. */
  46228. get uniqueId(): string;
  46229. /**
  46230. * Disposes of the object
  46231. */
  46232. dispose(): void;
  46233. /**
  46234. * Gets a world space ray coming from the pointer or grip
  46235. * @param result the resulting ray
  46236. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  46237. */
  46238. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  46239. /**
  46240. * Updates the controller pose based on the given XRFrame
  46241. * @param xrFrame xr frame to update the pose with
  46242. * @param referenceSpace reference space to use
  46243. */
  46244. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  46245. }
  46246. }
  46247. declare module "babylonjs/XR/webXRInput" {
  46248. import { Observable } from "babylonjs/Misc/observable";
  46249. import { IDisposable } from "babylonjs/scene";
  46250. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  46251. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46252. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  46253. /**
  46254. * The schema for initialization options of the XR Input class
  46255. */
  46256. export interface IWebXRInputOptions {
  46257. /**
  46258. * If set to true no model will be automatically loaded
  46259. */
  46260. doNotLoadControllerMeshes?: boolean;
  46261. /**
  46262. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  46263. * If not found, the xr input profile data will be used.
  46264. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  46265. */
  46266. forceInputProfile?: string;
  46267. /**
  46268. * Do not send a request to the controller repository to load the profile.
  46269. *
  46270. * Instead, use the controllers available in babylon itself.
  46271. */
  46272. disableOnlineControllerRepository?: boolean;
  46273. /**
  46274. * A custom URL for the controllers repository
  46275. */
  46276. customControllersRepositoryURL?: string;
  46277. /**
  46278. * Should the controller model's components not move according to the user input
  46279. */
  46280. disableControllerAnimation?: boolean;
  46281. }
  46282. /**
  46283. * XR input used to track XR inputs such as controllers/rays
  46284. */
  46285. export class WebXRInput implements IDisposable {
  46286. /**
  46287. * the xr session manager for this session
  46288. */
  46289. xrSessionManager: WebXRSessionManager;
  46290. /**
  46291. * the WebXR camera for this session. Mainly used for teleportation
  46292. */
  46293. xrCamera: WebXRCamera;
  46294. private readonly options;
  46295. /**
  46296. * XR controllers being tracked
  46297. */
  46298. controllers: Array<WebXRInputSource>;
  46299. private _frameObserver;
  46300. private _sessionEndedObserver;
  46301. private _sessionInitObserver;
  46302. /**
  46303. * Event when a controller has been connected/added
  46304. */
  46305. onControllerAddedObservable: Observable<WebXRInputSource>;
  46306. /**
  46307. * Event when a controller has been removed/disconnected
  46308. */
  46309. onControllerRemovedObservable: Observable<WebXRInputSource>;
  46310. /**
  46311. * Initializes the WebXRInput
  46312. * @param xrSessionManager the xr session manager for this session
  46313. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  46314. * @param options = initialization options for this xr input
  46315. */
  46316. constructor(
  46317. /**
  46318. * the xr session manager for this session
  46319. */
  46320. xrSessionManager: WebXRSessionManager,
  46321. /**
  46322. * the WebXR camera for this session. Mainly used for teleportation
  46323. */
  46324. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  46325. private _onInputSourcesChange;
  46326. private _addAndRemoveControllers;
  46327. /**
  46328. * Disposes of the object
  46329. */
  46330. dispose(): void;
  46331. }
  46332. }
  46333. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  46334. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46335. import { Observable, EventState } from "babylonjs/Misc/observable";
  46336. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46337. /**
  46338. * This is the base class for all WebXR features.
  46339. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  46340. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  46341. */
  46342. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  46343. protected _xrSessionManager: WebXRSessionManager;
  46344. private _attached;
  46345. private _removeOnDetach;
  46346. /**
  46347. * Should auto-attach be disabled?
  46348. */
  46349. disableAutoAttach: boolean;
  46350. /**
  46351. * Construct a new (abstract) WebXR feature
  46352. * @param _xrSessionManager the xr session manager for this feature
  46353. */
  46354. constructor(_xrSessionManager: WebXRSessionManager);
  46355. /**
  46356. * Is this feature attached
  46357. */
  46358. get attached(): boolean;
  46359. /**
  46360. * attach this feature
  46361. *
  46362. * @param force should attachment be forced (even when already attached)
  46363. * @returns true if successful, false is failed or already attached
  46364. */
  46365. attach(force?: boolean): boolean;
  46366. /**
  46367. * detach this feature.
  46368. *
  46369. * @returns true if successful, false if failed or already detached
  46370. */
  46371. detach(): boolean;
  46372. /**
  46373. * Dispose this feature and all of the resources attached
  46374. */
  46375. dispose(): void;
  46376. /**
  46377. * This is used to register callbacks that will automatically be removed when detach is called.
  46378. * @param observable the observable to which the observer will be attached
  46379. * @param callback the callback to register
  46380. */
  46381. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  46382. /**
  46383. * Code in this function will be executed on each xrFrame received from the browser.
  46384. * This function will not execute after the feature is detached.
  46385. * @param _xrFrame the current frame
  46386. */
  46387. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  46388. }
  46389. }
  46390. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  46391. import { IDisposable, Scene } from "babylonjs/scene";
  46392. import { Nullable } from "babylonjs/types";
  46393. import { Observable } from "babylonjs/Misc/observable";
  46394. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46395. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  46396. import { Camera } from "babylonjs/Cameras/camera";
  46397. /**
  46398. * Renders a layer on top of an existing scene
  46399. */
  46400. export class UtilityLayerRenderer implements IDisposable {
  46401. /** the original scene that will be rendered on top of */
  46402. originalScene: Scene;
  46403. private _pointerCaptures;
  46404. private _lastPointerEvents;
  46405. private static _DefaultUtilityLayer;
  46406. private static _DefaultKeepDepthUtilityLayer;
  46407. private _sharedGizmoLight;
  46408. private _renderCamera;
  46409. /**
  46410. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  46411. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  46412. * @returns the camera that is used when rendering the utility layer
  46413. */
  46414. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  46415. /**
  46416. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  46417. * @param cam the camera that should be used when rendering the utility layer
  46418. */
  46419. setRenderCamera(cam: Nullable<Camera>): void;
  46420. /**
  46421. * @hidden
  46422. * Light which used by gizmos to get light shading
  46423. */
  46424. _getSharedGizmoLight(): HemisphericLight;
  46425. /**
  46426. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  46427. */
  46428. pickUtilitySceneFirst: boolean;
  46429. /**
  46430. * 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)
  46431. */
  46432. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  46433. /**
  46434. * 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)
  46435. */
  46436. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  46437. /**
  46438. * The scene that is rendered on top of the original scene
  46439. */
  46440. utilityLayerScene: Scene;
  46441. /**
  46442. * If the utility layer should automatically be rendered on top of existing scene
  46443. */
  46444. shouldRender: boolean;
  46445. /**
  46446. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  46447. */
  46448. onlyCheckPointerDownEvents: boolean;
  46449. /**
  46450. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  46451. */
  46452. processAllEvents: boolean;
  46453. /**
  46454. * Observable raised when the pointer move from the utility layer scene to the main scene
  46455. */
  46456. onPointerOutObservable: Observable<number>;
  46457. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  46458. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  46459. private _afterRenderObserver;
  46460. private _sceneDisposeObserver;
  46461. private _originalPointerObserver;
  46462. /**
  46463. * Instantiates a UtilityLayerRenderer
  46464. * @param originalScene the original scene that will be rendered on top of
  46465. * @param handleEvents boolean indicating if the utility layer should handle events
  46466. */
  46467. constructor(
  46468. /** the original scene that will be rendered on top of */
  46469. originalScene: Scene, handleEvents?: boolean);
  46470. private _notifyObservers;
  46471. /**
  46472. * Renders the utility layers scene on top of the original scene
  46473. */
  46474. render(): void;
  46475. /**
  46476. * Disposes of the renderer
  46477. */
  46478. dispose(): void;
  46479. private _updateCamera;
  46480. }
  46481. }
  46482. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  46483. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46484. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46485. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46486. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  46487. import { Scene } from "babylonjs/scene";
  46488. import { Nullable } from "babylonjs/types";
  46489. import { Color3 } from "babylonjs/Maths/math.color";
  46490. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46491. /**
  46492. * Options interface for the pointer selection module
  46493. */
  46494. export interface IWebXRControllerPointerSelectionOptions {
  46495. /**
  46496. * if provided, this scene will be used to render meshes.
  46497. */
  46498. customUtilityLayerScene?: Scene;
  46499. /**
  46500. * Disable the pointer up event when the xr controller in screen and gaze mode is disposed (meaning - when the user removed the finger from the screen)
  46501. * If not disabled, the last picked point will be used to execute a pointer up event
  46502. * If disabled, pointer up event will be triggered right after the pointer down event.
  46503. * Used in screen and gaze target ray mode only
  46504. */
  46505. disablePointerUpOnTouchOut: boolean;
  46506. /**
  46507. * For gaze mode (time to select instead of press)
  46508. */
  46509. forceGazeMode: boolean;
  46510. /**
  46511. * Factor to be applied to the pointer-moved function in the gaze mode. How sensitive should the gaze mode be when checking if the pointer moved
  46512. * to start a new countdown to the pointer down event.
  46513. * Defaults to 1.
  46514. */
  46515. gazeModePointerMovedFactor?: number;
  46516. /**
  46517. * Different button type to use instead of the main component
  46518. */
  46519. overrideButtonId?: string;
  46520. /**
  46521. * use this rendering group id for the meshes (optional)
  46522. */
  46523. renderingGroupId?: number;
  46524. /**
  46525. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  46526. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  46527. * 3000 means 3 seconds between pointing at something and selecting it
  46528. */
  46529. timeToSelect?: number;
  46530. /**
  46531. * Should meshes created here be added to a utility layer or the main scene
  46532. */
  46533. useUtilityLayer?: boolean;
  46534. /**
  46535. * the xr input to use with this pointer selection
  46536. */
  46537. xrInput: WebXRInput;
  46538. }
  46539. /**
  46540. * A module that will enable pointer selection for motion controllers of XR Input Sources
  46541. */
  46542. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  46543. private readonly _options;
  46544. private static _idCounter;
  46545. private _attachController;
  46546. private _controllers;
  46547. private _scene;
  46548. private _tmpVectorForPickCompare;
  46549. /**
  46550. * The module's name
  46551. */
  46552. static readonly Name: string;
  46553. /**
  46554. * The (Babylon) version of this module.
  46555. * This is an integer representing the implementation version.
  46556. * This number does not correspond to the WebXR specs version
  46557. */
  46558. static readonly Version: number;
  46559. /**
  46560. * Disable lighting on the laser pointer (so it will always be visible)
  46561. */
  46562. disablePointerLighting: boolean;
  46563. /**
  46564. * Disable lighting on the selection mesh (so it will always be visible)
  46565. */
  46566. disableSelectionMeshLighting: boolean;
  46567. /**
  46568. * Should the laser pointer be displayed
  46569. */
  46570. displayLaserPointer: boolean;
  46571. /**
  46572. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  46573. */
  46574. displaySelectionMesh: boolean;
  46575. /**
  46576. * This color will be set to the laser pointer when selection is triggered
  46577. */
  46578. laserPointerPickedColor: Color3;
  46579. /**
  46580. * Default color of the laser pointer
  46581. */
  46582. lasterPointerDefaultColor: Color3;
  46583. /**
  46584. * default color of the selection ring
  46585. */
  46586. selectionMeshDefaultColor: Color3;
  46587. /**
  46588. * This color will be applied to the selection ring when selection is triggered
  46589. */
  46590. selectionMeshPickedColor: Color3;
  46591. /**
  46592. * Optional filter to be used for ray selection. This predicate shares behavior with
  46593. * scene.pointerMovePredicate which takes priority if it is also assigned.
  46594. */
  46595. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46596. /**
  46597. * constructs a new background remover module
  46598. * @param _xrSessionManager the session manager for this module
  46599. * @param _options read-only options to be used in this module
  46600. */
  46601. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  46602. /**
  46603. * attach this feature
  46604. * Will usually be called by the features manager
  46605. *
  46606. * @returns true if successful.
  46607. */
  46608. attach(): boolean;
  46609. /**
  46610. * detach this feature.
  46611. * Will usually be called by the features manager
  46612. *
  46613. * @returns true if successful.
  46614. */
  46615. detach(): boolean;
  46616. /**
  46617. * Will get the mesh under a specific pointer.
  46618. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  46619. * @param controllerId the controllerId to check
  46620. * @returns The mesh under pointer or null if no mesh is under the pointer
  46621. */
  46622. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  46623. /**
  46624. * Get the xr controller that correlates to the pointer id in the pointer event
  46625. *
  46626. * @param id the pointer id to search for
  46627. * @returns the controller that correlates to this id or null if not found
  46628. */
  46629. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  46630. protected _onXRFrame(_xrFrame: XRFrame): void;
  46631. private _attachGazeMode;
  46632. private _attachScreenRayMode;
  46633. private _attachTrackedPointerRayMode;
  46634. private _convertNormalToDirectionOfRay;
  46635. private _detachController;
  46636. private _generateNewMeshPair;
  46637. private _pickingMoved;
  46638. private _updatePointerDistance;
  46639. }
  46640. }
  46641. declare module "babylonjs/XR/webXREnterExitUI" {
  46642. import { Nullable } from "babylonjs/types";
  46643. import { Observable } from "babylonjs/Misc/observable";
  46644. import { IDisposable, Scene } from "babylonjs/scene";
  46645. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46646. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46647. /**
  46648. * Button which can be used to enter a different mode of XR
  46649. */
  46650. export class WebXREnterExitUIButton {
  46651. /** button element */
  46652. element: HTMLElement;
  46653. /** XR initialization options for the button */
  46654. sessionMode: XRSessionMode;
  46655. /** Reference space type */
  46656. referenceSpaceType: XRReferenceSpaceType;
  46657. /**
  46658. * Creates a WebXREnterExitUIButton
  46659. * @param element button element
  46660. * @param sessionMode XR initialization session mode
  46661. * @param referenceSpaceType the type of reference space to be used
  46662. */
  46663. constructor(
  46664. /** button element */
  46665. element: HTMLElement,
  46666. /** XR initialization options for the button */
  46667. sessionMode: XRSessionMode,
  46668. /** Reference space type */
  46669. referenceSpaceType: XRReferenceSpaceType);
  46670. /**
  46671. * Extendable function which can be used to update the button's visuals when the state changes
  46672. * @param activeButton the current active button in the UI
  46673. */
  46674. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  46675. }
  46676. /**
  46677. * Options to create the webXR UI
  46678. */
  46679. export class WebXREnterExitUIOptions {
  46680. /**
  46681. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  46682. */
  46683. customButtons?: Array<WebXREnterExitUIButton>;
  46684. /**
  46685. * A reference space type to use when creating the default button.
  46686. * Default is local-floor
  46687. */
  46688. referenceSpaceType?: XRReferenceSpaceType;
  46689. /**
  46690. * Context to enter xr with
  46691. */
  46692. renderTarget?: Nullable<WebXRRenderTarget>;
  46693. /**
  46694. * A session mode to use when creating the default button.
  46695. * Default is immersive-vr
  46696. */
  46697. sessionMode?: XRSessionMode;
  46698. }
  46699. /**
  46700. * UI to allow the user to enter/exit XR mode
  46701. */
  46702. export class WebXREnterExitUI implements IDisposable {
  46703. private scene;
  46704. /** version of the options passed to this UI */
  46705. options: WebXREnterExitUIOptions;
  46706. private _activeButton;
  46707. private _buttons;
  46708. private _overlay;
  46709. /**
  46710. * Fired every time the active button is changed.
  46711. *
  46712. * When xr is entered via a button that launches xr that button will be the callback parameter
  46713. *
  46714. * When exiting xr the callback parameter will be null)
  46715. */
  46716. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46717. /**
  46718. *
  46719. * @param scene babylon scene object to use
  46720. * @param options (read-only) version of the options passed to this UI
  46721. */
  46722. private constructor();
  46723. /**
  46724. * Creates UI to allow the user to enter/exit XR mode
  46725. * @param scene the scene to add the ui to
  46726. * @param helper the xr experience helper to enter/exit xr with
  46727. * @param options options to configure the UI
  46728. * @returns the created ui
  46729. */
  46730. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46731. /**
  46732. * Disposes of the XR UI component
  46733. */
  46734. dispose(): void;
  46735. private _updateButtons;
  46736. }
  46737. }
  46738. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46739. import { Vector3 } from "babylonjs/Maths/math.vector";
  46740. import { Color4 } from "babylonjs/Maths/math.color";
  46741. import { Nullable } from "babylonjs/types";
  46742. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46743. import { Scene } from "babylonjs/scene";
  46744. /**
  46745. * Class containing static functions to help procedurally build meshes
  46746. */
  46747. export class LinesBuilder {
  46748. /**
  46749. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46750. * * 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
  46751. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46752. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46753. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46754. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46755. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46756. * * 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
  46757. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46759. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46760. * @param name defines the name of the new line system
  46761. * @param options defines the options used to create the line system
  46762. * @param scene defines the hosting scene
  46763. * @returns a new line system mesh
  46764. */
  46765. static CreateLineSystem(name: string, options: {
  46766. lines: Vector3[][];
  46767. updatable?: boolean;
  46768. instance?: Nullable<LinesMesh>;
  46769. colors?: Nullable<Color4[][]>;
  46770. useVertexAlpha?: boolean;
  46771. }, scene: Nullable<Scene>): LinesMesh;
  46772. /**
  46773. * Creates a line mesh
  46774. * 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
  46775. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46776. * * The parameter `points` is an array successive Vector3
  46777. * * 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
  46778. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46779. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46780. * * When updating an instance, remember that only point positions can change, not the number of points
  46781. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46782. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46783. * @param name defines the name of the new line system
  46784. * @param options defines the options used to create the line system
  46785. * @param scene defines the hosting scene
  46786. * @returns a new line mesh
  46787. */
  46788. static CreateLines(name: string, options: {
  46789. points: Vector3[];
  46790. updatable?: boolean;
  46791. instance?: Nullable<LinesMesh>;
  46792. colors?: Color4[];
  46793. useVertexAlpha?: boolean;
  46794. }, scene?: Nullable<Scene>): LinesMesh;
  46795. /**
  46796. * Creates a dashed line mesh
  46797. * * 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
  46798. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46799. * * The parameter `points` is an array successive Vector3
  46800. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46801. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46802. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46803. * * 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
  46804. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46805. * * When updating an instance, remember that only point positions can change, not the number of points
  46806. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46807. * @param name defines the name of the mesh
  46808. * @param options defines the options used to create the mesh
  46809. * @param scene defines the hosting scene
  46810. * @returns the dashed line mesh
  46811. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46812. */
  46813. static CreateDashedLines(name: string, options: {
  46814. points: Vector3[];
  46815. dashSize?: number;
  46816. gapSize?: number;
  46817. dashNb?: number;
  46818. updatable?: boolean;
  46819. instance?: LinesMesh;
  46820. useVertexAlpha?: boolean;
  46821. }, scene?: Nullable<Scene>): LinesMesh;
  46822. }
  46823. }
  46824. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46825. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46826. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46827. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46828. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46829. import { Vector3 } from "babylonjs/Maths/math.vector";
  46830. import { Material } from "babylonjs/Materials/material";
  46831. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46832. import { Scene } from "babylonjs/scene";
  46833. /**
  46834. * The options container for the teleportation module
  46835. */
  46836. export interface IWebXRTeleportationOptions {
  46837. /**
  46838. * if provided, this scene will be used to render meshes.
  46839. */
  46840. customUtilityLayerScene?: Scene;
  46841. /**
  46842. * Values to configure the default target mesh
  46843. */
  46844. defaultTargetMeshOptions?: {
  46845. /**
  46846. * Fill color of the teleportation area
  46847. */
  46848. teleportationFillColor?: string;
  46849. /**
  46850. * Border color for the teleportation area
  46851. */
  46852. teleportationBorderColor?: string;
  46853. /**
  46854. * Disable the mesh's animation sequence
  46855. */
  46856. disableAnimation?: boolean;
  46857. /**
  46858. * Disable lighting on the material or the ring and arrow
  46859. */
  46860. disableLighting?: boolean;
  46861. /**
  46862. * Override the default material of the torus and arrow
  46863. */
  46864. torusArrowMaterial?: Material;
  46865. };
  46866. /**
  46867. * A list of meshes to use as floor meshes.
  46868. * Meshes can be added and removed after initializing the feature using the
  46869. * addFloorMesh and removeFloorMesh functions
  46870. * If empty, rotation will still work
  46871. */
  46872. floorMeshes?: AbstractMesh[];
  46873. /**
  46874. * use this rendering group id for the meshes (optional)
  46875. */
  46876. renderingGroupId?: number;
  46877. /**
  46878. * Should teleportation move only to snap points
  46879. */
  46880. snapPointsOnly?: boolean;
  46881. /**
  46882. * An array of points to which the teleportation will snap to.
  46883. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  46884. */
  46885. snapPositions?: Vector3[];
  46886. /**
  46887. * How close should the teleportation ray be in order to snap to position.
  46888. * Default to 0.8 units (meters)
  46889. */
  46890. snapToPositionRadius?: number;
  46891. /**
  46892. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  46893. * If you want to support rotation, make sure your mesh has a direction indicator.
  46894. *
  46895. * When left untouched, the default mesh will be initialized.
  46896. */
  46897. teleportationTargetMesh?: AbstractMesh;
  46898. /**
  46899. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  46900. */
  46901. timeToTeleport?: number;
  46902. /**
  46903. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  46904. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  46905. */
  46906. useMainComponentOnly?: boolean;
  46907. /**
  46908. * Should meshes created here be added to a utility layer or the main scene
  46909. */
  46910. useUtilityLayer?: boolean;
  46911. /**
  46912. * Babylon XR Input class for controller
  46913. */
  46914. xrInput: WebXRInput;
  46915. }
  46916. /**
  46917. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  46918. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  46919. * the input of the attached controllers.
  46920. */
  46921. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  46922. private _options;
  46923. private _controllers;
  46924. private _currentTeleportationControllerId;
  46925. private _floorMeshes;
  46926. private _quadraticBezierCurve;
  46927. private _selectionFeature;
  46928. private _snapToPositions;
  46929. private _snappedToPoint;
  46930. private _teleportationRingMaterial?;
  46931. private _tmpRay;
  46932. private _tmpVector;
  46933. /**
  46934. * The module's name
  46935. */
  46936. static readonly Name: string;
  46937. /**
  46938. * The (Babylon) version of this module.
  46939. * This is an integer representing the implementation version.
  46940. * This number does not correspond to the webxr specs version
  46941. */
  46942. static readonly Version: number;
  46943. /**
  46944. * Is movement backwards enabled
  46945. */
  46946. backwardsMovementEnabled: boolean;
  46947. /**
  46948. * Distance to travel when moving backwards
  46949. */
  46950. backwardsTeleportationDistance: number;
  46951. /**
  46952. * The distance from the user to the inspection point in the direction of the controller
  46953. * A higher number will allow the user to move further
  46954. * defaults to 5 (meters, in xr units)
  46955. */
  46956. parabolicCheckRadius: number;
  46957. /**
  46958. * Should the module support parabolic ray on top of direct ray
  46959. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  46960. * Very helpful when moving between floors / different heights
  46961. */
  46962. parabolicRayEnabled: boolean;
  46963. /**
  46964. * How much rotation should be applied when rotating right and left
  46965. */
  46966. rotationAngle: number;
  46967. /**
  46968. * Is rotation enabled when moving forward?
  46969. * Disabling this feature will prevent the user from deciding the direction when teleporting
  46970. */
  46971. rotationEnabled: boolean;
  46972. /**
  46973. * constructs a new anchor system
  46974. * @param _xrSessionManager an instance of WebXRSessionManager
  46975. * @param _options configuration object for this feature
  46976. */
  46977. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  46978. /**
  46979. * Get the snapPointsOnly flag
  46980. */
  46981. get snapPointsOnly(): boolean;
  46982. /**
  46983. * Sets the snapPointsOnly flag
  46984. * @param snapToPoints should teleportation be exclusively to snap points
  46985. */
  46986. set snapPointsOnly(snapToPoints: boolean);
  46987. /**
  46988. * Add a new mesh to the floor meshes array
  46989. * @param mesh the mesh to use as floor mesh
  46990. */
  46991. addFloorMesh(mesh: AbstractMesh): void;
  46992. /**
  46993. * Add a new snap-to point to fix teleportation to this position
  46994. * @param newSnapPoint The new Snap-To point
  46995. */
  46996. addSnapPoint(newSnapPoint: Vector3): void;
  46997. attach(): boolean;
  46998. detach(): boolean;
  46999. dispose(): void;
  47000. /**
  47001. * Remove a mesh from the floor meshes array
  47002. * @param mesh the mesh to remove
  47003. */
  47004. removeFloorMesh(mesh: AbstractMesh): void;
  47005. /**
  47006. * Remove a mesh from the floor meshes array using its name
  47007. * @param name the mesh name to remove
  47008. */
  47009. removeFloorMeshByName(name: string): void;
  47010. /**
  47011. * This function will iterate through the array, searching for this point or equal to it. It will then remove it from the snap-to array
  47012. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  47013. * @returns was the point found and removed or not
  47014. */
  47015. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  47016. /**
  47017. * This function sets a selection feature that will be disabled when
  47018. * the forward ray is shown and will be reattached when hidden.
  47019. * This is used to remove the selection rays when moving.
  47020. * @param selectionFeature the feature to disable when forward movement is enabled
  47021. */
  47022. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  47023. protected _onXRFrame(_xrFrame: XRFrame): void;
  47024. private _attachController;
  47025. private _createDefaultTargetMesh;
  47026. private _detachController;
  47027. private _findClosestSnapPointWithRadius;
  47028. private _setTargetMeshPosition;
  47029. private _setTargetMeshVisibility;
  47030. private _showParabolicPath;
  47031. private _teleportForward;
  47032. }
  47033. }
  47034. declare module "babylonjs/XR/webXRDefaultExperience" {
  47035. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  47036. import { Scene } from "babylonjs/scene";
  47037. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  47038. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  47039. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47040. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  47041. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47042. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  47043. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  47044. /**
  47045. * Options for the default xr helper
  47046. */
  47047. export class WebXRDefaultExperienceOptions {
  47048. /**
  47049. * Enable or disable default UI to enter XR
  47050. */
  47051. disableDefaultUI?: boolean;
  47052. /**
  47053. * Should teleportation not initialize. defaults to false.
  47054. */
  47055. disableTeleportation?: boolean;
  47056. /**
  47057. * Floor meshes that will be used for teleport
  47058. */
  47059. floorMeshes?: Array<AbstractMesh>;
  47060. /**
  47061. * If set to true, the first frame will not be used to reset position
  47062. * The first frame is mainly used when copying transformation from the old camera
  47063. * Mainly used in AR
  47064. */
  47065. ignoreNativeCameraTransformation?: boolean;
  47066. /**
  47067. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  47068. */
  47069. inputOptions?: IWebXRInputOptions;
  47070. /**
  47071. * optional configuration for the output canvas
  47072. */
  47073. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  47074. /**
  47075. * optional UI options. This can be used among other to change session mode and reference space type
  47076. */
  47077. uiOptions?: WebXREnterExitUIOptions;
  47078. /**
  47079. * When loading teleportation and pointer select, use stable versions instead of latest.
  47080. */
  47081. useStablePlugins?: boolean;
  47082. }
  47083. /**
  47084. * Default experience which provides a similar setup to the previous webVRExperience
  47085. */
  47086. export class WebXRDefaultExperience {
  47087. /**
  47088. * Base experience
  47089. */
  47090. baseExperience: WebXRExperienceHelper;
  47091. /**
  47092. * Enables ui for entering/exiting xr
  47093. */
  47094. enterExitUI: WebXREnterExitUI;
  47095. /**
  47096. * Input experience extension
  47097. */
  47098. input: WebXRInput;
  47099. /**
  47100. * Enables laser pointer and selection
  47101. */
  47102. pointerSelection: WebXRControllerPointerSelection;
  47103. /**
  47104. * Default target xr should render to
  47105. */
  47106. renderTarget: WebXRRenderTarget;
  47107. /**
  47108. * Enables teleportation
  47109. */
  47110. teleportation: WebXRMotionControllerTeleportation;
  47111. private constructor();
  47112. /**
  47113. * Creates the default xr experience
  47114. * @param scene scene
  47115. * @param options options for basic configuration
  47116. * @returns resulting WebXRDefaultExperience
  47117. */
  47118. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47119. /**
  47120. * DIsposes of the experience helper
  47121. */
  47122. dispose(): void;
  47123. }
  47124. }
  47125. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  47126. import { Observable } from "babylonjs/Misc/observable";
  47127. import { Nullable } from "babylonjs/types";
  47128. import { Camera } from "babylonjs/Cameras/camera";
  47129. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  47130. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47131. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  47132. import { Scene } from "babylonjs/scene";
  47133. import { Vector3 } from "babylonjs/Maths/math.vector";
  47134. import { Color3 } from "babylonjs/Maths/math.color";
  47135. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47136. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47137. import { Mesh } from "babylonjs/Meshes/mesh";
  47138. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  47139. import { EasingFunction } from "babylonjs/Animations/easing";
  47140. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47141. import "babylonjs/Meshes/Builders/groundBuilder";
  47142. import "babylonjs/Meshes/Builders/torusBuilder";
  47143. import "babylonjs/Meshes/Builders/cylinderBuilder";
  47144. import "babylonjs/Gamepads/gamepadSceneComponent";
  47145. import "babylonjs/Animations/animatable";
  47146. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  47147. /**
  47148. * Options to modify the vr teleportation behavior.
  47149. */
  47150. export interface VRTeleportationOptions {
  47151. /**
  47152. * The name of the mesh which should be used as the teleportation floor. (default: null)
  47153. */
  47154. floorMeshName?: string;
  47155. /**
  47156. * A list of meshes to be used as the teleportation floor. (default: empty)
  47157. */
  47158. floorMeshes?: Mesh[];
  47159. /**
  47160. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  47161. */
  47162. teleportationMode?: number;
  47163. /**
  47164. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  47165. */
  47166. teleportationTime?: number;
  47167. /**
  47168. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  47169. */
  47170. teleportationSpeed?: number;
  47171. /**
  47172. * The easing function used in the animation or null for Linear. (default CircleEase)
  47173. */
  47174. easingFunction?: EasingFunction;
  47175. }
  47176. /**
  47177. * Options to modify the vr experience helper's behavior.
  47178. */
  47179. export interface VRExperienceHelperOptions extends WebVROptions {
  47180. /**
  47181. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  47182. */
  47183. createDeviceOrientationCamera?: boolean;
  47184. /**
  47185. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  47186. */
  47187. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  47188. /**
  47189. * Uses the main button on the controller to toggle the laser casted. (default: true)
  47190. */
  47191. laserToggle?: boolean;
  47192. /**
  47193. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  47194. */
  47195. floorMeshes?: Mesh[];
  47196. /**
  47197. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  47198. */
  47199. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  47200. /**
  47201. * Defines if WebXR should be used instead of WebVR (if available)
  47202. */
  47203. useXR?: boolean;
  47204. }
  47205. /**
  47206. * Event containing information after VR has been entered
  47207. */
  47208. export class OnAfterEnteringVRObservableEvent {
  47209. /**
  47210. * If entering vr was successful
  47211. */
  47212. success: boolean;
  47213. }
  47214. /**
  47215. * Helps to quickly add VR support to an existing scene.
  47216. * See http://doc.babylonjs.com/how_to/webvr_helper
  47217. */
  47218. export class VRExperienceHelper {
  47219. /** Options to modify the vr experience helper's behavior. */
  47220. webVROptions: VRExperienceHelperOptions;
  47221. private _scene;
  47222. private _position;
  47223. private _btnVR;
  47224. private _btnVRDisplayed;
  47225. private _webVRsupported;
  47226. private _webVRready;
  47227. private _webVRrequesting;
  47228. private _webVRpresenting;
  47229. private _hasEnteredVR;
  47230. private _fullscreenVRpresenting;
  47231. private _inputElement;
  47232. private _webVRCamera;
  47233. private _vrDeviceOrientationCamera;
  47234. private _deviceOrientationCamera;
  47235. private _existingCamera;
  47236. private _onKeyDown;
  47237. private _onVrDisplayPresentChange;
  47238. private _onVRDisplayChanged;
  47239. private _onVRRequestPresentStart;
  47240. private _onVRRequestPresentComplete;
  47241. /**
  47242. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  47243. */
  47244. enableGazeEvenWhenNoPointerLock: boolean;
  47245. /**
  47246. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  47247. */
  47248. exitVROnDoubleTap: boolean;
  47249. /**
  47250. * Observable raised right before entering VR.
  47251. */
  47252. onEnteringVRObservable: Observable<VRExperienceHelper>;
  47253. /**
  47254. * Observable raised when entering VR has completed.
  47255. */
  47256. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  47257. /**
  47258. * Observable raised when exiting VR.
  47259. */
  47260. onExitingVRObservable: Observable<VRExperienceHelper>;
  47261. /**
  47262. * Observable raised when controller mesh is loaded.
  47263. */
  47264. onControllerMeshLoadedObservable: Observable<WebVRController>;
  47265. /** Return this.onEnteringVRObservable
  47266. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  47267. */
  47268. get onEnteringVR(): Observable<VRExperienceHelper>;
  47269. /** Return this.onExitingVRObservable
  47270. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  47271. */
  47272. get onExitingVR(): Observable<VRExperienceHelper>;
  47273. /** Return this.onControllerMeshLoadedObservable
  47274. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  47275. */
  47276. get onControllerMeshLoaded(): Observable<WebVRController>;
  47277. private _rayLength;
  47278. private _useCustomVRButton;
  47279. private _teleportationRequested;
  47280. private _teleportActive;
  47281. private _floorMeshName;
  47282. private _floorMeshesCollection;
  47283. private _teleportationMode;
  47284. private _teleportationTime;
  47285. private _teleportationSpeed;
  47286. private _teleportationEasing;
  47287. private _rotationAllowed;
  47288. private _teleportBackwardsVector;
  47289. private _teleportationTarget;
  47290. private _isDefaultTeleportationTarget;
  47291. private _postProcessMove;
  47292. private _teleportationFillColor;
  47293. private _teleportationBorderColor;
  47294. private _rotationAngle;
  47295. private _haloCenter;
  47296. private _cameraGazer;
  47297. private _padSensibilityUp;
  47298. private _padSensibilityDown;
  47299. private _leftController;
  47300. private _rightController;
  47301. private _gazeColor;
  47302. private _laserColor;
  47303. private _pickedLaserColor;
  47304. private _pickedGazeColor;
  47305. /**
  47306. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  47307. */
  47308. onNewMeshSelected: Observable<AbstractMesh>;
  47309. /**
  47310. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  47311. * This observable will provide the mesh and the controller used to select the mesh
  47312. */
  47313. onMeshSelectedWithController: Observable<{
  47314. mesh: AbstractMesh;
  47315. controller: WebVRController;
  47316. }>;
  47317. /**
  47318. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  47319. */
  47320. onNewMeshPicked: Observable<PickingInfo>;
  47321. private _circleEase;
  47322. /**
  47323. * Observable raised before camera teleportation
  47324. */
  47325. onBeforeCameraTeleport: Observable<Vector3>;
  47326. /**
  47327. * Observable raised after camera teleportation
  47328. */
  47329. onAfterCameraTeleport: Observable<Vector3>;
  47330. /**
  47331. * Observable raised when current selected mesh gets unselected
  47332. */
  47333. onSelectedMeshUnselected: Observable<AbstractMesh>;
  47334. private _raySelectionPredicate;
  47335. /**
  47336. * To be optionaly changed by user to define custom ray selection
  47337. */
  47338. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47339. /**
  47340. * To be optionaly changed by user to define custom selection logic (after ray selection)
  47341. */
  47342. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47343. /**
  47344. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  47345. */
  47346. teleportationEnabled: boolean;
  47347. private _defaultHeight;
  47348. private _teleportationInitialized;
  47349. private _interactionsEnabled;
  47350. private _interactionsRequested;
  47351. private _displayGaze;
  47352. private _displayLaserPointer;
  47353. /**
  47354. * The mesh used to display where the user is going to teleport.
  47355. */
  47356. get teleportationTarget(): Mesh;
  47357. /**
  47358. * Sets the mesh to be used to display where the user is going to teleport.
  47359. */
  47360. set teleportationTarget(value: Mesh);
  47361. /**
  47362. * 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
  47363. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  47364. * See http://doc.babylonjs.com/resources/baking_transformations
  47365. */
  47366. get gazeTrackerMesh(): Mesh;
  47367. set gazeTrackerMesh(value: Mesh);
  47368. /**
  47369. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  47370. */
  47371. updateGazeTrackerScale: boolean;
  47372. /**
  47373. * If the gaze trackers color should be updated when selecting meshes
  47374. */
  47375. updateGazeTrackerColor: boolean;
  47376. /**
  47377. * If the controller laser color should be updated when selecting meshes
  47378. */
  47379. updateControllerLaserColor: boolean;
  47380. /**
  47381. * The gaze tracking mesh corresponding to the left controller
  47382. */
  47383. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  47384. /**
  47385. * The gaze tracking mesh corresponding to the right controller
  47386. */
  47387. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  47388. /**
  47389. * If the ray of the gaze should be displayed.
  47390. */
  47391. get displayGaze(): boolean;
  47392. /**
  47393. * Sets if the ray of the gaze should be displayed.
  47394. */
  47395. set displayGaze(value: boolean);
  47396. /**
  47397. * If the ray of the LaserPointer should be displayed.
  47398. */
  47399. get displayLaserPointer(): boolean;
  47400. /**
  47401. * Sets if the ray of the LaserPointer should be displayed.
  47402. */
  47403. set displayLaserPointer(value: boolean);
  47404. /**
  47405. * The deviceOrientationCamera used as the camera when not in VR.
  47406. */
  47407. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  47408. /**
  47409. * Based on the current WebVR support, returns the current VR camera used.
  47410. */
  47411. get currentVRCamera(): Nullable<Camera>;
  47412. /**
  47413. * The webVRCamera which is used when in VR.
  47414. */
  47415. get webVRCamera(): WebVRFreeCamera;
  47416. /**
  47417. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  47418. */
  47419. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  47420. /**
  47421. * The html button that is used to trigger entering into VR.
  47422. */
  47423. get vrButton(): Nullable<HTMLButtonElement>;
  47424. private get _teleportationRequestInitiated();
  47425. /**
  47426. * Defines whether or not Pointer lock should be requested when switching to
  47427. * full screen.
  47428. */
  47429. requestPointerLockOnFullScreen: boolean;
  47430. /**
  47431. * If asking to force XR, this will be populated with the default xr experience
  47432. */
  47433. xr: WebXRDefaultExperience;
  47434. /**
  47435. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  47436. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  47437. */
  47438. xrTestDone: boolean;
  47439. /**
  47440. * Instantiates a VRExperienceHelper.
  47441. * Helps to quickly add VR support to an existing scene.
  47442. * @param scene The scene the VRExperienceHelper belongs to.
  47443. * @param webVROptions Options to modify the vr experience helper's behavior.
  47444. */
  47445. constructor(scene: Scene,
  47446. /** Options to modify the vr experience helper's behavior. */
  47447. webVROptions?: VRExperienceHelperOptions);
  47448. private completeVRInit;
  47449. private _onDefaultMeshLoaded;
  47450. private _onResize;
  47451. private _onFullscreenChange;
  47452. /**
  47453. * Gets a value indicating if we are currently in VR mode.
  47454. */
  47455. get isInVRMode(): boolean;
  47456. private onVrDisplayPresentChange;
  47457. private onVRDisplayChanged;
  47458. private moveButtonToBottomRight;
  47459. private displayVRButton;
  47460. private updateButtonVisibility;
  47461. private _cachedAngularSensibility;
  47462. /**
  47463. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  47464. * Otherwise, will use the fullscreen API.
  47465. */
  47466. enterVR(): void;
  47467. /**
  47468. * Attempt to exit VR, or fullscreen.
  47469. */
  47470. exitVR(): void;
  47471. /**
  47472. * The position of the vr experience helper.
  47473. */
  47474. get position(): Vector3;
  47475. /**
  47476. * Sets the position of the vr experience helper.
  47477. */
  47478. set position(value: Vector3);
  47479. /**
  47480. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  47481. */
  47482. enableInteractions(): void;
  47483. private get _noControllerIsActive();
  47484. private beforeRender;
  47485. private _isTeleportationFloor;
  47486. /**
  47487. * Adds a floor mesh to be used for teleportation.
  47488. * @param floorMesh the mesh to be used for teleportation.
  47489. */
  47490. addFloorMesh(floorMesh: Mesh): void;
  47491. /**
  47492. * Removes a floor mesh from being used for teleportation.
  47493. * @param floorMesh the mesh to be removed.
  47494. */
  47495. removeFloorMesh(floorMesh: Mesh): void;
  47496. /**
  47497. * Enables interactions and teleportation using the VR controllers and gaze.
  47498. * @param vrTeleportationOptions options to modify teleportation behavior.
  47499. */
  47500. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  47501. private _onNewGamepadConnected;
  47502. private _tryEnableInteractionOnController;
  47503. private _onNewGamepadDisconnected;
  47504. private _enableInteractionOnController;
  47505. private _checkTeleportWithRay;
  47506. private _checkRotate;
  47507. private _checkTeleportBackwards;
  47508. private _enableTeleportationOnController;
  47509. private _createTeleportationCircles;
  47510. private _displayTeleportationTarget;
  47511. private _hideTeleportationTarget;
  47512. private _rotateCamera;
  47513. private _moveTeleportationSelectorTo;
  47514. private _workingVector;
  47515. private _workingQuaternion;
  47516. private _workingMatrix;
  47517. /**
  47518. * Time Constant Teleportation Mode
  47519. */
  47520. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  47521. /**
  47522. * Speed Constant Teleportation Mode
  47523. */
  47524. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  47525. /**
  47526. * Teleports the users feet to the desired location
  47527. * @param location The location where the user's feet should be placed
  47528. */
  47529. teleportCamera(location: Vector3): void;
  47530. private _convertNormalToDirectionOfRay;
  47531. private _castRayAndSelectObject;
  47532. private _notifySelectedMeshUnselected;
  47533. /**
  47534. * Permanently set new colors for the laser pointer
  47535. * @param color the new laser color
  47536. * @param pickedColor the new laser color when picked mesh detected
  47537. */
  47538. setLaserColor(color: Color3, pickedColor?: Color3): void;
  47539. /**
  47540. * Set lighting enabled / disabled on the laser pointer of both controllers
  47541. * @param enabled should the lighting be enabled on the laser pointer
  47542. */
  47543. setLaserLightingState(enabled?: boolean): void;
  47544. /**
  47545. * Permanently set new colors for the gaze pointer
  47546. * @param color the new gaze color
  47547. * @param pickedColor the new gaze color when picked mesh detected
  47548. */
  47549. setGazeColor(color: Color3, pickedColor?: Color3): void;
  47550. /**
  47551. * Sets the color of the laser ray from the vr controllers.
  47552. * @param color new color for the ray.
  47553. */
  47554. changeLaserColor(color: Color3): void;
  47555. /**
  47556. * Sets the color of the ray from the vr headsets gaze.
  47557. * @param color new color for the ray.
  47558. */
  47559. changeGazeColor(color: Color3): void;
  47560. /**
  47561. * Exits VR and disposes of the vr experience helper
  47562. */
  47563. dispose(): void;
  47564. /**
  47565. * Gets the name of the VRExperienceHelper class
  47566. * @returns "VRExperienceHelper"
  47567. */
  47568. getClassName(): string;
  47569. }
  47570. }
  47571. declare module "babylonjs/Cameras/VR/index" {
  47572. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  47573. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  47574. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47575. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  47576. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  47577. export * from "babylonjs/Cameras/VR/webVRCamera";
  47578. }
  47579. declare module "babylonjs/Cameras/RigModes/index" {
  47580. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47581. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47582. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47583. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47584. }
  47585. declare module "babylonjs/Cameras/index" {
  47586. export * from "babylonjs/Cameras/Inputs/index";
  47587. export * from "babylonjs/Cameras/cameraInputsManager";
  47588. export * from "babylonjs/Cameras/camera";
  47589. export * from "babylonjs/Cameras/targetCamera";
  47590. export * from "babylonjs/Cameras/freeCamera";
  47591. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47592. export * from "babylonjs/Cameras/touchCamera";
  47593. export * from "babylonjs/Cameras/arcRotateCamera";
  47594. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47595. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47596. export * from "babylonjs/Cameras/flyCamera";
  47597. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47598. export * from "babylonjs/Cameras/followCamera";
  47599. export * from "babylonjs/Cameras/followCameraInputsManager";
  47600. export * from "babylonjs/Cameras/gamepadCamera";
  47601. export * from "babylonjs/Cameras/Stereoscopic/index";
  47602. export * from "babylonjs/Cameras/universalCamera";
  47603. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47604. export * from "babylonjs/Cameras/VR/index";
  47605. export * from "babylonjs/Cameras/RigModes/index";
  47606. }
  47607. declare module "babylonjs/Collisions/index" {
  47608. export * from "babylonjs/Collisions/collider";
  47609. export * from "babylonjs/Collisions/collisionCoordinator";
  47610. export * from "babylonjs/Collisions/pickingInfo";
  47611. export * from "babylonjs/Collisions/intersectionInfo";
  47612. export * from "babylonjs/Collisions/meshCollisionData";
  47613. }
  47614. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47615. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47616. import { Vector3 } from "babylonjs/Maths/math.vector";
  47617. import { Ray } from "babylonjs/Culling/ray";
  47618. import { Plane } from "babylonjs/Maths/math.plane";
  47619. /**
  47620. * Contains an array of blocks representing the octree
  47621. */
  47622. export interface IOctreeContainer<T> {
  47623. /**
  47624. * Blocks within the octree
  47625. */
  47626. blocks: Array<OctreeBlock<T>>;
  47627. }
  47628. /**
  47629. * Class used to store a cell in an octree
  47630. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47631. */
  47632. export class OctreeBlock<T> {
  47633. /**
  47634. * Gets the content of the current block
  47635. */
  47636. entries: T[];
  47637. /**
  47638. * Gets the list of block children
  47639. */
  47640. blocks: Array<OctreeBlock<T>>;
  47641. private _depth;
  47642. private _maxDepth;
  47643. private _capacity;
  47644. private _minPoint;
  47645. private _maxPoint;
  47646. private _boundingVectors;
  47647. private _creationFunc;
  47648. /**
  47649. * Creates a new block
  47650. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47651. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47652. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47653. * @param depth defines the current depth of this block in the octree
  47654. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47655. * @param creationFunc defines a callback to call when an element is added to the block
  47656. */
  47657. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47658. /**
  47659. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47660. */
  47661. get capacity(): number;
  47662. /**
  47663. * Gets the minimum vector (in world space) of the block's bounding box
  47664. */
  47665. get minPoint(): Vector3;
  47666. /**
  47667. * Gets the maximum vector (in world space) of the block's bounding box
  47668. */
  47669. get maxPoint(): Vector3;
  47670. /**
  47671. * Add a new element to this block
  47672. * @param entry defines the element to add
  47673. */
  47674. addEntry(entry: T): void;
  47675. /**
  47676. * Remove an element from this block
  47677. * @param entry defines the element to remove
  47678. */
  47679. removeEntry(entry: T): void;
  47680. /**
  47681. * Add an array of elements to this block
  47682. * @param entries defines the array of elements to add
  47683. */
  47684. addEntries(entries: T[]): void;
  47685. /**
  47686. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47687. * @param frustumPlanes defines the frustum planes to test
  47688. * @param selection defines the array to store current content if selection is positive
  47689. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47690. */
  47691. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47692. /**
  47693. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47694. * @param sphereCenter defines the bounding sphere center
  47695. * @param sphereRadius defines the bounding sphere radius
  47696. * @param selection defines the array to store current content if selection is positive
  47697. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47698. */
  47699. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47700. /**
  47701. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47702. * @param ray defines the ray to test with
  47703. * @param selection defines the array to store current content if selection is positive
  47704. */
  47705. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47706. /**
  47707. * Subdivide the content into child blocks (this block will then be empty)
  47708. */
  47709. createInnerBlocks(): void;
  47710. /**
  47711. * @hidden
  47712. */
  47713. 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;
  47714. }
  47715. }
  47716. declare module "babylonjs/Culling/Octrees/octree" {
  47717. import { SmartArray } from "babylonjs/Misc/smartArray";
  47718. import { Vector3 } from "babylonjs/Maths/math.vector";
  47719. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47720. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47721. import { Ray } from "babylonjs/Culling/ray";
  47722. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47723. import { Plane } from "babylonjs/Maths/math.plane";
  47724. /**
  47725. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47726. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47727. */
  47728. export class Octree<T> {
  47729. /** 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.) */
  47730. maxDepth: number;
  47731. /**
  47732. * Blocks within the octree containing objects
  47733. */
  47734. blocks: Array<OctreeBlock<T>>;
  47735. /**
  47736. * Content stored in the octree
  47737. */
  47738. dynamicContent: T[];
  47739. private _maxBlockCapacity;
  47740. private _selectionContent;
  47741. private _creationFunc;
  47742. /**
  47743. * Creates a octree
  47744. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47745. * @param creationFunc function to be used to instatiate the octree
  47746. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47747. * @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.)
  47748. */
  47749. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47750. /** 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.) */
  47751. maxDepth?: number);
  47752. /**
  47753. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47754. * @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);
  47755. * @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);
  47756. * @param entries meshes to be added to the octree blocks
  47757. */
  47758. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47759. /**
  47760. * Adds a mesh to the octree
  47761. * @param entry Mesh to add to the octree
  47762. */
  47763. addMesh(entry: T): void;
  47764. /**
  47765. * Remove an element from the octree
  47766. * @param entry defines the element to remove
  47767. */
  47768. removeMesh(entry: T): void;
  47769. /**
  47770. * Selects an array of meshes within the frustum
  47771. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47772. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47773. * @returns array of meshes within the frustum
  47774. */
  47775. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47776. /**
  47777. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47778. * @param sphereCenter defines the bounding sphere center
  47779. * @param sphereRadius defines the bounding sphere radius
  47780. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47781. * @returns an array of objects that intersect the sphere
  47782. */
  47783. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47784. /**
  47785. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47786. * @param ray defines the ray to test with
  47787. * @returns array of intersected objects
  47788. */
  47789. intersectsRay(ray: Ray): SmartArray<T>;
  47790. /**
  47791. * Adds a mesh into the octree block if it intersects the block
  47792. */
  47793. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47794. /**
  47795. * Adds a submesh into the octree block if it intersects the block
  47796. */
  47797. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47798. }
  47799. }
  47800. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47801. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47802. import { Scene } from "babylonjs/scene";
  47803. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47804. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47805. import { Ray } from "babylonjs/Culling/ray";
  47806. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47807. import { Collider } from "babylonjs/Collisions/collider";
  47808. module "babylonjs/scene" {
  47809. interface Scene {
  47810. /**
  47811. * @hidden
  47812. * Backing Filed
  47813. */
  47814. _selectionOctree: Octree<AbstractMesh>;
  47815. /**
  47816. * Gets the octree used to boost mesh selection (picking)
  47817. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47818. */
  47819. selectionOctree: Octree<AbstractMesh>;
  47820. /**
  47821. * Creates or updates the octree used to boost selection (picking)
  47822. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47823. * @param maxCapacity defines the maximum capacity per leaf
  47824. * @param maxDepth defines the maximum depth of the octree
  47825. * @returns an octree of AbstractMesh
  47826. */
  47827. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47828. }
  47829. }
  47830. module "babylonjs/Meshes/abstractMesh" {
  47831. interface AbstractMesh {
  47832. /**
  47833. * @hidden
  47834. * Backing Field
  47835. */
  47836. _submeshesOctree: Octree<SubMesh>;
  47837. /**
  47838. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47839. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47840. * @param maxCapacity defines the maximum size of each block (64 by default)
  47841. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47842. * @returns the new octree
  47843. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47844. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47845. */
  47846. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47847. }
  47848. }
  47849. /**
  47850. * Defines the octree scene component responsible to manage any octrees
  47851. * in a given scene.
  47852. */
  47853. export class OctreeSceneComponent {
  47854. /**
  47855. * The component name help to identify the component in the list of scene components.
  47856. */
  47857. readonly name: string;
  47858. /**
  47859. * The scene the component belongs to.
  47860. */
  47861. scene: Scene;
  47862. /**
  47863. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47864. */
  47865. readonly checksIsEnabled: boolean;
  47866. /**
  47867. * Creates a new instance of the component for the given scene
  47868. * @param scene Defines the scene to register the component in
  47869. */
  47870. constructor(scene: Scene);
  47871. /**
  47872. * Registers the component in a given scene
  47873. */
  47874. register(): void;
  47875. /**
  47876. * Return the list of active meshes
  47877. * @returns the list of active meshes
  47878. */
  47879. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47880. /**
  47881. * Return the list of active sub meshes
  47882. * @param mesh The mesh to get the candidates sub meshes from
  47883. * @returns the list of active sub meshes
  47884. */
  47885. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47886. private _tempRay;
  47887. /**
  47888. * Return the list of sub meshes intersecting with a given local ray
  47889. * @param mesh defines the mesh to find the submesh for
  47890. * @param localRay defines the ray in local space
  47891. * @returns the list of intersecting sub meshes
  47892. */
  47893. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47894. /**
  47895. * Return the list of sub meshes colliding with a collider
  47896. * @param mesh defines the mesh to find the submesh for
  47897. * @param collider defines the collider to evaluate the collision against
  47898. * @returns the list of colliding sub meshes
  47899. */
  47900. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47901. /**
  47902. * Rebuilds the elements related to this component in case of
  47903. * context lost for instance.
  47904. */
  47905. rebuild(): void;
  47906. /**
  47907. * Disposes the component and the associated ressources.
  47908. */
  47909. dispose(): void;
  47910. }
  47911. }
  47912. declare module "babylonjs/Culling/Octrees/index" {
  47913. export * from "babylonjs/Culling/Octrees/octree";
  47914. export * from "babylonjs/Culling/Octrees/octreeBlock";
  47915. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  47916. }
  47917. declare module "babylonjs/Culling/index" {
  47918. export * from "babylonjs/Culling/boundingBox";
  47919. export * from "babylonjs/Culling/boundingInfo";
  47920. export * from "babylonjs/Culling/boundingSphere";
  47921. export * from "babylonjs/Culling/Octrees/index";
  47922. export * from "babylonjs/Culling/ray";
  47923. }
  47924. declare module "babylonjs/Gizmos/gizmo" {
  47925. import { Nullable } from "babylonjs/types";
  47926. import { IDisposable } from "babylonjs/scene";
  47927. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47928. import { Mesh } from "babylonjs/Meshes/mesh";
  47929. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47930. /**
  47931. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47932. */
  47933. export class Gizmo implements IDisposable {
  47934. /** The utility layer the gizmo will be added to */
  47935. gizmoLayer: UtilityLayerRenderer;
  47936. /**
  47937. * The root mesh of the gizmo
  47938. */
  47939. _rootMesh: Mesh;
  47940. private _attachedMesh;
  47941. /**
  47942. * Ratio for the scale of the gizmo (Default: 1)
  47943. */
  47944. scaleRatio: number;
  47945. /**
  47946. * If a custom mesh has been set (Default: false)
  47947. */
  47948. protected _customMeshSet: boolean;
  47949. /**
  47950. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47951. * * When set, interactions will be enabled
  47952. */
  47953. get attachedMesh(): Nullable<AbstractMesh>;
  47954. set attachedMesh(value: Nullable<AbstractMesh>);
  47955. /**
  47956. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47957. * @param mesh The mesh to replace the default mesh of the gizmo
  47958. */
  47959. setCustomMesh(mesh: Mesh): void;
  47960. /**
  47961. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47962. */
  47963. updateGizmoRotationToMatchAttachedMesh: boolean;
  47964. /**
  47965. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47966. */
  47967. updateGizmoPositionToMatchAttachedMesh: boolean;
  47968. /**
  47969. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47970. */
  47971. updateScale: boolean;
  47972. protected _interactionsEnabled: boolean;
  47973. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47974. private _beforeRenderObserver;
  47975. private _tempVector;
  47976. /**
  47977. * Creates a gizmo
  47978. * @param gizmoLayer The utility layer the gizmo will be added to
  47979. */
  47980. constructor(
  47981. /** The utility layer the gizmo will be added to */
  47982. gizmoLayer?: UtilityLayerRenderer);
  47983. /**
  47984. * Updates the gizmo to match the attached mesh's position/rotation
  47985. */
  47986. protected _update(): void;
  47987. /**
  47988. * Disposes of the gizmo
  47989. */
  47990. dispose(): void;
  47991. }
  47992. }
  47993. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47994. import { Observable } from "babylonjs/Misc/observable";
  47995. import { Nullable } from "babylonjs/types";
  47996. import { Vector3 } from "babylonjs/Maths/math.vector";
  47997. import { Color3 } from "babylonjs/Maths/math.color";
  47998. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47999. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48000. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48001. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48002. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48003. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48004. import { Scene } from "babylonjs/scene";
  48005. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  48006. /**
  48007. * Single plane drag gizmo
  48008. */
  48009. export class PlaneDragGizmo extends Gizmo {
  48010. /**
  48011. * Drag behavior responsible for the gizmos dragging interactions
  48012. */
  48013. dragBehavior: PointerDragBehavior;
  48014. private _pointerObserver;
  48015. /**
  48016. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48017. */
  48018. snapDistance: number;
  48019. /**
  48020. * Event that fires each time the gizmo snaps to a new location.
  48021. * * snapDistance is the the change in distance
  48022. */
  48023. onSnapObservable: Observable<{
  48024. snapDistance: number;
  48025. }>;
  48026. private _plane;
  48027. private _coloredMaterial;
  48028. private _hoverMaterial;
  48029. private _isEnabled;
  48030. private _parent;
  48031. /** @hidden */
  48032. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  48033. /** @hidden */
  48034. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48035. /**
  48036. * Creates a PlaneDragGizmo
  48037. * @param gizmoLayer The utility layer the gizmo will be added to
  48038. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  48039. * @param color The color of the gizmo
  48040. */
  48041. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48042. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48043. /**
  48044. * If the gizmo is enabled
  48045. */
  48046. set isEnabled(value: boolean);
  48047. get isEnabled(): boolean;
  48048. /**
  48049. * Disposes of the gizmo
  48050. */
  48051. dispose(): void;
  48052. }
  48053. }
  48054. declare module "babylonjs/Gizmos/positionGizmo" {
  48055. import { Observable } from "babylonjs/Misc/observable";
  48056. import { Nullable } from "babylonjs/types";
  48057. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48058. import { Mesh } from "babylonjs/Meshes/mesh";
  48059. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48060. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  48061. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  48062. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48063. /**
  48064. * Gizmo that enables dragging a mesh along 3 axis
  48065. */
  48066. export class PositionGizmo extends Gizmo {
  48067. /**
  48068. * Internal gizmo used for interactions on the x axis
  48069. */
  48070. xGizmo: AxisDragGizmo;
  48071. /**
  48072. * Internal gizmo used for interactions on the y axis
  48073. */
  48074. yGizmo: AxisDragGizmo;
  48075. /**
  48076. * Internal gizmo used for interactions on the z axis
  48077. */
  48078. zGizmo: AxisDragGizmo;
  48079. /**
  48080. * Internal gizmo used for interactions on the yz plane
  48081. */
  48082. xPlaneGizmo: PlaneDragGizmo;
  48083. /**
  48084. * Internal gizmo used for interactions on the xz plane
  48085. */
  48086. yPlaneGizmo: PlaneDragGizmo;
  48087. /**
  48088. * Internal gizmo used for interactions on the xy plane
  48089. */
  48090. zPlaneGizmo: PlaneDragGizmo;
  48091. /**
  48092. * private variables
  48093. */
  48094. private _meshAttached;
  48095. private _updateGizmoRotationToMatchAttachedMesh;
  48096. private _snapDistance;
  48097. private _scaleRatio;
  48098. /** Fires an event when any of it's sub gizmos are dragged */
  48099. onDragStartObservable: Observable<unknown>;
  48100. /** Fires an event when any of it's sub gizmos are released from dragging */
  48101. onDragEndObservable: Observable<unknown>;
  48102. /**
  48103. * If set to true, planar drag is enabled
  48104. */
  48105. private _planarGizmoEnabled;
  48106. get attachedMesh(): Nullable<AbstractMesh>;
  48107. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48108. /**
  48109. * Creates a PositionGizmo
  48110. * @param gizmoLayer The utility layer the gizmo will be added to
  48111. */
  48112. constructor(gizmoLayer?: UtilityLayerRenderer);
  48113. /**
  48114. * If the planar drag gizmo is enabled
  48115. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  48116. */
  48117. set planarGizmoEnabled(value: boolean);
  48118. get planarGizmoEnabled(): boolean;
  48119. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48120. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48121. /**
  48122. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48123. */
  48124. set snapDistance(value: number);
  48125. get snapDistance(): number;
  48126. /**
  48127. * Ratio for the scale of the gizmo (Default: 1)
  48128. */
  48129. set scaleRatio(value: number);
  48130. get scaleRatio(): number;
  48131. /**
  48132. * Disposes of the gizmo
  48133. */
  48134. dispose(): void;
  48135. /**
  48136. * CustomMeshes are not supported by this gizmo
  48137. * @param mesh The mesh to replace the default mesh of the gizmo
  48138. */
  48139. setCustomMesh(mesh: Mesh): void;
  48140. }
  48141. }
  48142. declare module "babylonjs/Gizmos/axisDragGizmo" {
  48143. import { Observable } from "babylonjs/Misc/observable";
  48144. import { Nullable } from "babylonjs/types";
  48145. import { Vector3 } from "babylonjs/Maths/math.vector";
  48146. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48147. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48148. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48149. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48150. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48151. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48152. import { Scene } from "babylonjs/scene";
  48153. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  48154. import { Color3 } from "babylonjs/Maths/math.color";
  48155. /**
  48156. * Single axis drag gizmo
  48157. */
  48158. export class AxisDragGizmo extends Gizmo {
  48159. /**
  48160. * Drag behavior responsible for the gizmos dragging interactions
  48161. */
  48162. dragBehavior: PointerDragBehavior;
  48163. private _pointerObserver;
  48164. /**
  48165. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48166. */
  48167. snapDistance: number;
  48168. /**
  48169. * Event that fires each time the gizmo snaps to a new location.
  48170. * * snapDistance is the the change in distance
  48171. */
  48172. onSnapObservable: Observable<{
  48173. snapDistance: number;
  48174. }>;
  48175. private _isEnabled;
  48176. private _parent;
  48177. private _arrow;
  48178. private _coloredMaterial;
  48179. private _hoverMaterial;
  48180. /** @hidden */
  48181. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  48182. /** @hidden */
  48183. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48184. /**
  48185. * Creates an AxisDragGizmo
  48186. * @param gizmoLayer The utility layer the gizmo will be added to
  48187. * @param dragAxis The axis which the gizmo will be able to drag on
  48188. * @param color The color of the gizmo
  48189. */
  48190. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48191. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48192. /**
  48193. * If the gizmo is enabled
  48194. */
  48195. set isEnabled(value: boolean);
  48196. get isEnabled(): boolean;
  48197. /**
  48198. * Disposes of the gizmo
  48199. */
  48200. dispose(): void;
  48201. }
  48202. }
  48203. declare module "babylonjs/Debug/axesViewer" {
  48204. import { Vector3 } from "babylonjs/Maths/math.vector";
  48205. import { Nullable } from "babylonjs/types";
  48206. import { Scene } from "babylonjs/scene";
  48207. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48208. /**
  48209. * The Axes viewer will show 3 axes in a specific point in space
  48210. */
  48211. export class AxesViewer {
  48212. private _xAxis;
  48213. private _yAxis;
  48214. private _zAxis;
  48215. private _scaleLinesFactor;
  48216. private _instanced;
  48217. /**
  48218. * Gets the hosting scene
  48219. */
  48220. scene: Scene;
  48221. /**
  48222. * Gets or sets a number used to scale line length
  48223. */
  48224. scaleLines: number;
  48225. /** Gets the node hierarchy used to render x-axis */
  48226. get xAxis(): TransformNode;
  48227. /** Gets the node hierarchy used to render y-axis */
  48228. get yAxis(): TransformNode;
  48229. /** Gets the node hierarchy used to render z-axis */
  48230. get zAxis(): TransformNode;
  48231. /**
  48232. * Creates a new AxesViewer
  48233. * @param scene defines the hosting scene
  48234. * @param scaleLines defines a number used to scale line length (1 by default)
  48235. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  48236. * @param xAxis defines the node hierarchy used to render the x-axis
  48237. * @param yAxis defines the node hierarchy used to render the y-axis
  48238. * @param zAxis defines the node hierarchy used to render the z-axis
  48239. */
  48240. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  48241. /**
  48242. * Force the viewer to update
  48243. * @param position defines the position of the viewer
  48244. * @param xaxis defines the x axis of the viewer
  48245. * @param yaxis defines the y axis of the viewer
  48246. * @param zaxis defines the z axis of the viewer
  48247. */
  48248. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  48249. /**
  48250. * Creates an instance of this axes viewer.
  48251. * @returns a new axes viewer with instanced meshes
  48252. */
  48253. createInstance(): AxesViewer;
  48254. /** Releases resources */
  48255. dispose(): void;
  48256. private static _SetRenderingGroupId;
  48257. }
  48258. }
  48259. declare module "babylonjs/Debug/boneAxesViewer" {
  48260. import { Nullable } from "babylonjs/types";
  48261. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  48262. import { Vector3 } from "babylonjs/Maths/math.vector";
  48263. import { Mesh } from "babylonjs/Meshes/mesh";
  48264. import { Bone } from "babylonjs/Bones/bone";
  48265. import { Scene } from "babylonjs/scene";
  48266. /**
  48267. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  48268. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  48269. */
  48270. export class BoneAxesViewer extends AxesViewer {
  48271. /**
  48272. * Gets or sets the target mesh where to display the axes viewer
  48273. */
  48274. mesh: Nullable<Mesh>;
  48275. /**
  48276. * Gets or sets the target bone where to display the axes viewer
  48277. */
  48278. bone: Nullable<Bone>;
  48279. /** Gets current position */
  48280. pos: Vector3;
  48281. /** Gets direction of X axis */
  48282. xaxis: Vector3;
  48283. /** Gets direction of Y axis */
  48284. yaxis: Vector3;
  48285. /** Gets direction of Z axis */
  48286. zaxis: Vector3;
  48287. /**
  48288. * Creates a new BoneAxesViewer
  48289. * @param scene defines the hosting scene
  48290. * @param bone defines the target bone
  48291. * @param mesh defines the target mesh
  48292. * @param scaleLines defines a scaling factor for line length (1 by default)
  48293. */
  48294. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  48295. /**
  48296. * Force the viewer to update
  48297. */
  48298. update(): void;
  48299. /** Releases resources */
  48300. dispose(): void;
  48301. }
  48302. }
  48303. declare module "babylonjs/Debug/debugLayer" {
  48304. import { Scene } from "babylonjs/scene";
  48305. /**
  48306. * Interface used to define scene explorer extensibility option
  48307. */
  48308. export interface IExplorerExtensibilityOption {
  48309. /**
  48310. * Define the option label
  48311. */
  48312. label: string;
  48313. /**
  48314. * Defines the action to execute on click
  48315. */
  48316. action: (entity: any) => void;
  48317. }
  48318. /**
  48319. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  48320. */
  48321. export interface IExplorerExtensibilityGroup {
  48322. /**
  48323. * Defines a predicate to test if a given type mut be extended
  48324. */
  48325. predicate: (entity: any) => boolean;
  48326. /**
  48327. * Gets the list of options added to a type
  48328. */
  48329. entries: IExplorerExtensibilityOption[];
  48330. }
  48331. /**
  48332. * Interface used to define the options to use to create the Inspector
  48333. */
  48334. export interface IInspectorOptions {
  48335. /**
  48336. * Display in overlay mode (default: false)
  48337. */
  48338. overlay?: boolean;
  48339. /**
  48340. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  48341. */
  48342. globalRoot?: HTMLElement;
  48343. /**
  48344. * Display the Scene explorer
  48345. */
  48346. showExplorer?: boolean;
  48347. /**
  48348. * Display the property inspector
  48349. */
  48350. showInspector?: boolean;
  48351. /**
  48352. * Display in embed mode (both panes on the right)
  48353. */
  48354. embedMode?: boolean;
  48355. /**
  48356. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  48357. */
  48358. handleResize?: boolean;
  48359. /**
  48360. * Allow the panes to popup (default: true)
  48361. */
  48362. enablePopup?: boolean;
  48363. /**
  48364. * Allow the panes to be closed by users (default: true)
  48365. */
  48366. enableClose?: boolean;
  48367. /**
  48368. * Optional list of extensibility entries
  48369. */
  48370. explorerExtensibility?: IExplorerExtensibilityGroup[];
  48371. /**
  48372. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  48373. */
  48374. inspectorURL?: string;
  48375. /**
  48376. * Optional initial tab (default to DebugLayerTab.Properties)
  48377. */
  48378. initialTab?: DebugLayerTab;
  48379. }
  48380. module "babylonjs/scene" {
  48381. interface Scene {
  48382. /**
  48383. * @hidden
  48384. * Backing field
  48385. */
  48386. _debugLayer: DebugLayer;
  48387. /**
  48388. * Gets the debug layer (aka Inspector) associated with the scene
  48389. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48390. */
  48391. debugLayer: DebugLayer;
  48392. }
  48393. }
  48394. /**
  48395. * Enum of inspector action tab
  48396. */
  48397. export enum DebugLayerTab {
  48398. /**
  48399. * Properties tag (default)
  48400. */
  48401. Properties = 0,
  48402. /**
  48403. * Debug tab
  48404. */
  48405. Debug = 1,
  48406. /**
  48407. * Statistics tab
  48408. */
  48409. Statistics = 2,
  48410. /**
  48411. * Tools tab
  48412. */
  48413. Tools = 3,
  48414. /**
  48415. * Settings tab
  48416. */
  48417. Settings = 4
  48418. }
  48419. /**
  48420. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48421. * what is happening in your scene
  48422. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48423. */
  48424. export class DebugLayer {
  48425. /**
  48426. * Define the url to get the inspector script from.
  48427. * By default it uses the babylonjs CDN.
  48428. * @ignoreNaming
  48429. */
  48430. static InspectorURL: string;
  48431. private _scene;
  48432. private BJSINSPECTOR;
  48433. private _onPropertyChangedObservable?;
  48434. /**
  48435. * Observable triggered when a property is changed through the inspector.
  48436. */
  48437. get onPropertyChangedObservable(): any;
  48438. /**
  48439. * Instantiates a new debug layer.
  48440. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48441. * what is happening in your scene
  48442. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48443. * @param scene Defines the scene to inspect
  48444. */
  48445. constructor(scene: Scene);
  48446. /** Creates the inspector window. */
  48447. private _createInspector;
  48448. /**
  48449. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  48450. * @param entity defines the entity to select
  48451. * @param lineContainerTitle defines the specific block to highlight
  48452. */
  48453. select(entity: any, lineContainerTitle?: string): void;
  48454. /** Get the inspector from bundle or global */
  48455. private _getGlobalInspector;
  48456. /**
  48457. * Get if the inspector is visible or not.
  48458. * @returns true if visible otherwise, false
  48459. */
  48460. isVisible(): boolean;
  48461. /**
  48462. * Hide the inspector and close its window.
  48463. */
  48464. hide(): void;
  48465. /**
  48466. * Launch the debugLayer.
  48467. * @param config Define the configuration of the inspector
  48468. * @return a promise fulfilled when the debug layer is visible
  48469. */
  48470. show(config?: IInspectorOptions): Promise<DebugLayer>;
  48471. }
  48472. }
  48473. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  48474. import { Nullable } from "babylonjs/types";
  48475. import { Scene } from "babylonjs/scene";
  48476. import { Vector4 } from "babylonjs/Maths/math.vector";
  48477. import { Color4 } from "babylonjs/Maths/math.color";
  48478. import { Mesh } from "babylonjs/Meshes/mesh";
  48479. /**
  48480. * Class containing static functions to help procedurally build meshes
  48481. */
  48482. export class BoxBuilder {
  48483. /**
  48484. * Creates a box mesh
  48485. * * The parameter `size` sets the size (float) of each box side (default 1)
  48486. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  48487. * * 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)
  48488. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48489. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48490. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48492. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  48493. * @param name defines the name of the mesh
  48494. * @param options defines the options used to create the mesh
  48495. * @param scene defines the hosting scene
  48496. * @returns the box mesh
  48497. */
  48498. static CreateBox(name: string, options: {
  48499. size?: number;
  48500. width?: number;
  48501. height?: number;
  48502. depth?: number;
  48503. faceUV?: Vector4[];
  48504. faceColors?: Color4[];
  48505. sideOrientation?: number;
  48506. frontUVs?: Vector4;
  48507. backUVs?: Vector4;
  48508. wrap?: boolean;
  48509. topBaseAt?: number;
  48510. bottomBaseAt?: number;
  48511. updatable?: boolean;
  48512. }, scene?: Nullable<Scene>): Mesh;
  48513. }
  48514. }
  48515. declare module "babylonjs/Debug/physicsViewer" {
  48516. import { Nullable } from "babylonjs/types";
  48517. import { Scene } from "babylonjs/scene";
  48518. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48519. import { Mesh } from "babylonjs/Meshes/mesh";
  48520. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48521. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48522. /**
  48523. * Used to show the physics impostor around the specific mesh
  48524. */
  48525. export class PhysicsViewer {
  48526. /** @hidden */
  48527. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  48528. /** @hidden */
  48529. protected _meshes: Array<Nullable<AbstractMesh>>;
  48530. /** @hidden */
  48531. protected _scene: Nullable<Scene>;
  48532. /** @hidden */
  48533. protected _numMeshes: number;
  48534. /** @hidden */
  48535. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  48536. private _renderFunction;
  48537. private _utilityLayer;
  48538. private _debugBoxMesh;
  48539. private _debugSphereMesh;
  48540. private _debugCylinderMesh;
  48541. private _debugMaterial;
  48542. private _debugMeshMeshes;
  48543. /**
  48544. * Creates a new PhysicsViewer
  48545. * @param scene defines the hosting scene
  48546. */
  48547. constructor(scene: Scene);
  48548. /** @hidden */
  48549. protected _updateDebugMeshes(): void;
  48550. /**
  48551. * Renders a specified physic impostor
  48552. * @param impostor defines the impostor to render
  48553. * @param targetMesh defines the mesh represented by the impostor
  48554. * @returns the new debug mesh used to render the impostor
  48555. */
  48556. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48557. /**
  48558. * Hides a specified physic impostor
  48559. * @param impostor defines the impostor to hide
  48560. */
  48561. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48562. private _getDebugMaterial;
  48563. private _getDebugBoxMesh;
  48564. private _getDebugSphereMesh;
  48565. private _getDebugCylinderMesh;
  48566. private _getDebugMeshMesh;
  48567. private _getDebugMesh;
  48568. /** Releases all resources */
  48569. dispose(): void;
  48570. }
  48571. }
  48572. declare module "babylonjs/Debug/rayHelper" {
  48573. import { Nullable } from "babylonjs/types";
  48574. import { Ray } from "babylonjs/Culling/ray";
  48575. import { Vector3 } from "babylonjs/Maths/math.vector";
  48576. import { Color3 } from "babylonjs/Maths/math.color";
  48577. import { Scene } from "babylonjs/scene";
  48578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48579. import "babylonjs/Meshes/Builders/linesBuilder";
  48580. /**
  48581. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48582. * in order to better appreciate the issue one might have.
  48583. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48584. */
  48585. export class RayHelper {
  48586. /**
  48587. * Defines the ray we are currently tryin to visualize.
  48588. */
  48589. ray: Nullable<Ray>;
  48590. private _renderPoints;
  48591. private _renderLine;
  48592. private _renderFunction;
  48593. private _scene;
  48594. private _updateToMeshFunction;
  48595. private _attachedToMesh;
  48596. private _meshSpaceDirection;
  48597. private _meshSpaceOrigin;
  48598. /**
  48599. * Helper function to create a colored helper in a scene in one line.
  48600. * @param ray Defines the ray we are currently tryin to visualize
  48601. * @param scene Defines the scene the ray is used in
  48602. * @param color Defines the color we want to see the ray in
  48603. * @returns The newly created ray helper.
  48604. */
  48605. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48606. /**
  48607. * Instantiate a new ray helper.
  48608. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48609. * in order to better appreciate the issue one might have.
  48610. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48611. * @param ray Defines the ray we are currently tryin to visualize
  48612. */
  48613. constructor(ray: Ray);
  48614. /**
  48615. * Shows the ray we are willing to debug.
  48616. * @param scene Defines the scene the ray needs to be rendered in
  48617. * @param color Defines the color the ray needs to be rendered in
  48618. */
  48619. show(scene: Scene, color?: Color3): void;
  48620. /**
  48621. * Hides the ray we are debugging.
  48622. */
  48623. hide(): void;
  48624. private _render;
  48625. /**
  48626. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48627. * @param mesh Defines the mesh we want the helper attached to
  48628. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48629. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48630. * @param length Defines the length of the ray
  48631. */
  48632. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48633. /**
  48634. * Detach the ray helper from the mesh it has previously been attached to.
  48635. */
  48636. detachFromMesh(): void;
  48637. private _updateToMesh;
  48638. /**
  48639. * Dispose the helper and release its associated resources.
  48640. */
  48641. dispose(): void;
  48642. }
  48643. }
  48644. declare module "babylonjs/Debug/skeletonViewer" {
  48645. import { Color3 } from "babylonjs/Maths/math.color";
  48646. import { Scene } from "babylonjs/scene";
  48647. import { Nullable } from "babylonjs/types";
  48648. import { Skeleton } from "babylonjs/Bones/skeleton";
  48649. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48650. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48651. /**
  48652. * Class used to render a debug view of a given skeleton
  48653. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48654. */
  48655. export class SkeletonViewer {
  48656. /** defines the skeleton to render */
  48657. skeleton: Skeleton;
  48658. /** defines the mesh attached to the skeleton */
  48659. mesh: AbstractMesh;
  48660. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48661. autoUpdateBonesMatrices: boolean;
  48662. /** defines the rendering group id to use with the viewer */
  48663. renderingGroupId: number;
  48664. /** Gets or sets the color used to render the skeleton */
  48665. color: Color3;
  48666. private _scene;
  48667. private _debugLines;
  48668. private _debugMesh;
  48669. private _isEnabled;
  48670. private _renderFunction;
  48671. private _utilityLayer;
  48672. /**
  48673. * Returns the mesh used to render the bones
  48674. */
  48675. get debugMesh(): Nullable<LinesMesh>;
  48676. /**
  48677. * Creates a new SkeletonViewer
  48678. * @param skeleton defines the skeleton to render
  48679. * @param mesh defines the mesh attached to the skeleton
  48680. * @param scene defines the hosting scene
  48681. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48682. * @param renderingGroupId defines the rendering group id to use with the viewer
  48683. */
  48684. constructor(
  48685. /** defines the skeleton to render */
  48686. skeleton: Skeleton,
  48687. /** defines the mesh attached to the skeleton */
  48688. mesh: AbstractMesh, scene: Scene,
  48689. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48690. autoUpdateBonesMatrices?: boolean,
  48691. /** defines the rendering group id to use with the viewer */
  48692. renderingGroupId?: number);
  48693. /** Gets or sets a boolean indicating if the viewer is enabled */
  48694. set isEnabled(value: boolean);
  48695. get isEnabled(): boolean;
  48696. private _getBonePosition;
  48697. private _getLinesForBonesWithLength;
  48698. private _getLinesForBonesNoLength;
  48699. /** Update the viewer to sync with current skeleton state */
  48700. update(): void;
  48701. /** Release associated resources */
  48702. dispose(): void;
  48703. }
  48704. }
  48705. declare module "babylonjs/Debug/index" {
  48706. export * from "babylonjs/Debug/axesViewer";
  48707. export * from "babylonjs/Debug/boneAxesViewer";
  48708. export * from "babylonjs/Debug/debugLayer";
  48709. export * from "babylonjs/Debug/physicsViewer";
  48710. export * from "babylonjs/Debug/rayHelper";
  48711. export * from "babylonjs/Debug/skeletonViewer";
  48712. }
  48713. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  48714. import { Observable } from "babylonjs/Misc/observable";
  48715. import { Engine } from "babylonjs/Engines/engine";
  48716. import { IDisposable } from "babylonjs/scene";
  48717. import { Nullable } from "babylonjs/types";
  48718. /**
  48719. * This class will take all inputs from Keyboard, Pointer, and
  48720. * any Gamepads and provide a polling system that all devices
  48721. * will use. This class assumes that there will only be one
  48722. * pointer device and one keyboard.
  48723. */
  48724. export class DeviceInputSystem implements IDisposable {
  48725. /** POINTER_DEVICE */
  48726. static readonly POINTER_DEVICE: string;
  48727. /** KEYBOARD_DEVICE */
  48728. static readonly KEYBOARD_DEVICE: string;
  48729. /**
  48730. * Observable to be triggered when a device is connected
  48731. */
  48732. onDeviceConnectedObservable: Observable<string>;
  48733. /**
  48734. * Observable to be triggered when a device is disconnected
  48735. */
  48736. onDeviceDisconnectedObservable: Observable<string>;
  48737. private _inputs;
  48738. private _gamepads;
  48739. private _keyboardActive;
  48740. private _pointerActive;
  48741. private _elementToAttachTo;
  48742. private _keyboardDownEvent;
  48743. private _keyboardUpEvent;
  48744. private _pointerMoveEvent;
  48745. private _pointerDownEvent;
  48746. private _pointerUpEvent;
  48747. private _gamepadConnectedEvent;
  48748. private _gamepadDisconnectedEvent;
  48749. private static _MAX_KEYCODES;
  48750. private static _MAX_POINTER_INPUTS;
  48751. /**
  48752. * Default Constructor
  48753. * @param engine - engine to pull input element from
  48754. */
  48755. constructor(engine: Engine);
  48756. /**
  48757. * Checks for current device input value, given an id and input index
  48758. * @param deviceName Id of connected device
  48759. * @param inputIndex Index of device input
  48760. * @returns Current value of input
  48761. */
  48762. pollInput(deviceName: string, inputIndex: number): Nullable<number>;
  48763. /**
  48764. * Dispose of all the eventlisteners and clears the observables
  48765. */
  48766. dispose(): void;
  48767. /**
  48768. * Add device and inputs to device map
  48769. * @param deviceName Assigned name of device (may be SN)
  48770. * @param numberOfInputs Number of input entries to create for given device
  48771. */
  48772. private _registerDevice;
  48773. /**
  48774. * Given a specific device name, remove that device from the device map
  48775. * @param deviceName Name of device to be removed
  48776. */
  48777. private _unregisterDevice;
  48778. /**
  48779. * Handle all actions that come from keyboard interaction
  48780. */
  48781. private _handleKeyActions;
  48782. /**
  48783. * Handle all actions that come from pointer interaction
  48784. */
  48785. private _handlePointerActions;
  48786. /**
  48787. * Handle all actions that come from gamepad interaction
  48788. */
  48789. private _handleGamepadActions;
  48790. /**
  48791. * Update all non-event based devices with each frame
  48792. */
  48793. private _updateDevice;
  48794. }
  48795. }
  48796. declare module "babylonjs/DeviceInput/index" {
  48797. export * from "babylonjs/DeviceInput/deviceInputSystem";
  48798. }
  48799. declare module "babylonjs/Engines/nullEngine" {
  48800. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48801. import { Engine } from "babylonjs/Engines/engine";
  48802. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48803. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48804. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48805. import { Effect } from "babylonjs/Materials/effect";
  48806. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48807. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48808. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48809. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  48810. /**
  48811. * Options to create the null engine
  48812. */
  48813. export class NullEngineOptions {
  48814. /**
  48815. * Render width (Default: 512)
  48816. */
  48817. renderWidth: number;
  48818. /**
  48819. * Render height (Default: 256)
  48820. */
  48821. renderHeight: number;
  48822. /**
  48823. * Texture size (Default: 512)
  48824. */
  48825. textureSize: number;
  48826. /**
  48827. * If delta time between frames should be constant
  48828. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48829. */
  48830. deterministicLockstep: boolean;
  48831. /**
  48832. * Maximum about of steps between frames (Default: 4)
  48833. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48834. */
  48835. lockstepMaxSteps: number;
  48836. }
  48837. /**
  48838. * The null engine class provides support for headless version of babylon.js.
  48839. * This can be used in server side scenario or for testing purposes
  48840. */
  48841. export class NullEngine extends Engine {
  48842. private _options;
  48843. /**
  48844. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48845. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48846. * @returns true if engine is in deterministic lock step mode
  48847. */
  48848. isDeterministicLockStep(): boolean;
  48849. /**
  48850. * Gets the max steps when engine is running in deterministic lock step
  48851. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48852. * @returns the max steps
  48853. */
  48854. getLockstepMaxSteps(): number;
  48855. /**
  48856. * Gets the current hardware scaling level.
  48857. * By default the hardware scaling level is computed from the window device ratio.
  48858. * 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.
  48859. * @returns a number indicating the current hardware scaling level
  48860. */
  48861. getHardwareScalingLevel(): number;
  48862. constructor(options?: NullEngineOptions);
  48863. /**
  48864. * Creates a vertex buffer
  48865. * @param vertices the data for the vertex buffer
  48866. * @returns the new WebGL static buffer
  48867. */
  48868. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48869. /**
  48870. * Creates a new index buffer
  48871. * @param indices defines the content of the index buffer
  48872. * @param updatable defines if the index buffer must be updatable
  48873. * @returns a new webGL buffer
  48874. */
  48875. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48876. /**
  48877. * Clear the current render buffer or the current render target (if any is set up)
  48878. * @param color defines the color to use
  48879. * @param backBuffer defines if the back buffer must be cleared
  48880. * @param depth defines if the depth buffer must be cleared
  48881. * @param stencil defines if the stencil buffer must be cleared
  48882. */
  48883. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48884. /**
  48885. * Gets the current render width
  48886. * @param useScreen defines if screen size must be used (or the current render target if any)
  48887. * @returns a number defining the current render width
  48888. */
  48889. getRenderWidth(useScreen?: boolean): number;
  48890. /**
  48891. * Gets the current render height
  48892. * @param useScreen defines if screen size must be used (or the current render target if any)
  48893. * @returns a number defining the current render height
  48894. */
  48895. getRenderHeight(useScreen?: boolean): number;
  48896. /**
  48897. * Set the WebGL's viewport
  48898. * @param viewport defines the viewport element to be used
  48899. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48900. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48901. */
  48902. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48903. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48904. /**
  48905. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48906. * @param pipelineContext defines the pipeline context to use
  48907. * @param uniformsNames defines the list of uniform names
  48908. * @returns an array of webGL uniform locations
  48909. */
  48910. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48911. /**
  48912. * Gets the lsit of active attributes for a given webGL program
  48913. * @param pipelineContext defines the pipeline context to use
  48914. * @param attributesNames defines the list of attribute names to get
  48915. * @returns an array of indices indicating the offset of each attribute
  48916. */
  48917. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48918. /**
  48919. * Binds an effect to the webGL context
  48920. * @param effect defines the effect to bind
  48921. */
  48922. bindSamplers(effect: Effect): void;
  48923. /**
  48924. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48925. * @param effect defines the effect to activate
  48926. */
  48927. enableEffect(effect: Effect): void;
  48928. /**
  48929. * Set various states to the webGL context
  48930. * @param culling defines backface culling state
  48931. * @param zOffset defines the value to apply to zOffset (0 by default)
  48932. * @param force defines if states must be applied even if cache is up to date
  48933. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48934. */
  48935. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48936. /**
  48937. * Set the value of an uniform to an array of int32
  48938. * @param uniform defines the webGL uniform location where to store the value
  48939. * @param array defines the array of int32 to store
  48940. */
  48941. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48942. /**
  48943. * Set the value of an uniform to an array of int32 (stored as vec2)
  48944. * @param uniform defines the webGL uniform location where to store the value
  48945. * @param array defines the array of int32 to store
  48946. */
  48947. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48948. /**
  48949. * Set the value of an uniform to an array of int32 (stored as vec3)
  48950. * @param uniform defines the webGL uniform location where to store the value
  48951. * @param array defines the array of int32 to store
  48952. */
  48953. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48954. /**
  48955. * Set the value of an uniform to an array of int32 (stored as vec4)
  48956. * @param uniform defines the webGL uniform location where to store the value
  48957. * @param array defines the array of int32 to store
  48958. */
  48959. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48960. /**
  48961. * Set the value of an uniform to an array of float32
  48962. * @param uniform defines the webGL uniform location where to store the value
  48963. * @param array defines the array of float32 to store
  48964. */
  48965. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48966. /**
  48967. * Set the value of an uniform to an array of float32 (stored as vec2)
  48968. * @param uniform defines the webGL uniform location where to store the value
  48969. * @param array defines the array of float32 to store
  48970. */
  48971. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48972. /**
  48973. * Set the value of an uniform to an array of float32 (stored as vec3)
  48974. * @param uniform defines the webGL uniform location where to store the value
  48975. * @param array defines the array of float32 to store
  48976. */
  48977. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48978. /**
  48979. * Set the value of an uniform to an array of float32 (stored as vec4)
  48980. * @param uniform defines the webGL uniform location where to store the value
  48981. * @param array defines the array of float32 to store
  48982. */
  48983. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48984. /**
  48985. * Set the value of an uniform to an array of number
  48986. * @param uniform defines the webGL uniform location where to store the value
  48987. * @param array defines the array of number to store
  48988. */
  48989. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48990. /**
  48991. * Set the value of an uniform to an array of number (stored as vec2)
  48992. * @param uniform defines the webGL uniform location where to store the value
  48993. * @param array defines the array of number to store
  48994. */
  48995. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48996. /**
  48997. * Set the value of an uniform to an array of number (stored as vec3)
  48998. * @param uniform defines the webGL uniform location where to store the value
  48999. * @param array defines the array of number to store
  49000. */
  49001. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49002. /**
  49003. * Set the value of an uniform to an array of number (stored as vec4)
  49004. * @param uniform defines the webGL uniform location where to store the value
  49005. * @param array defines the array of number to store
  49006. */
  49007. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49008. /**
  49009. * Set the value of an uniform to an array of float32 (stored as matrices)
  49010. * @param uniform defines the webGL uniform location where to store the value
  49011. * @param matrices defines the array of float32 to store
  49012. */
  49013. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49014. /**
  49015. * Set the value of an uniform to a matrix (3x3)
  49016. * @param uniform defines the webGL uniform location where to store the value
  49017. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  49018. */
  49019. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49020. /**
  49021. * Set the value of an uniform to a matrix (2x2)
  49022. * @param uniform defines the webGL uniform location where to store the value
  49023. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  49024. */
  49025. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49026. /**
  49027. * Set the value of an uniform to a number (float)
  49028. * @param uniform defines the webGL uniform location where to store the value
  49029. * @param value defines the float number to store
  49030. */
  49031. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49032. /**
  49033. * Set the value of an uniform to a vec2
  49034. * @param uniform defines the webGL uniform location where to store the value
  49035. * @param x defines the 1st component of the value
  49036. * @param y defines the 2nd component of the value
  49037. */
  49038. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49039. /**
  49040. * Set the value of an uniform to a vec3
  49041. * @param uniform defines the webGL uniform location where to store the value
  49042. * @param x defines the 1st component of the value
  49043. * @param y defines the 2nd component of the value
  49044. * @param z defines the 3rd component of the value
  49045. */
  49046. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49047. /**
  49048. * Set the value of an uniform to a boolean
  49049. * @param uniform defines the webGL uniform location where to store the value
  49050. * @param bool defines the boolean to store
  49051. */
  49052. setBool(uniform: WebGLUniformLocation, bool: number): void;
  49053. /**
  49054. * Set the value of an uniform to a vec4
  49055. * @param uniform defines the webGL uniform location where to store the value
  49056. * @param x defines the 1st component of the value
  49057. * @param y defines the 2nd component of the value
  49058. * @param z defines the 3rd component of the value
  49059. * @param w defines the 4th component of the value
  49060. */
  49061. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49062. /**
  49063. * Sets the current alpha mode
  49064. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  49065. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49066. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49067. */
  49068. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49069. /**
  49070. * Bind webGl buffers directly to the webGL context
  49071. * @param vertexBuffers defines the vertex buffer to bind
  49072. * @param indexBuffer defines the index buffer to bind
  49073. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  49074. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  49075. * @param effect defines the effect associated with the vertex buffer
  49076. */
  49077. bindBuffers(vertexBuffers: {
  49078. [key: string]: VertexBuffer;
  49079. }, indexBuffer: DataBuffer, effect: Effect): void;
  49080. /**
  49081. * Force the entire cache to be cleared
  49082. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  49083. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  49084. */
  49085. wipeCaches(bruteForce?: boolean): void;
  49086. /**
  49087. * Send a draw order
  49088. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  49089. * @param indexStart defines the starting index
  49090. * @param indexCount defines the number of index to draw
  49091. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49092. */
  49093. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  49094. /**
  49095. * Draw a list of indexed primitives
  49096. * @param fillMode defines the primitive to use
  49097. * @param indexStart defines the starting index
  49098. * @param indexCount defines the number of index to draw
  49099. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49100. */
  49101. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49102. /**
  49103. * Draw a list of unindexed primitives
  49104. * @param fillMode defines the primitive to use
  49105. * @param verticesStart defines the index of first vertex to draw
  49106. * @param verticesCount defines the count of vertices to draw
  49107. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49108. */
  49109. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49110. /** @hidden */
  49111. _createTexture(): WebGLTexture;
  49112. /** @hidden */
  49113. _releaseTexture(texture: InternalTexture): void;
  49114. /**
  49115. * Usually called from Texture.ts.
  49116. * Passed information to create a WebGLTexture
  49117. * @param urlArg defines a value which contains one of the following:
  49118. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49119. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49120. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49121. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49122. * @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)
  49123. * @param scene needed for loading to the correct scene
  49124. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  49125. * @param onLoad optional callback to be called upon successful completion
  49126. * @param onError optional callback to be called upon failure
  49127. * @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
  49128. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49129. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49130. * @param forcedExtension defines the extension to use to pick the right loader
  49131. * @param mimeType defines an optional mime type
  49132. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49133. */
  49134. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  49135. /**
  49136. * Creates a new render target texture
  49137. * @param size defines the size of the texture
  49138. * @param options defines the options used to create the texture
  49139. * @returns a new render target texture stored in an InternalTexture
  49140. */
  49141. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  49142. /**
  49143. * Update the sampling mode of a given texture
  49144. * @param samplingMode defines the required sampling mode
  49145. * @param texture defines the texture to update
  49146. */
  49147. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49148. /**
  49149. * Binds the frame buffer to the specified texture.
  49150. * @param texture The texture to render to or null for the default canvas
  49151. * @param faceIndex The face of the texture to render to in case of cube texture
  49152. * @param requiredWidth The width of the target to render to
  49153. * @param requiredHeight The height of the target to render to
  49154. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  49155. * @param lodLevel defines le lod level to bind to the frame buffer
  49156. */
  49157. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49158. /**
  49159. * Unbind the current render target texture from the webGL context
  49160. * @param texture defines the render target texture to unbind
  49161. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  49162. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  49163. */
  49164. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49165. /**
  49166. * Creates a dynamic vertex buffer
  49167. * @param vertices the data for the dynamic vertex buffer
  49168. * @returns the new WebGL dynamic buffer
  49169. */
  49170. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  49171. /**
  49172. * Update the content of a dynamic texture
  49173. * @param texture defines the texture to update
  49174. * @param canvas defines the canvas containing the source
  49175. * @param invertY defines if data must be stored with Y axis inverted
  49176. * @param premulAlpha defines if alpha is stored as premultiplied
  49177. * @param format defines the format of the data
  49178. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  49179. */
  49180. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  49181. /**
  49182. * Gets a boolean indicating if all created effects are ready
  49183. * @returns true if all effects are ready
  49184. */
  49185. areAllEffectsReady(): boolean;
  49186. /**
  49187. * @hidden
  49188. * Get the current error code of the webGL context
  49189. * @returns the error code
  49190. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  49191. */
  49192. getError(): number;
  49193. /** @hidden */
  49194. _getUnpackAlignement(): number;
  49195. /** @hidden */
  49196. _unpackFlipY(value: boolean): void;
  49197. /**
  49198. * Update a dynamic index buffer
  49199. * @param indexBuffer defines the target index buffer
  49200. * @param indices defines the data to update
  49201. * @param offset defines the offset in the target index buffer where update should start
  49202. */
  49203. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  49204. /**
  49205. * Updates a dynamic vertex buffer.
  49206. * @param vertexBuffer the vertex buffer to update
  49207. * @param vertices the data used to update the vertex buffer
  49208. * @param byteOffset the byte offset of the data (optional)
  49209. * @param byteLength the byte length of the data (optional)
  49210. */
  49211. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  49212. /** @hidden */
  49213. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  49214. /** @hidden */
  49215. _bindTexture(channel: number, texture: InternalTexture): void;
  49216. protected _deleteBuffer(buffer: WebGLBuffer): void;
  49217. /**
  49218. * 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
  49219. */
  49220. releaseEffects(): void;
  49221. displayLoadingUI(): void;
  49222. hideLoadingUI(): void;
  49223. /** @hidden */
  49224. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49225. /** @hidden */
  49226. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49227. /** @hidden */
  49228. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49229. /** @hidden */
  49230. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49231. }
  49232. }
  49233. declare module "babylonjs/Instrumentation/timeToken" {
  49234. import { Nullable } from "babylonjs/types";
  49235. /**
  49236. * @hidden
  49237. **/
  49238. export class _TimeToken {
  49239. _startTimeQuery: Nullable<WebGLQuery>;
  49240. _endTimeQuery: Nullable<WebGLQuery>;
  49241. _timeElapsedQuery: Nullable<WebGLQuery>;
  49242. _timeElapsedQueryEnded: boolean;
  49243. }
  49244. }
  49245. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  49246. import { Nullable, int } from "babylonjs/types";
  49247. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  49248. /** @hidden */
  49249. export class _OcclusionDataStorage {
  49250. /** @hidden */
  49251. occlusionInternalRetryCounter: number;
  49252. /** @hidden */
  49253. isOcclusionQueryInProgress: boolean;
  49254. /** @hidden */
  49255. isOccluded: boolean;
  49256. /** @hidden */
  49257. occlusionRetryCount: number;
  49258. /** @hidden */
  49259. occlusionType: number;
  49260. /** @hidden */
  49261. occlusionQueryAlgorithmType: number;
  49262. }
  49263. module "babylonjs/Engines/engine" {
  49264. interface Engine {
  49265. /**
  49266. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  49267. * @return the new query
  49268. */
  49269. createQuery(): WebGLQuery;
  49270. /**
  49271. * Delete and release a webGL query
  49272. * @param query defines the query to delete
  49273. * @return the current engine
  49274. */
  49275. deleteQuery(query: WebGLQuery): Engine;
  49276. /**
  49277. * Check if a given query has resolved and got its value
  49278. * @param query defines the query to check
  49279. * @returns true if the query got its value
  49280. */
  49281. isQueryResultAvailable(query: WebGLQuery): boolean;
  49282. /**
  49283. * Gets the value of a given query
  49284. * @param query defines the query to check
  49285. * @returns the value of the query
  49286. */
  49287. getQueryResult(query: WebGLQuery): number;
  49288. /**
  49289. * Initiates an occlusion query
  49290. * @param algorithmType defines the algorithm to use
  49291. * @param query defines the query to use
  49292. * @returns the current engine
  49293. * @see http://doc.babylonjs.com/features/occlusionquery
  49294. */
  49295. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  49296. /**
  49297. * Ends an occlusion query
  49298. * @see http://doc.babylonjs.com/features/occlusionquery
  49299. * @param algorithmType defines the algorithm to use
  49300. * @returns the current engine
  49301. */
  49302. endOcclusionQuery(algorithmType: number): Engine;
  49303. /**
  49304. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  49305. * Please note that only one query can be issued at a time
  49306. * @returns a time token used to track the time span
  49307. */
  49308. startTimeQuery(): Nullable<_TimeToken>;
  49309. /**
  49310. * Ends a time query
  49311. * @param token defines the token used to measure the time span
  49312. * @returns the time spent (in ns)
  49313. */
  49314. endTimeQuery(token: _TimeToken): int;
  49315. /** @hidden */
  49316. _currentNonTimestampToken: Nullable<_TimeToken>;
  49317. /** @hidden */
  49318. _createTimeQuery(): WebGLQuery;
  49319. /** @hidden */
  49320. _deleteTimeQuery(query: WebGLQuery): void;
  49321. /** @hidden */
  49322. _getGlAlgorithmType(algorithmType: number): number;
  49323. /** @hidden */
  49324. _getTimeQueryResult(query: WebGLQuery): any;
  49325. /** @hidden */
  49326. _getTimeQueryAvailability(query: WebGLQuery): any;
  49327. }
  49328. }
  49329. module "babylonjs/Meshes/abstractMesh" {
  49330. interface AbstractMesh {
  49331. /**
  49332. * Backing filed
  49333. * @hidden
  49334. */
  49335. __occlusionDataStorage: _OcclusionDataStorage;
  49336. /**
  49337. * Access property
  49338. * @hidden
  49339. */
  49340. _occlusionDataStorage: _OcclusionDataStorage;
  49341. /**
  49342. * 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.
  49343. * The default value is -1 which means don't break the query and wait till the result
  49344. * @see http://doc.babylonjs.com/features/occlusionquery
  49345. */
  49346. occlusionRetryCount: number;
  49347. /**
  49348. * 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:
  49349. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  49350. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  49351. * * 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.
  49352. * @see http://doc.babylonjs.com/features/occlusionquery
  49353. */
  49354. occlusionType: number;
  49355. /**
  49356. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  49357. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  49358. * * 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.
  49359. * @see http://doc.babylonjs.com/features/occlusionquery
  49360. */
  49361. occlusionQueryAlgorithmType: number;
  49362. /**
  49363. * 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
  49364. * @see http://doc.babylonjs.com/features/occlusionquery
  49365. */
  49366. isOccluded: boolean;
  49367. /**
  49368. * Flag to check the progress status of the query
  49369. * @see http://doc.babylonjs.com/features/occlusionquery
  49370. */
  49371. isOcclusionQueryInProgress: boolean;
  49372. }
  49373. }
  49374. }
  49375. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  49376. import { Nullable } from "babylonjs/types";
  49377. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49378. /** @hidden */
  49379. export var _forceTransformFeedbackToBundle: boolean;
  49380. module "babylonjs/Engines/engine" {
  49381. interface Engine {
  49382. /**
  49383. * Creates a webGL transform feedback object
  49384. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  49385. * @returns the webGL transform feedback object
  49386. */
  49387. createTransformFeedback(): WebGLTransformFeedback;
  49388. /**
  49389. * Delete a webGL transform feedback object
  49390. * @param value defines the webGL transform feedback object to delete
  49391. */
  49392. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  49393. /**
  49394. * Bind a webGL transform feedback object to the webgl context
  49395. * @param value defines the webGL transform feedback object to bind
  49396. */
  49397. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  49398. /**
  49399. * Begins a transform feedback operation
  49400. * @param usePoints defines if points or triangles must be used
  49401. */
  49402. beginTransformFeedback(usePoints: boolean): void;
  49403. /**
  49404. * Ends a transform feedback operation
  49405. */
  49406. endTransformFeedback(): void;
  49407. /**
  49408. * Specify the varyings to use with transform feedback
  49409. * @param program defines the associated webGL program
  49410. * @param value defines the list of strings representing the varying names
  49411. */
  49412. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  49413. /**
  49414. * Bind a webGL buffer for a transform feedback operation
  49415. * @param value defines the webGL buffer to bind
  49416. */
  49417. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  49418. }
  49419. }
  49420. }
  49421. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  49422. import { Scene } from "babylonjs/scene";
  49423. import { Engine } from "babylonjs/Engines/engine";
  49424. import { Texture } from "babylonjs/Materials/Textures/texture";
  49425. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49426. import "babylonjs/Engines/Extensions/engine.multiRender";
  49427. /**
  49428. * Creation options of the multi render target texture.
  49429. */
  49430. export interface IMultiRenderTargetOptions {
  49431. /**
  49432. * Define if the texture needs to create mip maps after render.
  49433. */
  49434. generateMipMaps?: boolean;
  49435. /**
  49436. * Define the types of all the draw buffers we want to create
  49437. */
  49438. types?: number[];
  49439. /**
  49440. * Define the sampling modes of all the draw buffers we want to create
  49441. */
  49442. samplingModes?: number[];
  49443. /**
  49444. * Define if a depth buffer is required
  49445. */
  49446. generateDepthBuffer?: boolean;
  49447. /**
  49448. * Define if a stencil buffer is required
  49449. */
  49450. generateStencilBuffer?: boolean;
  49451. /**
  49452. * Define if a depth texture is required instead of a depth buffer
  49453. */
  49454. generateDepthTexture?: boolean;
  49455. /**
  49456. * Define the number of desired draw buffers
  49457. */
  49458. textureCount?: number;
  49459. /**
  49460. * Define if aspect ratio should be adapted to the texture or stay the scene one
  49461. */
  49462. doNotChangeAspectRatio?: boolean;
  49463. /**
  49464. * Define the default type of the buffers we are creating
  49465. */
  49466. defaultType?: number;
  49467. }
  49468. /**
  49469. * A multi render target, like a render target provides the ability to render to a texture.
  49470. * Unlike the render target, it can render to several draw buffers in one draw.
  49471. * This is specially interesting in deferred rendering or for any effects requiring more than
  49472. * just one color from a single pass.
  49473. */
  49474. export class MultiRenderTarget extends RenderTargetTexture {
  49475. private _internalTextures;
  49476. private _textures;
  49477. private _multiRenderTargetOptions;
  49478. /**
  49479. * Get if draw buffers are currently supported by the used hardware and browser.
  49480. */
  49481. get isSupported(): boolean;
  49482. /**
  49483. * Get the list of textures generated by the multi render target.
  49484. */
  49485. get textures(): Texture[];
  49486. /**
  49487. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  49488. */
  49489. get depthTexture(): Texture;
  49490. /**
  49491. * Set the wrapping mode on U of all the textures we are rendering to.
  49492. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49493. */
  49494. set wrapU(wrap: number);
  49495. /**
  49496. * Set the wrapping mode on V of all the textures we are rendering to.
  49497. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49498. */
  49499. set wrapV(wrap: number);
  49500. /**
  49501. * Instantiate a new multi render target texture.
  49502. * A multi render target, like a render target provides the ability to render to a texture.
  49503. * Unlike the render target, it can render to several draw buffers in one draw.
  49504. * This is specially interesting in deferred rendering or for any effects requiring more than
  49505. * just one color from a single pass.
  49506. * @param name Define the name of the texture
  49507. * @param size Define the size of the buffers to render to
  49508. * @param count Define the number of target we are rendering into
  49509. * @param scene Define the scene the texture belongs to
  49510. * @param options Define the options used to create the multi render target
  49511. */
  49512. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  49513. /** @hidden */
  49514. _rebuild(): void;
  49515. private _createInternalTextures;
  49516. private _createTextures;
  49517. /**
  49518. * Define the number of samples used if MSAA is enabled.
  49519. */
  49520. get samples(): number;
  49521. set samples(value: number);
  49522. /**
  49523. * Resize all the textures in the multi render target.
  49524. * Be carrefull as it will recreate all the data in the new texture.
  49525. * @param size Define the new size
  49526. */
  49527. resize(size: any): void;
  49528. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  49529. /**
  49530. * Dispose the render targets and their associated resources
  49531. */
  49532. dispose(): void;
  49533. /**
  49534. * Release all the underlying texture used as draw buffers.
  49535. */
  49536. releaseInternalTextures(): void;
  49537. }
  49538. }
  49539. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  49540. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49541. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  49542. import { Nullable } from "babylonjs/types";
  49543. module "babylonjs/Engines/thinEngine" {
  49544. interface ThinEngine {
  49545. /**
  49546. * Unbind a list of render target textures from the webGL context
  49547. * This is used only when drawBuffer extension or webGL2 are active
  49548. * @param textures defines the render target textures to unbind
  49549. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  49550. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  49551. */
  49552. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  49553. /**
  49554. * Create a multi render target texture
  49555. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  49556. * @param size defines the size of the texture
  49557. * @param options defines the creation options
  49558. * @returns the cube texture as an InternalTexture
  49559. */
  49560. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  49561. /**
  49562. * Update the sample count for a given multiple render target texture
  49563. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  49564. * @param textures defines the textures to update
  49565. * @param samples defines the sample count to set
  49566. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  49567. */
  49568. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  49569. }
  49570. }
  49571. }
  49572. declare module "babylonjs/Engines/Extensions/engine.views" {
  49573. import { Camera } from "babylonjs/Cameras/camera";
  49574. import { Nullable } from "babylonjs/types";
  49575. /**
  49576. * Class used to define an additional view for the engine
  49577. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49578. */
  49579. export class EngineView {
  49580. /** Defines the canvas where to render the view */
  49581. target: HTMLCanvasElement;
  49582. /** Defines an optional camera used to render the view (will use active camera else) */
  49583. camera?: Camera;
  49584. }
  49585. module "babylonjs/Engines/engine" {
  49586. interface Engine {
  49587. /**
  49588. * Gets or sets the HTML element to use for attaching events
  49589. */
  49590. inputElement: Nullable<HTMLElement>;
  49591. /**
  49592. * Gets the current engine view
  49593. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49594. */
  49595. activeView: Nullable<EngineView>;
  49596. /** Gets or sets the list of views */
  49597. views: EngineView[];
  49598. /**
  49599. * Register a new child canvas
  49600. * @param canvas defines the canvas to register
  49601. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  49602. * @returns the associated view
  49603. */
  49604. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  49605. /**
  49606. * Remove a registered child canvas
  49607. * @param canvas defines the canvas to remove
  49608. * @returns the current engine
  49609. */
  49610. unRegisterView(canvas: HTMLCanvasElement): Engine;
  49611. }
  49612. }
  49613. }
  49614. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  49615. import { Nullable } from "babylonjs/types";
  49616. module "babylonjs/Engines/engine" {
  49617. interface Engine {
  49618. /** @hidden */
  49619. _excludedCompressedTextures: string[];
  49620. /** @hidden */
  49621. _textureFormatInUse: string;
  49622. /**
  49623. * Gets the list of texture formats supported
  49624. */
  49625. readonly texturesSupported: Array<string>;
  49626. /**
  49627. * Gets the texture format in use
  49628. */
  49629. readonly textureFormatInUse: Nullable<string>;
  49630. /**
  49631. * Set the compressed texture extensions or file names to skip.
  49632. *
  49633. * @param skippedFiles defines the list of those texture files you want to skip
  49634. * Example: [".dds", ".env", "myfile.png"]
  49635. */
  49636. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  49637. /**
  49638. * Set the compressed texture format to use, based on the formats you have, and the formats
  49639. * supported by the hardware / browser.
  49640. *
  49641. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  49642. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  49643. * to API arguments needed to compressed textures. This puts the burden on the container
  49644. * generator to house the arcane code for determining these for current & future formats.
  49645. *
  49646. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49647. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49648. *
  49649. * Note: The result of this call is not taken into account when a texture is base64.
  49650. *
  49651. * @param formatsAvailable defines the list of those format families you have created
  49652. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  49653. *
  49654. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  49655. * @returns The extension selected.
  49656. */
  49657. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  49658. }
  49659. }
  49660. }
  49661. declare module "babylonjs/Engines/Extensions/index" {
  49662. export * from "babylonjs/Engines/Extensions/engine.alpha";
  49663. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  49664. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  49665. export * from "babylonjs/Engines/Extensions/engine.multiview";
  49666. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  49667. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  49668. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  49669. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  49670. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  49671. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  49672. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49673. export * from "babylonjs/Engines/Extensions/engine.webVR";
  49674. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  49675. export * from "babylonjs/Engines/Extensions/engine.views";
  49676. import "babylonjs/Engines/Extensions/engine.textureSelector";
  49677. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  49678. }
  49679. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  49680. import { Nullable } from "babylonjs/types";
  49681. /**
  49682. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49683. */
  49684. export interface CubeMapInfo {
  49685. /**
  49686. * The pixel array for the front face.
  49687. * This is stored in format, left to right, up to down format.
  49688. */
  49689. front: Nullable<ArrayBufferView>;
  49690. /**
  49691. * The pixel array for the back face.
  49692. * This is stored in format, left to right, up to down format.
  49693. */
  49694. back: Nullable<ArrayBufferView>;
  49695. /**
  49696. * The pixel array for the left face.
  49697. * This is stored in format, left to right, up to down format.
  49698. */
  49699. left: Nullable<ArrayBufferView>;
  49700. /**
  49701. * The pixel array for the right face.
  49702. * This is stored in format, left to right, up to down format.
  49703. */
  49704. right: Nullable<ArrayBufferView>;
  49705. /**
  49706. * The pixel array for the up face.
  49707. * This is stored in format, left to right, up to down format.
  49708. */
  49709. up: Nullable<ArrayBufferView>;
  49710. /**
  49711. * The pixel array for the down face.
  49712. * This is stored in format, left to right, up to down format.
  49713. */
  49714. down: Nullable<ArrayBufferView>;
  49715. /**
  49716. * The size of the cubemap stored.
  49717. *
  49718. * Each faces will be size * size pixels.
  49719. */
  49720. size: number;
  49721. /**
  49722. * The format of the texture.
  49723. *
  49724. * RGBA, RGB.
  49725. */
  49726. format: number;
  49727. /**
  49728. * The type of the texture data.
  49729. *
  49730. * UNSIGNED_INT, FLOAT.
  49731. */
  49732. type: number;
  49733. /**
  49734. * Specifies whether the texture is in gamma space.
  49735. */
  49736. gammaSpace: boolean;
  49737. }
  49738. /**
  49739. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49740. */
  49741. export class PanoramaToCubeMapTools {
  49742. private static FACE_FRONT;
  49743. private static FACE_BACK;
  49744. private static FACE_RIGHT;
  49745. private static FACE_LEFT;
  49746. private static FACE_DOWN;
  49747. private static FACE_UP;
  49748. /**
  49749. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49750. *
  49751. * @param float32Array The source data.
  49752. * @param inputWidth The width of the input panorama.
  49753. * @param inputHeight The height of the input panorama.
  49754. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49755. * @return The cubemap data
  49756. */
  49757. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49758. private static CreateCubemapTexture;
  49759. private static CalcProjectionSpherical;
  49760. }
  49761. }
  49762. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49763. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49764. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49765. import { Nullable } from "babylonjs/types";
  49766. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49767. /**
  49768. * Helper class dealing with the extraction of spherical polynomial dataArray
  49769. * from a cube map.
  49770. */
  49771. export class CubeMapToSphericalPolynomialTools {
  49772. private static FileFaces;
  49773. /**
  49774. * Converts a texture to the according Spherical Polynomial data.
  49775. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49776. *
  49777. * @param texture The texture to extract the information from.
  49778. * @return The Spherical Polynomial data.
  49779. */
  49780. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49781. /**
  49782. * Converts a cubemap to the according Spherical Polynomial data.
  49783. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49784. *
  49785. * @param cubeInfo The Cube map to extract the information from.
  49786. * @return The Spherical Polynomial data.
  49787. */
  49788. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49789. }
  49790. }
  49791. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49792. import { Nullable } from "babylonjs/types";
  49793. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49794. module "babylonjs/Materials/Textures/baseTexture" {
  49795. interface BaseTexture {
  49796. /**
  49797. * Get the polynomial representation of the texture data.
  49798. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49799. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49800. */
  49801. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49802. }
  49803. }
  49804. }
  49805. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49806. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49807. /** @hidden */
  49808. export var rgbdEncodePixelShader: {
  49809. name: string;
  49810. shader: string;
  49811. };
  49812. }
  49813. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49814. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49815. /** @hidden */
  49816. export var rgbdDecodePixelShader: {
  49817. name: string;
  49818. shader: string;
  49819. };
  49820. }
  49821. declare module "babylonjs/Misc/environmentTextureTools" {
  49822. import { Nullable } from "babylonjs/types";
  49823. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49824. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49825. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49826. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49827. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49828. import "babylonjs/Shaders/rgbdEncode.fragment";
  49829. import "babylonjs/Shaders/rgbdDecode.fragment";
  49830. /**
  49831. * Raw texture data and descriptor sufficient for WebGL texture upload
  49832. */
  49833. export interface EnvironmentTextureInfo {
  49834. /**
  49835. * Version of the environment map
  49836. */
  49837. version: number;
  49838. /**
  49839. * Width of image
  49840. */
  49841. width: number;
  49842. /**
  49843. * Irradiance information stored in the file.
  49844. */
  49845. irradiance: any;
  49846. /**
  49847. * Specular information stored in the file.
  49848. */
  49849. specular: any;
  49850. }
  49851. /**
  49852. * Defines One Image in the file. It requires only the position in the file
  49853. * as well as the length.
  49854. */
  49855. interface BufferImageData {
  49856. /**
  49857. * Length of the image data.
  49858. */
  49859. length: number;
  49860. /**
  49861. * Position of the data from the null terminator delimiting the end of the JSON.
  49862. */
  49863. position: number;
  49864. }
  49865. /**
  49866. * Defines the specular data enclosed in the file.
  49867. * This corresponds to the version 1 of the data.
  49868. */
  49869. export interface EnvironmentTextureSpecularInfoV1 {
  49870. /**
  49871. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49872. */
  49873. specularDataPosition?: number;
  49874. /**
  49875. * This contains all the images data needed to reconstruct the cubemap.
  49876. */
  49877. mipmaps: Array<BufferImageData>;
  49878. /**
  49879. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49880. */
  49881. lodGenerationScale: number;
  49882. }
  49883. /**
  49884. * Sets of helpers addressing the serialization and deserialization of environment texture
  49885. * stored in a BabylonJS env file.
  49886. * Those files are usually stored as .env files.
  49887. */
  49888. export class EnvironmentTextureTools {
  49889. /**
  49890. * Magic number identifying the env file.
  49891. */
  49892. private static _MagicBytes;
  49893. /**
  49894. * Gets the environment info from an env file.
  49895. * @param data The array buffer containing the .env bytes.
  49896. * @returns the environment file info (the json header) if successfully parsed.
  49897. */
  49898. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  49899. /**
  49900. * Creates an environment texture from a loaded cube texture.
  49901. * @param texture defines the cube texture to convert in env file
  49902. * @return a promise containing the environment data if succesfull.
  49903. */
  49904. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49905. /**
  49906. * Creates a JSON representation of the spherical data.
  49907. * @param texture defines the texture containing the polynomials
  49908. * @return the JSON representation of the spherical info
  49909. */
  49910. private static _CreateEnvTextureIrradiance;
  49911. /**
  49912. * Creates the ArrayBufferViews used for initializing environment texture image data.
  49913. * @param data the image data
  49914. * @param info parameters that determine what views will be created for accessing the underlying buffer
  49915. * @return the views described by info providing access to the underlying buffer
  49916. */
  49917. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49918. /**
  49919. * Uploads the texture info contained in the env file to the GPU.
  49920. * @param texture defines the internal texture to upload to
  49921. * @param data defines the data to load
  49922. * @param info defines the texture info retrieved through the GetEnvInfo method
  49923. * @returns a promise
  49924. */
  49925. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  49926. private static _OnImageReadyAsync;
  49927. /**
  49928. * Uploads the levels of image data to the GPU.
  49929. * @param texture defines the internal texture to upload to
  49930. * @param imageData defines the array buffer views of image data [mipmap][face]
  49931. * @returns a promise
  49932. */
  49933. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49934. /**
  49935. * Uploads spherical polynomials information to the texture.
  49936. * @param texture defines the texture we are trying to upload the information to
  49937. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49938. */
  49939. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49940. /** @hidden */
  49941. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49942. }
  49943. }
  49944. declare module "babylonjs/Maths/math.vertexFormat" {
  49945. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49946. /**
  49947. * Contains position and normal vectors for a vertex
  49948. */
  49949. export class PositionNormalVertex {
  49950. /** the position of the vertex (defaut: 0,0,0) */
  49951. position: Vector3;
  49952. /** the normal of the vertex (defaut: 0,1,0) */
  49953. normal: Vector3;
  49954. /**
  49955. * Creates a PositionNormalVertex
  49956. * @param position the position of the vertex (defaut: 0,0,0)
  49957. * @param normal the normal of the vertex (defaut: 0,1,0)
  49958. */
  49959. constructor(
  49960. /** the position of the vertex (defaut: 0,0,0) */
  49961. position?: Vector3,
  49962. /** the normal of the vertex (defaut: 0,1,0) */
  49963. normal?: Vector3);
  49964. /**
  49965. * Clones the PositionNormalVertex
  49966. * @returns the cloned PositionNormalVertex
  49967. */
  49968. clone(): PositionNormalVertex;
  49969. }
  49970. /**
  49971. * Contains position, normal and uv vectors for a vertex
  49972. */
  49973. export class PositionNormalTextureVertex {
  49974. /** the position of the vertex (defaut: 0,0,0) */
  49975. position: Vector3;
  49976. /** the normal of the vertex (defaut: 0,1,0) */
  49977. normal: Vector3;
  49978. /** the uv of the vertex (default: 0,0) */
  49979. uv: Vector2;
  49980. /**
  49981. * Creates a PositionNormalTextureVertex
  49982. * @param position the position of the vertex (defaut: 0,0,0)
  49983. * @param normal the normal of the vertex (defaut: 0,1,0)
  49984. * @param uv the uv of the vertex (default: 0,0)
  49985. */
  49986. constructor(
  49987. /** the position of the vertex (defaut: 0,0,0) */
  49988. position?: Vector3,
  49989. /** the normal of the vertex (defaut: 0,1,0) */
  49990. normal?: Vector3,
  49991. /** the uv of the vertex (default: 0,0) */
  49992. uv?: Vector2);
  49993. /**
  49994. * Clones the PositionNormalTextureVertex
  49995. * @returns the cloned PositionNormalTextureVertex
  49996. */
  49997. clone(): PositionNormalTextureVertex;
  49998. }
  49999. }
  50000. declare module "babylonjs/Maths/math" {
  50001. export * from "babylonjs/Maths/math.axis";
  50002. export * from "babylonjs/Maths/math.color";
  50003. export * from "babylonjs/Maths/math.constants";
  50004. export * from "babylonjs/Maths/math.frustum";
  50005. export * from "babylonjs/Maths/math.path";
  50006. export * from "babylonjs/Maths/math.plane";
  50007. export * from "babylonjs/Maths/math.size";
  50008. export * from "babylonjs/Maths/math.vector";
  50009. export * from "babylonjs/Maths/math.vertexFormat";
  50010. export * from "babylonjs/Maths/math.viewport";
  50011. }
  50012. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  50013. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  50014. /** @hidden */
  50015. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  50016. private _genericAttributeLocation;
  50017. private _varyingLocationCount;
  50018. private _varyingLocationMap;
  50019. private _replacements;
  50020. private _textureCount;
  50021. private _uniforms;
  50022. lineProcessor(line: string): string;
  50023. attributeProcessor(attribute: string): string;
  50024. varyingProcessor(varying: string, isFragment: boolean): string;
  50025. uniformProcessor(uniform: string): string;
  50026. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  50027. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  50028. }
  50029. }
  50030. declare module "babylonjs/Engines/nativeEngine" {
  50031. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  50032. import { Engine } from "babylonjs/Engines/engine";
  50033. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  50034. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50035. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50036. import { Effect } from "babylonjs/Materials/effect";
  50037. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  50038. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  50039. import { IColor4Like } from "babylonjs/Maths/math.like";
  50040. import { Scene } from "babylonjs/scene";
  50041. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  50042. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  50043. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  50044. /**
  50045. * Container for accessors for natively-stored mesh data buffers.
  50046. */
  50047. class NativeDataBuffer extends DataBuffer {
  50048. /**
  50049. * Accessor value used to identify/retrieve a natively-stored index buffer.
  50050. */
  50051. nativeIndexBuffer?: any;
  50052. /**
  50053. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  50054. */
  50055. nativeVertexBuffer?: any;
  50056. }
  50057. /** @hidden */
  50058. class NativeTexture extends InternalTexture {
  50059. getInternalTexture(): InternalTexture;
  50060. getViewCount(): number;
  50061. }
  50062. /** @hidden */
  50063. export class NativeEngine extends Engine {
  50064. private readonly _native;
  50065. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  50066. private readonly INVALID_HANDLE;
  50067. getHardwareScalingLevel(): number;
  50068. constructor();
  50069. dispose(): void;
  50070. /**
  50071. * Can be used to override the current requestAnimationFrame requester.
  50072. * @hidden
  50073. */
  50074. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  50075. /**
  50076. * Override default engine behavior.
  50077. * @param color
  50078. * @param backBuffer
  50079. * @param depth
  50080. * @param stencil
  50081. */
  50082. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  50083. /**
  50084. * Gets host document
  50085. * @returns the host document object
  50086. */
  50087. getHostDocument(): Nullable<Document>;
  50088. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  50089. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  50090. createVertexBuffer(data: DataArray): NativeDataBuffer;
  50091. recordVertexArrayObject(vertexBuffers: {
  50092. [key: string]: VertexBuffer;
  50093. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  50094. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  50095. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  50096. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  50097. /**
  50098. * Draw a list of indexed primitives
  50099. * @param fillMode defines the primitive to use
  50100. * @param indexStart defines the starting index
  50101. * @param indexCount defines the number of index to draw
  50102. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50103. */
  50104. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  50105. /**
  50106. * Draw a list of unindexed primitives
  50107. * @param fillMode defines the primitive to use
  50108. * @param verticesStart defines the index of first vertex to draw
  50109. * @param verticesCount defines the count of vertices to draw
  50110. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50111. */
  50112. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  50113. createPipelineContext(): IPipelineContext;
  50114. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  50115. /** @hidden */
  50116. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  50117. /** @hidden */
  50118. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  50119. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  50120. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  50121. protected _setProgram(program: WebGLProgram): void;
  50122. _releaseEffect(effect: Effect): void;
  50123. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  50124. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  50125. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  50126. bindSamplers(effect: Effect): void;
  50127. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  50128. getRenderWidth(useScreen?: boolean): number;
  50129. getRenderHeight(useScreen?: boolean): number;
  50130. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  50131. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  50132. /**
  50133. * Set the z offset to apply to current rendering
  50134. * @param value defines the offset to apply
  50135. */
  50136. setZOffset(value: number): void;
  50137. /**
  50138. * Gets the current value of the zOffset
  50139. * @returns the current zOffset state
  50140. */
  50141. getZOffset(): number;
  50142. /**
  50143. * Enable or disable depth buffering
  50144. * @param enable defines the state to set
  50145. */
  50146. setDepthBuffer(enable: boolean): void;
  50147. /**
  50148. * Gets a boolean indicating if depth writing is enabled
  50149. * @returns the current depth writing state
  50150. */
  50151. getDepthWrite(): boolean;
  50152. /**
  50153. * Enable or disable depth writing
  50154. * @param enable defines the state to set
  50155. */
  50156. setDepthWrite(enable: boolean): void;
  50157. /**
  50158. * Enable or disable color writing
  50159. * @param enable defines the state to set
  50160. */
  50161. setColorWrite(enable: boolean): void;
  50162. /**
  50163. * Gets a boolean indicating if color writing is enabled
  50164. * @returns the current color writing state
  50165. */
  50166. getColorWrite(): boolean;
  50167. /**
  50168. * Sets alpha constants used by some alpha blending modes
  50169. * @param r defines the red component
  50170. * @param g defines the green component
  50171. * @param b defines the blue component
  50172. * @param a defines the alpha component
  50173. */
  50174. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  50175. /**
  50176. * Sets the current alpha mode
  50177. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  50178. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  50179. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50180. */
  50181. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  50182. /**
  50183. * Gets the current alpha mode
  50184. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50185. * @returns the current alpha mode
  50186. */
  50187. getAlphaMode(): number;
  50188. setInt(uniform: WebGLUniformLocation, int: number): void;
  50189. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50190. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50191. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50192. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50193. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50194. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50195. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50196. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50197. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50198. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50199. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50200. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50201. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50202. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50203. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50204. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50205. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50206. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50207. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50208. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  50209. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  50210. wipeCaches(bruteForce?: boolean): void;
  50211. _createTexture(): WebGLTexture;
  50212. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  50213. /**
  50214. * Usually called from Texture.ts.
  50215. * Passed information to create a WebGLTexture
  50216. * @param url defines a value which contains one of the following:
  50217. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50218. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50219. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50220. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50221. * @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)
  50222. * @param scene needed for loading to the correct scene
  50223. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50224. * @param onLoad optional callback to be called upon successful completion
  50225. * @param onError optional callback to be called upon failure
  50226. * @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
  50227. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50228. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50229. * @param forcedExtension defines the extension to use to pick the right loader
  50230. * @param mimeType defines an optional mime type
  50231. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50232. */
  50233. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  50234. /**
  50235. * Creates a cube texture
  50236. * @param rootUrl defines the url where the files to load is located
  50237. * @param scene defines the current scene
  50238. * @param files defines the list of files to load (1 per face)
  50239. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  50240. * @param onLoad defines an optional callback raised when the texture is loaded
  50241. * @param onError defines an optional callback raised if there is an issue to load the texture
  50242. * @param format defines the format of the data
  50243. * @param forcedExtension defines the extension to use to pick the right loader
  50244. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  50245. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50246. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50247. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  50248. * @returns the cube texture as an InternalTexture
  50249. */
  50250. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  50251. private _getSamplingFilter;
  50252. private static _GetNativeTextureFormat;
  50253. createRenderTargetTexture(size: number | {
  50254. width: number;
  50255. height: number;
  50256. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  50257. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50258. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50259. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50260. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  50261. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  50262. /**
  50263. * Updates a dynamic vertex buffer.
  50264. * @param vertexBuffer the vertex buffer to update
  50265. * @param data the data used to update the vertex buffer
  50266. * @param byteOffset the byte offset of the data (optional)
  50267. * @param byteLength the byte length of the data (optional)
  50268. */
  50269. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  50270. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  50271. private _updateAnisotropicLevel;
  50272. private _getAddressMode;
  50273. /** @hidden */
  50274. _bindTexture(channel: number, texture: InternalTexture): void;
  50275. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  50276. releaseEffects(): void;
  50277. /** @hidden */
  50278. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50279. /** @hidden */
  50280. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50281. /** @hidden */
  50282. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50283. /** @hidden */
  50284. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50285. }
  50286. }
  50287. declare module "babylonjs/Engines/index" {
  50288. export * from "babylonjs/Engines/constants";
  50289. export * from "babylonjs/Engines/engineCapabilities";
  50290. export * from "babylonjs/Engines/instancingAttributeInfo";
  50291. export * from "babylonjs/Engines/thinEngine";
  50292. export * from "babylonjs/Engines/engine";
  50293. export * from "babylonjs/Engines/engineStore";
  50294. export * from "babylonjs/Engines/nullEngine";
  50295. export * from "babylonjs/Engines/Extensions/index";
  50296. export * from "babylonjs/Engines/IPipelineContext";
  50297. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  50298. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  50299. export * from "babylonjs/Engines/nativeEngine";
  50300. }
  50301. declare module "babylonjs/Events/clipboardEvents" {
  50302. /**
  50303. * Gather the list of clipboard event types as constants.
  50304. */
  50305. export class ClipboardEventTypes {
  50306. /**
  50307. * The clipboard event is fired when a copy command is active (pressed).
  50308. */
  50309. static readonly COPY: number;
  50310. /**
  50311. * The clipboard event is fired when a cut command is active (pressed).
  50312. */
  50313. static readonly CUT: number;
  50314. /**
  50315. * The clipboard event is fired when a paste command is active (pressed).
  50316. */
  50317. static readonly PASTE: number;
  50318. }
  50319. /**
  50320. * This class is used to store clipboard related info for the onClipboardObservable event.
  50321. */
  50322. export class ClipboardInfo {
  50323. /**
  50324. * Defines the type of event (BABYLON.ClipboardEventTypes)
  50325. */
  50326. type: number;
  50327. /**
  50328. * Defines the related dom event
  50329. */
  50330. event: ClipboardEvent;
  50331. /**
  50332. *Creates an instance of ClipboardInfo.
  50333. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  50334. * @param event Defines the related dom event
  50335. */
  50336. constructor(
  50337. /**
  50338. * Defines the type of event (BABYLON.ClipboardEventTypes)
  50339. */
  50340. type: number,
  50341. /**
  50342. * Defines the related dom event
  50343. */
  50344. event: ClipboardEvent);
  50345. /**
  50346. * Get the clipboard event's type from the keycode.
  50347. * @param keyCode Defines the keyCode for the current keyboard event.
  50348. * @return {number}
  50349. */
  50350. static GetTypeFromCharacter(keyCode: number): number;
  50351. }
  50352. }
  50353. declare module "babylonjs/Events/index" {
  50354. export * from "babylonjs/Events/keyboardEvents";
  50355. export * from "babylonjs/Events/pointerEvents";
  50356. export * from "babylonjs/Events/clipboardEvents";
  50357. }
  50358. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  50359. import { Scene } from "babylonjs/scene";
  50360. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50361. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50362. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50363. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50364. /**
  50365. * Google Daydream controller
  50366. */
  50367. export class DaydreamController extends WebVRController {
  50368. /**
  50369. * Base Url for the controller model.
  50370. */
  50371. static MODEL_BASE_URL: string;
  50372. /**
  50373. * File name for the controller model.
  50374. */
  50375. static MODEL_FILENAME: string;
  50376. /**
  50377. * Gamepad Id prefix used to identify Daydream Controller.
  50378. */
  50379. static readonly GAMEPAD_ID_PREFIX: string;
  50380. /**
  50381. * Creates a new DaydreamController from a gamepad
  50382. * @param vrGamepad the gamepad that the controller should be created from
  50383. */
  50384. constructor(vrGamepad: any);
  50385. /**
  50386. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50387. * @param scene scene in which to add meshes
  50388. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50389. */
  50390. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50391. /**
  50392. * Called once for each button that changed state since the last frame
  50393. * @param buttonIdx Which button index changed
  50394. * @param state New state of the button
  50395. * @param changes Which properties on the state changed since last frame
  50396. */
  50397. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50398. }
  50399. }
  50400. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  50401. import { Scene } from "babylonjs/scene";
  50402. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50403. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50404. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50405. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50406. /**
  50407. * Gear VR Controller
  50408. */
  50409. export class GearVRController extends WebVRController {
  50410. /**
  50411. * Base Url for the controller model.
  50412. */
  50413. static MODEL_BASE_URL: string;
  50414. /**
  50415. * File name for the controller model.
  50416. */
  50417. static MODEL_FILENAME: string;
  50418. /**
  50419. * Gamepad Id prefix used to identify this controller.
  50420. */
  50421. static readonly GAMEPAD_ID_PREFIX: string;
  50422. private readonly _buttonIndexToObservableNameMap;
  50423. /**
  50424. * Creates a new GearVRController from a gamepad
  50425. * @param vrGamepad the gamepad that the controller should be created from
  50426. */
  50427. constructor(vrGamepad: any);
  50428. /**
  50429. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50430. * @param scene scene in which to add meshes
  50431. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50432. */
  50433. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50434. /**
  50435. * Called once for each button that changed state since the last frame
  50436. * @param buttonIdx Which button index changed
  50437. * @param state New state of the button
  50438. * @param changes Which properties on the state changed since last frame
  50439. */
  50440. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50441. }
  50442. }
  50443. declare module "babylonjs/Gamepads/Controllers/genericController" {
  50444. import { Scene } from "babylonjs/scene";
  50445. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50446. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50447. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50448. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50449. /**
  50450. * Generic Controller
  50451. */
  50452. export class GenericController extends WebVRController {
  50453. /**
  50454. * Base Url for the controller model.
  50455. */
  50456. static readonly MODEL_BASE_URL: string;
  50457. /**
  50458. * File name for the controller model.
  50459. */
  50460. static readonly MODEL_FILENAME: string;
  50461. /**
  50462. * Creates a new GenericController from a gamepad
  50463. * @param vrGamepad the gamepad that the controller should be created from
  50464. */
  50465. constructor(vrGamepad: any);
  50466. /**
  50467. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50468. * @param scene scene in which to add meshes
  50469. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50470. */
  50471. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50472. /**
  50473. * Called once for each button that changed state since the last frame
  50474. * @param buttonIdx Which button index changed
  50475. * @param state New state of the button
  50476. * @param changes Which properties on the state changed since last frame
  50477. */
  50478. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50479. }
  50480. }
  50481. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  50482. import { Observable } from "babylonjs/Misc/observable";
  50483. import { Scene } from "babylonjs/scene";
  50484. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50485. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50486. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50487. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50488. /**
  50489. * Oculus Touch Controller
  50490. */
  50491. export class OculusTouchController extends WebVRController {
  50492. /**
  50493. * Base Url for the controller model.
  50494. */
  50495. static MODEL_BASE_URL: string;
  50496. /**
  50497. * File name for the left controller model.
  50498. */
  50499. static MODEL_LEFT_FILENAME: string;
  50500. /**
  50501. * File name for the right controller model.
  50502. */
  50503. static MODEL_RIGHT_FILENAME: string;
  50504. /**
  50505. * Base Url for the Quest controller model.
  50506. */
  50507. static QUEST_MODEL_BASE_URL: string;
  50508. /**
  50509. * @hidden
  50510. * If the controllers are running on a device that needs the updated Quest controller models
  50511. */
  50512. static _IsQuest: boolean;
  50513. /**
  50514. * Fired when the secondary trigger on this controller is modified
  50515. */
  50516. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  50517. /**
  50518. * Fired when the thumb rest on this controller is modified
  50519. */
  50520. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  50521. /**
  50522. * Creates a new OculusTouchController from a gamepad
  50523. * @param vrGamepad the gamepad that the controller should be created from
  50524. */
  50525. constructor(vrGamepad: any);
  50526. /**
  50527. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50528. * @param scene scene in which to add meshes
  50529. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50530. */
  50531. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50532. /**
  50533. * Fired when the A button on this controller is modified
  50534. */
  50535. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50536. /**
  50537. * Fired when the B button on this controller is modified
  50538. */
  50539. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50540. /**
  50541. * Fired when the X button on this controller is modified
  50542. */
  50543. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50544. /**
  50545. * Fired when the Y button on this controller is modified
  50546. */
  50547. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50548. /**
  50549. * Called once for each button that changed state since the last frame
  50550. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  50551. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  50552. * 2) secondary trigger (same)
  50553. * 3) A (right) X (left), touch, pressed = value
  50554. * 4) B / Y
  50555. * 5) thumb rest
  50556. * @param buttonIdx Which button index changed
  50557. * @param state New state of the button
  50558. * @param changes Which properties on the state changed since last frame
  50559. */
  50560. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50561. }
  50562. }
  50563. declare module "babylonjs/Gamepads/Controllers/viveController" {
  50564. import { Scene } from "babylonjs/scene";
  50565. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50566. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50567. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50568. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50569. import { Observable } from "babylonjs/Misc/observable";
  50570. /**
  50571. * Vive Controller
  50572. */
  50573. export class ViveController extends WebVRController {
  50574. /**
  50575. * Base Url for the controller model.
  50576. */
  50577. static MODEL_BASE_URL: string;
  50578. /**
  50579. * File name for the controller model.
  50580. */
  50581. static MODEL_FILENAME: string;
  50582. /**
  50583. * Creates a new ViveController from a gamepad
  50584. * @param vrGamepad the gamepad that the controller should be created from
  50585. */
  50586. constructor(vrGamepad: any);
  50587. /**
  50588. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50589. * @param scene scene in which to add meshes
  50590. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50591. */
  50592. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50593. /**
  50594. * Fired when the left button on this controller is modified
  50595. */
  50596. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50597. /**
  50598. * Fired when the right button on this controller is modified
  50599. */
  50600. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50601. /**
  50602. * Fired when the menu button on this controller is modified
  50603. */
  50604. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50605. /**
  50606. * Called once for each button that changed state since the last frame
  50607. * Vive mapping:
  50608. * 0: touchpad
  50609. * 1: trigger
  50610. * 2: left AND right buttons
  50611. * 3: menu button
  50612. * @param buttonIdx Which button index changed
  50613. * @param state New state of the button
  50614. * @param changes Which properties on the state changed since last frame
  50615. */
  50616. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50617. }
  50618. }
  50619. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  50620. import { Observable } from "babylonjs/Misc/observable";
  50621. import { Scene } from "babylonjs/scene";
  50622. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50623. import { Ray } from "babylonjs/Culling/ray";
  50624. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50625. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50626. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50627. /**
  50628. * Defines the WindowsMotionController object that the state of the windows motion controller
  50629. */
  50630. export class WindowsMotionController extends WebVRController {
  50631. /**
  50632. * The base url used to load the left and right controller models
  50633. */
  50634. static MODEL_BASE_URL: string;
  50635. /**
  50636. * The name of the left controller model file
  50637. */
  50638. static MODEL_LEFT_FILENAME: string;
  50639. /**
  50640. * The name of the right controller model file
  50641. */
  50642. static MODEL_RIGHT_FILENAME: string;
  50643. /**
  50644. * The controller name prefix for this controller type
  50645. */
  50646. static readonly GAMEPAD_ID_PREFIX: string;
  50647. /**
  50648. * The controller id pattern for this controller type
  50649. */
  50650. private static readonly GAMEPAD_ID_PATTERN;
  50651. private _loadedMeshInfo;
  50652. protected readonly _mapping: {
  50653. buttons: string[];
  50654. buttonMeshNames: {
  50655. trigger: string;
  50656. menu: string;
  50657. grip: string;
  50658. thumbstick: string;
  50659. trackpad: string;
  50660. };
  50661. buttonObservableNames: {
  50662. trigger: string;
  50663. menu: string;
  50664. grip: string;
  50665. thumbstick: string;
  50666. trackpad: string;
  50667. };
  50668. axisMeshNames: string[];
  50669. pointingPoseMeshName: string;
  50670. };
  50671. /**
  50672. * Fired when the trackpad on this controller is clicked
  50673. */
  50674. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50675. /**
  50676. * Fired when the trackpad on this controller is modified
  50677. */
  50678. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50679. /**
  50680. * The current x and y values of this controller's trackpad
  50681. */
  50682. trackpad: StickValues;
  50683. /**
  50684. * Creates a new WindowsMotionController from a gamepad
  50685. * @param vrGamepad the gamepad that the controller should be created from
  50686. */
  50687. constructor(vrGamepad: any);
  50688. /**
  50689. * Fired when the trigger on this controller is modified
  50690. */
  50691. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50692. /**
  50693. * Fired when the menu button on this controller is modified
  50694. */
  50695. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50696. /**
  50697. * Fired when the grip button on this controller is modified
  50698. */
  50699. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50700. /**
  50701. * Fired when the thumbstick button on this controller is modified
  50702. */
  50703. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50704. /**
  50705. * Fired when the touchpad button on this controller is modified
  50706. */
  50707. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50708. /**
  50709. * Fired when the touchpad values on this controller are modified
  50710. */
  50711. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50712. protected _updateTrackpad(): void;
  50713. /**
  50714. * Called once per frame by the engine.
  50715. */
  50716. update(): void;
  50717. /**
  50718. * Called once for each button that changed state since the last frame
  50719. * @param buttonIdx Which button index changed
  50720. * @param state New state of the button
  50721. * @param changes Which properties on the state changed since last frame
  50722. */
  50723. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50724. /**
  50725. * Moves the buttons on the controller mesh based on their current state
  50726. * @param buttonName the name of the button to move
  50727. * @param buttonValue the value of the button which determines the buttons new position
  50728. */
  50729. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50730. /**
  50731. * Moves the axis on the controller mesh based on its current state
  50732. * @param axis the index of the axis
  50733. * @param axisValue the value of the axis which determines the meshes new position
  50734. * @hidden
  50735. */
  50736. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50737. /**
  50738. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50739. * @param scene scene in which to add meshes
  50740. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50741. */
  50742. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50743. /**
  50744. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50745. * can be transformed by button presses and axes values, based on this._mapping.
  50746. *
  50747. * @param scene scene in which the meshes exist
  50748. * @param meshes list of meshes that make up the controller model to process
  50749. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50750. */
  50751. private processModel;
  50752. private createMeshInfo;
  50753. /**
  50754. * Gets the ray of the controller in the direction the controller is pointing
  50755. * @param length the length the resulting ray should be
  50756. * @returns a ray in the direction the controller is pointing
  50757. */
  50758. getForwardRay(length?: number): Ray;
  50759. /**
  50760. * Disposes of the controller
  50761. */
  50762. dispose(): void;
  50763. }
  50764. /**
  50765. * This class represents a new windows motion controller in XR.
  50766. */
  50767. export class XRWindowsMotionController extends WindowsMotionController {
  50768. /**
  50769. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50770. */
  50771. protected readonly _mapping: {
  50772. buttons: string[];
  50773. buttonMeshNames: {
  50774. trigger: string;
  50775. menu: string;
  50776. grip: string;
  50777. thumbstick: string;
  50778. trackpad: string;
  50779. };
  50780. buttonObservableNames: {
  50781. trigger: string;
  50782. menu: string;
  50783. grip: string;
  50784. thumbstick: string;
  50785. trackpad: string;
  50786. };
  50787. axisMeshNames: string[];
  50788. pointingPoseMeshName: string;
  50789. };
  50790. /**
  50791. * Construct a new XR-Based windows motion controller
  50792. *
  50793. * @param gamepadInfo the gamepad object from the browser
  50794. */
  50795. constructor(gamepadInfo: any);
  50796. /**
  50797. * holds the thumbstick values (X,Y)
  50798. */
  50799. thumbstickValues: StickValues;
  50800. /**
  50801. * Fired when the thumbstick on this controller is clicked
  50802. */
  50803. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50804. /**
  50805. * Fired when the thumbstick on this controller is modified
  50806. */
  50807. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50808. /**
  50809. * Fired when the touchpad button on this controller is modified
  50810. */
  50811. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50812. /**
  50813. * Fired when the touchpad values on this controller are modified
  50814. */
  50815. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50816. /**
  50817. * Fired when the thumbstick button on this controller is modified
  50818. * here to prevent breaking changes
  50819. */
  50820. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50821. /**
  50822. * updating the thumbstick(!) and not the trackpad.
  50823. * This is named this way due to the difference between WebVR and XR and to avoid
  50824. * changing the parent class.
  50825. */
  50826. protected _updateTrackpad(): void;
  50827. /**
  50828. * Disposes the class with joy
  50829. */
  50830. dispose(): void;
  50831. }
  50832. }
  50833. declare module "babylonjs/Gamepads/Controllers/index" {
  50834. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50835. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50836. export * from "babylonjs/Gamepads/Controllers/genericController";
  50837. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50838. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50839. export * from "babylonjs/Gamepads/Controllers/viveController";
  50840. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50841. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50842. }
  50843. declare module "babylonjs/Gamepads/index" {
  50844. export * from "babylonjs/Gamepads/Controllers/index";
  50845. export * from "babylonjs/Gamepads/gamepad";
  50846. export * from "babylonjs/Gamepads/gamepadManager";
  50847. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50848. export * from "babylonjs/Gamepads/xboxGamepad";
  50849. export * from "babylonjs/Gamepads/dualShockGamepad";
  50850. }
  50851. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50852. import { Scene } from "babylonjs/scene";
  50853. import { Vector4 } from "babylonjs/Maths/math.vector";
  50854. import { Color4 } from "babylonjs/Maths/math.color";
  50855. import { Mesh } from "babylonjs/Meshes/mesh";
  50856. import { Nullable } from "babylonjs/types";
  50857. /**
  50858. * Class containing static functions to help procedurally build meshes
  50859. */
  50860. export class PolyhedronBuilder {
  50861. /**
  50862. * Creates a polyhedron mesh
  50863. * * 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
  50864. * * The parameter `size` (positive float, default 1) sets the polygon size
  50865. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50866. * * 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`
  50867. * * 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
  50868. * * 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)`)
  50869. * * 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
  50870. * * 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
  50871. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50872. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50874. * @param name defines the name of the mesh
  50875. * @param options defines the options used to create the mesh
  50876. * @param scene defines the hosting scene
  50877. * @returns the polyhedron mesh
  50878. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50879. */
  50880. static CreatePolyhedron(name: string, options: {
  50881. type?: number;
  50882. size?: number;
  50883. sizeX?: number;
  50884. sizeY?: number;
  50885. sizeZ?: number;
  50886. custom?: any;
  50887. faceUV?: Vector4[];
  50888. faceColors?: Color4[];
  50889. flat?: boolean;
  50890. updatable?: boolean;
  50891. sideOrientation?: number;
  50892. frontUVs?: Vector4;
  50893. backUVs?: Vector4;
  50894. }, scene?: Nullable<Scene>): Mesh;
  50895. }
  50896. }
  50897. declare module "babylonjs/Gizmos/scaleGizmo" {
  50898. import { Observable } from "babylonjs/Misc/observable";
  50899. import { Nullable } from "babylonjs/types";
  50900. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50901. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50902. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50903. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50904. /**
  50905. * Gizmo that enables scaling a mesh along 3 axis
  50906. */
  50907. export class ScaleGizmo extends Gizmo {
  50908. /**
  50909. * Internal gizmo used for interactions on the x axis
  50910. */
  50911. xGizmo: AxisScaleGizmo;
  50912. /**
  50913. * Internal gizmo used for interactions on the y axis
  50914. */
  50915. yGizmo: AxisScaleGizmo;
  50916. /**
  50917. * Internal gizmo used for interactions on the z axis
  50918. */
  50919. zGizmo: AxisScaleGizmo;
  50920. /**
  50921. * Internal gizmo used to scale all axis equally
  50922. */
  50923. uniformScaleGizmo: AxisScaleGizmo;
  50924. private _meshAttached;
  50925. private _updateGizmoRotationToMatchAttachedMesh;
  50926. private _snapDistance;
  50927. private _scaleRatio;
  50928. private _uniformScalingMesh;
  50929. private _octahedron;
  50930. private _sensitivity;
  50931. /** Fires an event when any of it's sub gizmos are dragged */
  50932. onDragStartObservable: Observable<unknown>;
  50933. /** Fires an event when any of it's sub gizmos are released from dragging */
  50934. onDragEndObservable: Observable<unknown>;
  50935. get attachedMesh(): Nullable<AbstractMesh>;
  50936. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50937. /**
  50938. * Creates a ScaleGizmo
  50939. * @param gizmoLayer The utility layer the gizmo will be added to
  50940. */
  50941. constructor(gizmoLayer?: UtilityLayerRenderer);
  50942. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50943. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50944. /**
  50945. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50946. */
  50947. set snapDistance(value: number);
  50948. get snapDistance(): number;
  50949. /**
  50950. * Ratio for the scale of the gizmo (Default: 1)
  50951. */
  50952. set scaleRatio(value: number);
  50953. get scaleRatio(): number;
  50954. /**
  50955. * Sensitivity factor for dragging (Default: 1)
  50956. */
  50957. set sensitivity(value: number);
  50958. get sensitivity(): number;
  50959. /**
  50960. * Disposes of the gizmo
  50961. */
  50962. dispose(): void;
  50963. }
  50964. }
  50965. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50966. import { Observable } from "babylonjs/Misc/observable";
  50967. import { Nullable } from "babylonjs/types";
  50968. import { Vector3 } from "babylonjs/Maths/math.vector";
  50969. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50970. import { Mesh } from "babylonjs/Meshes/mesh";
  50971. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50972. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50973. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50974. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50975. import { Color3 } from "babylonjs/Maths/math.color";
  50976. /**
  50977. * Single axis scale gizmo
  50978. */
  50979. export class AxisScaleGizmo extends Gizmo {
  50980. /**
  50981. * Drag behavior responsible for the gizmos dragging interactions
  50982. */
  50983. dragBehavior: PointerDragBehavior;
  50984. private _pointerObserver;
  50985. /**
  50986. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50987. */
  50988. snapDistance: number;
  50989. /**
  50990. * Event that fires each time the gizmo snaps to a new location.
  50991. * * snapDistance is the the change in distance
  50992. */
  50993. onSnapObservable: Observable<{
  50994. snapDistance: number;
  50995. }>;
  50996. /**
  50997. * If the scaling operation should be done on all axis (default: false)
  50998. */
  50999. uniformScaling: boolean;
  51000. /**
  51001. * Custom sensitivity value for the drag strength
  51002. */
  51003. sensitivity: number;
  51004. private _isEnabled;
  51005. private _parent;
  51006. private _arrow;
  51007. private _coloredMaterial;
  51008. private _hoverMaterial;
  51009. /**
  51010. * Creates an AxisScaleGizmo
  51011. * @param gizmoLayer The utility layer the gizmo will be added to
  51012. * @param dragAxis The axis which the gizmo will be able to scale on
  51013. * @param color The color of the gizmo
  51014. */
  51015. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  51016. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51017. /**
  51018. * If the gizmo is enabled
  51019. */
  51020. set isEnabled(value: boolean);
  51021. get isEnabled(): boolean;
  51022. /**
  51023. * Disposes of the gizmo
  51024. */
  51025. dispose(): void;
  51026. /**
  51027. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  51028. * @param mesh The mesh to replace the default mesh of the gizmo
  51029. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  51030. */
  51031. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  51032. }
  51033. }
  51034. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  51035. import { Observable } from "babylonjs/Misc/observable";
  51036. import { Nullable } from "babylonjs/types";
  51037. import { Vector3 } from "babylonjs/Maths/math.vector";
  51038. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51039. import { Mesh } from "babylonjs/Meshes/mesh";
  51040. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51041. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51042. import { Color3 } from "babylonjs/Maths/math.color";
  51043. import "babylonjs/Meshes/Builders/boxBuilder";
  51044. /**
  51045. * Bounding box gizmo
  51046. */
  51047. export class BoundingBoxGizmo extends Gizmo {
  51048. private _lineBoundingBox;
  51049. private _rotateSpheresParent;
  51050. private _scaleBoxesParent;
  51051. private _boundingDimensions;
  51052. private _renderObserver;
  51053. private _pointerObserver;
  51054. private _scaleDragSpeed;
  51055. private _tmpQuaternion;
  51056. private _tmpVector;
  51057. private _tmpRotationMatrix;
  51058. /**
  51059. * 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)
  51060. */
  51061. ignoreChildren: boolean;
  51062. /**
  51063. * 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)
  51064. */
  51065. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  51066. /**
  51067. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  51068. */
  51069. rotationSphereSize: number;
  51070. /**
  51071. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  51072. */
  51073. scaleBoxSize: number;
  51074. /**
  51075. * 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)
  51076. */
  51077. fixedDragMeshScreenSize: boolean;
  51078. /**
  51079. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  51080. */
  51081. fixedDragMeshScreenSizeDistanceFactor: number;
  51082. /**
  51083. * Fired when a rotation sphere or scale box is dragged
  51084. */
  51085. onDragStartObservable: Observable<{}>;
  51086. /**
  51087. * Fired when a scale box is dragged
  51088. */
  51089. onScaleBoxDragObservable: Observable<{}>;
  51090. /**
  51091. * Fired when a scale box drag is ended
  51092. */
  51093. onScaleBoxDragEndObservable: Observable<{}>;
  51094. /**
  51095. * Fired when a rotation sphere is dragged
  51096. */
  51097. onRotationSphereDragObservable: Observable<{}>;
  51098. /**
  51099. * Fired when a rotation sphere drag is ended
  51100. */
  51101. onRotationSphereDragEndObservable: Observable<{}>;
  51102. /**
  51103. * 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)
  51104. */
  51105. scalePivot: Nullable<Vector3>;
  51106. /**
  51107. * Mesh used as a pivot to rotate the attached mesh
  51108. */
  51109. private _anchorMesh;
  51110. private _existingMeshScale;
  51111. private _dragMesh;
  51112. private pointerDragBehavior;
  51113. private coloredMaterial;
  51114. private hoverColoredMaterial;
  51115. /**
  51116. * Sets the color of the bounding box gizmo
  51117. * @param color the color to set
  51118. */
  51119. setColor(color: Color3): void;
  51120. /**
  51121. * Creates an BoundingBoxGizmo
  51122. * @param gizmoLayer The utility layer the gizmo will be added to
  51123. * @param color The color of the gizmo
  51124. */
  51125. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  51126. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51127. private _selectNode;
  51128. /**
  51129. * Updates the bounding box information for the Gizmo
  51130. */
  51131. updateBoundingBox(): void;
  51132. private _updateRotationSpheres;
  51133. private _updateScaleBoxes;
  51134. /**
  51135. * Enables rotation on the specified axis and disables rotation on the others
  51136. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  51137. */
  51138. setEnabledRotationAxis(axis: string): void;
  51139. /**
  51140. * Enables/disables scaling
  51141. * @param enable if scaling should be enabled
  51142. * @param homogeneousScaling defines if scaling should only be homogeneous
  51143. */
  51144. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  51145. private _updateDummy;
  51146. /**
  51147. * Enables a pointer drag behavior on the bounding box of the gizmo
  51148. */
  51149. enableDragBehavior(): void;
  51150. /**
  51151. * Disposes of the gizmo
  51152. */
  51153. dispose(): void;
  51154. /**
  51155. * 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)
  51156. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  51157. * @returns the bounding box mesh with the passed in mesh as a child
  51158. */
  51159. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  51160. /**
  51161. * CustomMeshes are not supported by this gizmo
  51162. * @param mesh The mesh to replace the default mesh of the gizmo
  51163. */
  51164. setCustomMesh(mesh: Mesh): void;
  51165. }
  51166. }
  51167. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  51168. import { Observable } from "babylonjs/Misc/observable";
  51169. import { Nullable } from "babylonjs/types";
  51170. import { Vector3 } from "babylonjs/Maths/math.vector";
  51171. import { Color3 } from "babylonjs/Maths/math.color";
  51172. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51173. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51174. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51175. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51176. import "babylonjs/Meshes/Builders/linesBuilder";
  51177. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  51178. /**
  51179. * Single plane rotation gizmo
  51180. */
  51181. export class PlaneRotationGizmo extends Gizmo {
  51182. /**
  51183. * Drag behavior responsible for the gizmos dragging interactions
  51184. */
  51185. dragBehavior: PointerDragBehavior;
  51186. private _pointerObserver;
  51187. /**
  51188. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  51189. */
  51190. snapDistance: number;
  51191. /**
  51192. * Event that fires each time the gizmo snaps to a new location.
  51193. * * snapDistance is the the change in distance
  51194. */
  51195. onSnapObservable: Observable<{
  51196. snapDistance: number;
  51197. }>;
  51198. private _isEnabled;
  51199. private _parent;
  51200. /**
  51201. * Creates a PlaneRotationGizmo
  51202. * @param gizmoLayer The utility layer the gizmo will be added to
  51203. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  51204. * @param color The color of the gizmo
  51205. * @param tessellation Amount of tessellation to be used when creating rotation circles
  51206. * @param useEulerRotation Use and update Euler angle instead of quaternion
  51207. */
  51208. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  51209. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51210. /**
  51211. * If the gizmo is enabled
  51212. */
  51213. set isEnabled(value: boolean);
  51214. get isEnabled(): boolean;
  51215. /**
  51216. * Disposes of the gizmo
  51217. */
  51218. dispose(): void;
  51219. }
  51220. }
  51221. declare module "babylonjs/Gizmos/rotationGizmo" {
  51222. import { Observable } from "babylonjs/Misc/observable";
  51223. import { Nullable } from "babylonjs/types";
  51224. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51225. import { Mesh } from "babylonjs/Meshes/mesh";
  51226. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51227. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  51228. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51229. /**
  51230. * Gizmo that enables rotating a mesh along 3 axis
  51231. */
  51232. export class RotationGizmo extends Gizmo {
  51233. /**
  51234. * Internal gizmo used for interactions on the x axis
  51235. */
  51236. xGizmo: PlaneRotationGizmo;
  51237. /**
  51238. * Internal gizmo used for interactions on the y axis
  51239. */
  51240. yGizmo: PlaneRotationGizmo;
  51241. /**
  51242. * Internal gizmo used for interactions on the z axis
  51243. */
  51244. zGizmo: PlaneRotationGizmo;
  51245. /** Fires an event when any of it's sub gizmos are dragged */
  51246. onDragStartObservable: Observable<unknown>;
  51247. /** Fires an event when any of it's sub gizmos are released from dragging */
  51248. onDragEndObservable: Observable<unknown>;
  51249. private _meshAttached;
  51250. get attachedMesh(): Nullable<AbstractMesh>;
  51251. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51252. /**
  51253. * Creates a RotationGizmo
  51254. * @param gizmoLayer The utility layer the gizmo will be added to
  51255. * @param tessellation Amount of tessellation to be used when creating rotation circles
  51256. * @param useEulerRotation Use and update Euler angle instead of quaternion
  51257. */
  51258. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  51259. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51260. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51261. /**
  51262. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51263. */
  51264. set snapDistance(value: number);
  51265. get snapDistance(): number;
  51266. /**
  51267. * Ratio for the scale of the gizmo (Default: 1)
  51268. */
  51269. set scaleRatio(value: number);
  51270. get scaleRatio(): number;
  51271. /**
  51272. * Disposes of the gizmo
  51273. */
  51274. dispose(): void;
  51275. /**
  51276. * CustomMeshes are not supported by this gizmo
  51277. * @param mesh The mesh to replace the default mesh of the gizmo
  51278. */
  51279. setCustomMesh(mesh: Mesh): void;
  51280. }
  51281. }
  51282. declare module "babylonjs/Gizmos/gizmoManager" {
  51283. import { Observable } from "babylonjs/Misc/observable";
  51284. import { Nullable } from "babylonjs/types";
  51285. import { Scene, IDisposable } from "babylonjs/scene";
  51286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51287. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51288. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  51289. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  51290. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51291. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  51292. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  51293. /**
  51294. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  51295. */
  51296. export class GizmoManager implements IDisposable {
  51297. private scene;
  51298. /**
  51299. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  51300. */
  51301. gizmos: {
  51302. positionGizmo: Nullable<PositionGizmo>;
  51303. rotationGizmo: Nullable<RotationGizmo>;
  51304. scaleGizmo: Nullable<ScaleGizmo>;
  51305. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  51306. };
  51307. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  51308. clearGizmoOnEmptyPointerEvent: boolean;
  51309. /** Fires an event when the manager is attached to a mesh */
  51310. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  51311. private _gizmosEnabled;
  51312. private _pointerObserver;
  51313. private _attachedMesh;
  51314. private _boundingBoxColor;
  51315. private _defaultUtilityLayer;
  51316. private _defaultKeepDepthUtilityLayer;
  51317. /**
  51318. * When bounding box gizmo is enabled, this can be used to track drag/end events
  51319. */
  51320. boundingBoxDragBehavior: SixDofDragBehavior;
  51321. /**
  51322. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  51323. */
  51324. attachableMeshes: Nullable<Array<AbstractMesh>>;
  51325. /**
  51326. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  51327. */
  51328. usePointerToAttachGizmos: boolean;
  51329. /**
  51330. * Utility layer that the bounding box gizmo belongs to
  51331. */
  51332. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  51333. /**
  51334. * Utility layer that all gizmos besides bounding box belong to
  51335. */
  51336. get utilityLayer(): UtilityLayerRenderer;
  51337. /**
  51338. * Instatiates a gizmo manager
  51339. * @param scene the scene to overlay the gizmos on top of
  51340. */
  51341. constructor(scene: Scene);
  51342. /**
  51343. * Attaches a set of gizmos to the specified mesh
  51344. * @param mesh The mesh the gizmo's should be attached to
  51345. */
  51346. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51347. /**
  51348. * If the position gizmo is enabled
  51349. */
  51350. set positionGizmoEnabled(value: boolean);
  51351. get positionGizmoEnabled(): boolean;
  51352. /**
  51353. * If the rotation gizmo is enabled
  51354. */
  51355. set rotationGizmoEnabled(value: boolean);
  51356. get rotationGizmoEnabled(): boolean;
  51357. /**
  51358. * If the scale gizmo is enabled
  51359. */
  51360. set scaleGizmoEnabled(value: boolean);
  51361. get scaleGizmoEnabled(): boolean;
  51362. /**
  51363. * If the boundingBox gizmo is enabled
  51364. */
  51365. set boundingBoxGizmoEnabled(value: boolean);
  51366. get boundingBoxGizmoEnabled(): boolean;
  51367. /**
  51368. * Disposes of the gizmo manager
  51369. */
  51370. dispose(): void;
  51371. }
  51372. }
  51373. declare module "babylonjs/Lights/directionalLight" {
  51374. import { Camera } from "babylonjs/Cameras/camera";
  51375. import { Scene } from "babylonjs/scene";
  51376. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51377. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51378. import { Light } from "babylonjs/Lights/light";
  51379. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51380. import { Effect } from "babylonjs/Materials/effect";
  51381. /**
  51382. * A directional light is defined by a direction (what a surprise!).
  51383. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  51384. * 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.
  51385. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51386. */
  51387. export class DirectionalLight extends ShadowLight {
  51388. private _shadowFrustumSize;
  51389. /**
  51390. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  51391. */
  51392. get shadowFrustumSize(): number;
  51393. /**
  51394. * Specifies a fix frustum size for the shadow generation.
  51395. */
  51396. set shadowFrustumSize(value: number);
  51397. private _shadowOrthoScale;
  51398. /**
  51399. * Gets the shadow projection scale against the optimal computed one.
  51400. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  51401. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  51402. */
  51403. get shadowOrthoScale(): number;
  51404. /**
  51405. * Sets the shadow projection scale against the optimal computed one.
  51406. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  51407. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  51408. */
  51409. set shadowOrthoScale(value: number);
  51410. /**
  51411. * Automatically compute the projection matrix to best fit (including all the casters)
  51412. * on each frame.
  51413. */
  51414. autoUpdateExtends: boolean;
  51415. /**
  51416. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  51417. * on each frame. autoUpdateExtends must be set to true for this to work
  51418. */
  51419. autoCalcShadowZBounds: boolean;
  51420. private _orthoLeft;
  51421. private _orthoRight;
  51422. private _orthoTop;
  51423. private _orthoBottom;
  51424. /**
  51425. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  51426. * The directional light is emitted from everywhere in the given direction.
  51427. * It can cast shadows.
  51428. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51429. * @param name The friendly name of the light
  51430. * @param direction The direction of the light
  51431. * @param scene The scene the light belongs to
  51432. */
  51433. constructor(name: string, direction: Vector3, scene: Scene);
  51434. /**
  51435. * Returns the string "DirectionalLight".
  51436. * @return The class name
  51437. */
  51438. getClassName(): string;
  51439. /**
  51440. * Returns the integer 1.
  51441. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51442. */
  51443. getTypeID(): number;
  51444. /**
  51445. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  51446. * Returns the DirectionalLight Shadow projection matrix.
  51447. */
  51448. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51449. /**
  51450. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  51451. * Returns the DirectionalLight Shadow projection matrix.
  51452. */
  51453. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  51454. /**
  51455. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  51456. * Returns the DirectionalLight Shadow projection matrix.
  51457. */
  51458. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51459. protected _buildUniformLayout(): void;
  51460. /**
  51461. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  51462. * @param effect The effect to update
  51463. * @param lightIndex The index of the light in the effect to update
  51464. * @returns The directional light
  51465. */
  51466. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  51467. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  51468. /**
  51469. * Gets the minZ used for shadow according to both the scene and the light.
  51470. *
  51471. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51472. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51473. * @param activeCamera The camera we are returning the min for
  51474. * @returns the depth min z
  51475. */
  51476. getDepthMinZ(activeCamera: Camera): number;
  51477. /**
  51478. * Gets the maxZ used for shadow according to both the scene and the light.
  51479. *
  51480. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51481. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51482. * @param activeCamera The camera we are returning the max for
  51483. * @returns the depth max z
  51484. */
  51485. getDepthMaxZ(activeCamera: Camera): number;
  51486. /**
  51487. * Prepares the list of defines specific to the light type.
  51488. * @param defines the list of defines
  51489. * @param lightIndex defines the index of the light for the effect
  51490. */
  51491. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51492. }
  51493. }
  51494. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  51495. import { Mesh } from "babylonjs/Meshes/mesh";
  51496. /**
  51497. * Class containing static functions to help procedurally build meshes
  51498. */
  51499. export class HemisphereBuilder {
  51500. /**
  51501. * Creates a hemisphere mesh
  51502. * @param name defines the name of the mesh
  51503. * @param options defines the options used to create the mesh
  51504. * @param scene defines the hosting scene
  51505. * @returns the hemisphere mesh
  51506. */
  51507. static CreateHemisphere(name: string, options: {
  51508. segments?: number;
  51509. diameter?: number;
  51510. sideOrientation?: number;
  51511. }, scene: any): Mesh;
  51512. }
  51513. }
  51514. declare module "babylonjs/Lights/spotLight" {
  51515. import { Nullable } from "babylonjs/types";
  51516. import { Scene } from "babylonjs/scene";
  51517. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51518. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51519. import { Effect } from "babylonjs/Materials/effect";
  51520. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51521. import { Light } from "babylonjs/Lights/light";
  51522. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51523. /**
  51524. * A spot light is defined by a position, a direction, an angle, and an exponent.
  51525. * These values define a cone of light starting from the position, emitting toward the direction.
  51526. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  51527. * and the exponent defines the speed of the decay of the light with distance (reach).
  51528. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51529. */
  51530. export class SpotLight extends ShadowLight {
  51531. private _angle;
  51532. private _innerAngle;
  51533. private _cosHalfAngle;
  51534. private _lightAngleScale;
  51535. private _lightAngleOffset;
  51536. /**
  51537. * Gets the cone angle of the spot light in Radians.
  51538. */
  51539. get angle(): number;
  51540. /**
  51541. * Sets the cone angle of the spot light in Radians.
  51542. */
  51543. set angle(value: number);
  51544. /**
  51545. * Only used in gltf falloff mode, this defines the angle where
  51546. * the directional falloff will start before cutting at angle which could be seen
  51547. * as outer angle.
  51548. */
  51549. get innerAngle(): number;
  51550. /**
  51551. * Only used in gltf falloff mode, this defines the angle where
  51552. * the directional falloff will start before cutting at angle which could be seen
  51553. * as outer angle.
  51554. */
  51555. set innerAngle(value: number);
  51556. private _shadowAngleScale;
  51557. /**
  51558. * Allows scaling the angle of the light for shadow generation only.
  51559. */
  51560. get shadowAngleScale(): number;
  51561. /**
  51562. * Allows scaling the angle of the light for shadow generation only.
  51563. */
  51564. set shadowAngleScale(value: number);
  51565. /**
  51566. * The light decay speed with the distance from the emission spot.
  51567. */
  51568. exponent: number;
  51569. private _projectionTextureMatrix;
  51570. /**
  51571. * Allows reading the projecton texture
  51572. */
  51573. get projectionTextureMatrix(): Matrix;
  51574. protected _projectionTextureLightNear: number;
  51575. /**
  51576. * Gets the near clip of the Spotlight for texture projection.
  51577. */
  51578. get projectionTextureLightNear(): number;
  51579. /**
  51580. * Sets the near clip of the Spotlight for texture projection.
  51581. */
  51582. set projectionTextureLightNear(value: number);
  51583. protected _projectionTextureLightFar: number;
  51584. /**
  51585. * Gets the far clip of the Spotlight for texture projection.
  51586. */
  51587. get projectionTextureLightFar(): number;
  51588. /**
  51589. * Sets the far clip of the Spotlight for texture projection.
  51590. */
  51591. set projectionTextureLightFar(value: number);
  51592. protected _projectionTextureUpDirection: Vector3;
  51593. /**
  51594. * Gets the Up vector of the Spotlight for texture projection.
  51595. */
  51596. get projectionTextureUpDirection(): Vector3;
  51597. /**
  51598. * Sets the Up vector of the Spotlight for texture projection.
  51599. */
  51600. set projectionTextureUpDirection(value: Vector3);
  51601. private _projectionTexture;
  51602. /**
  51603. * Gets the projection texture of the light.
  51604. */
  51605. get projectionTexture(): Nullable<BaseTexture>;
  51606. /**
  51607. * Sets the projection texture of the light.
  51608. */
  51609. set projectionTexture(value: Nullable<BaseTexture>);
  51610. private _projectionTextureViewLightDirty;
  51611. private _projectionTextureProjectionLightDirty;
  51612. private _projectionTextureDirty;
  51613. private _projectionTextureViewTargetVector;
  51614. private _projectionTextureViewLightMatrix;
  51615. private _projectionTextureProjectionLightMatrix;
  51616. private _projectionTextureScalingMatrix;
  51617. /**
  51618. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  51619. * It can cast shadows.
  51620. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51621. * @param name The light friendly name
  51622. * @param position The position of the spot light in the scene
  51623. * @param direction The direction of the light in the scene
  51624. * @param angle The cone angle of the light in Radians
  51625. * @param exponent The light decay speed with the distance from the emission spot
  51626. * @param scene The scene the lights belongs to
  51627. */
  51628. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  51629. /**
  51630. * Returns the string "SpotLight".
  51631. * @returns the class name
  51632. */
  51633. getClassName(): string;
  51634. /**
  51635. * Returns the integer 2.
  51636. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51637. */
  51638. getTypeID(): number;
  51639. /**
  51640. * Overrides the direction setter to recompute the projection texture view light Matrix.
  51641. */
  51642. protected _setDirection(value: Vector3): void;
  51643. /**
  51644. * Overrides the position setter to recompute the projection texture view light Matrix.
  51645. */
  51646. protected _setPosition(value: Vector3): void;
  51647. /**
  51648. * 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.
  51649. * Returns the SpotLight.
  51650. */
  51651. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51652. protected _computeProjectionTextureViewLightMatrix(): void;
  51653. protected _computeProjectionTextureProjectionLightMatrix(): void;
  51654. /**
  51655. * Main function for light texture projection matrix computing.
  51656. */
  51657. protected _computeProjectionTextureMatrix(): void;
  51658. protected _buildUniformLayout(): void;
  51659. private _computeAngleValues;
  51660. /**
  51661. * Sets the passed Effect "effect" with the Light textures.
  51662. * @param effect The effect to update
  51663. * @param lightIndex The index of the light in the effect to update
  51664. * @returns The light
  51665. */
  51666. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  51667. /**
  51668. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  51669. * @param effect The effect to update
  51670. * @param lightIndex The index of the light in the effect to update
  51671. * @returns The spot light
  51672. */
  51673. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  51674. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51675. /**
  51676. * Disposes the light and the associated resources.
  51677. */
  51678. dispose(): void;
  51679. /**
  51680. * Prepares the list of defines specific to the light type.
  51681. * @param defines the list of defines
  51682. * @param lightIndex defines the index of the light for the effect
  51683. */
  51684. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51685. }
  51686. }
  51687. declare module "babylonjs/Gizmos/lightGizmo" {
  51688. import { Nullable } from "babylonjs/types";
  51689. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51690. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51691. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51692. import { Light } from "babylonjs/Lights/light";
  51693. /**
  51694. * Gizmo that enables viewing a light
  51695. */
  51696. export class LightGizmo extends Gizmo {
  51697. private _lightMesh;
  51698. private _material;
  51699. private _cachedPosition;
  51700. private _cachedForward;
  51701. private _attachedMeshParent;
  51702. /**
  51703. * Creates a LightGizmo
  51704. * @param gizmoLayer The utility layer the gizmo will be added to
  51705. */
  51706. constructor(gizmoLayer?: UtilityLayerRenderer);
  51707. private _light;
  51708. /**
  51709. * The light that the gizmo is attached to
  51710. */
  51711. set light(light: Nullable<Light>);
  51712. get light(): Nullable<Light>;
  51713. /**
  51714. * Gets the material used to render the light gizmo
  51715. */
  51716. get material(): StandardMaterial;
  51717. /**
  51718. * @hidden
  51719. * Updates the gizmo to match the attached mesh's position/rotation
  51720. */
  51721. protected _update(): void;
  51722. private static _Scale;
  51723. /**
  51724. * Creates the lines for a light mesh
  51725. */
  51726. private static _CreateLightLines;
  51727. /**
  51728. * Disposes of the light gizmo
  51729. */
  51730. dispose(): void;
  51731. private static _CreateHemisphericLightMesh;
  51732. private static _CreatePointLightMesh;
  51733. private static _CreateSpotLightMesh;
  51734. private static _CreateDirectionalLightMesh;
  51735. }
  51736. }
  51737. declare module "babylonjs/Gizmos/index" {
  51738. export * from "babylonjs/Gizmos/axisDragGizmo";
  51739. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51740. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51741. export * from "babylonjs/Gizmos/gizmo";
  51742. export * from "babylonjs/Gizmos/gizmoManager";
  51743. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51744. export * from "babylonjs/Gizmos/positionGizmo";
  51745. export * from "babylonjs/Gizmos/rotationGizmo";
  51746. export * from "babylonjs/Gizmos/scaleGizmo";
  51747. export * from "babylonjs/Gizmos/lightGizmo";
  51748. export * from "babylonjs/Gizmos/planeDragGizmo";
  51749. }
  51750. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51751. /** @hidden */
  51752. export var backgroundFragmentDeclaration: {
  51753. name: string;
  51754. shader: string;
  51755. };
  51756. }
  51757. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51758. /** @hidden */
  51759. export var backgroundUboDeclaration: {
  51760. name: string;
  51761. shader: string;
  51762. };
  51763. }
  51764. declare module "babylonjs/Shaders/background.fragment" {
  51765. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51766. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51767. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51768. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51769. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51770. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51771. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51772. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51773. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51774. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51775. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51776. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51777. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51778. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51779. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51780. /** @hidden */
  51781. export var backgroundPixelShader: {
  51782. name: string;
  51783. shader: string;
  51784. };
  51785. }
  51786. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51787. /** @hidden */
  51788. export var backgroundVertexDeclaration: {
  51789. name: string;
  51790. shader: string;
  51791. };
  51792. }
  51793. declare module "babylonjs/Shaders/background.vertex" {
  51794. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51795. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51796. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51797. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51798. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51799. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51800. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51801. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51802. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51803. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51804. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51805. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51806. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51807. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51808. /** @hidden */
  51809. export var backgroundVertexShader: {
  51810. name: string;
  51811. shader: string;
  51812. };
  51813. }
  51814. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51815. import { Nullable, int, float } from "babylonjs/types";
  51816. import { Scene } from "babylonjs/scene";
  51817. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51818. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51819. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51820. import { Mesh } from "babylonjs/Meshes/mesh";
  51821. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51822. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51823. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51824. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51825. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51826. import { Color3 } from "babylonjs/Maths/math.color";
  51827. import "babylonjs/Shaders/background.fragment";
  51828. import "babylonjs/Shaders/background.vertex";
  51829. /**
  51830. * Background material used to create an efficient environement around your scene.
  51831. */
  51832. export class BackgroundMaterial extends PushMaterial {
  51833. /**
  51834. * Standard reflectance value at parallel view angle.
  51835. */
  51836. static StandardReflectance0: number;
  51837. /**
  51838. * Standard reflectance value at grazing angle.
  51839. */
  51840. static StandardReflectance90: number;
  51841. protected _primaryColor: Color3;
  51842. /**
  51843. * Key light Color (multiply against the environement texture)
  51844. */
  51845. primaryColor: Color3;
  51846. protected __perceptualColor: Nullable<Color3>;
  51847. /**
  51848. * Experimental Internal Use Only.
  51849. *
  51850. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51851. * This acts as a helper to set the primary color to a more "human friendly" value.
  51852. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51853. * output color as close as possible from the chosen value.
  51854. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51855. * part of lighting setup.)
  51856. */
  51857. get _perceptualColor(): Nullable<Color3>;
  51858. set _perceptualColor(value: Nullable<Color3>);
  51859. protected _primaryColorShadowLevel: float;
  51860. /**
  51861. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51862. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51863. */
  51864. get primaryColorShadowLevel(): float;
  51865. set primaryColorShadowLevel(value: float);
  51866. protected _primaryColorHighlightLevel: float;
  51867. /**
  51868. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51869. * The primary color is used at the level chosen to define what the white area would look.
  51870. */
  51871. get primaryColorHighlightLevel(): float;
  51872. set primaryColorHighlightLevel(value: float);
  51873. protected _reflectionTexture: Nullable<BaseTexture>;
  51874. /**
  51875. * Reflection Texture used in the material.
  51876. * Should be author in a specific way for the best result (refer to the documentation).
  51877. */
  51878. reflectionTexture: Nullable<BaseTexture>;
  51879. protected _reflectionBlur: float;
  51880. /**
  51881. * Reflection Texture level of blur.
  51882. *
  51883. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51884. * texture twice.
  51885. */
  51886. reflectionBlur: float;
  51887. protected _diffuseTexture: Nullable<BaseTexture>;
  51888. /**
  51889. * Diffuse Texture used in the material.
  51890. * Should be author in a specific way for the best result (refer to the documentation).
  51891. */
  51892. diffuseTexture: Nullable<BaseTexture>;
  51893. protected _shadowLights: Nullable<IShadowLight[]>;
  51894. /**
  51895. * Specify the list of lights casting shadow on the material.
  51896. * All scene shadow lights will be included if null.
  51897. */
  51898. shadowLights: Nullable<IShadowLight[]>;
  51899. protected _shadowLevel: float;
  51900. /**
  51901. * Helps adjusting the shadow to a softer level if required.
  51902. * 0 means black shadows and 1 means no shadows.
  51903. */
  51904. shadowLevel: float;
  51905. protected _sceneCenter: Vector3;
  51906. /**
  51907. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51908. * It is usually zero but might be interesting to modify according to your setup.
  51909. */
  51910. sceneCenter: Vector3;
  51911. protected _opacityFresnel: boolean;
  51912. /**
  51913. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51914. * This helps ensuring a nice transition when the camera goes under the ground.
  51915. */
  51916. opacityFresnel: boolean;
  51917. protected _reflectionFresnel: boolean;
  51918. /**
  51919. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51920. * This helps adding a mirror texture on the ground.
  51921. */
  51922. reflectionFresnel: boolean;
  51923. protected _reflectionFalloffDistance: number;
  51924. /**
  51925. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51926. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51927. */
  51928. reflectionFalloffDistance: number;
  51929. protected _reflectionAmount: number;
  51930. /**
  51931. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51932. */
  51933. reflectionAmount: number;
  51934. protected _reflectionReflectance0: number;
  51935. /**
  51936. * This specifies the weight of the reflection at grazing angle.
  51937. */
  51938. reflectionReflectance0: number;
  51939. protected _reflectionReflectance90: number;
  51940. /**
  51941. * This specifies the weight of the reflection at a perpendicular point of view.
  51942. */
  51943. reflectionReflectance90: number;
  51944. /**
  51945. * Sets the reflection reflectance fresnel values according to the default standard
  51946. * empirically know to work well :-)
  51947. */
  51948. set reflectionStandardFresnelWeight(value: number);
  51949. protected _useRGBColor: boolean;
  51950. /**
  51951. * Helps to directly use the maps channels instead of their level.
  51952. */
  51953. useRGBColor: boolean;
  51954. protected _enableNoise: boolean;
  51955. /**
  51956. * This helps reducing the banding effect that could occur on the background.
  51957. */
  51958. enableNoise: boolean;
  51959. /**
  51960. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51961. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51962. * Recommended to be keep at 1.0 except for special cases.
  51963. */
  51964. get fovMultiplier(): number;
  51965. set fovMultiplier(value: number);
  51966. private _fovMultiplier;
  51967. /**
  51968. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51969. */
  51970. useEquirectangularFOV: boolean;
  51971. private _maxSimultaneousLights;
  51972. /**
  51973. * Number of Simultaneous lights allowed on the material.
  51974. */
  51975. maxSimultaneousLights: int;
  51976. /**
  51977. * Default configuration related to image processing available in the Background Material.
  51978. */
  51979. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51980. /**
  51981. * Keep track of the image processing observer to allow dispose and replace.
  51982. */
  51983. private _imageProcessingObserver;
  51984. /**
  51985. * Attaches a new image processing configuration to the PBR Material.
  51986. * @param configuration (if null the scene configuration will be use)
  51987. */
  51988. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51989. /**
  51990. * Gets the image processing configuration used either in this material.
  51991. */
  51992. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51993. /**
  51994. * Sets the Default image processing configuration used either in the this material.
  51995. *
  51996. * If sets to null, the scene one is in use.
  51997. */
  51998. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51999. /**
  52000. * Gets wether the color curves effect is enabled.
  52001. */
  52002. get cameraColorCurvesEnabled(): boolean;
  52003. /**
  52004. * Sets wether the color curves effect is enabled.
  52005. */
  52006. set cameraColorCurvesEnabled(value: boolean);
  52007. /**
  52008. * Gets wether the color grading effect is enabled.
  52009. */
  52010. get cameraColorGradingEnabled(): boolean;
  52011. /**
  52012. * Gets wether the color grading effect is enabled.
  52013. */
  52014. set cameraColorGradingEnabled(value: boolean);
  52015. /**
  52016. * Gets wether tonemapping is enabled or not.
  52017. */
  52018. get cameraToneMappingEnabled(): boolean;
  52019. /**
  52020. * Sets wether tonemapping is enabled or not
  52021. */
  52022. set cameraToneMappingEnabled(value: boolean);
  52023. /**
  52024. * The camera exposure used on this material.
  52025. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52026. * This corresponds to a photographic exposure.
  52027. */
  52028. get cameraExposure(): float;
  52029. /**
  52030. * The camera exposure used on this material.
  52031. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52032. * This corresponds to a photographic exposure.
  52033. */
  52034. set cameraExposure(value: float);
  52035. /**
  52036. * Gets The camera contrast used on this material.
  52037. */
  52038. get cameraContrast(): float;
  52039. /**
  52040. * Sets The camera contrast used on this material.
  52041. */
  52042. set cameraContrast(value: float);
  52043. /**
  52044. * Gets the Color Grading 2D Lookup Texture.
  52045. */
  52046. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52047. /**
  52048. * Sets the Color Grading 2D Lookup Texture.
  52049. */
  52050. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52051. /**
  52052. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52053. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52054. * 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;
  52055. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52056. */
  52057. get cameraColorCurves(): Nullable<ColorCurves>;
  52058. /**
  52059. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52060. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52061. * 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;
  52062. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52063. */
  52064. set cameraColorCurves(value: Nullable<ColorCurves>);
  52065. /**
  52066. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  52067. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  52068. */
  52069. switchToBGR: boolean;
  52070. private _renderTargets;
  52071. private _reflectionControls;
  52072. private _white;
  52073. private _primaryShadowColor;
  52074. private _primaryHighlightColor;
  52075. /**
  52076. * Instantiates a Background Material in the given scene
  52077. * @param name The friendly name of the material
  52078. * @param scene The scene to add the material to
  52079. */
  52080. constructor(name: string, scene: Scene);
  52081. /**
  52082. * Gets a boolean indicating that current material needs to register RTT
  52083. */
  52084. get hasRenderTargetTextures(): boolean;
  52085. /**
  52086. * The entire material has been created in order to prevent overdraw.
  52087. * @returns false
  52088. */
  52089. needAlphaTesting(): boolean;
  52090. /**
  52091. * The entire material has been created in order to prevent overdraw.
  52092. * @returns true if blending is enable
  52093. */
  52094. needAlphaBlending(): boolean;
  52095. /**
  52096. * Checks wether the material is ready to be rendered for a given mesh.
  52097. * @param mesh The mesh to render
  52098. * @param subMesh The submesh to check against
  52099. * @param useInstances Specify wether or not the material is used with instances
  52100. * @returns true if all the dependencies are ready (Textures, Effects...)
  52101. */
  52102. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52103. /**
  52104. * Compute the primary color according to the chosen perceptual color.
  52105. */
  52106. private _computePrimaryColorFromPerceptualColor;
  52107. /**
  52108. * Compute the highlights and shadow colors according to their chosen levels.
  52109. */
  52110. private _computePrimaryColors;
  52111. /**
  52112. * Build the uniform buffer used in the material.
  52113. */
  52114. buildUniformLayout(): void;
  52115. /**
  52116. * Unbind the material.
  52117. */
  52118. unbind(): void;
  52119. /**
  52120. * Bind only the world matrix to the material.
  52121. * @param world The world matrix to bind.
  52122. */
  52123. bindOnlyWorldMatrix(world: Matrix): void;
  52124. /**
  52125. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  52126. * @param world The world matrix to bind.
  52127. * @param subMesh The submesh to bind for.
  52128. */
  52129. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52130. /**
  52131. * Checks to see if a texture is used in the material.
  52132. * @param texture - Base texture to use.
  52133. * @returns - Boolean specifying if a texture is used in the material.
  52134. */
  52135. hasTexture(texture: BaseTexture): boolean;
  52136. /**
  52137. * Dispose the material.
  52138. * @param forceDisposeEffect Force disposal of the associated effect.
  52139. * @param forceDisposeTextures Force disposal of the associated textures.
  52140. */
  52141. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52142. /**
  52143. * Clones the material.
  52144. * @param name The cloned name.
  52145. * @returns The cloned material.
  52146. */
  52147. clone(name: string): BackgroundMaterial;
  52148. /**
  52149. * Serializes the current material to its JSON representation.
  52150. * @returns The JSON representation.
  52151. */
  52152. serialize(): any;
  52153. /**
  52154. * Gets the class name of the material
  52155. * @returns "BackgroundMaterial"
  52156. */
  52157. getClassName(): string;
  52158. /**
  52159. * Parse a JSON input to create back a background material.
  52160. * @param source The JSON data to parse
  52161. * @param scene The scene to create the parsed material in
  52162. * @param rootUrl The root url of the assets the material depends upon
  52163. * @returns the instantiated BackgroundMaterial.
  52164. */
  52165. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  52166. }
  52167. }
  52168. declare module "babylonjs/Helpers/environmentHelper" {
  52169. import { Observable } from "babylonjs/Misc/observable";
  52170. import { Nullable } from "babylonjs/types";
  52171. import { Scene } from "babylonjs/scene";
  52172. import { Vector3 } from "babylonjs/Maths/math.vector";
  52173. import { Color3 } from "babylonjs/Maths/math.color";
  52174. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52175. import { Mesh } from "babylonjs/Meshes/mesh";
  52176. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52177. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  52178. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52179. import "babylonjs/Meshes/Builders/planeBuilder";
  52180. import "babylonjs/Meshes/Builders/boxBuilder";
  52181. /**
  52182. * Represents the different options available during the creation of
  52183. * a Environment helper.
  52184. *
  52185. * This can control the default ground, skybox and image processing setup of your scene.
  52186. */
  52187. export interface IEnvironmentHelperOptions {
  52188. /**
  52189. * Specifies whether or not to create a ground.
  52190. * True by default.
  52191. */
  52192. createGround: boolean;
  52193. /**
  52194. * Specifies the ground size.
  52195. * 15 by default.
  52196. */
  52197. groundSize: number;
  52198. /**
  52199. * The texture used on the ground for the main color.
  52200. * Comes from the BabylonJS CDN by default.
  52201. *
  52202. * Remarks: Can be either a texture or a url.
  52203. */
  52204. groundTexture: string | BaseTexture;
  52205. /**
  52206. * The color mixed in the ground texture by default.
  52207. * BabylonJS clearColor by default.
  52208. */
  52209. groundColor: Color3;
  52210. /**
  52211. * Specifies the ground opacity.
  52212. * 1 by default.
  52213. */
  52214. groundOpacity: number;
  52215. /**
  52216. * Enables the ground to receive shadows.
  52217. * True by default.
  52218. */
  52219. enableGroundShadow: boolean;
  52220. /**
  52221. * Helps preventing the shadow to be fully black on the ground.
  52222. * 0.5 by default.
  52223. */
  52224. groundShadowLevel: number;
  52225. /**
  52226. * Creates a mirror texture attach to the ground.
  52227. * false by default.
  52228. */
  52229. enableGroundMirror: boolean;
  52230. /**
  52231. * Specifies the ground mirror size ratio.
  52232. * 0.3 by default as the default kernel is 64.
  52233. */
  52234. groundMirrorSizeRatio: number;
  52235. /**
  52236. * Specifies the ground mirror blur kernel size.
  52237. * 64 by default.
  52238. */
  52239. groundMirrorBlurKernel: number;
  52240. /**
  52241. * Specifies the ground mirror visibility amount.
  52242. * 1 by default
  52243. */
  52244. groundMirrorAmount: number;
  52245. /**
  52246. * Specifies the ground mirror reflectance weight.
  52247. * This uses the standard weight of the background material to setup the fresnel effect
  52248. * of the mirror.
  52249. * 1 by default.
  52250. */
  52251. groundMirrorFresnelWeight: number;
  52252. /**
  52253. * Specifies the ground mirror Falloff distance.
  52254. * This can helps reducing the size of the reflection.
  52255. * 0 by Default.
  52256. */
  52257. groundMirrorFallOffDistance: number;
  52258. /**
  52259. * Specifies the ground mirror texture type.
  52260. * Unsigned Int by Default.
  52261. */
  52262. groundMirrorTextureType: number;
  52263. /**
  52264. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  52265. * the shown objects.
  52266. */
  52267. groundYBias: number;
  52268. /**
  52269. * Specifies whether or not to create a skybox.
  52270. * True by default.
  52271. */
  52272. createSkybox: boolean;
  52273. /**
  52274. * Specifies the skybox size.
  52275. * 20 by default.
  52276. */
  52277. skyboxSize: number;
  52278. /**
  52279. * The texture used on the skybox for the main color.
  52280. * Comes from the BabylonJS CDN by default.
  52281. *
  52282. * Remarks: Can be either a texture or a url.
  52283. */
  52284. skyboxTexture: string | BaseTexture;
  52285. /**
  52286. * The color mixed in the skybox texture by default.
  52287. * BabylonJS clearColor by default.
  52288. */
  52289. skyboxColor: Color3;
  52290. /**
  52291. * The background rotation around the Y axis of the scene.
  52292. * This helps aligning the key lights of your scene with the background.
  52293. * 0 by default.
  52294. */
  52295. backgroundYRotation: number;
  52296. /**
  52297. * Compute automatically the size of the elements to best fit with the scene.
  52298. */
  52299. sizeAuto: boolean;
  52300. /**
  52301. * Default position of the rootMesh if autoSize is not true.
  52302. */
  52303. rootPosition: Vector3;
  52304. /**
  52305. * Sets up the image processing in the scene.
  52306. * true by default.
  52307. */
  52308. setupImageProcessing: boolean;
  52309. /**
  52310. * The texture used as your environment texture in the scene.
  52311. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  52312. *
  52313. * Remarks: Can be either a texture or a url.
  52314. */
  52315. environmentTexture: string | BaseTexture;
  52316. /**
  52317. * The value of the exposure to apply to the scene.
  52318. * 0.6 by default if setupImageProcessing is true.
  52319. */
  52320. cameraExposure: number;
  52321. /**
  52322. * The value of the contrast to apply to the scene.
  52323. * 1.6 by default if setupImageProcessing is true.
  52324. */
  52325. cameraContrast: number;
  52326. /**
  52327. * Specifies whether or not tonemapping should be enabled in the scene.
  52328. * true by default if setupImageProcessing is true.
  52329. */
  52330. toneMappingEnabled: boolean;
  52331. }
  52332. /**
  52333. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  52334. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  52335. * It also helps with the default setup of your imageProcessing configuration.
  52336. */
  52337. export class EnvironmentHelper {
  52338. /**
  52339. * Default ground texture URL.
  52340. */
  52341. private static _groundTextureCDNUrl;
  52342. /**
  52343. * Default skybox texture URL.
  52344. */
  52345. private static _skyboxTextureCDNUrl;
  52346. /**
  52347. * Default environment texture URL.
  52348. */
  52349. private static _environmentTextureCDNUrl;
  52350. /**
  52351. * Creates the default options for the helper.
  52352. */
  52353. private static _getDefaultOptions;
  52354. private _rootMesh;
  52355. /**
  52356. * Gets the root mesh created by the helper.
  52357. */
  52358. get rootMesh(): Mesh;
  52359. private _skybox;
  52360. /**
  52361. * Gets the skybox created by the helper.
  52362. */
  52363. get skybox(): Nullable<Mesh>;
  52364. private _skyboxTexture;
  52365. /**
  52366. * Gets the skybox texture created by the helper.
  52367. */
  52368. get skyboxTexture(): Nullable<BaseTexture>;
  52369. private _skyboxMaterial;
  52370. /**
  52371. * Gets the skybox material created by the helper.
  52372. */
  52373. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  52374. private _ground;
  52375. /**
  52376. * Gets the ground mesh created by the helper.
  52377. */
  52378. get ground(): Nullable<Mesh>;
  52379. private _groundTexture;
  52380. /**
  52381. * Gets the ground texture created by the helper.
  52382. */
  52383. get groundTexture(): Nullable<BaseTexture>;
  52384. private _groundMirror;
  52385. /**
  52386. * Gets the ground mirror created by the helper.
  52387. */
  52388. get groundMirror(): Nullable<MirrorTexture>;
  52389. /**
  52390. * Gets the ground mirror render list to helps pushing the meshes
  52391. * you wish in the ground reflection.
  52392. */
  52393. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  52394. private _groundMaterial;
  52395. /**
  52396. * Gets the ground material created by the helper.
  52397. */
  52398. get groundMaterial(): Nullable<BackgroundMaterial>;
  52399. /**
  52400. * Stores the creation options.
  52401. */
  52402. private readonly _scene;
  52403. private _options;
  52404. /**
  52405. * This observable will be notified with any error during the creation of the environment,
  52406. * mainly texture creation errors.
  52407. */
  52408. onErrorObservable: Observable<{
  52409. message?: string;
  52410. exception?: any;
  52411. }>;
  52412. /**
  52413. * constructor
  52414. * @param options Defines the options we want to customize the helper
  52415. * @param scene The scene to add the material to
  52416. */
  52417. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  52418. /**
  52419. * Updates the background according to the new options
  52420. * @param options
  52421. */
  52422. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  52423. /**
  52424. * Sets the primary color of all the available elements.
  52425. * @param color the main color to affect to the ground and the background
  52426. */
  52427. setMainColor(color: Color3): void;
  52428. /**
  52429. * Setup the image processing according to the specified options.
  52430. */
  52431. private _setupImageProcessing;
  52432. /**
  52433. * Setup the environment texture according to the specified options.
  52434. */
  52435. private _setupEnvironmentTexture;
  52436. /**
  52437. * Setup the background according to the specified options.
  52438. */
  52439. private _setupBackground;
  52440. /**
  52441. * Get the scene sizes according to the setup.
  52442. */
  52443. private _getSceneSize;
  52444. /**
  52445. * Setup the ground according to the specified options.
  52446. */
  52447. private _setupGround;
  52448. /**
  52449. * Setup the ground material according to the specified options.
  52450. */
  52451. private _setupGroundMaterial;
  52452. /**
  52453. * Setup the ground diffuse texture according to the specified options.
  52454. */
  52455. private _setupGroundDiffuseTexture;
  52456. /**
  52457. * Setup the ground mirror texture according to the specified options.
  52458. */
  52459. private _setupGroundMirrorTexture;
  52460. /**
  52461. * Setup the ground to receive the mirror texture.
  52462. */
  52463. private _setupMirrorInGroundMaterial;
  52464. /**
  52465. * Setup the skybox according to the specified options.
  52466. */
  52467. private _setupSkybox;
  52468. /**
  52469. * Setup the skybox material according to the specified options.
  52470. */
  52471. private _setupSkyboxMaterial;
  52472. /**
  52473. * Setup the skybox reflection texture according to the specified options.
  52474. */
  52475. private _setupSkyboxReflectionTexture;
  52476. private _errorHandler;
  52477. /**
  52478. * Dispose all the elements created by the Helper.
  52479. */
  52480. dispose(): void;
  52481. }
  52482. }
  52483. declare module "babylonjs/Helpers/photoDome" {
  52484. import { Observable } from "babylonjs/Misc/observable";
  52485. import { Nullable } from "babylonjs/types";
  52486. import { Scene } from "babylonjs/scene";
  52487. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52488. import { Mesh } from "babylonjs/Meshes/mesh";
  52489. import { Texture } from "babylonjs/Materials/Textures/texture";
  52490. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52491. import "babylonjs/Meshes/Builders/sphereBuilder";
  52492. /**
  52493. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  52494. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  52495. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  52496. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52497. */
  52498. export class PhotoDome extends TransformNode {
  52499. /**
  52500. * Define the image as a Monoscopic panoramic 360 image.
  52501. */
  52502. static readonly MODE_MONOSCOPIC: number;
  52503. /**
  52504. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52505. */
  52506. static readonly MODE_TOPBOTTOM: number;
  52507. /**
  52508. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52509. */
  52510. static readonly MODE_SIDEBYSIDE: number;
  52511. private _useDirectMapping;
  52512. /**
  52513. * The texture being displayed on the sphere
  52514. */
  52515. protected _photoTexture: Texture;
  52516. /**
  52517. * Gets or sets the texture being displayed on the sphere
  52518. */
  52519. get photoTexture(): Texture;
  52520. set photoTexture(value: Texture);
  52521. /**
  52522. * Observable raised when an error occured while loading the 360 image
  52523. */
  52524. onLoadErrorObservable: Observable<string>;
  52525. /**
  52526. * The skybox material
  52527. */
  52528. protected _material: BackgroundMaterial;
  52529. /**
  52530. * The surface used for the skybox
  52531. */
  52532. protected _mesh: Mesh;
  52533. /**
  52534. * Gets the mesh used for the skybox.
  52535. */
  52536. get mesh(): Mesh;
  52537. /**
  52538. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52539. * Also see the options.resolution property.
  52540. */
  52541. get fovMultiplier(): number;
  52542. set fovMultiplier(value: number);
  52543. private _imageMode;
  52544. /**
  52545. * Gets or set the current video mode for the video. It can be:
  52546. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  52547. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52548. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52549. */
  52550. get imageMode(): number;
  52551. set imageMode(value: number);
  52552. /**
  52553. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  52554. * @param name Element's name, child elements will append suffixes for their own names.
  52555. * @param urlsOfPhoto defines the url of the photo to display
  52556. * @param options defines an object containing optional or exposed sub element properties
  52557. * @param onError defines a callback called when an error occured while loading the texture
  52558. */
  52559. constructor(name: string, urlOfPhoto: string, options: {
  52560. resolution?: number;
  52561. size?: number;
  52562. useDirectMapping?: boolean;
  52563. faceForward?: boolean;
  52564. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  52565. private _onBeforeCameraRenderObserver;
  52566. private _changeImageMode;
  52567. /**
  52568. * Releases resources associated with this node.
  52569. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52570. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52571. */
  52572. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52573. }
  52574. }
  52575. declare module "babylonjs/Misc/rgbdTextureTools" {
  52576. import "babylonjs/Shaders/rgbdDecode.fragment";
  52577. import "babylonjs/Engines/Extensions/engine.renderTarget";
  52578. import { Texture } from "babylonjs/Materials/Textures/texture";
  52579. /**
  52580. * Class used to host RGBD texture specific utilities
  52581. */
  52582. export class RGBDTextureTools {
  52583. /**
  52584. * Expand the RGBD Texture from RGBD to Half Float if possible.
  52585. * @param texture the texture to expand.
  52586. */
  52587. static ExpandRGBDTexture(texture: Texture): void;
  52588. }
  52589. }
  52590. declare module "babylonjs/Misc/brdfTextureTools" {
  52591. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52592. import { Scene } from "babylonjs/scene";
  52593. /**
  52594. * Class used to host texture specific utilities
  52595. */
  52596. export class BRDFTextureTools {
  52597. /**
  52598. * Prevents texture cache collision
  52599. */
  52600. private static _instanceNumber;
  52601. /**
  52602. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  52603. * @param scene defines the hosting scene
  52604. * @returns the environment BRDF texture
  52605. */
  52606. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  52607. private static _environmentBRDFBase64Texture;
  52608. }
  52609. }
  52610. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  52611. import { Nullable } from "babylonjs/types";
  52612. import { Color3 } from "babylonjs/Maths/math.color";
  52613. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52614. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52615. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52616. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52617. import { Engine } from "babylonjs/Engines/engine";
  52618. import { Scene } from "babylonjs/scene";
  52619. /**
  52620. * @hidden
  52621. */
  52622. export interface IMaterialClearCoatDefines {
  52623. CLEARCOAT: boolean;
  52624. CLEARCOAT_DEFAULTIOR: boolean;
  52625. CLEARCOAT_TEXTURE: boolean;
  52626. CLEARCOAT_TEXTUREDIRECTUV: number;
  52627. CLEARCOAT_BUMP: boolean;
  52628. CLEARCOAT_BUMPDIRECTUV: number;
  52629. CLEARCOAT_TINT: boolean;
  52630. CLEARCOAT_TINT_TEXTURE: boolean;
  52631. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52632. /** @hidden */
  52633. _areTexturesDirty: boolean;
  52634. }
  52635. /**
  52636. * Define the code related to the clear coat parameters of the pbr material.
  52637. */
  52638. export class PBRClearCoatConfiguration {
  52639. /**
  52640. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52641. * The default fits with a polyurethane material.
  52642. */
  52643. private static readonly _DefaultIndexOfRefraction;
  52644. private _isEnabled;
  52645. /**
  52646. * Defines if the clear coat is enabled in the material.
  52647. */
  52648. isEnabled: boolean;
  52649. /**
  52650. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  52651. */
  52652. intensity: number;
  52653. /**
  52654. * Defines the clear coat layer roughness.
  52655. */
  52656. roughness: number;
  52657. private _indexOfRefraction;
  52658. /**
  52659. * Defines the index of refraction of the clear coat.
  52660. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52661. * The default fits with a polyurethane material.
  52662. * Changing the default value is more performance intensive.
  52663. */
  52664. indexOfRefraction: number;
  52665. private _texture;
  52666. /**
  52667. * Stores the clear coat values in a texture.
  52668. */
  52669. texture: Nullable<BaseTexture>;
  52670. private _bumpTexture;
  52671. /**
  52672. * Define the clear coat specific bump texture.
  52673. */
  52674. bumpTexture: Nullable<BaseTexture>;
  52675. private _isTintEnabled;
  52676. /**
  52677. * Defines if the clear coat tint is enabled in the material.
  52678. */
  52679. isTintEnabled: boolean;
  52680. /**
  52681. * Defines the clear coat tint of the material.
  52682. * This is only use if tint is enabled
  52683. */
  52684. tintColor: Color3;
  52685. /**
  52686. * Defines the distance at which the tint color should be found in the
  52687. * clear coat media.
  52688. * This is only use if tint is enabled
  52689. */
  52690. tintColorAtDistance: number;
  52691. /**
  52692. * Defines the clear coat layer thickness.
  52693. * This is only use if tint is enabled
  52694. */
  52695. tintThickness: number;
  52696. private _tintTexture;
  52697. /**
  52698. * Stores the clear tint values in a texture.
  52699. * rgb is tint
  52700. * a is a thickness factor
  52701. */
  52702. tintTexture: Nullable<BaseTexture>;
  52703. /** @hidden */
  52704. private _internalMarkAllSubMeshesAsTexturesDirty;
  52705. /** @hidden */
  52706. _markAllSubMeshesAsTexturesDirty(): void;
  52707. /**
  52708. * Instantiate a new istance of clear coat configuration.
  52709. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52710. */
  52711. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52712. /**
  52713. * Gets wehter the submesh is ready to be used or not.
  52714. * @param defines the list of "defines" to update.
  52715. * @param scene defines the scene the material belongs to.
  52716. * @param engine defines the engine the material belongs to.
  52717. * @param disableBumpMap defines wether the material disables bump or not.
  52718. * @returns - boolean indicating that the submesh is ready or not.
  52719. */
  52720. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52721. /**
  52722. * Checks to see if a texture is used in the material.
  52723. * @param defines the list of "defines" to update.
  52724. * @param scene defines the scene to the material belongs to.
  52725. */
  52726. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52727. /**
  52728. * Binds the material data.
  52729. * @param uniformBuffer defines the Uniform buffer to fill in.
  52730. * @param scene defines the scene the material belongs to.
  52731. * @param engine defines the engine the material belongs to.
  52732. * @param disableBumpMap defines wether the material disables bump or not.
  52733. * @param isFrozen defines wether the material is frozen or not.
  52734. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52735. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52736. */
  52737. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52738. /**
  52739. * Checks to see if a texture is used in the material.
  52740. * @param texture - Base texture to use.
  52741. * @returns - Boolean specifying if a texture is used in the material.
  52742. */
  52743. hasTexture(texture: BaseTexture): boolean;
  52744. /**
  52745. * Returns an array of the actively used textures.
  52746. * @param activeTextures Array of BaseTextures
  52747. */
  52748. getActiveTextures(activeTextures: BaseTexture[]): void;
  52749. /**
  52750. * Returns the animatable textures.
  52751. * @param animatables Array of animatable textures.
  52752. */
  52753. getAnimatables(animatables: IAnimatable[]): void;
  52754. /**
  52755. * Disposes the resources of the material.
  52756. * @param forceDisposeTextures - Forces the disposal of all textures.
  52757. */
  52758. dispose(forceDisposeTextures?: boolean): void;
  52759. /**
  52760. * Get the current class name of the texture useful for serialization or dynamic coding.
  52761. * @returns "PBRClearCoatConfiguration"
  52762. */
  52763. getClassName(): string;
  52764. /**
  52765. * Add fallbacks to the effect fallbacks list.
  52766. * @param defines defines the Base texture to use.
  52767. * @param fallbacks defines the current fallback list.
  52768. * @param currentRank defines the current fallback rank.
  52769. * @returns the new fallback rank.
  52770. */
  52771. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52772. /**
  52773. * Add the required uniforms to the current list.
  52774. * @param uniforms defines the current uniform list.
  52775. */
  52776. static AddUniforms(uniforms: string[]): void;
  52777. /**
  52778. * Add the required samplers to the current list.
  52779. * @param samplers defines the current sampler list.
  52780. */
  52781. static AddSamplers(samplers: string[]): void;
  52782. /**
  52783. * Add the required uniforms to the current buffer.
  52784. * @param uniformBuffer defines the current uniform buffer.
  52785. */
  52786. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52787. /**
  52788. * Makes a duplicate of the current configuration into another one.
  52789. * @param clearCoatConfiguration define the config where to copy the info
  52790. */
  52791. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52792. /**
  52793. * Serializes this clear coat configuration.
  52794. * @returns - An object with the serialized config.
  52795. */
  52796. serialize(): any;
  52797. /**
  52798. * Parses a anisotropy Configuration from a serialized object.
  52799. * @param source - Serialized object.
  52800. * @param scene Defines the scene we are parsing for
  52801. * @param rootUrl Defines the rootUrl to load from
  52802. */
  52803. parse(source: any, scene: Scene, rootUrl: string): void;
  52804. }
  52805. }
  52806. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52807. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52808. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52809. import { Vector2 } from "babylonjs/Maths/math.vector";
  52810. import { Scene } from "babylonjs/scene";
  52811. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52812. import { Nullable } from "babylonjs/types";
  52813. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52814. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52815. /**
  52816. * @hidden
  52817. */
  52818. export interface IMaterialAnisotropicDefines {
  52819. ANISOTROPIC: boolean;
  52820. ANISOTROPIC_TEXTURE: boolean;
  52821. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52822. MAINUV1: boolean;
  52823. _areTexturesDirty: boolean;
  52824. _needUVs: boolean;
  52825. }
  52826. /**
  52827. * Define the code related to the anisotropic parameters of the pbr material.
  52828. */
  52829. export class PBRAnisotropicConfiguration {
  52830. private _isEnabled;
  52831. /**
  52832. * Defines if the anisotropy is enabled in the material.
  52833. */
  52834. isEnabled: boolean;
  52835. /**
  52836. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52837. */
  52838. intensity: number;
  52839. /**
  52840. * Defines if the effect is along the tangents, bitangents or in between.
  52841. * By default, the effect is "strectching" the highlights along the tangents.
  52842. */
  52843. direction: Vector2;
  52844. private _texture;
  52845. /**
  52846. * Stores the anisotropy values in a texture.
  52847. * rg is direction (like normal from -1 to 1)
  52848. * b is a intensity
  52849. */
  52850. texture: Nullable<BaseTexture>;
  52851. /** @hidden */
  52852. private _internalMarkAllSubMeshesAsTexturesDirty;
  52853. /** @hidden */
  52854. _markAllSubMeshesAsTexturesDirty(): void;
  52855. /**
  52856. * Instantiate a new istance of anisotropy configuration.
  52857. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52858. */
  52859. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52860. /**
  52861. * Specifies that the submesh is ready to be used.
  52862. * @param defines the list of "defines" to update.
  52863. * @param scene defines the scene the material belongs to.
  52864. * @returns - boolean indicating that the submesh is ready or not.
  52865. */
  52866. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52867. /**
  52868. * Checks to see if a texture is used in the material.
  52869. * @param defines the list of "defines" to update.
  52870. * @param mesh the mesh we are preparing the defines for.
  52871. * @param scene defines the scene the material belongs to.
  52872. */
  52873. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52874. /**
  52875. * Binds the material data.
  52876. * @param uniformBuffer defines the Uniform buffer to fill in.
  52877. * @param scene defines the scene the material belongs to.
  52878. * @param isFrozen defines wether the material is frozen or not.
  52879. */
  52880. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52881. /**
  52882. * Checks to see if a texture is used in the material.
  52883. * @param texture - Base texture to use.
  52884. * @returns - Boolean specifying if a texture is used in the material.
  52885. */
  52886. hasTexture(texture: BaseTexture): boolean;
  52887. /**
  52888. * Returns an array of the actively used textures.
  52889. * @param activeTextures Array of BaseTextures
  52890. */
  52891. getActiveTextures(activeTextures: BaseTexture[]): void;
  52892. /**
  52893. * Returns the animatable textures.
  52894. * @param animatables Array of animatable textures.
  52895. */
  52896. getAnimatables(animatables: IAnimatable[]): void;
  52897. /**
  52898. * Disposes the resources of the material.
  52899. * @param forceDisposeTextures - Forces the disposal of all textures.
  52900. */
  52901. dispose(forceDisposeTextures?: boolean): void;
  52902. /**
  52903. * Get the current class name of the texture useful for serialization or dynamic coding.
  52904. * @returns "PBRAnisotropicConfiguration"
  52905. */
  52906. getClassName(): string;
  52907. /**
  52908. * Add fallbacks to the effect fallbacks list.
  52909. * @param defines defines the Base texture to use.
  52910. * @param fallbacks defines the current fallback list.
  52911. * @param currentRank defines the current fallback rank.
  52912. * @returns the new fallback rank.
  52913. */
  52914. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52915. /**
  52916. * Add the required uniforms to the current list.
  52917. * @param uniforms defines the current uniform list.
  52918. */
  52919. static AddUniforms(uniforms: string[]): void;
  52920. /**
  52921. * Add the required uniforms to the current buffer.
  52922. * @param uniformBuffer defines the current uniform buffer.
  52923. */
  52924. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52925. /**
  52926. * Add the required samplers to the current list.
  52927. * @param samplers defines the current sampler list.
  52928. */
  52929. static AddSamplers(samplers: string[]): void;
  52930. /**
  52931. * Makes a duplicate of the current configuration into another one.
  52932. * @param anisotropicConfiguration define the config where to copy the info
  52933. */
  52934. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52935. /**
  52936. * Serializes this anisotropy configuration.
  52937. * @returns - An object with the serialized config.
  52938. */
  52939. serialize(): any;
  52940. /**
  52941. * Parses a anisotropy Configuration from a serialized object.
  52942. * @param source - Serialized object.
  52943. * @param scene Defines the scene we are parsing for
  52944. * @param rootUrl Defines the rootUrl to load from
  52945. */
  52946. parse(source: any, scene: Scene, rootUrl: string): void;
  52947. }
  52948. }
  52949. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52950. import { Scene } from "babylonjs/scene";
  52951. /**
  52952. * @hidden
  52953. */
  52954. export interface IMaterialBRDFDefines {
  52955. BRDF_V_HEIGHT_CORRELATED: boolean;
  52956. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52957. SPHERICAL_HARMONICS: boolean;
  52958. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52959. /** @hidden */
  52960. _areMiscDirty: boolean;
  52961. }
  52962. /**
  52963. * Define the code related to the BRDF parameters of the pbr material.
  52964. */
  52965. export class PBRBRDFConfiguration {
  52966. /**
  52967. * Default value used for the energy conservation.
  52968. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52969. */
  52970. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52971. /**
  52972. * Default value used for the Smith Visibility Height Correlated mode.
  52973. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52974. */
  52975. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52976. /**
  52977. * Default value used for the IBL diffuse part.
  52978. * This can help switching back to the polynomials mode globally which is a tiny bit
  52979. * less GPU intensive at the drawback of a lower quality.
  52980. */
  52981. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52982. /**
  52983. * Default value used for activating energy conservation for the specular workflow.
  52984. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52985. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52986. */
  52987. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52988. private _useEnergyConservation;
  52989. /**
  52990. * Defines if the material uses energy conservation.
  52991. */
  52992. useEnergyConservation: boolean;
  52993. private _useSmithVisibilityHeightCorrelated;
  52994. /**
  52995. * LEGACY Mode set to false
  52996. * Defines if the material uses height smith correlated visibility term.
  52997. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52998. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52999. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  53000. * Not relying on height correlated will also disable energy conservation.
  53001. */
  53002. useSmithVisibilityHeightCorrelated: boolean;
  53003. private _useSphericalHarmonics;
  53004. /**
  53005. * LEGACY Mode set to false
  53006. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  53007. * diffuse part of the IBL.
  53008. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  53009. * to the ground truth.
  53010. */
  53011. useSphericalHarmonics: boolean;
  53012. private _useSpecularGlossinessInputEnergyConservation;
  53013. /**
  53014. * Defines if the material uses energy conservation, when the specular workflow is active.
  53015. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53016. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53017. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  53018. */
  53019. useSpecularGlossinessInputEnergyConservation: boolean;
  53020. /** @hidden */
  53021. private _internalMarkAllSubMeshesAsMiscDirty;
  53022. /** @hidden */
  53023. _markAllSubMeshesAsMiscDirty(): void;
  53024. /**
  53025. * Instantiate a new istance of clear coat configuration.
  53026. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  53027. */
  53028. constructor(markAllSubMeshesAsMiscDirty: () => void);
  53029. /**
  53030. * Checks to see if a texture is used in the material.
  53031. * @param defines the list of "defines" to update.
  53032. */
  53033. prepareDefines(defines: IMaterialBRDFDefines): void;
  53034. /**
  53035. * Get the current class name of the texture useful for serialization or dynamic coding.
  53036. * @returns "PBRClearCoatConfiguration"
  53037. */
  53038. getClassName(): string;
  53039. /**
  53040. * Makes a duplicate of the current configuration into another one.
  53041. * @param brdfConfiguration define the config where to copy the info
  53042. */
  53043. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  53044. /**
  53045. * Serializes this BRDF configuration.
  53046. * @returns - An object with the serialized config.
  53047. */
  53048. serialize(): any;
  53049. /**
  53050. * Parses a anisotropy Configuration from a serialized object.
  53051. * @param source - Serialized object.
  53052. * @param scene Defines the scene we are parsing for
  53053. * @param rootUrl Defines the rootUrl to load from
  53054. */
  53055. parse(source: any, scene: Scene, rootUrl: string): void;
  53056. }
  53057. }
  53058. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  53059. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  53060. import { Color3 } from "babylonjs/Maths/math.color";
  53061. import { Scene } from "babylonjs/scene";
  53062. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53063. import { Nullable } from "babylonjs/types";
  53064. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53065. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  53066. /**
  53067. * @hidden
  53068. */
  53069. export interface IMaterialSheenDefines {
  53070. SHEEN: boolean;
  53071. SHEEN_TEXTURE: boolean;
  53072. SHEEN_TEXTUREDIRECTUV: number;
  53073. SHEEN_LINKWITHALBEDO: boolean;
  53074. SHEEN_ROUGHNESS: boolean;
  53075. SHEEN_ALBEDOSCALING: boolean;
  53076. /** @hidden */
  53077. _areTexturesDirty: boolean;
  53078. }
  53079. /**
  53080. * Define the code related to the Sheen parameters of the pbr material.
  53081. */
  53082. export class PBRSheenConfiguration {
  53083. private _isEnabled;
  53084. /**
  53085. * Defines if the material uses sheen.
  53086. */
  53087. isEnabled: boolean;
  53088. private _linkSheenWithAlbedo;
  53089. /**
  53090. * Defines if the sheen is linked to the sheen color.
  53091. */
  53092. linkSheenWithAlbedo: boolean;
  53093. /**
  53094. * Defines the sheen intensity.
  53095. */
  53096. intensity: number;
  53097. /**
  53098. * Defines the sheen color.
  53099. */
  53100. color: Color3;
  53101. private _texture;
  53102. /**
  53103. * Stores the sheen tint values in a texture.
  53104. * rgb is tint
  53105. * a is a intensity
  53106. */
  53107. texture: Nullable<BaseTexture>;
  53108. private _roughness;
  53109. /**
  53110. * Defines the sheen roughness.
  53111. * It is not taken into account if linkSheenWithAlbedo is true.
  53112. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  53113. */
  53114. roughness: Nullable<number>;
  53115. private _albedoScaling;
  53116. /**
  53117. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  53118. * It allows the strength of the sheen effect to not depend on the base color of the material,
  53119. * making it easier to setup and tweak the effect
  53120. */
  53121. albedoScaling: boolean;
  53122. /** @hidden */
  53123. private _internalMarkAllSubMeshesAsTexturesDirty;
  53124. /** @hidden */
  53125. _markAllSubMeshesAsTexturesDirty(): void;
  53126. /**
  53127. * Instantiate a new istance of clear coat configuration.
  53128. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53129. */
  53130. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53131. /**
  53132. * Specifies that the submesh is ready to be used.
  53133. * @param defines the list of "defines" to update.
  53134. * @param scene defines the scene the material belongs to.
  53135. * @returns - boolean indicating that the submesh is ready or not.
  53136. */
  53137. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  53138. /**
  53139. * Checks to see if a texture is used in the material.
  53140. * @param defines the list of "defines" to update.
  53141. * @param scene defines the scene the material belongs to.
  53142. */
  53143. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  53144. /**
  53145. * Binds the material data.
  53146. * @param uniformBuffer defines the Uniform buffer to fill in.
  53147. * @param scene defines the scene the material belongs to.
  53148. * @param isFrozen defines wether the material is frozen or not.
  53149. */
  53150. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53151. /**
  53152. * Checks to see if a texture is used in the material.
  53153. * @param texture - Base texture to use.
  53154. * @returns - Boolean specifying if a texture is used in the material.
  53155. */
  53156. hasTexture(texture: BaseTexture): boolean;
  53157. /**
  53158. * Returns an array of the actively used textures.
  53159. * @param activeTextures Array of BaseTextures
  53160. */
  53161. getActiveTextures(activeTextures: BaseTexture[]): void;
  53162. /**
  53163. * Returns the animatable textures.
  53164. * @param animatables Array of animatable textures.
  53165. */
  53166. getAnimatables(animatables: IAnimatable[]): void;
  53167. /**
  53168. * Disposes the resources of the material.
  53169. * @param forceDisposeTextures - Forces the disposal of all textures.
  53170. */
  53171. dispose(forceDisposeTextures?: boolean): void;
  53172. /**
  53173. * Get the current class name of the texture useful for serialization or dynamic coding.
  53174. * @returns "PBRSheenConfiguration"
  53175. */
  53176. getClassName(): string;
  53177. /**
  53178. * Add fallbacks to the effect fallbacks list.
  53179. * @param defines defines the Base texture to use.
  53180. * @param fallbacks defines the current fallback list.
  53181. * @param currentRank defines the current fallback rank.
  53182. * @returns the new fallback rank.
  53183. */
  53184. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53185. /**
  53186. * Add the required uniforms to the current list.
  53187. * @param uniforms defines the current uniform list.
  53188. */
  53189. static AddUniforms(uniforms: string[]): void;
  53190. /**
  53191. * Add the required uniforms to the current buffer.
  53192. * @param uniformBuffer defines the current uniform buffer.
  53193. */
  53194. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53195. /**
  53196. * Add the required samplers to the current list.
  53197. * @param samplers defines the current sampler list.
  53198. */
  53199. static AddSamplers(samplers: string[]): void;
  53200. /**
  53201. * Makes a duplicate of the current configuration into another one.
  53202. * @param sheenConfiguration define the config where to copy the info
  53203. */
  53204. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  53205. /**
  53206. * Serializes this BRDF configuration.
  53207. * @returns - An object with the serialized config.
  53208. */
  53209. serialize(): any;
  53210. /**
  53211. * Parses a anisotropy Configuration from a serialized object.
  53212. * @param source - Serialized object.
  53213. * @param scene Defines the scene we are parsing for
  53214. * @param rootUrl Defines the rootUrl to load from
  53215. */
  53216. parse(source: any, scene: Scene, rootUrl: string): void;
  53217. }
  53218. }
  53219. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  53220. import { Nullable } from "babylonjs/types";
  53221. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53222. import { Color3 } from "babylonjs/Maths/math.color";
  53223. import { SmartArray } from "babylonjs/Misc/smartArray";
  53224. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53225. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53226. import { Effect } from "babylonjs/Materials/effect";
  53227. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  53228. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  53229. import { Engine } from "babylonjs/Engines/engine";
  53230. import { Scene } from "babylonjs/scene";
  53231. /**
  53232. * @hidden
  53233. */
  53234. export interface IMaterialSubSurfaceDefines {
  53235. SUBSURFACE: boolean;
  53236. SS_REFRACTION: boolean;
  53237. SS_TRANSLUCENCY: boolean;
  53238. SS_SCATERRING: boolean;
  53239. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53240. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53241. SS_REFRACTIONMAP_3D: boolean;
  53242. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53243. SS_LODINREFRACTIONALPHA: boolean;
  53244. SS_GAMMAREFRACTION: boolean;
  53245. SS_RGBDREFRACTION: boolean;
  53246. SS_LINEARSPECULARREFRACTION: boolean;
  53247. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53248. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53249. /** @hidden */
  53250. _areTexturesDirty: boolean;
  53251. }
  53252. /**
  53253. * Define the code related to the sub surface parameters of the pbr material.
  53254. */
  53255. export class PBRSubSurfaceConfiguration {
  53256. private _isRefractionEnabled;
  53257. /**
  53258. * Defines if the refraction is enabled in the material.
  53259. */
  53260. isRefractionEnabled: boolean;
  53261. private _isTranslucencyEnabled;
  53262. /**
  53263. * Defines if the translucency is enabled in the material.
  53264. */
  53265. isTranslucencyEnabled: boolean;
  53266. private _isScatteringEnabled;
  53267. /**
  53268. * Defines the refraction intensity of the material.
  53269. * The refraction when enabled replaces the Diffuse part of the material.
  53270. * The intensity helps transitionning between diffuse and refraction.
  53271. */
  53272. refractionIntensity: number;
  53273. /**
  53274. * Defines the translucency intensity of the material.
  53275. * When translucency has been enabled, this defines how much of the "translucency"
  53276. * is addded to the diffuse part of the material.
  53277. */
  53278. translucencyIntensity: number;
  53279. /**
  53280. * Defines the scattering intensity of the material.
  53281. * When scattering has been enabled, this defines how much of the "scattered light"
  53282. * is addded to the diffuse part of the material.
  53283. */
  53284. scatteringIntensity: number;
  53285. private _thicknessTexture;
  53286. /**
  53287. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  53288. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  53289. * 0 would mean minimumThickness
  53290. * 1 would mean maximumThickness
  53291. * The other channels might be use as a mask to vary the different effects intensity.
  53292. */
  53293. thicknessTexture: Nullable<BaseTexture>;
  53294. private _refractionTexture;
  53295. /**
  53296. * Defines the texture to use for refraction.
  53297. */
  53298. refractionTexture: Nullable<BaseTexture>;
  53299. private _indexOfRefraction;
  53300. /**
  53301. * Defines the index of refraction used in the material.
  53302. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  53303. */
  53304. indexOfRefraction: number;
  53305. private _invertRefractionY;
  53306. /**
  53307. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53308. */
  53309. invertRefractionY: boolean;
  53310. private _linkRefractionWithTransparency;
  53311. /**
  53312. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53313. * Materials half opaque for instance using refraction could benefit from this control.
  53314. */
  53315. linkRefractionWithTransparency: boolean;
  53316. /**
  53317. * Defines the minimum thickness stored in the thickness map.
  53318. * If no thickness map is defined, this value will be used to simulate thickness.
  53319. */
  53320. minimumThickness: number;
  53321. /**
  53322. * Defines the maximum thickness stored in the thickness map.
  53323. */
  53324. maximumThickness: number;
  53325. /**
  53326. * Defines the volume tint of the material.
  53327. * This is used for both translucency and scattering.
  53328. */
  53329. tintColor: Color3;
  53330. /**
  53331. * Defines the distance at which the tint color should be found in the media.
  53332. * This is used for refraction only.
  53333. */
  53334. tintColorAtDistance: number;
  53335. /**
  53336. * Defines how far each channel transmit through the media.
  53337. * It is defined as a color to simplify it selection.
  53338. */
  53339. diffusionDistance: Color3;
  53340. private _useMaskFromThicknessTexture;
  53341. /**
  53342. * Stores the intensity of the different subsurface effects in the thickness texture.
  53343. * * the green channel is the translucency intensity.
  53344. * * the blue channel is the scattering intensity.
  53345. * * the alpha channel is the refraction intensity.
  53346. */
  53347. useMaskFromThicknessTexture: boolean;
  53348. /** @hidden */
  53349. private _internalMarkAllSubMeshesAsTexturesDirty;
  53350. /** @hidden */
  53351. _markAllSubMeshesAsTexturesDirty(): void;
  53352. /**
  53353. * Instantiate a new istance of sub surface configuration.
  53354. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53355. */
  53356. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53357. /**
  53358. * Gets wehter the submesh is ready to be used or not.
  53359. * @param defines the list of "defines" to update.
  53360. * @param scene defines the scene the material belongs to.
  53361. * @returns - boolean indicating that the submesh is ready or not.
  53362. */
  53363. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  53364. /**
  53365. * Checks to see if a texture is used in the material.
  53366. * @param defines the list of "defines" to update.
  53367. * @param scene defines the scene to the material belongs to.
  53368. */
  53369. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  53370. /**
  53371. * Binds the material data.
  53372. * @param uniformBuffer defines the Uniform buffer to fill in.
  53373. * @param scene defines the scene the material belongs to.
  53374. * @param engine defines the engine the material belongs to.
  53375. * @param isFrozen defines wether the material is frozen or not.
  53376. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  53377. */
  53378. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  53379. /**
  53380. * Unbinds the material from the mesh.
  53381. * @param activeEffect defines the effect that should be unbound from.
  53382. * @returns true if unbound, otherwise false
  53383. */
  53384. unbind(activeEffect: Effect): boolean;
  53385. /**
  53386. * Returns the texture used for refraction or null if none is used.
  53387. * @param scene defines the scene the material belongs to.
  53388. * @returns - Refraction texture if present. If no refraction texture and refraction
  53389. * is linked with transparency, returns environment texture. Otherwise, returns null.
  53390. */
  53391. private _getRefractionTexture;
  53392. /**
  53393. * Returns true if alpha blending should be disabled.
  53394. */
  53395. get disableAlphaBlending(): boolean;
  53396. /**
  53397. * Fills the list of render target textures.
  53398. * @param renderTargets the list of render targets to update
  53399. */
  53400. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  53401. /**
  53402. * Checks to see if a texture is used in the material.
  53403. * @param texture - Base texture to use.
  53404. * @returns - Boolean specifying if a texture is used in the material.
  53405. */
  53406. hasTexture(texture: BaseTexture): boolean;
  53407. /**
  53408. * Gets a boolean indicating that current material needs to register RTT
  53409. * @returns true if this uses a render target otherwise false.
  53410. */
  53411. hasRenderTargetTextures(): boolean;
  53412. /**
  53413. * Returns an array of the actively used textures.
  53414. * @param activeTextures Array of BaseTextures
  53415. */
  53416. getActiveTextures(activeTextures: BaseTexture[]): void;
  53417. /**
  53418. * Returns the animatable textures.
  53419. * @param animatables Array of animatable textures.
  53420. */
  53421. getAnimatables(animatables: IAnimatable[]): void;
  53422. /**
  53423. * Disposes the resources of the material.
  53424. * @param forceDisposeTextures - Forces the disposal of all textures.
  53425. */
  53426. dispose(forceDisposeTextures?: boolean): void;
  53427. /**
  53428. * Get the current class name of the texture useful for serialization or dynamic coding.
  53429. * @returns "PBRSubSurfaceConfiguration"
  53430. */
  53431. getClassName(): string;
  53432. /**
  53433. * Add fallbacks to the effect fallbacks list.
  53434. * @param defines defines the Base texture to use.
  53435. * @param fallbacks defines the current fallback list.
  53436. * @param currentRank defines the current fallback rank.
  53437. * @returns the new fallback rank.
  53438. */
  53439. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53440. /**
  53441. * Add the required uniforms to the current list.
  53442. * @param uniforms defines the current uniform list.
  53443. */
  53444. static AddUniforms(uniforms: string[]): void;
  53445. /**
  53446. * Add the required samplers to the current list.
  53447. * @param samplers defines the current sampler list.
  53448. */
  53449. static AddSamplers(samplers: string[]): void;
  53450. /**
  53451. * Add the required uniforms to the current buffer.
  53452. * @param uniformBuffer defines the current uniform buffer.
  53453. */
  53454. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53455. /**
  53456. * Makes a duplicate of the current configuration into another one.
  53457. * @param configuration define the config where to copy the info
  53458. */
  53459. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  53460. /**
  53461. * Serializes this Sub Surface configuration.
  53462. * @returns - An object with the serialized config.
  53463. */
  53464. serialize(): any;
  53465. /**
  53466. * Parses a anisotropy Configuration from a serialized object.
  53467. * @param source - Serialized object.
  53468. * @param scene Defines the scene we are parsing for
  53469. * @param rootUrl Defines the rootUrl to load from
  53470. */
  53471. parse(source: any, scene: Scene, rootUrl: string): void;
  53472. }
  53473. }
  53474. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  53475. /** @hidden */
  53476. export var pbrFragmentDeclaration: {
  53477. name: string;
  53478. shader: string;
  53479. };
  53480. }
  53481. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  53482. /** @hidden */
  53483. export var pbrUboDeclaration: {
  53484. name: string;
  53485. shader: string;
  53486. };
  53487. }
  53488. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  53489. /** @hidden */
  53490. export var pbrFragmentExtraDeclaration: {
  53491. name: string;
  53492. shader: string;
  53493. };
  53494. }
  53495. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  53496. /** @hidden */
  53497. export var pbrFragmentSamplersDeclaration: {
  53498. name: string;
  53499. shader: string;
  53500. };
  53501. }
  53502. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  53503. /** @hidden */
  53504. export var pbrHelperFunctions: {
  53505. name: string;
  53506. shader: string;
  53507. };
  53508. }
  53509. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  53510. /** @hidden */
  53511. export var harmonicsFunctions: {
  53512. name: string;
  53513. shader: string;
  53514. };
  53515. }
  53516. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  53517. /** @hidden */
  53518. export var pbrDirectLightingSetupFunctions: {
  53519. name: string;
  53520. shader: string;
  53521. };
  53522. }
  53523. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  53524. /** @hidden */
  53525. export var pbrDirectLightingFalloffFunctions: {
  53526. name: string;
  53527. shader: string;
  53528. };
  53529. }
  53530. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  53531. /** @hidden */
  53532. export var pbrBRDFFunctions: {
  53533. name: string;
  53534. shader: string;
  53535. };
  53536. }
  53537. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  53538. /** @hidden */
  53539. export var pbrDirectLightingFunctions: {
  53540. name: string;
  53541. shader: string;
  53542. };
  53543. }
  53544. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  53545. /** @hidden */
  53546. export var pbrIBLFunctions: {
  53547. name: string;
  53548. shader: string;
  53549. };
  53550. }
  53551. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  53552. /** @hidden */
  53553. export var pbrBlockAlbedoOpacity: {
  53554. name: string;
  53555. shader: string;
  53556. };
  53557. }
  53558. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  53559. /** @hidden */
  53560. export var pbrBlockReflectivity: {
  53561. name: string;
  53562. shader: string;
  53563. };
  53564. }
  53565. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  53566. /** @hidden */
  53567. export var pbrBlockAmbientOcclusion: {
  53568. name: string;
  53569. shader: string;
  53570. };
  53571. }
  53572. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  53573. /** @hidden */
  53574. export var pbrBlockAlphaFresnel: {
  53575. name: string;
  53576. shader: string;
  53577. };
  53578. }
  53579. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  53580. /** @hidden */
  53581. export var pbrBlockAnisotropic: {
  53582. name: string;
  53583. shader: string;
  53584. };
  53585. }
  53586. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  53587. /** @hidden */
  53588. export var pbrBlockReflection: {
  53589. name: string;
  53590. shader: string;
  53591. };
  53592. }
  53593. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  53594. /** @hidden */
  53595. export var pbrBlockSheen: {
  53596. name: string;
  53597. shader: string;
  53598. };
  53599. }
  53600. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  53601. /** @hidden */
  53602. export var pbrBlockClearcoat: {
  53603. name: string;
  53604. shader: string;
  53605. };
  53606. }
  53607. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  53608. /** @hidden */
  53609. export var pbrBlockSubSurface: {
  53610. name: string;
  53611. shader: string;
  53612. };
  53613. }
  53614. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  53615. /** @hidden */
  53616. export var pbrBlockNormalGeometric: {
  53617. name: string;
  53618. shader: string;
  53619. };
  53620. }
  53621. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  53622. /** @hidden */
  53623. export var pbrBlockNormalFinal: {
  53624. name: string;
  53625. shader: string;
  53626. };
  53627. }
  53628. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  53629. /** @hidden */
  53630. export var pbrBlockGeometryInfo: {
  53631. name: string;
  53632. shader: string;
  53633. };
  53634. }
  53635. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  53636. /** @hidden */
  53637. export var pbrBlockReflectance0: {
  53638. name: string;
  53639. shader: string;
  53640. };
  53641. }
  53642. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  53643. /** @hidden */
  53644. export var pbrBlockReflectance: {
  53645. name: string;
  53646. shader: string;
  53647. };
  53648. }
  53649. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  53650. /** @hidden */
  53651. export var pbrBlockDirectLighting: {
  53652. name: string;
  53653. shader: string;
  53654. };
  53655. }
  53656. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  53657. /** @hidden */
  53658. export var pbrBlockFinalLitComponents: {
  53659. name: string;
  53660. shader: string;
  53661. };
  53662. }
  53663. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  53664. /** @hidden */
  53665. export var pbrBlockFinalUnlitComponents: {
  53666. name: string;
  53667. shader: string;
  53668. };
  53669. }
  53670. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  53671. /** @hidden */
  53672. export var pbrBlockFinalColorComposition: {
  53673. name: string;
  53674. shader: string;
  53675. };
  53676. }
  53677. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  53678. /** @hidden */
  53679. export var pbrBlockImageProcessing: {
  53680. name: string;
  53681. shader: string;
  53682. };
  53683. }
  53684. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  53685. /** @hidden */
  53686. export var pbrDebug: {
  53687. name: string;
  53688. shader: string;
  53689. };
  53690. }
  53691. declare module "babylonjs/Shaders/pbr.fragment" {
  53692. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  53693. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53694. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  53695. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53696. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53697. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  53698. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53699. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  53700. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53701. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  53702. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53703. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  53704. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53705. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  53706. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53707. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  53708. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  53709. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  53710. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  53711. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  53712. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  53713. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  53714. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  53715. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  53716. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  53717. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  53718. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  53719. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  53720. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  53721. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  53722. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  53723. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53724. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  53725. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  53726. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  53727. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  53728. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  53729. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  53730. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  53731. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  53732. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  53733. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  53734. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  53735. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  53736. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  53737. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  53738. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  53739. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  53740. /** @hidden */
  53741. export var pbrPixelShader: {
  53742. name: string;
  53743. shader: string;
  53744. };
  53745. }
  53746. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  53747. /** @hidden */
  53748. export var pbrVertexDeclaration: {
  53749. name: string;
  53750. shader: string;
  53751. };
  53752. }
  53753. declare module "babylonjs/Shaders/pbr.vertex" {
  53754. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  53755. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53756. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53757. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53758. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53759. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53760. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  53761. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  53762. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  53763. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53764. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53765. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  53766. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  53767. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53768. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  53769. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53770. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53771. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  53772. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53773. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  53774. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  53775. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  53776. /** @hidden */
  53777. export var pbrVertexShader: {
  53778. name: string;
  53779. shader: string;
  53780. };
  53781. }
  53782. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  53783. import { Nullable } from "babylonjs/types";
  53784. import { Scene } from "babylonjs/scene";
  53785. import { Matrix } from "babylonjs/Maths/math.vector";
  53786. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53787. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53788. import { Mesh } from "babylonjs/Meshes/mesh";
  53789. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  53790. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  53791. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  53792. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  53793. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  53794. import { Color3 } from "babylonjs/Maths/math.color";
  53795. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53796. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  53797. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53798. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53799. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53800. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53801. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53802. import "babylonjs/Shaders/pbr.fragment";
  53803. import "babylonjs/Shaders/pbr.vertex";
  53804. /**
  53805. * Manages the defines for the PBR Material.
  53806. * @hidden
  53807. */
  53808. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  53809. PBR: boolean;
  53810. MAINUV1: boolean;
  53811. MAINUV2: boolean;
  53812. UV1: boolean;
  53813. UV2: boolean;
  53814. ALBEDO: boolean;
  53815. GAMMAALBEDO: boolean;
  53816. ALBEDODIRECTUV: number;
  53817. VERTEXCOLOR: boolean;
  53818. AMBIENT: boolean;
  53819. AMBIENTDIRECTUV: number;
  53820. AMBIENTINGRAYSCALE: boolean;
  53821. OPACITY: boolean;
  53822. VERTEXALPHA: boolean;
  53823. OPACITYDIRECTUV: number;
  53824. OPACITYRGB: boolean;
  53825. ALPHATEST: boolean;
  53826. DEPTHPREPASS: boolean;
  53827. ALPHABLEND: boolean;
  53828. ALPHAFROMALBEDO: boolean;
  53829. ALPHATESTVALUE: string;
  53830. SPECULAROVERALPHA: boolean;
  53831. RADIANCEOVERALPHA: boolean;
  53832. ALPHAFRESNEL: boolean;
  53833. LINEARALPHAFRESNEL: boolean;
  53834. PREMULTIPLYALPHA: boolean;
  53835. EMISSIVE: boolean;
  53836. EMISSIVEDIRECTUV: number;
  53837. REFLECTIVITY: boolean;
  53838. REFLECTIVITYDIRECTUV: number;
  53839. SPECULARTERM: boolean;
  53840. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  53841. MICROSURFACEAUTOMATIC: boolean;
  53842. LODBASEDMICROSFURACE: boolean;
  53843. MICROSURFACEMAP: boolean;
  53844. MICROSURFACEMAPDIRECTUV: number;
  53845. METALLICWORKFLOW: boolean;
  53846. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  53847. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  53848. METALLNESSSTOREINMETALMAPBLUE: boolean;
  53849. AOSTOREINMETALMAPRED: boolean;
  53850. METALLICF0FACTORFROMMETALLICMAP: boolean;
  53851. ENVIRONMENTBRDF: boolean;
  53852. ENVIRONMENTBRDF_RGBD: boolean;
  53853. NORMAL: boolean;
  53854. TANGENT: boolean;
  53855. BUMP: boolean;
  53856. BUMPDIRECTUV: number;
  53857. OBJECTSPACE_NORMALMAP: boolean;
  53858. PARALLAX: boolean;
  53859. PARALLAXOCCLUSION: boolean;
  53860. NORMALXYSCALE: boolean;
  53861. LIGHTMAP: boolean;
  53862. LIGHTMAPDIRECTUV: number;
  53863. USELIGHTMAPASSHADOWMAP: boolean;
  53864. GAMMALIGHTMAP: boolean;
  53865. RGBDLIGHTMAP: boolean;
  53866. REFLECTION: boolean;
  53867. REFLECTIONMAP_3D: boolean;
  53868. REFLECTIONMAP_SPHERICAL: boolean;
  53869. REFLECTIONMAP_PLANAR: boolean;
  53870. REFLECTIONMAP_CUBIC: boolean;
  53871. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  53872. REFLECTIONMAP_PROJECTION: boolean;
  53873. REFLECTIONMAP_SKYBOX: boolean;
  53874. REFLECTIONMAP_EXPLICIT: boolean;
  53875. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  53876. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  53877. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  53878. INVERTCUBICMAP: boolean;
  53879. USESPHERICALFROMREFLECTIONMAP: boolean;
  53880. USEIRRADIANCEMAP: boolean;
  53881. SPHERICAL_HARMONICS: boolean;
  53882. USESPHERICALINVERTEX: boolean;
  53883. REFLECTIONMAP_OPPOSITEZ: boolean;
  53884. LODINREFLECTIONALPHA: boolean;
  53885. GAMMAREFLECTION: boolean;
  53886. RGBDREFLECTION: boolean;
  53887. LINEARSPECULARREFLECTION: boolean;
  53888. RADIANCEOCCLUSION: boolean;
  53889. HORIZONOCCLUSION: boolean;
  53890. INSTANCES: boolean;
  53891. NUM_BONE_INFLUENCERS: number;
  53892. BonesPerMesh: number;
  53893. BONETEXTURE: boolean;
  53894. NONUNIFORMSCALING: boolean;
  53895. MORPHTARGETS: boolean;
  53896. MORPHTARGETS_NORMAL: boolean;
  53897. MORPHTARGETS_TANGENT: boolean;
  53898. MORPHTARGETS_UV: boolean;
  53899. NUM_MORPH_INFLUENCERS: number;
  53900. IMAGEPROCESSING: boolean;
  53901. VIGNETTE: boolean;
  53902. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53903. VIGNETTEBLENDMODEOPAQUE: boolean;
  53904. TONEMAPPING: boolean;
  53905. TONEMAPPING_ACES: boolean;
  53906. CONTRAST: boolean;
  53907. COLORCURVES: boolean;
  53908. COLORGRADING: boolean;
  53909. COLORGRADING3D: boolean;
  53910. SAMPLER3DGREENDEPTH: boolean;
  53911. SAMPLER3DBGRMAP: boolean;
  53912. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53913. EXPOSURE: boolean;
  53914. MULTIVIEW: boolean;
  53915. USEPHYSICALLIGHTFALLOFF: boolean;
  53916. USEGLTFLIGHTFALLOFF: boolean;
  53917. TWOSIDEDLIGHTING: boolean;
  53918. SHADOWFLOAT: boolean;
  53919. CLIPPLANE: boolean;
  53920. CLIPPLANE2: boolean;
  53921. CLIPPLANE3: boolean;
  53922. CLIPPLANE4: boolean;
  53923. CLIPPLANE5: boolean;
  53924. CLIPPLANE6: boolean;
  53925. POINTSIZE: boolean;
  53926. FOG: boolean;
  53927. LOGARITHMICDEPTH: boolean;
  53928. FORCENORMALFORWARD: boolean;
  53929. SPECULARAA: boolean;
  53930. CLEARCOAT: boolean;
  53931. CLEARCOAT_DEFAULTIOR: boolean;
  53932. CLEARCOAT_TEXTURE: boolean;
  53933. CLEARCOAT_TEXTUREDIRECTUV: number;
  53934. CLEARCOAT_BUMP: boolean;
  53935. CLEARCOAT_BUMPDIRECTUV: number;
  53936. CLEARCOAT_TINT: boolean;
  53937. CLEARCOAT_TINT_TEXTURE: boolean;
  53938. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53939. ANISOTROPIC: boolean;
  53940. ANISOTROPIC_TEXTURE: boolean;
  53941. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53942. BRDF_V_HEIGHT_CORRELATED: boolean;
  53943. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53944. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53945. SHEEN: boolean;
  53946. SHEEN_TEXTURE: boolean;
  53947. SHEEN_TEXTUREDIRECTUV: number;
  53948. SHEEN_LINKWITHALBEDO: boolean;
  53949. SHEEN_ROUGHNESS: boolean;
  53950. SHEEN_ALBEDOSCALING: boolean;
  53951. SUBSURFACE: boolean;
  53952. SS_REFRACTION: boolean;
  53953. SS_TRANSLUCENCY: boolean;
  53954. SS_SCATERRING: boolean;
  53955. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53956. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53957. SS_REFRACTIONMAP_3D: boolean;
  53958. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53959. SS_LODINREFRACTIONALPHA: boolean;
  53960. SS_GAMMAREFRACTION: boolean;
  53961. SS_RGBDREFRACTION: boolean;
  53962. SS_LINEARSPECULARREFRACTION: boolean;
  53963. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53964. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53965. UNLIT: boolean;
  53966. DEBUGMODE: number;
  53967. /**
  53968. * Initializes the PBR Material defines.
  53969. */
  53970. constructor();
  53971. /**
  53972. * Resets the PBR Material defines.
  53973. */
  53974. reset(): void;
  53975. }
  53976. /**
  53977. * The Physically based material base class of BJS.
  53978. *
  53979. * This offers the main features of a standard PBR material.
  53980. * For more information, please refer to the documentation :
  53981. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53982. */
  53983. export abstract class PBRBaseMaterial extends PushMaterial {
  53984. /**
  53985. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53986. */
  53987. static readonly PBRMATERIAL_OPAQUE: number;
  53988. /**
  53989. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53990. */
  53991. static readonly PBRMATERIAL_ALPHATEST: number;
  53992. /**
  53993. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53994. */
  53995. static readonly PBRMATERIAL_ALPHABLEND: number;
  53996. /**
  53997. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53998. * They are also discarded below the alpha cutoff threshold to improve performances.
  53999. */
  54000. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54001. /**
  54002. * Defines the default value of how much AO map is occluding the analytical lights
  54003. * (point spot...).
  54004. */
  54005. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54006. /**
  54007. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  54008. */
  54009. static readonly LIGHTFALLOFF_PHYSICAL: number;
  54010. /**
  54011. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  54012. * to enhance interoperability with other engines.
  54013. */
  54014. static readonly LIGHTFALLOFF_GLTF: number;
  54015. /**
  54016. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  54017. * to enhance interoperability with other materials.
  54018. */
  54019. static readonly LIGHTFALLOFF_STANDARD: number;
  54020. /**
  54021. * Intensity of the direct lights e.g. the four lights available in your scene.
  54022. * This impacts both the direct diffuse and specular highlights.
  54023. */
  54024. protected _directIntensity: number;
  54025. /**
  54026. * Intensity of the emissive part of the material.
  54027. * This helps controlling the emissive effect without modifying the emissive color.
  54028. */
  54029. protected _emissiveIntensity: number;
  54030. /**
  54031. * Intensity of the environment e.g. how much the environment will light the object
  54032. * either through harmonics for rough material or through the refelction for shiny ones.
  54033. */
  54034. protected _environmentIntensity: number;
  54035. /**
  54036. * This is a special control allowing the reduction of the specular highlights coming from the
  54037. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54038. */
  54039. protected _specularIntensity: number;
  54040. /**
  54041. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  54042. */
  54043. private _lightingInfos;
  54044. /**
  54045. * Debug Control allowing disabling the bump map on this material.
  54046. */
  54047. protected _disableBumpMap: boolean;
  54048. /**
  54049. * AKA Diffuse Texture in standard nomenclature.
  54050. */
  54051. protected _albedoTexture: Nullable<BaseTexture>;
  54052. /**
  54053. * AKA Occlusion Texture in other nomenclature.
  54054. */
  54055. protected _ambientTexture: Nullable<BaseTexture>;
  54056. /**
  54057. * AKA Occlusion Texture Intensity in other nomenclature.
  54058. */
  54059. protected _ambientTextureStrength: number;
  54060. /**
  54061. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54062. * 1 means it completely occludes it
  54063. * 0 mean it has no impact
  54064. */
  54065. protected _ambientTextureImpactOnAnalyticalLights: number;
  54066. /**
  54067. * Stores the alpha values in a texture.
  54068. */
  54069. protected _opacityTexture: Nullable<BaseTexture>;
  54070. /**
  54071. * Stores the reflection values in a texture.
  54072. */
  54073. protected _reflectionTexture: Nullable<BaseTexture>;
  54074. /**
  54075. * Stores the emissive values in a texture.
  54076. */
  54077. protected _emissiveTexture: Nullable<BaseTexture>;
  54078. /**
  54079. * AKA Specular texture in other nomenclature.
  54080. */
  54081. protected _reflectivityTexture: Nullable<BaseTexture>;
  54082. /**
  54083. * Used to switch from specular/glossiness to metallic/roughness workflow.
  54084. */
  54085. protected _metallicTexture: Nullable<BaseTexture>;
  54086. /**
  54087. * Specifies the metallic scalar of the metallic/roughness workflow.
  54088. * Can also be used to scale the metalness values of the metallic texture.
  54089. */
  54090. protected _metallic: Nullable<number>;
  54091. /**
  54092. * Specifies the roughness scalar of the metallic/roughness workflow.
  54093. * Can also be used to scale the roughness values of the metallic texture.
  54094. */
  54095. protected _roughness: Nullable<number>;
  54096. /**
  54097. * Specifies the an F0 factor to help configuring the material F0.
  54098. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  54099. * to 0.5 the previously hard coded value stays the same.
  54100. * Can also be used to scale the F0 values of the metallic texture.
  54101. */
  54102. protected _metallicF0Factor: number;
  54103. /**
  54104. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  54105. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  54106. * your expectation as it multiplies with the texture data.
  54107. */
  54108. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  54109. /**
  54110. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54111. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54112. */
  54113. protected _microSurfaceTexture: Nullable<BaseTexture>;
  54114. /**
  54115. * Stores surface normal data used to displace a mesh in a texture.
  54116. */
  54117. protected _bumpTexture: Nullable<BaseTexture>;
  54118. /**
  54119. * Stores the pre-calculated light information of a mesh in a texture.
  54120. */
  54121. protected _lightmapTexture: Nullable<BaseTexture>;
  54122. /**
  54123. * The color of a material in ambient lighting.
  54124. */
  54125. protected _ambientColor: Color3;
  54126. /**
  54127. * AKA Diffuse Color in other nomenclature.
  54128. */
  54129. protected _albedoColor: Color3;
  54130. /**
  54131. * AKA Specular Color in other nomenclature.
  54132. */
  54133. protected _reflectivityColor: Color3;
  54134. /**
  54135. * The color applied when light is reflected from a material.
  54136. */
  54137. protected _reflectionColor: Color3;
  54138. /**
  54139. * The color applied when light is emitted from a material.
  54140. */
  54141. protected _emissiveColor: Color3;
  54142. /**
  54143. * AKA Glossiness in other nomenclature.
  54144. */
  54145. protected _microSurface: number;
  54146. /**
  54147. * Specifies that the material will use the light map as a show map.
  54148. */
  54149. protected _useLightmapAsShadowmap: boolean;
  54150. /**
  54151. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54152. * makes the reflect vector face the model (under horizon).
  54153. */
  54154. protected _useHorizonOcclusion: boolean;
  54155. /**
  54156. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54157. * too much the area relying on ambient texture to define their ambient occlusion.
  54158. */
  54159. protected _useRadianceOcclusion: boolean;
  54160. /**
  54161. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54162. */
  54163. protected _useAlphaFromAlbedoTexture: boolean;
  54164. /**
  54165. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  54166. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54167. */
  54168. protected _useSpecularOverAlpha: boolean;
  54169. /**
  54170. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54171. */
  54172. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54173. /**
  54174. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54175. */
  54176. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  54177. /**
  54178. * Specifies if the metallic texture contains the roughness information in its green channel.
  54179. */
  54180. protected _useRoughnessFromMetallicTextureGreen: boolean;
  54181. /**
  54182. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54183. */
  54184. protected _useMetallnessFromMetallicTextureBlue: boolean;
  54185. /**
  54186. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54187. */
  54188. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  54189. /**
  54190. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54191. */
  54192. protected _useAmbientInGrayScale: boolean;
  54193. /**
  54194. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54195. * The material will try to infer what glossiness each pixel should be.
  54196. */
  54197. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  54198. /**
  54199. * Defines the falloff type used in this material.
  54200. * It by default is Physical.
  54201. */
  54202. protected _lightFalloff: number;
  54203. /**
  54204. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54205. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54206. */
  54207. protected _useRadianceOverAlpha: boolean;
  54208. /**
  54209. * Allows using an object space normal map (instead of tangent space).
  54210. */
  54211. protected _useObjectSpaceNormalMap: boolean;
  54212. /**
  54213. * Allows using the bump map in parallax mode.
  54214. */
  54215. protected _useParallax: boolean;
  54216. /**
  54217. * Allows using the bump map in parallax occlusion mode.
  54218. */
  54219. protected _useParallaxOcclusion: boolean;
  54220. /**
  54221. * Controls the scale bias of the parallax mode.
  54222. */
  54223. protected _parallaxScaleBias: number;
  54224. /**
  54225. * If sets to true, disables all the lights affecting the material.
  54226. */
  54227. protected _disableLighting: boolean;
  54228. /**
  54229. * Number of Simultaneous lights allowed on the material.
  54230. */
  54231. protected _maxSimultaneousLights: number;
  54232. /**
  54233. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54234. */
  54235. protected _invertNormalMapX: boolean;
  54236. /**
  54237. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54238. */
  54239. protected _invertNormalMapY: boolean;
  54240. /**
  54241. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54242. */
  54243. protected _twoSidedLighting: boolean;
  54244. /**
  54245. * Defines the alpha limits in alpha test mode.
  54246. */
  54247. protected _alphaCutOff: number;
  54248. /**
  54249. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54250. */
  54251. protected _forceAlphaTest: boolean;
  54252. /**
  54253. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54254. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54255. */
  54256. protected _useAlphaFresnel: boolean;
  54257. /**
  54258. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54259. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54260. */
  54261. protected _useLinearAlphaFresnel: boolean;
  54262. /**
  54263. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  54264. * from cos thetav and roughness:
  54265. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  54266. */
  54267. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  54268. /**
  54269. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54270. */
  54271. protected _forceIrradianceInFragment: boolean;
  54272. /**
  54273. * Force normal to face away from face.
  54274. */
  54275. protected _forceNormalForward: boolean;
  54276. /**
  54277. * Enables specular anti aliasing in the PBR shader.
  54278. * It will both interacts on the Geometry for analytical and IBL lighting.
  54279. * It also prefilter the roughness map based on the bump values.
  54280. */
  54281. protected _enableSpecularAntiAliasing: boolean;
  54282. /**
  54283. * Default configuration related to image processing available in the PBR Material.
  54284. */
  54285. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54286. /**
  54287. * Keep track of the image processing observer to allow dispose and replace.
  54288. */
  54289. private _imageProcessingObserver;
  54290. /**
  54291. * Attaches a new image processing configuration to the PBR Material.
  54292. * @param configuration
  54293. */
  54294. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54295. /**
  54296. * Stores the available render targets.
  54297. */
  54298. private _renderTargets;
  54299. /**
  54300. * Sets the global ambient color for the material used in lighting calculations.
  54301. */
  54302. private _globalAmbientColor;
  54303. /**
  54304. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  54305. */
  54306. private _useLogarithmicDepth;
  54307. /**
  54308. * If set to true, no lighting calculations will be applied.
  54309. */
  54310. private _unlit;
  54311. private _debugMode;
  54312. /**
  54313. * @hidden
  54314. * This is reserved for the inspector.
  54315. * Defines the material debug mode.
  54316. * It helps seeing only some components of the material while troubleshooting.
  54317. */
  54318. debugMode: number;
  54319. /**
  54320. * @hidden
  54321. * This is reserved for the inspector.
  54322. * Specify from where on screen the debug mode should start.
  54323. * The value goes from -1 (full screen) to 1 (not visible)
  54324. * It helps with side by side comparison against the final render
  54325. * This defaults to -1
  54326. */
  54327. private debugLimit;
  54328. /**
  54329. * @hidden
  54330. * This is reserved for the inspector.
  54331. * As the default viewing range might not be enough (if the ambient is really small for instance)
  54332. * You can use the factor to better multiply the final value.
  54333. */
  54334. private debugFactor;
  54335. /**
  54336. * Defines the clear coat layer parameters for the material.
  54337. */
  54338. readonly clearCoat: PBRClearCoatConfiguration;
  54339. /**
  54340. * Defines the anisotropic parameters for the material.
  54341. */
  54342. readonly anisotropy: PBRAnisotropicConfiguration;
  54343. /**
  54344. * Defines the BRDF parameters for the material.
  54345. */
  54346. readonly brdf: PBRBRDFConfiguration;
  54347. /**
  54348. * Defines the Sheen parameters for the material.
  54349. */
  54350. readonly sheen: PBRSheenConfiguration;
  54351. /**
  54352. * Defines the SubSurface parameters for the material.
  54353. */
  54354. readonly subSurface: PBRSubSurfaceConfiguration;
  54355. protected _rebuildInParallel: boolean;
  54356. /**
  54357. * Instantiates a new PBRMaterial instance.
  54358. *
  54359. * @param name The material name
  54360. * @param scene The scene the material will be use in.
  54361. */
  54362. constructor(name: string, scene: Scene);
  54363. /**
  54364. * Gets a boolean indicating that current material needs to register RTT
  54365. */
  54366. get hasRenderTargetTextures(): boolean;
  54367. /**
  54368. * Gets the name of the material class.
  54369. */
  54370. getClassName(): string;
  54371. /**
  54372. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  54373. */
  54374. get useLogarithmicDepth(): boolean;
  54375. /**
  54376. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  54377. */
  54378. set useLogarithmicDepth(value: boolean);
  54379. /**
  54380. * Returns true if alpha blending should be disabled.
  54381. */
  54382. protected get _disableAlphaBlending(): boolean;
  54383. /**
  54384. * Specifies whether or not this material should be rendered in alpha blend mode.
  54385. */
  54386. needAlphaBlending(): boolean;
  54387. /**
  54388. * Specifies whether or not this material should be rendered in alpha test mode.
  54389. */
  54390. needAlphaTesting(): boolean;
  54391. /**
  54392. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  54393. */
  54394. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  54395. /**
  54396. * Gets the texture used for the alpha test.
  54397. */
  54398. getAlphaTestTexture(): Nullable<BaseTexture>;
  54399. /**
  54400. * Specifies that the submesh is ready to be used.
  54401. * @param mesh - BJS mesh.
  54402. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  54403. * @param useInstances - Specifies that instances should be used.
  54404. * @returns - boolean indicating that the submesh is ready or not.
  54405. */
  54406. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54407. /**
  54408. * Specifies if the material uses metallic roughness workflow.
  54409. * @returns boolean specifiying if the material uses metallic roughness workflow.
  54410. */
  54411. isMetallicWorkflow(): boolean;
  54412. private _prepareEffect;
  54413. private _prepareDefines;
  54414. /**
  54415. * Force shader compilation
  54416. */
  54417. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  54418. /**
  54419. * Initializes the uniform buffer layout for the shader.
  54420. */
  54421. buildUniformLayout(): void;
  54422. /**
  54423. * Unbinds the material from the mesh
  54424. */
  54425. unbind(): void;
  54426. /**
  54427. * Binds the submesh data.
  54428. * @param world - The world matrix.
  54429. * @param mesh - The BJS mesh.
  54430. * @param subMesh - A submesh of the BJS mesh.
  54431. */
  54432. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54433. /**
  54434. * Returns the animatable textures.
  54435. * @returns - Array of animatable textures.
  54436. */
  54437. getAnimatables(): IAnimatable[];
  54438. /**
  54439. * Returns the texture used for reflections.
  54440. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  54441. */
  54442. private _getReflectionTexture;
  54443. /**
  54444. * Returns an array of the actively used textures.
  54445. * @returns - Array of BaseTextures
  54446. */
  54447. getActiveTextures(): BaseTexture[];
  54448. /**
  54449. * Checks to see if a texture is used in the material.
  54450. * @param texture - Base texture to use.
  54451. * @returns - Boolean specifying if a texture is used in the material.
  54452. */
  54453. hasTexture(texture: BaseTexture): boolean;
  54454. /**
  54455. * Disposes the resources of the material.
  54456. * @param forceDisposeEffect - Forces the disposal of effects.
  54457. * @param forceDisposeTextures - Forces the disposal of all textures.
  54458. */
  54459. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54460. }
  54461. }
  54462. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  54463. import { Nullable } from "babylonjs/types";
  54464. import { Scene } from "babylonjs/scene";
  54465. import { Color3 } from "babylonjs/Maths/math.color";
  54466. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  54467. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  54468. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54469. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54470. /**
  54471. * The Physically based material of BJS.
  54472. *
  54473. * This offers the main features of a standard PBR material.
  54474. * For more information, please refer to the documentation :
  54475. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54476. */
  54477. export class PBRMaterial extends PBRBaseMaterial {
  54478. /**
  54479. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54480. */
  54481. static readonly PBRMATERIAL_OPAQUE: number;
  54482. /**
  54483. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54484. */
  54485. static readonly PBRMATERIAL_ALPHATEST: number;
  54486. /**
  54487. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54488. */
  54489. static readonly PBRMATERIAL_ALPHABLEND: number;
  54490. /**
  54491. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54492. * They are also discarded below the alpha cutoff threshold to improve performances.
  54493. */
  54494. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54495. /**
  54496. * Defines the default value of how much AO map is occluding the analytical lights
  54497. * (point spot...).
  54498. */
  54499. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54500. /**
  54501. * Intensity of the direct lights e.g. the four lights available in your scene.
  54502. * This impacts both the direct diffuse and specular highlights.
  54503. */
  54504. directIntensity: number;
  54505. /**
  54506. * Intensity of the emissive part of the material.
  54507. * This helps controlling the emissive effect without modifying the emissive color.
  54508. */
  54509. emissiveIntensity: number;
  54510. /**
  54511. * Intensity of the environment e.g. how much the environment will light the object
  54512. * either through harmonics for rough material or through the refelction for shiny ones.
  54513. */
  54514. environmentIntensity: number;
  54515. /**
  54516. * This is a special control allowing the reduction of the specular highlights coming from the
  54517. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54518. */
  54519. specularIntensity: number;
  54520. /**
  54521. * Debug Control allowing disabling the bump map on this material.
  54522. */
  54523. disableBumpMap: boolean;
  54524. /**
  54525. * AKA Diffuse Texture in standard nomenclature.
  54526. */
  54527. albedoTexture: BaseTexture;
  54528. /**
  54529. * AKA Occlusion Texture in other nomenclature.
  54530. */
  54531. ambientTexture: BaseTexture;
  54532. /**
  54533. * AKA Occlusion Texture Intensity in other nomenclature.
  54534. */
  54535. ambientTextureStrength: number;
  54536. /**
  54537. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54538. * 1 means it completely occludes it
  54539. * 0 mean it has no impact
  54540. */
  54541. ambientTextureImpactOnAnalyticalLights: number;
  54542. /**
  54543. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  54544. */
  54545. opacityTexture: BaseTexture;
  54546. /**
  54547. * Stores the reflection values in a texture.
  54548. */
  54549. reflectionTexture: Nullable<BaseTexture>;
  54550. /**
  54551. * Stores the emissive values in a texture.
  54552. */
  54553. emissiveTexture: BaseTexture;
  54554. /**
  54555. * AKA Specular texture in other nomenclature.
  54556. */
  54557. reflectivityTexture: BaseTexture;
  54558. /**
  54559. * Used to switch from specular/glossiness to metallic/roughness workflow.
  54560. */
  54561. metallicTexture: BaseTexture;
  54562. /**
  54563. * Specifies the metallic scalar of the metallic/roughness workflow.
  54564. * Can also be used to scale the metalness values of the metallic texture.
  54565. */
  54566. metallic: Nullable<number>;
  54567. /**
  54568. * Specifies the roughness scalar of the metallic/roughness workflow.
  54569. * Can also be used to scale the roughness values of the metallic texture.
  54570. */
  54571. roughness: Nullable<number>;
  54572. /**
  54573. * Specifies the an F0 factor to help configuring the material F0.
  54574. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  54575. * to 0.5 the previously hard coded value stays the same.
  54576. * Can also be used to scale the F0 values of the metallic texture.
  54577. */
  54578. metallicF0Factor: number;
  54579. /**
  54580. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  54581. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  54582. * your expectation as it multiplies with the texture data.
  54583. */
  54584. useMetallicF0FactorFromMetallicTexture: boolean;
  54585. /**
  54586. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54587. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54588. */
  54589. microSurfaceTexture: BaseTexture;
  54590. /**
  54591. * Stores surface normal data used to displace a mesh in a texture.
  54592. */
  54593. bumpTexture: BaseTexture;
  54594. /**
  54595. * Stores the pre-calculated light information of a mesh in a texture.
  54596. */
  54597. lightmapTexture: BaseTexture;
  54598. /**
  54599. * Stores the refracted light information in a texture.
  54600. */
  54601. get refractionTexture(): Nullable<BaseTexture>;
  54602. set refractionTexture(value: Nullable<BaseTexture>);
  54603. /**
  54604. * The color of a material in ambient lighting.
  54605. */
  54606. ambientColor: Color3;
  54607. /**
  54608. * AKA Diffuse Color in other nomenclature.
  54609. */
  54610. albedoColor: Color3;
  54611. /**
  54612. * AKA Specular Color in other nomenclature.
  54613. */
  54614. reflectivityColor: Color3;
  54615. /**
  54616. * The color reflected from the material.
  54617. */
  54618. reflectionColor: Color3;
  54619. /**
  54620. * The color emitted from the material.
  54621. */
  54622. emissiveColor: Color3;
  54623. /**
  54624. * AKA Glossiness in other nomenclature.
  54625. */
  54626. microSurface: number;
  54627. /**
  54628. * source material index of refraction (IOR)' / 'destination material IOR.
  54629. */
  54630. get indexOfRefraction(): number;
  54631. set indexOfRefraction(value: number);
  54632. /**
  54633. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54634. */
  54635. get invertRefractionY(): boolean;
  54636. set invertRefractionY(value: boolean);
  54637. /**
  54638. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54639. * Materials half opaque for instance using refraction could benefit from this control.
  54640. */
  54641. get linkRefractionWithTransparency(): boolean;
  54642. set linkRefractionWithTransparency(value: boolean);
  54643. /**
  54644. * If true, the light map contains occlusion information instead of lighting info.
  54645. */
  54646. useLightmapAsShadowmap: boolean;
  54647. /**
  54648. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54649. */
  54650. useAlphaFromAlbedoTexture: boolean;
  54651. /**
  54652. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54653. */
  54654. forceAlphaTest: boolean;
  54655. /**
  54656. * Defines the alpha limits in alpha test mode.
  54657. */
  54658. alphaCutOff: number;
  54659. /**
  54660. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  54661. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54662. */
  54663. useSpecularOverAlpha: boolean;
  54664. /**
  54665. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54666. */
  54667. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54668. /**
  54669. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54670. */
  54671. useRoughnessFromMetallicTextureAlpha: boolean;
  54672. /**
  54673. * Specifies if the metallic texture contains the roughness information in its green channel.
  54674. */
  54675. useRoughnessFromMetallicTextureGreen: boolean;
  54676. /**
  54677. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54678. */
  54679. useMetallnessFromMetallicTextureBlue: boolean;
  54680. /**
  54681. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54682. */
  54683. useAmbientOcclusionFromMetallicTextureRed: boolean;
  54684. /**
  54685. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54686. */
  54687. useAmbientInGrayScale: boolean;
  54688. /**
  54689. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54690. * The material will try to infer what glossiness each pixel should be.
  54691. */
  54692. useAutoMicroSurfaceFromReflectivityMap: boolean;
  54693. /**
  54694. * BJS is using an harcoded light falloff based on a manually sets up range.
  54695. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54696. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54697. */
  54698. get usePhysicalLightFalloff(): boolean;
  54699. /**
  54700. * BJS is using an harcoded light falloff based on a manually sets up range.
  54701. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54702. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54703. */
  54704. set usePhysicalLightFalloff(value: boolean);
  54705. /**
  54706. * In order to support the falloff compatibility with gltf, a special mode has been added
  54707. * to reproduce the gltf light falloff.
  54708. */
  54709. get useGLTFLightFalloff(): boolean;
  54710. /**
  54711. * In order to support the falloff compatibility with gltf, a special mode has been added
  54712. * to reproduce the gltf light falloff.
  54713. */
  54714. set useGLTFLightFalloff(value: boolean);
  54715. /**
  54716. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54717. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54718. */
  54719. useRadianceOverAlpha: boolean;
  54720. /**
  54721. * Allows using an object space normal map (instead of tangent space).
  54722. */
  54723. useObjectSpaceNormalMap: boolean;
  54724. /**
  54725. * Allows using the bump map in parallax mode.
  54726. */
  54727. useParallax: boolean;
  54728. /**
  54729. * Allows using the bump map in parallax occlusion mode.
  54730. */
  54731. useParallaxOcclusion: boolean;
  54732. /**
  54733. * Controls the scale bias of the parallax mode.
  54734. */
  54735. parallaxScaleBias: number;
  54736. /**
  54737. * If sets to true, disables all the lights affecting the material.
  54738. */
  54739. disableLighting: boolean;
  54740. /**
  54741. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54742. */
  54743. forceIrradianceInFragment: boolean;
  54744. /**
  54745. * Number of Simultaneous lights allowed on the material.
  54746. */
  54747. maxSimultaneousLights: number;
  54748. /**
  54749. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54750. */
  54751. invertNormalMapX: boolean;
  54752. /**
  54753. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54754. */
  54755. invertNormalMapY: boolean;
  54756. /**
  54757. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54758. */
  54759. twoSidedLighting: boolean;
  54760. /**
  54761. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54762. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54763. */
  54764. useAlphaFresnel: boolean;
  54765. /**
  54766. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54767. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54768. */
  54769. useLinearAlphaFresnel: boolean;
  54770. /**
  54771. * Let user defines the brdf lookup texture used for IBL.
  54772. * A default 8bit version is embedded but you could point at :
  54773. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  54774. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  54775. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  54776. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  54777. */
  54778. environmentBRDFTexture: Nullable<BaseTexture>;
  54779. /**
  54780. * Force normal to face away from face.
  54781. */
  54782. forceNormalForward: boolean;
  54783. /**
  54784. * Enables specular anti aliasing in the PBR shader.
  54785. * It will both interacts on the Geometry for analytical and IBL lighting.
  54786. * It also prefilter the roughness map based on the bump values.
  54787. */
  54788. enableSpecularAntiAliasing: boolean;
  54789. /**
  54790. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54791. * makes the reflect vector face the model (under horizon).
  54792. */
  54793. useHorizonOcclusion: boolean;
  54794. /**
  54795. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54796. * too much the area relying on ambient texture to define their ambient occlusion.
  54797. */
  54798. useRadianceOcclusion: boolean;
  54799. /**
  54800. * If set to true, no lighting calculations will be applied.
  54801. */
  54802. unlit: boolean;
  54803. /**
  54804. * Gets the image processing configuration used either in this material.
  54805. */
  54806. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  54807. /**
  54808. * Sets the Default image processing configuration used either in the this material.
  54809. *
  54810. * If sets to null, the scene one is in use.
  54811. */
  54812. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  54813. /**
  54814. * Gets wether the color curves effect is enabled.
  54815. */
  54816. get cameraColorCurvesEnabled(): boolean;
  54817. /**
  54818. * Sets wether the color curves effect is enabled.
  54819. */
  54820. set cameraColorCurvesEnabled(value: boolean);
  54821. /**
  54822. * Gets wether the color grading effect is enabled.
  54823. */
  54824. get cameraColorGradingEnabled(): boolean;
  54825. /**
  54826. * Gets wether the color grading effect is enabled.
  54827. */
  54828. set cameraColorGradingEnabled(value: boolean);
  54829. /**
  54830. * Gets wether tonemapping is enabled or not.
  54831. */
  54832. get cameraToneMappingEnabled(): boolean;
  54833. /**
  54834. * Sets wether tonemapping is enabled or not
  54835. */
  54836. set cameraToneMappingEnabled(value: boolean);
  54837. /**
  54838. * The camera exposure used on this material.
  54839. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54840. * This corresponds to a photographic exposure.
  54841. */
  54842. get cameraExposure(): number;
  54843. /**
  54844. * The camera exposure used on this material.
  54845. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54846. * This corresponds to a photographic exposure.
  54847. */
  54848. set cameraExposure(value: number);
  54849. /**
  54850. * Gets The camera contrast used on this material.
  54851. */
  54852. get cameraContrast(): number;
  54853. /**
  54854. * Sets The camera contrast used on this material.
  54855. */
  54856. set cameraContrast(value: number);
  54857. /**
  54858. * Gets the Color Grading 2D Lookup Texture.
  54859. */
  54860. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54861. /**
  54862. * Sets the Color Grading 2D Lookup Texture.
  54863. */
  54864. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54865. /**
  54866. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54867. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54868. * 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;
  54869. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54870. */
  54871. get cameraColorCurves(): Nullable<ColorCurves>;
  54872. /**
  54873. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54874. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54875. * 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;
  54876. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54877. */
  54878. set cameraColorCurves(value: Nullable<ColorCurves>);
  54879. /**
  54880. * Instantiates a new PBRMaterial instance.
  54881. *
  54882. * @param name The material name
  54883. * @param scene The scene the material will be use in.
  54884. */
  54885. constructor(name: string, scene: Scene);
  54886. /**
  54887. * Returns the name of this material class.
  54888. */
  54889. getClassName(): string;
  54890. /**
  54891. * Makes a duplicate of the current material.
  54892. * @param name - name to use for the new material.
  54893. */
  54894. clone(name: string): PBRMaterial;
  54895. /**
  54896. * Serializes this PBR Material.
  54897. * @returns - An object with the serialized material.
  54898. */
  54899. serialize(): any;
  54900. /**
  54901. * Parses a PBR Material from a serialized object.
  54902. * @param source - Serialized object.
  54903. * @param scene - BJS scene instance.
  54904. * @param rootUrl - url for the scene object
  54905. * @returns - PBRMaterial
  54906. */
  54907. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  54908. }
  54909. }
  54910. declare module "babylonjs/Misc/dds" {
  54911. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54912. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54913. import { Nullable } from "babylonjs/types";
  54914. import { Scene } from "babylonjs/scene";
  54915. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  54916. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54917. /**
  54918. * Direct draw surface info
  54919. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  54920. */
  54921. export interface DDSInfo {
  54922. /**
  54923. * Width of the texture
  54924. */
  54925. width: number;
  54926. /**
  54927. * Width of the texture
  54928. */
  54929. height: number;
  54930. /**
  54931. * Number of Mipmaps for the texture
  54932. * @see https://en.wikipedia.org/wiki/Mipmap
  54933. */
  54934. mipmapCount: number;
  54935. /**
  54936. * If the textures format is a known fourCC format
  54937. * @see https://www.fourcc.org/
  54938. */
  54939. isFourCC: boolean;
  54940. /**
  54941. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  54942. */
  54943. isRGB: boolean;
  54944. /**
  54945. * If the texture is a lumincance format
  54946. */
  54947. isLuminance: boolean;
  54948. /**
  54949. * If this is a cube texture
  54950. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  54951. */
  54952. isCube: boolean;
  54953. /**
  54954. * If the texture is a compressed format eg. FOURCC_DXT1
  54955. */
  54956. isCompressed: boolean;
  54957. /**
  54958. * The dxgiFormat of the texture
  54959. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  54960. */
  54961. dxgiFormat: number;
  54962. /**
  54963. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  54964. */
  54965. textureType: number;
  54966. /**
  54967. * Sphericle polynomial created for the dds texture
  54968. */
  54969. sphericalPolynomial?: SphericalPolynomial;
  54970. }
  54971. /**
  54972. * Class used to provide DDS decompression tools
  54973. */
  54974. export class DDSTools {
  54975. /**
  54976. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  54977. */
  54978. static StoreLODInAlphaChannel: boolean;
  54979. /**
  54980. * Gets DDS information from an array buffer
  54981. * @param data defines the array buffer view to read data from
  54982. * @returns the DDS information
  54983. */
  54984. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  54985. private static _FloatView;
  54986. private static _Int32View;
  54987. private static _ToHalfFloat;
  54988. private static _FromHalfFloat;
  54989. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  54990. private static _GetHalfFloatRGBAArrayBuffer;
  54991. private static _GetFloatRGBAArrayBuffer;
  54992. private static _GetFloatAsUIntRGBAArrayBuffer;
  54993. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  54994. private static _GetRGBAArrayBuffer;
  54995. private static _ExtractLongWordOrder;
  54996. private static _GetRGBArrayBuffer;
  54997. private static _GetLuminanceArrayBuffer;
  54998. /**
  54999. * Uploads DDS Levels to a Babylon Texture
  55000. * @hidden
  55001. */
  55002. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  55003. }
  55004. module "babylonjs/Engines/thinEngine" {
  55005. interface ThinEngine {
  55006. /**
  55007. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  55008. * @param rootUrl defines the url where the file to load is located
  55009. * @param scene defines the current scene
  55010. * @param lodScale defines scale to apply to the mip map selection
  55011. * @param lodOffset defines offset to apply to the mip map selection
  55012. * @param onLoad defines an optional callback raised when the texture is loaded
  55013. * @param onError defines an optional callback raised if there is an issue to load the texture
  55014. * @param format defines the format of the data
  55015. * @param forcedExtension defines the extension to use to pick the right loader
  55016. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  55017. * @returns the cube texture as an InternalTexture
  55018. */
  55019. 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;
  55020. }
  55021. }
  55022. }
  55023. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  55024. import { Nullable } from "babylonjs/types";
  55025. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55026. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55027. /**
  55028. * Implementation of the DDS Texture Loader.
  55029. * @hidden
  55030. */
  55031. export class _DDSTextureLoader implements IInternalTextureLoader {
  55032. /**
  55033. * Defines wether the loader supports cascade loading the different faces.
  55034. */
  55035. readonly supportCascades: boolean;
  55036. /**
  55037. * This returns if the loader support the current file information.
  55038. * @param extension defines the file extension of the file being loaded
  55039. * @returns true if the loader can load the specified file
  55040. */
  55041. canLoad(extension: string): boolean;
  55042. /**
  55043. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55044. * @param data contains the texture data
  55045. * @param texture defines the BabylonJS internal texture
  55046. * @param createPolynomials will be true if polynomials have been requested
  55047. * @param onLoad defines the callback to trigger once the texture is ready
  55048. * @param onError defines the callback to trigger in case of error
  55049. */
  55050. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55051. /**
  55052. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55053. * @param data contains the texture data
  55054. * @param texture defines the BabylonJS internal texture
  55055. * @param callback defines the method to call once ready to upload
  55056. */
  55057. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55058. }
  55059. }
  55060. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  55061. import { Nullable } from "babylonjs/types";
  55062. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55063. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55064. /**
  55065. * Implementation of the ENV Texture Loader.
  55066. * @hidden
  55067. */
  55068. export class _ENVTextureLoader implements IInternalTextureLoader {
  55069. /**
  55070. * Defines wether the loader supports cascade loading the different faces.
  55071. */
  55072. readonly supportCascades: boolean;
  55073. /**
  55074. * This returns if the loader support the current file information.
  55075. * @param extension defines the file extension of the file being loaded
  55076. * @returns true if the loader can load the specified file
  55077. */
  55078. canLoad(extension: string): boolean;
  55079. /**
  55080. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55081. * @param data contains the texture data
  55082. * @param texture defines the BabylonJS internal texture
  55083. * @param createPolynomials will be true if polynomials have been requested
  55084. * @param onLoad defines the callback to trigger once the texture is ready
  55085. * @param onError defines the callback to trigger in case of error
  55086. */
  55087. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55088. /**
  55089. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55090. * @param data contains the texture data
  55091. * @param texture defines the BabylonJS internal texture
  55092. * @param callback defines the method to call once ready to upload
  55093. */
  55094. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55095. }
  55096. }
  55097. declare module "babylonjs/Misc/khronosTextureContainer" {
  55098. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55099. /**
  55100. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  55101. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  55102. */
  55103. export class KhronosTextureContainer {
  55104. /** contents of the KTX container file */
  55105. data: ArrayBufferView;
  55106. private static HEADER_LEN;
  55107. private static COMPRESSED_2D;
  55108. private static COMPRESSED_3D;
  55109. private static TEX_2D;
  55110. private static TEX_3D;
  55111. /**
  55112. * Gets the openGL type
  55113. */
  55114. glType: number;
  55115. /**
  55116. * Gets the openGL type size
  55117. */
  55118. glTypeSize: number;
  55119. /**
  55120. * Gets the openGL format
  55121. */
  55122. glFormat: number;
  55123. /**
  55124. * Gets the openGL internal format
  55125. */
  55126. glInternalFormat: number;
  55127. /**
  55128. * Gets the base internal format
  55129. */
  55130. glBaseInternalFormat: number;
  55131. /**
  55132. * Gets image width in pixel
  55133. */
  55134. pixelWidth: number;
  55135. /**
  55136. * Gets image height in pixel
  55137. */
  55138. pixelHeight: number;
  55139. /**
  55140. * Gets image depth in pixels
  55141. */
  55142. pixelDepth: number;
  55143. /**
  55144. * Gets the number of array elements
  55145. */
  55146. numberOfArrayElements: number;
  55147. /**
  55148. * Gets the number of faces
  55149. */
  55150. numberOfFaces: number;
  55151. /**
  55152. * Gets the number of mipmap levels
  55153. */
  55154. numberOfMipmapLevels: number;
  55155. /**
  55156. * Gets the bytes of key value data
  55157. */
  55158. bytesOfKeyValueData: number;
  55159. /**
  55160. * Gets the load type
  55161. */
  55162. loadType: number;
  55163. /**
  55164. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  55165. */
  55166. isInvalid: boolean;
  55167. /**
  55168. * Creates a new KhronosTextureContainer
  55169. * @param data contents of the KTX container file
  55170. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  55171. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  55172. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  55173. */
  55174. constructor(
  55175. /** contents of the KTX container file */
  55176. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  55177. /**
  55178. * Uploads KTX content to a Babylon Texture.
  55179. * It is assumed that the texture has already been created & is currently bound
  55180. * @hidden
  55181. */
  55182. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  55183. private _upload2DCompressedLevels;
  55184. /**
  55185. * Checks if the given data starts with a KTX file identifier.
  55186. * @param data the data to check
  55187. * @returns true if the data is a KTX file or false otherwise
  55188. */
  55189. static IsValid(data: ArrayBufferView): boolean;
  55190. }
  55191. }
  55192. declare module "babylonjs/Misc/khronosTextureContainer2" {
  55193. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55194. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55195. /**
  55196. * Class for loading KTX2 files
  55197. * !!! Experimental Extension Subject to Changes !!!
  55198. * @hidden
  55199. */
  55200. export class KhronosTextureContainer2 {
  55201. private static _ModulePromise;
  55202. private static _TranscodeFormat;
  55203. constructor(engine: ThinEngine);
  55204. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  55205. private _determineTranscodeFormat;
  55206. /**
  55207. * Checks if the given data starts with a KTX2 file identifier.
  55208. * @param data the data to check
  55209. * @returns true if the data is a KTX2 file or false otherwise
  55210. */
  55211. static IsValid(data: ArrayBufferView): boolean;
  55212. }
  55213. }
  55214. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  55215. import { Nullable } from "babylonjs/types";
  55216. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55217. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55218. /**
  55219. * Implementation of the KTX Texture Loader.
  55220. * @hidden
  55221. */
  55222. export class _KTXTextureLoader implements IInternalTextureLoader {
  55223. /**
  55224. * Defines wether the loader supports cascade loading the different faces.
  55225. */
  55226. readonly supportCascades: boolean;
  55227. /**
  55228. * This returns if the loader support the current file information.
  55229. * @param extension defines the file extension of the file being loaded
  55230. * @returns true if the loader can load the specified file
  55231. */
  55232. canLoad(extension: string): boolean;
  55233. /**
  55234. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55235. * @param data contains the texture data
  55236. * @param texture defines the BabylonJS internal texture
  55237. * @param createPolynomials will be true if polynomials have been requested
  55238. * @param onLoad defines the callback to trigger once the texture is ready
  55239. * @param onError defines the callback to trigger in case of error
  55240. */
  55241. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55242. /**
  55243. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55244. * @param data contains the texture data
  55245. * @param texture defines the BabylonJS internal texture
  55246. * @param callback defines the method to call once ready to upload
  55247. */
  55248. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  55249. }
  55250. }
  55251. declare module "babylonjs/Helpers/sceneHelpers" {
  55252. import { Nullable } from "babylonjs/types";
  55253. import { Mesh } from "babylonjs/Meshes/mesh";
  55254. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55255. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  55256. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  55257. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  55258. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  55259. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  55260. import "babylonjs/Meshes/Builders/boxBuilder";
  55261. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  55262. /** @hidden */
  55263. export var _forceSceneHelpersToBundle: boolean;
  55264. module "babylonjs/scene" {
  55265. interface Scene {
  55266. /**
  55267. * Creates a default light for the scene.
  55268. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  55269. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  55270. */
  55271. createDefaultLight(replace?: boolean): void;
  55272. /**
  55273. * Creates a default camera for the scene.
  55274. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  55275. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55276. * @param replace has default false, when true replaces the active camera in the scene
  55277. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  55278. */
  55279. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55280. /**
  55281. * Creates a default camera and a default light.
  55282. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  55283. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55284. * @param replace has the default false, when true replaces the active camera/light in the scene
  55285. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  55286. */
  55287. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55288. /**
  55289. * Creates a new sky box
  55290. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  55291. * @param environmentTexture defines the texture to use as environment texture
  55292. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  55293. * @param scale defines the overall scale of the skybox
  55294. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  55295. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  55296. * @returns a new mesh holding the sky box
  55297. */
  55298. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  55299. /**
  55300. * Creates a new environment
  55301. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  55302. * @param options defines the options you can use to configure the environment
  55303. * @returns the new EnvironmentHelper
  55304. */
  55305. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  55306. /**
  55307. * Creates a new VREXperienceHelper
  55308. * @see http://doc.babylonjs.com/how_to/webvr_helper
  55309. * @param webVROptions defines the options used to create the new VREXperienceHelper
  55310. * @returns a new VREXperienceHelper
  55311. */
  55312. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  55313. /**
  55314. * Creates a new WebXRDefaultExperience
  55315. * @see http://doc.babylonjs.com/how_to/webxr
  55316. * @param options experience options
  55317. * @returns a promise for a new WebXRDefaultExperience
  55318. */
  55319. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  55320. }
  55321. }
  55322. }
  55323. declare module "babylonjs/Helpers/videoDome" {
  55324. import { Scene } from "babylonjs/scene";
  55325. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55326. import { Mesh } from "babylonjs/Meshes/mesh";
  55327. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  55328. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55329. import "babylonjs/Meshes/Builders/sphereBuilder";
  55330. /**
  55331. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  55332. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  55333. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  55334. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55335. */
  55336. export class VideoDome extends TransformNode {
  55337. /**
  55338. * Define the video source as a Monoscopic panoramic 360 video.
  55339. */
  55340. static readonly MODE_MONOSCOPIC: number;
  55341. /**
  55342. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55343. */
  55344. static readonly MODE_TOPBOTTOM: number;
  55345. /**
  55346. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55347. */
  55348. static readonly MODE_SIDEBYSIDE: number;
  55349. private _halfDome;
  55350. private _useDirectMapping;
  55351. /**
  55352. * The video texture being displayed on the sphere
  55353. */
  55354. protected _videoTexture: VideoTexture;
  55355. /**
  55356. * Gets the video texture being displayed on the sphere
  55357. */
  55358. get videoTexture(): VideoTexture;
  55359. /**
  55360. * The skybox material
  55361. */
  55362. protected _material: BackgroundMaterial;
  55363. /**
  55364. * The surface used for the skybox
  55365. */
  55366. protected _mesh: Mesh;
  55367. /**
  55368. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  55369. */
  55370. private _halfDomeMask;
  55371. /**
  55372. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55373. * Also see the options.resolution property.
  55374. */
  55375. get fovMultiplier(): number;
  55376. set fovMultiplier(value: number);
  55377. private _videoMode;
  55378. /**
  55379. * Gets or set the current video mode for the video. It can be:
  55380. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  55381. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55382. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55383. */
  55384. get videoMode(): number;
  55385. set videoMode(value: number);
  55386. /**
  55387. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  55388. *
  55389. */
  55390. get halfDome(): boolean;
  55391. /**
  55392. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  55393. */
  55394. set halfDome(enabled: boolean);
  55395. /**
  55396. * Oberserver used in Stereoscopic VR Mode.
  55397. */
  55398. private _onBeforeCameraRenderObserver;
  55399. /**
  55400. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  55401. * @param name Element's name, child elements will append suffixes for their own names.
  55402. * @param urlsOrVideo defines the url(s) or the video element to use
  55403. * @param options An object containing optional or exposed sub element properties
  55404. */
  55405. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  55406. resolution?: number;
  55407. clickToPlay?: boolean;
  55408. autoPlay?: boolean;
  55409. loop?: boolean;
  55410. size?: number;
  55411. poster?: string;
  55412. faceForward?: boolean;
  55413. useDirectMapping?: boolean;
  55414. halfDomeMode?: boolean;
  55415. }, scene: Scene);
  55416. private _changeVideoMode;
  55417. /**
  55418. * Releases resources associated with this node.
  55419. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55420. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55421. */
  55422. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55423. }
  55424. }
  55425. declare module "babylonjs/Helpers/index" {
  55426. export * from "babylonjs/Helpers/environmentHelper";
  55427. export * from "babylonjs/Helpers/photoDome";
  55428. export * from "babylonjs/Helpers/sceneHelpers";
  55429. export * from "babylonjs/Helpers/videoDome";
  55430. }
  55431. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  55432. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  55433. import { IDisposable } from "babylonjs/scene";
  55434. import { Engine } from "babylonjs/Engines/engine";
  55435. /**
  55436. * This class can be used to get instrumentation data from a Babylon engine
  55437. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  55438. */
  55439. export class EngineInstrumentation implements IDisposable {
  55440. /**
  55441. * Define the instrumented engine.
  55442. */
  55443. engine: Engine;
  55444. private _captureGPUFrameTime;
  55445. private _gpuFrameTimeToken;
  55446. private _gpuFrameTime;
  55447. private _captureShaderCompilationTime;
  55448. private _shaderCompilationTime;
  55449. private _onBeginFrameObserver;
  55450. private _onEndFrameObserver;
  55451. private _onBeforeShaderCompilationObserver;
  55452. private _onAfterShaderCompilationObserver;
  55453. /**
  55454. * Gets the perf counter used for GPU frame time
  55455. */
  55456. get gpuFrameTimeCounter(): PerfCounter;
  55457. /**
  55458. * Gets the GPU frame time capture status
  55459. */
  55460. get captureGPUFrameTime(): boolean;
  55461. /**
  55462. * Enable or disable the GPU frame time capture
  55463. */
  55464. set captureGPUFrameTime(value: boolean);
  55465. /**
  55466. * Gets the perf counter used for shader compilation time
  55467. */
  55468. get shaderCompilationTimeCounter(): PerfCounter;
  55469. /**
  55470. * Gets the shader compilation time capture status
  55471. */
  55472. get captureShaderCompilationTime(): boolean;
  55473. /**
  55474. * Enable or disable the shader compilation time capture
  55475. */
  55476. set captureShaderCompilationTime(value: boolean);
  55477. /**
  55478. * Instantiates a new engine instrumentation.
  55479. * This class can be used to get instrumentation data from a Babylon engine
  55480. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  55481. * @param engine Defines the engine to instrument
  55482. */
  55483. constructor(
  55484. /**
  55485. * Define the instrumented engine.
  55486. */
  55487. engine: Engine);
  55488. /**
  55489. * Dispose and release associated resources.
  55490. */
  55491. dispose(): void;
  55492. }
  55493. }
  55494. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  55495. import { Scene, IDisposable } from "babylonjs/scene";
  55496. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  55497. /**
  55498. * This class can be used to get instrumentation data from a Babylon engine
  55499. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55500. */
  55501. export class SceneInstrumentation implements IDisposable {
  55502. /**
  55503. * Defines the scene to instrument
  55504. */
  55505. scene: Scene;
  55506. private _captureActiveMeshesEvaluationTime;
  55507. private _activeMeshesEvaluationTime;
  55508. private _captureRenderTargetsRenderTime;
  55509. private _renderTargetsRenderTime;
  55510. private _captureFrameTime;
  55511. private _frameTime;
  55512. private _captureRenderTime;
  55513. private _renderTime;
  55514. private _captureInterFrameTime;
  55515. private _interFrameTime;
  55516. private _captureParticlesRenderTime;
  55517. private _particlesRenderTime;
  55518. private _captureSpritesRenderTime;
  55519. private _spritesRenderTime;
  55520. private _capturePhysicsTime;
  55521. private _physicsTime;
  55522. private _captureAnimationsTime;
  55523. private _animationsTime;
  55524. private _captureCameraRenderTime;
  55525. private _cameraRenderTime;
  55526. private _onBeforeActiveMeshesEvaluationObserver;
  55527. private _onAfterActiveMeshesEvaluationObserver;
  55528. private _onBeforeRenderTargetsRenderObserver;
  55529. private _onAfterRenderTargetsRenderObserver;
  55530. private _onAfterRenderObserver;
  55531. private _onBeforeDrawPhaseObserver;
  55532. private _onAfterDrawPhaseObserver;
  55533. private _onBeforeAnimationsObserver;
  55534. private _onBeforeParticlesRenderingObserver;
  55535. private _onAfterParticlesRenderingObserver;
  55536. private _onBeforeSpritesRenderingObserver;
  55537. private _onAfterSpritesRenderingObserver;
  55538. private _onBeforePhysicsObserver;
  55539. private _onAfterPhysicsObserver;
  55540. private _onAfterAnimationsObserver;
  55541. private _onBeforeCameraRenderObserver;
  55542. private _onAfterCameraRenderObserver;
  55543. /**
  55544. * Gets the perf counter used for active meshes evaluation time
  55545. */
  55546. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  55547. /**
  55548. * Gets the active meshes evaluation time capture status
  55549. */
  55550. get captureActiveMeshesEvaluationTime(): boolean;
  55551. /**
  55552. * Enable or disable the active meshes evaluation time capture
  55553. */
  55554. set captureActiveMeshesEvaluationTime(value: boolean);
  55555. /**
  55556. * Gets the perf counter used for render targets render time
  55557. */
  55558. get renderTargetsRenderTimeCounter(): PerfCounter;
  55559. /**
  55560. * Gets the render targets render time capture status
  55561. */
  55562. get captureRenderTargetsRenderTime(): boolean;
  55563. /**
  55564. * Enable or disable the render targets render time capture
  55565. */
  55566. set captureRenderTargetsRenderTime(value: boolean);
  55567. /**
  55568. * Gets the perf counter used for particles render time
  55569. */
  55570. get particlesRenderTimeCounter(): PerfCounter;
  55571. /**
  55572. * Gets the particles render time capture status
  55573. */
  55574. get captureParticlesRenderTime(): boolean;
  55575. /**
  55576. * Enable or disable the particles render time capture
  55577. */
  55578. set captureParticlesRenderTime(value: boolean);
  55579. /**
  55580. * Gets the perf counter used for sprites render time
  55581. */
  55582. get spritesRenderTimeCounter(): PerfCounter;
  55583. /**
  55584. * Gets the sprites render time capture status
  55585. */
  55586. get captureSpritesRenderTime(): boolean;
  55587. /**
  55588. * Enable or disable the sprites render time capture
  55589. */
  55590. set captureSpritesRenderTime(value: boolean);
  55591. /**
  55592. * Gets the perf counter used for physics time
  55593. */
  55594. get physicsTimeCounter(): PerfCounter;
  55595. /**
  55596. * Gets the physics time capture status
  55597. */
  55598. get capturePhysicsTime(): boolean;
  55599. /**
  55600. * Enable or disable the physics time capture
  55601. */
  55602. set capturePhysicsTime(value: boolean);
  55603. /**
  55604. * Gets the perf counter used for animations time
  55605. */
  55606. get animationsTimeCounter(): PerfCounter;
  55607. /**
  55608. * Gets the animations time capture status
  55609. */
  55610. get captureAnimationsTime(): boolean;
  55611. /**
  55612. * Enable or disable the animations time capture
  55613. */
  55614. set captureAnimationsTime(value: boolean);
  55615. /**
  55616. * Gets the perf counter used for frame time capture
  55617. */
  55618. get frameTimeCounter(): PerfCounter;
  55619. /**
  55620. * Gets the frame time capture status
  55621. */
  55622. get captureFrameTime(): boolean;
  55623. /**
  55624. * Enable or disable the frame time capture
  55625. */
  55626. set captureFrameTime(value: boolean);
  55627. /**
  55628. * Gets the perf counter used for inter-frames time capture
  55629. */
  55630. get interFrameTimeCounter(): PerfCounter;
  55631. /**
  55632. * Gets the inter-frames time capture status
  55633. */
  55634. get captureInterFrameTime(): boolean;
  55635. /**
  55636. * Enable or disable the inter-frames time capture
  55637. */
  55638. set captureInterFrameTime(value: boolean);
  55639. /**
  55640. * Gets the perf counter used for render time capture
  55641. */
  55642. get renderTimeCounter(): PerfCounter;
  55643. /**
  55644. * Gets the render time capture status
  55645. */
  55646. get captureRenderTime(): boolean;
  55647. /**
  55648. * Enable or disable the render time capture
  55649. */
  55650. set captureRenderTime(value: boolean);
  55651. /**
  55652. * Gets the perf counter used for camera render time capture
  55653. */
  55654. get cameraRenderTimeCounter(): PerfCounter;
  55655. /**
  55656. * Gets the camera render time capture status
  55657. */
  55658. get captureCameraRenderTime(): boolean;
  55659. /**
  55660. * Enable or disable the camera render time capture
  55661. */
  55662. set captureCameraRenderTime(value: boolean);
  55663. /**
  55664. * Gets the perf counter used for draw calls
  55665. */
  55666. get drawCallsCounter(): PerfCounter;
  55667. /**
  55668. * Instantiates a new scene instrumentation.
  55669. * This class can be used to get instrumentation data from a Babylon engine
  55670. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55671. * @param scene Defines the scene to instrument
  55672. */
  55673. constructor(
  55674. /**
  55675. * Defines the scene to instrument
  55676. */
  55677. scene: Scene);
  55678. /**
  55679. * Dispose and release associated resources.
  55680. */
  55681. dispose(): void;
  55682. }
  55683. }
  55684. declare module "babylonjs/Instrumentation/index" {
  55685. export * from "babylonjs/Instrumentation/engineInstrumentation";
  55686. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  55687. export * from "babylonjs/Instrumentation/timeToken";
  55688. }
  55689. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  55690. /** @hidden */
  55691. export var glowMapGenerationPixelShader: {
  55692. name: string;
  55693. shader: string;
  55694. };
  55695. }
  55696. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  55697. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55698. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  55699. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  55700. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55701. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  55702. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55703. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55704. /** @hidden */
  55705. export var glowMapGenerationVertexShader: {
  55706. name: string;
  55707. shader: string;
  55708. };
  55709. }
  55710. declare module "babylonjs/Layers/effectLayer" {
  55711. import { Observable } from "babylonjs/Misc/observable";
  55712. import { Nullable } from "babylonjs/types";
  55713. import { Camera } from "babylonjs/Cameras/camera";
  55714. import { Scene } from "babylonjs/scene";
  55715. import { ISize } from "babylonjs/Maths/math.size";
  55716. import { Color4 } from "babylonjs/Maths/math.color";
  55717. import { Engine } from "babylonjs/Engines/engine";
  55718. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55719. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55720. import { Mesh } from "babylonjs/Meshes/mesh";
  55721. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55722. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55723. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55724. import { Effect } from "babylonjs/Materials/effect";
  55725. import { Material } from "babylonjs/Materials/material";
  55726. import "babylonjs/Shaders/glowMapGeneration.fragment";
  55727. import "babylonjs/Shaders/glowMapGeneration.vertex";
  55728. /**
  55729. * Effect layer options. This helps customizing the behaviour
  55730. * of the effect layer.
  55731. */
  55732. export interface IEffectLayerOptions {
  55733. /**
  55734. * Multiplication factor apply to the canvas size to compute the render target size
  55735. * used to generated the objects (the smaller the faster).
  55736. */
  55737. mainTextureRatio: number;
  55738. /**
  55739. * Enforces a fixed size texture to ensure effect stability across devices.
  55740. */
  55741. mainTextureFixedSize?: number;
  55742. /**
  55743. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  55744. */
  55745. alphaBlendingMode: number;
  55746. /**
  55747. * The camera attached to the layer.
  55748. */
  55749. camera: Nullable<Camera>;
  55750. /**
  55751. * The rendering group to draw the layer in.
  55752. */
  55753. renderingGroupId: number;
  55754. }
  55755. /**
  55756. * The effect layer Helps adding post process effect blended with the main pass.
  55757. *
  55758. * This can be for instance use to generate glow or higlight effects on the scene.
  55759. *
  55760. * The effect layer class can not be used directly and is intented to inherited from to be
  55761. * customized per effects.
  55762. */
  55763. export abstract class EffectLayer {
  55764. private _vertexBuffers;
  55765. private _indexBuffer;
  55766. private _cachedDefines;
  55767. private _effectLayerMapGenerationEffect;
  55768. private _effectLayerOptions;
  55769. private _mergeEffect;
  55770. protected _scene: Scene;
  55771. protected _engine: Engine;
  55772. protected _maxSize: number;
  55773. protected _mainTextureDesiredSize: ISize;
  55774. protected _mainTexture: RenderTargetTexture;
  55775. protected _shouldRender: boolean;
  55776. protected _postProcesses: PostProcess[];
  55777. protected _textures: BaseTexture[];
  55778. protected _emissiveTextureAndColor: {
  55779. texture: Nullable<BaseTexture>;
  55780. color: Color4;
  55781. };
  55782. /**
  55783. * The name of the layer
  55784. */
  55785. name: string;
  55786. /**
  55787. * The clear color of the texture used to generate the glow map.
  55788. */
  55789. neutralColor: Color4;
  55790. /**
  55791. * Specifies whether the highlight layer is enabled or not.
  55792. */
  55793. isEnabled: boolean;
  55794. /**
  55795. * Gets the camera attached to the layer.
  55796. */
  55797. get camera(): Nullable<Camera>;
  55798. /**
  55799. * Gets the rendering group id the layer should render in.
  55800. */
  55801. get renderingGroupId(): number;
  55802. set renderingGroupId(renderingGroupId: number);
  55803. /**
  55804. * An event triggered when the effect layer has been disposed.
  55805. */
  55806. onDisposeObservable: Observable<EffectLayer>;
  55807. /**
  55808. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  55809. */
  55810. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  55811. /**
  55812. * An event triggered when the generated texture is being merged in the scene.
  55813. */
  55814. onBeforeComposeObservable: Observable<EffectLayer>;
  55815. /**
  55816. * An event triggered when the mesh is rendered into the effect render target.
  55817. */
  55818. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  55819. /**
  55820. * An event triggered after the mesh has been rendered into the effect render target.
  55821. */
  55822. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  55823. /**
  55824. * An event triggered when the generated texture has been merged in the scene.
  55825. */
  55826. onAfterComposeObservable: Observable<EffectLayer>;
  55827. /**
  55828. * An event triggered when the efffect layer changes its size.
  55829. */
  55830. onSizeChangedObservable: Observable<EffectLayer>;
  55831. /** @hidden */
  55832. static _SceneComponentInitialization: (scene: Scene) => void;
  55833. /**
  55834. * Instantiates a new effect Layer and references it in the scene.
  55835. * @param name The name of the layer
  55836. * @param scene The scene to use the layer in
  55837. */
  55838. constructor(
  55839. /** The Friendly of the effect in the scene */
  55840. name: string, scene: Scene);
  55841. /**
  55842. * Get the effect name of the layer.
  55843. * @return The effect name
  55844. */
  55845. abstract getEffectName(): string;
  55846. /**
  55847. * Checks for the readiness of the element composing the layer.
  55848. * @param subMesh the mesh to check for
  55849. * @param useInstances specify whether or not to use instances to render the mesh
  55850. * @return true if ready otherwise, false
  55851. */
  55852. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55853. /**
  55854. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55855. * @returns true if the effect requires stencil during the main canvas render pass.
  55856. */
  55857. abstract needStencil(): boolean;
  55858. /**
  55859. * Create the merge effect. This is the shader use to blit the information back
  55860. * to the main canvas at the end of the scene rendering.
  55861. * @returns The effect containing the shader used to merge the effect on the main canvas
  55862. */
  55863. protected abstract _createMergeEffect(): Effect;
  55864. /**
  55865. * Creates the render target textures and post processes used in the effect layer.
  55866. */
  55867. protected abstract _createTextureAndPostProcesses(): void;
  55868. /**
  55869. * Implementation specific of rendering the generating effect on the main canvas.
  55870. * @param effect The effect used to render through
  55871. */
  55872. protected abstract _internalRender(effect: Effect): void;
  55873. /**
  55874. * Sets the required values for both the emissive texture and and the main color.
  55875. */
  55876. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55877. /**
  55878. * Free any resources and references associated to a mesh.
  55879. * Internal use
  55880. * @param mesh The mesh to free.
  55881. */
  55882. abstract _disposeMesh(mesh: Mesh): void;
  55883. /**
  55884. * Serializes this layer (Glow or Highlight for example)
  55885. * @returns a serialized layer object
  55886. */
  55887. abstract serialize?(): any;
  55888. /**
  55889. * Initializes the effect layer with the required options.
  55890. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  55891. */
  55892. protected _init(options: Partial<IEffectLayerOptions>): void;
  55893. /**
  55894. * Generates the index buffer of the full screen quad blending to the main canvas.
  55895. */
  55896. private _generateIndexBuffer;
  55897. /**
  55898. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  55899. */
  55900. private _generateVertexBuffer;
  55901. /**
  55902. * Sets the main texture desired size which is the closest power of two
  55903. * of the engine canvas size.
  55904. */
  55905. private _setMainTextureSize;
  55906. /**
  55907. * Creates the main texture for the effect layer.
  55908. */
  55909. protected _createMainTexture(): void;
  55910. /**
  55911. * Adds specific effects defines.
  55912. * @param defines The defines to add specifics to.
  55913. */
  55914. protected _addCustomEffectDefines(defines: string[]): void;
  55915. /**
  55916. * Checks for the readiness of the element composing the layer.
  55917. * @param subMesh the mesh to check for
  55918. * @param useInstances specify whether or not to use instances to render the mesh
  55919. * @param emissiveTexture the associated emissive texture used to generate the glow
  55920. * @return true if ready otherwise, false
  55921. */
  55922. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  55923. /**
  55924. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  55925. */
  55926. render(): void;
  55927. /**
  55928. * Determine if a given mesh will be used in the current effect.
  55929. * @param mesh mesh to test
  55930. * @returns true if the mesh will be used
  55931. */
  55932. hasMesh(mesh: AbstractMesh): boolean;
  55933. /**
  55934. * Returns true if the layer contains information to display, otherwise false.
  55935. * @returns true if the glow layer should be rendered
  55936. */
  55937. shouldRender(): boolean;
  55938. /**
  55939. * Returns true if the mesh should render, otherwise false.
  55940. * @param mesh The mesh to render
  55941. * @returns true if it should render otherwise false
  55942. */
  55943. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  55944. /**
  55945. * Returns true if the mesh can be rendered, otherwise false.
  55946. * @param mesh The mesh to render
  55947. * @param material The material used on the mesh
  55948. * @returns true if it can be rendered otherwise false
  55949. */
  55950. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55951. /**
  55952. * Returns true if the mesh should render, otherwise false.
  55953. * @param mesh The mesh to render
  55954. * @returns true if it should render otherwise false
  55955. */
  55956. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  55957. /**
  55958. * Renders the submesh passed in parameter to the generation map.
  55959. */
  55960. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  55961. /**
  55962. * Defines whether the current material of the mesh should be use to render the effect.
  55963. * @param mesh defines the current mesh to render
  55964. */
  55965. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55966. /**
  55967. * Rebuild the required buffers.
  55968. * @hidden Internal use only.
  55969. */
  55970. _rebuild(): void;
  55971. /**
  55972. * Dispose only the render target textures and post process.
  55973. */
  55974. private _disposeTextureAndPostProcesses;
  55975. /**
  55976. * Dispose the highlight layer and free resources.
  55977. */
  55978. dispose(): void;
  55979. /**
  55980. * Gets the class name of the effect layer
  55981. * @returns the string with the class name of the effect layer
  55982. */
  55983. getClassName(): string;
  55984. /**
  55985. * Creates an effect layer from parsed effect layer data
  55986. * @param parsedEffectLayer defines effect layer data
  55987. * @param scene defines the current scene
  55988. * @param rootUrl defines the root URL containing the effect layer information
  55989. * @returns a parsed effect Layer
  55990. */
  55991. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  55992. }
  55993. }
  55994. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  55995. import { Scene } from "babylonjs/scene";
  55996. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55997. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55998. import { AbstractScene } from "babylonjs/abstractScene";
  55999. module "babylonjs/abstractScene" {
  56000. interface AbstractScene {
  56001. /**
  56002. * The list of effect layers (highlights/glow) added to the scene
  56003. * @see http://doc.babylonjs.com/how_to/highlight_layer
  56004. * @see http://doc.babylonjs.com/how_to/glow_layer
  56005. */
  56006. effectLayers: Array<EffectLayer>;
  56007. /**
  56008. * Removes the given effect layer from this scene.
  56009. * @param toRemove defines the effect layer to remove
  56010. * @returns the index of the removed effect layer
  56011. */
  56012. removeEffectLayer(toRemove: EffectLayer): number;
  56013. /**
  56014. * Adds the given effect layer to this scene
  56015. * @param newEffectLayer defines the effect layer to add
  56016. */
  56017. addEffectLayer(newEffectLayer: EffectLayer): void;
  56018. }
  56019. }
  56020. /**
  56021. * Defines the layer scene component responsible to manage any effect layers
  56022. * in a given scene.
  56023. */
  56024. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  56025. /**
  56026. * The component name helpfull to identify the component in the list of scene components.
  56027. */
  56028. readonly name: string;
  56029. /**
  56030. * The scene the component belongs to.
  56031. */
  56032. scene: Scene;
  56033. private _engine;
  56034. private _renderEffects;
  56035. private _needStencil;
  56036. private _previousStencilState;
  56037. /**
  56038. * Creates a new instance of the component for the given scene
  56039. * @param scene Defines the scene to register the component in
  56040. */
  56041. constructor(scene: Scene);
  56042. /**
  56043. * Registers the component in a given scene
  56044. */
  56045. register(): void;
  56046. /**
  56047. * Rebuilds the elements related to this component in case of
  56048. * context lost for instance.
  56049. */
  56050. rebuild(): void;
  56051. /**
  56052. * Serializes the component data to the specified json object
  56053. * @param serializationObject The object to serialize to
  56054. */
  56055. serialize(serializationObject: any): void;
  56056. /**
  56057. * Adds all the elements from the container to the scene
  56058. * @param container the container holding the elements
  56059. */
  56060. addFromContainer(container: AbstractScene): void;
  56061. /**
  56062. * Removes all the elements in the container from the scene
  56063. * @param container contains the elements to remove
  56064. * @param dispose if the removed element should be disposed (default: false)
  56065. */
  56066. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56067. /**
  56068. * Disposes the component and the associated ressources.
  56069. */
  56070. dispose(): void;
  56071. private _isReadyForMesh;
  56072. private _renderMainTexture;
  56073. private _setStencil;
  56074. private _setStencilBack;
  56075. private _draw;
  56076. private _drawCamera;
  56077. private _drawRenderingGroup;
  56078. }
  56079. }
  56080. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  56081. /** @hidden */
  56082. export var glowMapMergePixelShader: {
  56083. name: string;
  56084. shader: string;
  56085. };
  56086. }
  56087. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  56088. /** @hidden */
  56089. export var glowMapMergeVertexShader: {
  56090. name: string;
  56091. shader: string;
  56092. };
  56093. }
  56094. declare module "babylonjs/Layers/glowLayer" {
  56095. import { Nullable } from "babylonjs/types";
  56096. import { Camera } from "babylonjs/Cameras/camera";
  56097. import { Scene } from "babylonjs/scene";
  56098. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56099. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56100. import { Mesh } from "babylonjs/Meshes/mesh";
  56101. import { Texture } from "babylonjs/Materials/Textures/texture";
  56102. import { Effect } from "babylonjs/Materials/effect";
  56103. import { Material } from "babylonjs/Materials/material";
  56104. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  56105. import { Color4 } from "babylonjs/Maths/math.color";
  56106. import "babylonjs/Shaders/glowMapMerge.fragment";
  56107. import "babylonjs/Shaders/glowMapMerge.vertex";
  56108. import "babylonjs/Layers/effectLayerSceneComponent";
  56109. module "babylonjs/abstractScene" {
  56110. interface AbstractScene {
  56111. /**
  56112. * Return a the first highlight layer of the scene with a given name.
  56113. * @param name The name of the highlight layer to look for.
  56114. * @return The highlight layer if found otherwise null.
  56115. */
  56116. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  56117. }
  56118. }
  56119. /**
  56120. * Glow layer options. This helps customizing the behaviour
  56121. * of the glow layer.
  56122. */
  56123. export interface IGlowLayerOptions {
  56124. /**
  56125. * Multiplication factor apply to the canvas size to compute the render target size
  56126. * used to generated the glowing objects (the smaller the faster).
  56127. */
  56128. mainTextureRatio: number;
  56129. /**
  56130. * Enforces a fixed size texture to ensure resize independant blur.
  56131. */
  56132. mainTextureFixedSize?: number;
  56133. /**
  56134. * How big is the kernel of the blur texture.
  56135. */
  56136. blurKernelSize: number;
  56137. /**
  56138. * The camera attached to the layer.
  56139. */
  56140. camera: Nullable<Camera>;
  56141. /**
  56142. * Enable MSAA by chosing the number of samples.
  56143. */
  56144. mainTextureSamples?: number;
  56145. /**
  56146. * The rendering group to draw the layer in.
  56147. */
  56148. renderingGroupId: number;
  56149. }
  56150. /**
  56151. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  56152. *
  56153. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  56154. *
  56155. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  56156. */
  56157. export class GlowLayer extends EffectLayer {
  56158. /**
  56159. * Effect Name of the layer.
  56160. */
  56161. static readonly EffectName: string;
  56162. /**
  56163. * The default blur kernel size used for the glow.
  56164. */
  56165. static DefaultBlurKernelSize: number;
  56166. /**
  56167. * The default texture size ratio used for the glow.
  56168. */
  56169. static DefaultTextureRatio: number;
  56170. /**
  56171. * Sets the kernel size of the blur.
  56172. */
  56173. set blurKernelSize(value: number);
  56174. /**
  56175. * Gets the kernel size of the blur.
  56176. */
  56177. get blurKernelSize(): number;
  56178. /**
  56179. * Sets the glow intensity.
  56180. */
  56181. set intensity(value: number);
  56182. /**
  56183. * Gets the glow intensity.
  56184. */
  56185. get intensity(): number;
  56186. private _options;
  56187. private _intensity;
  56188. private _horizontalBlurPostprocess1;
  56189. private _verticalBlurPostprocess1;
  56190. private _horizontalBlurPostprocess2;
  56191. private _verticalBlurPostprocess2;
  56192. private _blurTexture1;
  56193. private _blurTexture2;
  56194. private _postProcesses1;
  56195. private _postProcesses2;
  56196. private _includedOnlyMeshes;
  56197. private _excludedMeshes;
  56198. private _meshesUsingTheirOwnMaterials;
  56199. /**
  56200. * Callback used to let the user override the color selection on a per mesh basis
  56201. */
  56202. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  56203. /**
  56204. * Callback used to let the user override the texture selection on a per mesh basis
  56205. */
  56206. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  56207. /**
  56208. * Instantiates a new glow Layer and references it to the scene.
  56209. * @param name The name of the layer
  56210. * @param scene The scene to use the layer in
  56211. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  56212. */
  56213. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  56214. /**
  56215. * Get the effect name of the layer.
  56216. * @return The effect name
  56217. */
  56218. getEffectName(): string;
  56219. /**
  56220. * Create the merge effect. This is the shader use to blit the information back
  56221. * to the main canvas at the end of the scene rendering.
  56222. */
  56223. protected _createMergeEffect(): Effect;
  56224. /**
  56225. * Creates the render target textures and post processes used in the glow layer.
  56226. */
  56227. protected _createTextureAndPostProcesses(): void;
  56228. /**
  56229. * Checks for the readiness of the element composing the layer.
  56230. * @param subMesh the mesh to check for
  56231. * @param useInstances specify wether or not to use instances to render the mesh
  56232. * @param emissiveTexture the associated emissive texture used to generate the glow
  56233. * @return true if ready otherwise, false
  56234. */
  56235. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56236. /**
  56237. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56238. */
  56239. needStencil(): boolean;
  56240. /**
  56241. * Returns true if the mesh can be rendered, otherwise false.
  56242. * @param mesh The mesh to render
  56243. * @param material The material used on the mesh
  56244. * @returns true if it can be rendered otherwise false
  56245. */
  56246. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56247. /**
  56248. * Implementation specific of rendering the generating effect on the main canvas.
  56249. * @param effect The effect used to render through
  56250. */
  56251. protected _internalRender(effect: Effect): void;
  56252. /**
  56253. * Sets the required values for both the emissive texture and and the main color.
  56254. */
  56255. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56256. /**
  56257. * Returns true if the mesh should render, otherwise false.
  56258. * @param mesh The mesh to render
  56259. * @returns true if it should render otherwise false
  56260. */
  56261. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56262. /**
  56263. * Adds specific effects defines.
  56264. * @param defines The defines to add specifics to.
  56265. */
  56266. protected _addCustomEffectDefines(defines: string[]): void;
  56267. /**
  56268. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  56269. * @param mesh The mesh to exclude from the glow layer
  56270. */
  56271. addExcludedMesh(mesh: Mesh): void;
  56272. /**
  56273. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  56274. * @param mesh The mesh to remove
  56275. */
  56276. removeExcludedMesh(mesh: Mesh): void;
  56277. /**
  56278. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  56279. * @param mesh The mesh to include in the glow layer
  56280. */
  56281. addIncludedOnlyMesh(mesh: Mesh): void;
  56282. /**
  56283. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  56284. * @param mesh The mesh to remove
  56285. */
  56286. removeIncludedOnlyMesh(mesh: Mesh): void;
  56287. /**
  56288. * Determine if a given mesh will be used in the glow layer
  56289. * @param mesh The mesh to test
  56290. * @returns true if the mesh will be highlighted by the current glow layer
  56291. */
  56292. hasMesh(mesh: AbstractMesh): boolean;
  56293. /**
  56294. * Defines whether the current material of the mesh should be use to render the effect.
  56295. * @param mesh defines the current mesh to render
  56296. */
  56297. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56298. /**
  56299. * Add a mesh to be rendered through its own material and not with emissive only.
  56300. * @param mesh The mesh for which we need to use its material
  56301. */
  56302. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  56303. /**
  56304. * Remove a mesh from being rendered through its own material and not with emissive only.
  56305. * @param mesh The mesh for which we need to not use its material
  56306. */
  56307. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  56308. /**
  56309. * Free any resources and references associated to a mesh.
  56310. * Internal use
  56311. * @param mesh The mesh to free.
  56312. * @hidden
  56313. */
  56314. _disposeMesh(mesh: Mesh): void;
  56315. /**
  56316. * Gets the class name of the effect layer
  56317. * @returns the string with the class name of the effect layer
  56318. */
  56319. getClassName(): string;
  56320. /**
  56321. * Serializes this glow layer
  56322. * @returns a serialized glow layer object
  56323. */
  56324. serialize(): any;
  56325. /**
  56326. * Creates a Glow Layer from parsed glow layer data
  56327. * @param parsedGlowLayer defines glow layer data
  56328. * @param scene defines the current scene
  56329. * @param rootUrl defines the root URL containing the glow layer information
  56330. * @returns a parsed Glow Layer
  56331. */
  56332. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  56333. }
  56334. }
  56335. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  56336. /** @hidden */
  56337. export var glowBlurPostProcessPixelShader: {
  56338. name: string;
  56339. shader: string;
  56340. };
  56341. }
  56342. declare module "babylonjs/Layers/highlightLayer" {
  56343. import { Observable } from "babylonjs/Misc/observable";
  56344. import { Nullable } from "babylonjs/types";
  56345. import { Camera } from "babylonjs/Cameras/camera";
  56346. import { Scene } from "babylonjs/scene";
  56347. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56348. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56349. import { Mesh } from "babylonjs/Meshes/mesh";
  56350. import { Effect } from "babylonjs/Materials/effect";
  56351. import { Material } from "babylonjs/Materials/material";
  56352. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  56353. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  56354. import "babylonjs/Shaders/glowMapMerge.fragment";
  56355. import "babylonjs/Shaders/glowMapMerge.vertex";
  56356. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  56357. module "babylonjs/abstractScene" {
  56358. interface AbstractScene {
  56359. /**
  56360. * Return a the first highlight layer of the scene with a given name.
  56361. * @param name The name of the highlight layer to look for.
  56362. * @return The highlight layer if found otherwise null.
  56363. */
  56364. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  56365. }
  56366. }
  56367. /**
  56368. * Highlight layer options. This helps customizing the behaviour
  56369. * of the highlight layer.
  56370. */
  56371. export interface IHighlightLayerOptions {
  56372. /**
  56373. * Multiplication factor apply to the canvas size to compute the render target size
  56374. * used to generated the glowing objects (the smaller the faster).
  56375. */
  56376. mainTextureRatio: number;
  56377. /**
  56378. * Enforces a fixed size texture to ensure resize independant blur.
  56379. */
  56380. mainTextureFixedSize?: number;
  56381. /**
  56382. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  56383. * of the picture to blur (the smaller the faster).
  56384. */
  56385. blurTextureSizeRatio: number;
  56386. /**
  56387. * How big in texel of the blur texture is the vertical blur.
  56388. */
  56389. blurVerticalSize: number;
  56390. /**
  56391. * How big in texel of the blur texture is the horizontal blur.
  56392. */
  56393. blurHorizontalSize: number;
  56394. /**
  56395. * Alpha blending mode used to apply the blur. Default is combine.
  56396. */
  56397. alphaBlendingMode: number;
  56398. /**
  56399. * The camera attached to the layer.
  56400. */
  56401. camera: Nullable<Camera>;
  56402. /**
  56403. * Should we display highlight as a solid stroke?
  56404. */
  56405. isStroke?: boolean;
  56406. /**
  56407. * The rendering group to draw the layer in.
  56408. */
  56409. renderingGroupId: number;
  56410. }
  56411. /**
  56412. * The highlight layer Helps adding a glow effect around a mesh.
  56413. *
  56414. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  56415. * glowy meshes to your scene.
  56416. *
  56417. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  56418. */
  56419. export class HighlightLayer extends EffectLayer {
  56420. name: string;
  56421. /**
  56422. * Effect Name of the highlight layer.
  56423. */
  56424. static readonly EffectName: string;
  56425. /**
  56426. * The neutral color used during the preparation of the glow effect.
  56427. * This is black by default as the blend operation is a blend operation.
  56428. */
  56429. static NeutralColor: Color4;
  56430. /**
  56431. * Stencil value used for glowing meshes.
  56432. */
  56433. static GlowingMeshStencilReference: number;
  56434. /**
  56435. * Stencil value used for the other meshes in the scene.
  56436. */
  56437. static NormalMeshStencilReference: number;
  56438. /**
  56439. * Specifies whether or not the inner glow is ACTIVE in the layer.
  56440. */
  56441. innerGlow: boolean;
  56442. /**
  56443. * Specifies whether or not the outer glow is ACTIVE in the layer.
  56444. */
  56445. outerGlow: boolean;
  56446. /**
  56447. * Specifies the horizontal size of the blur.
  56448. */
  56449. set blurHorizontalSize(value: number);
  56450. /**
  56451. * Specifies the vertical size of the blur.
  56452. */
  56453. set blurVerticalSize(value: number);
  56454. /**
  56455. * Gets the horizontal size of the blur.
  56456. */
  56457. get blurHorizontalSize(): number;
  56458. /**
  56459. * Gets the vertical size of the blur.
  56460. */
  56461. get blurVerticalSize(): number;
  56462. /**
  56463. * An event triggered when the highlight layer is being blurred.
  56464. */
  56465. onBeforeBlurObservable: Observable<HighlightLayer>;
  56466. /**
  56467. * An event triggered when the highlight layer has been blurred.
  56468. */
  56469. onAfterBlurObservable: Observable<HighlightLayer>;
  56470. private _instanceGlowingMeshStencilReference;
  56471. private _options;
  56472. private _downSamplePostprocess;
  56473. private _horizontalBlurPostprocess;
  56474. private _verticalBlurPostprocess;
  56475. private _blurTexture;
  56476. private _meshes;
  56477. private _excludedMeshes;
  56478. /**
  56479. * Instantiates a new highlight Layer and references it to the scene..
  56480. * @param name The name of the layer
  56481. * @param scene The scene to use the layer in
  56482. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  56483. */
  56484. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  56485. /**
  56486. * Get the effect name of the layer.
  56487. * @return The effect name
  56488. */
  56489. getEffectName(): string;
  56490. /**
  56491. * Create the merge effect. This is the shader use to blit the information back
  56492. * to the main canvas at the end of the scene rendering.
  56493. */
  56494. protected _createMergeEffect(): Effect;
  56495. /**
  56496. * Creates the render target textures and post processes used in the highlight layer.
  56497. */
  56498. protected _createTextureAndPostProcesses(): void;
  56499. /**
  56500. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  56501. */
  56502. needStencil(): boolean;
  56503. /**
  56504. * Checks for the readiness of the element composing the layer.
  56505. * @param subMesh the mesh to check for
  56506. * @param useInstances specify wether or not to use instances to render the mesh
  56507. * @param emissiveTexture the associated emissive texture used to generate the glow
  56508. * @return true if ready otherwise, false
  56509. */
  56510. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56511. /**
  56512. * Implementation specific of rendering the generating effect on the main canvas.
  56513. * @param effect The effect used to render through
  56514. */
  56515. protected _internalRender(effect: Effect): void;
  56516. /**
  56517. * Returns true if the layer contains information to display, otherwise false.
  56518. */
  56519. shouldRender(): boolean;
  56520. /**
  56521. * Returns true if the mesh should render, otherwise false.
  56522. * @param mesh The mesh to render
  56523. * @returns true if it should render otherwise false
  56524. */
  56525. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56526. /**
  56527. * Adds specific effects defines.
  56528. * @param defines The defines to add specifics to.
  56529. */
  56530. protected _addCustomEffectDefines(defines: string[]): void;
  56531. /**
  56532. * Sets the required values for both the emissive texture and and the main color.
  56533. */
  56534. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56535. /**
  56536. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  56537. * @param mesh The mesh to exclude from the highlight layer
  56538. */
  56539. addExcludedMesh(mesh: Mesh): void;
  56540. /**
  56541. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  56542. * @param mesh The mesh to highlight
  56543. */
  56544. removeExcludedMesh(mesh: Mesh): void;
  56545. /**
  56546. * Determine if a given mesh will be highlighted by the current HighlightLayer
  56547. * @param mesh mesh to test
  56548. * @returns true if the mesh will be highlighted by the current HighlightLayer
  56549. */
  56550. hasMesh(mesh: AbstractMesh): boolean;
  56551. /**
  56552. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  56553. * @param mesh The mesh to highlight
  56554. * @param color The color of the highlight
  56555. * @param glowEmissiveOnly Extract the glow from the emissive texture
  56556. */
  56557. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  56558. /**
  56559. * Remove a mesh from the highlight layer in order to make it stop glowing.
  56560. * @param mesh The mesh to highlight
  56561. */
  56562. removeMesh(mesh: Mesh): void;
  56563. /**
  56564. * Remove all the meshes currently referenced in the highlight layer
  56565. */
  56566. removeAllMeshes(): void;
  56567. /**
  56568. * Force the stencil to the normal expected value for none glowing parts
  56569. */
  56570. private _defaultStencilReference;
  56571. /**
  56572. * Free any resources and references associated to a mesh.
  56573. * Internal use
  56574. * @param mesh The mesh to free.
  56575. * @hidden
  56576. */
  56577. _disposeMesh(mesh: Mesh): void;
  56578. /**
  56579. * Dispose the highlight layer and free resources.
  56580. */
  56581. dispose(): void;
  56582. /**
  56583. * Gets the class name of the effect layer
  56584. * @returns the string with the class name of the effect layer
  56585. */
  56586. getClassName(): string;
  56587. /**
  56588. * Serializes this Highlight layer
  56589. * @returns a serialized Highlight layer object
  56590. */
  56591. serialize(): any;
  56592. /**
  56593. * Creates a Highlight layer from parsed Highlight layer data
  56594. * @param parsedHightlightLayer defines the Highlight layer data
  56595. * @param scene defines the current scene
  56596. * @param rootUrl defines the root URL containing the Highlight layer information
  56597. * @returns a parsed Highlight layer
  56598. */
  56599. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  56600. }
  56601. }
  56602. declare module "babylonjs/Layers/layerSceneComponent" {
  56603. import { Scene } from "babylonjs/scene";
  56604. import { ISceneComponent } from "babylonjs/sceneComponent";
  56605. import { Layer } from "babylonjs/Layers/layer";
  56606. import { AbstractScene } from "babylonjs/abstractScene";
  56607. module "babylonjs/abstractScene" {
  56608. interface AbstractScene {
  56609. /**
  56610. * The list of layers (background and foreground) of the scene
  56611. */
  56612. layers: Array<Layer>;
  56613. }
  56614. }
  56615. /**
  56616. * Defines the layer scene component responsible to manage any layers
  56617. * in a given scene.
  56618. */
  56619. export class LayerSceneComponent implements ISceneComponent {
  56620. /**
  56621. * The component name helpfull to identify the component in the list of scene components.
  56622. */
  56623. readonly name: string;
  56624. /**
  56625. * The scene the component belongs to.
  56626. */
  56627. scene: Scene;
  56628. private _engine;
  56629. /**
  56630. * Creates a new instance of the component for the given scene
  56631. * @param scene Defines the scene to register the component in
  56632. */
  56633. constructor(scene: Scene);
  56634. /**
  56635. * Registers the component in a given scene
  56636. */
  56637. register(): void;
  56638. /**
  56639. * Rebuilds the elements related to this component in case of
  56640. * context lost for instance.
  56641. */
  56642. rebuild(): void;
  56643. /**
  56644. * Disposes the component and the associated ressources.
  56645. */
  56646. dispose(): void;
  56647. private _draw;
  56648. private _drawCameraPredicate;
  56649. private _drawCameraBackground;
  56650. private _drawCameraForeground;
  56651. private _drawRenderTargetPredicate;
  56652. private _drawRenderTargetBackground;
  56653. private _drawRenderTargetForeground;
  56654. /**
  56655. * Adds all the elements from the container to the scene
  56656. * @param container the container holding the elements
  56657. */
  56658. addFromContainer(container: AbstractScene): void;
  56659. /**
  56660. * Removes all the elements in the container from the scene
  56661. * @param container contains the elements to remove
  56662. * @param dispose if the removed element should be disposed (default: false)
  56663. */
  56664. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56665. }
  56666. }
  56667. declare module "babylonjs/Shaders/layer.fragment" {
  56668. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56669. /** @hidden */
  56670. export var layerPixelShader: {
  56671. name: string;
  56672. shader: string;
  56673. };
  56674. }
  56675. declare module "babylonjs/Shaders/layer.vertex" {
  56676. /** @hidden */
  56677. export var layerVertexShader: {
  56678. name: string;
  56679. shader: string;
  56680. };
  56681. }
  56682. declare module "babylonjs/Layers/layer" {
  56683. import { Observable } from "babylonjs/Misc/observable";
  56684. import { Nullable } from "babylonjs/types";
  56685. import { Scene } from "babylonjs/scene";
  56686. import { Vector2 } from "babylonjs/Maths/math.vector";
  56687. import { Color4 } from "babylonjs/Maths/math.color";
  56688. import { Texture } from "babylonjs/Materials/Textures/texture";
  56689. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56690. import "babylonjs/Shaders/layer.fragment";
  56691. import "babylonjs/Shaders/layer.vertex";
  56692. /**
  56693. * This represents a full screen 2d layer.
  56694. * This can be useful to display a picture in the background of your scene for instance.
  56695. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56696. */
  56697. export class Layer {
  56698. /**
  56699. * Define the name of the layer.
  56700. */
  56701. name: string;
  56702. /**
  56703. * Define the texture the layer should display.
  56704. */
  56705. texture: Nullable<Texture>;
  56706. /**
  56707. * Is the layer in background or foreground.
  56708. */
  56709. isBackground: boolean;
  56710. /**
  56711. * Define the color of the layer (instead of texture).
  56712. */
  56713. color: Color4;
  56714. /**
  56715. * Define the scale of the layer in order to zoom in out of the texture.
  56716. */
  56717. scale: Vector2;
  56718. /**
  56719. * Define an offset for the layer in order to shift the texture.
  56720. */
  56721. offset: Vector2;
  56722. /**
  56723. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  56724. */
  56725. alphaBlendingMode: number;
  56726. /**
  56727. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  56728. * Alpha test will not mix with the background color in case of transparency.
  56729. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  56730. */
  56731. alphaTest: boolean;
  56732. /**
  56733. * Define a mask to restrict the layer to only some of the scene cameras.
  56734. */
  56735. layerMask: number;
  56736. /**
  56737. * Define the list of render target the layer is visible into.
  56738. */
  56739. renderTargetTextures: RenderTargetTexture[];
  56740. /**
  56741. * Define if the layer is only used in renderTarget or if it also
  56742. * renders in the main frame buffer of the canvas.
  56743. */
  56744. renderOnlyInRenderTargetTextures: boolean;
  56745. private _scene;
  56746. private _vertexBuffers;
  56747. private _indexBuffer;
  56748. private _effect;
  56749. private _previousDefines;
  56750. /**
  56751. * An event triggered when the layer is disposed.
  56752. */
  56753. onDisposeObservable: Observable<Layer>;
  56754. private _onDisposeObserver;
  56755. /**
  56756. * Back compatibility with callback before the onDisposeObservable existed.
  56757. * The set callback will be triggered when the layer has been disposed.
  56758. */
  56759. set onDispose(callback: () => void);
  56760. /**
  56761. * An event triggered before rendering the scene
  56762. */
  56763. onBeforeRenderObservable: Observable<Layer>;
  56764. private _onBeforeRenderObserver;
  56765. /**
  56766. * Back compatibility with callback before the onBeforeRenderObservable existed.
  56767. * The set callback will be triggered just before rendering the layer.
  56768. */
  56769. set onBeforeRender(callback: () => void);
  56770. /**
  56771. * An event triggered after rendering the scene
  56772. */
  56773. onAfterRenderObservable: Observable<Layer>;
  56774. private _onAfterRenderObserver;
  56775. /**
  56776. * Back compatibility with callback before the onAfterRenderObservable existed.
  56777. * The set callback will be triggered just after rendering the layer.
  56778. */
  56779. set onAfterRender(callback: () => void);
  56780. /**
  56781. * Instantiates a new layer.
  56782. * This represents a full screen 2d layer.
  56783. * This can be useful to display a picture in the background of your scene for instance.
  56784. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56785. * @param name Define the name of the layer in the scene
  56786. * @param imgUrl Define the url of the texture to display in the layer
  56787. * @param scene Define the scene the layer belongs to
  56788. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  56789. * @param color Defines a color for the layer
  56790. */
  56791. constructor(
  56792. /**
  56793. * Define the name of the layer.
  56794. */
  56795. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  56796. private _createIndexBuffer;
  56797. /** @hidden */
  56798. _rebuild(): void;
  56799. /**
  56800. * Renders the layer in the scene.
  56801. */
  56802. render(): void;
  56803. /**
  56804. * Disposes and releases the associated ressources.
  56805. */
  56806. dispose(): void;
  56807. }
  56808. }
  56809. declare module "babylonjs/Layers/index" {
  56810. export * from "babylonjs/Layers/effectLayer";
  56811. export * from "babylonjs/Layers/effectLayerSceneComponent";
  56812. export * from "babylonjs/Layers/glowLayer";
  56813. export * from "babylonjs/Layers/highlightLayer";
  56814. export * from "babylonjs/Layers/layer";
  56815. export * from "babylonjs/Layers/layerSceneComponent";
  56816. }
  56817. declare module "babylonjs/Shaders/lensFlare.fragment" {
  56818. /** @hidden */
  56819. export var lensFlarePixelShader: {
  56820. name: string;
  56821. shader: string;
  56822. };
  56823. }
  56824. declare module "babylonjs/Shaders/lensFlare.vertex" {
  56825. /** @hidden */
  56826. export var lensFlareVertexShader: {
  56827. name: string;
  56828. shader: string;
  56829. };
  56830. }
  56831. declare module "babylonjs/LensFlares/lensFlareSystem" {
  56832. import { Scene } from "babylonjs/scene";
  56833. import { Vector3 } from "babylonjs/Maths/math.vector";
  56834. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56835. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  56836. import "babylonjs/Shaders/lensFlare.fragment";
  56837. import "babylonjs/Shaders/lensFlare.vertex";
  56838. import { Viewport } from "babylonjs/Maths/math.viewport";
  56839. /**
  56840. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56841. * It is usually composed of several `lensFlare`.
  56842. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56843. */
  56844. export class LensFlareSystem {
  56845. /**
  56846. * Define the name of the lens flare system
  56847. */
  56848. name: string;
  56849. /**
  56850. * List of lens flares used in this system.
  56851. */
  56852. lensFlares: LensFlare[];
  56853. /**
  56854. * Define a limit from the border the lens flare can be visible.
  56855. */
  56856. borderLimit: number;
  56857. /**
  56858. * Define a viewport border we do not want to see the lens flare in.
  56859. */
  56860. viewportBorder: number;
  56861. /**
  56862. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56863. */
  56864. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56865. /**
  56866. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  56867. */
  56868. layerMask: number;
  56869. /**
  56870. * Define the id of the lens flare system in the scene.
  56871. * (equal to name by default)
  56872. */
  56873. id: string;
  56874. private _scene;
  56875. private _emitter;
  56876. private _vertexBuffers;
  56877. private _indexBuffer;
  56878. private _effect;
  56879. private _positionX;
  56880. private _positionY;
  56881. private _isEnabled;
  56882. /** @hidden */
  56883. static _SceneComponentInitialization: (scene: Scene) => void;
  56884. /**
  56885. * Instantiates a lens flare system.
  56886. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56887. * It is usually composed of several `lensFlare`.
  56888. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56889. * @param name Define the name of the lens flare system in the scene
  56890. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  56891. * @param scene Define the scene the lens flare system belongs to
  56892. */
  56893. constructor(
  56894. /**
  56895. * Define the name of the lens flare system
  56896. */
  56897. name: string, emitter: any, scene: Scene);
  56898. /**
  56899. * Define if the lens flare system is enabled.
  56900. */
  56901. get isEnabled(): boolean;
  56902. set isEnabled(value: boolean);
  56903. /**
  56904. * Get the scene the effects belongs to.
  56905. * @returns the scene holding the lens flare system
  56906. */
  56907. getScene(): Scene;
  56908. /**
  56909. * Get the emitter of the lens flare system.
  56910. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56911. * @returns the emitter of the lens flare system
  56912. */
  56913. getEmitter(): any;
  56914. /**
  56915. * Set the emitter of the lens flare system.
  56916. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56917. * @param newEmitter Define the new emitter of the system
  56918. */
  56919. setEmitter(newEmitter: any): void;
  56920. /**
  56921. * Get the lens flare system emitter position.
  56922. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  56923. * @returns the position
  56924. */
  56925. getEmitterPosition(): Vector3;
  56926. /**
  56927. * @hidden
  56928. */
  56929. computeEffectivePosition(globalViewport: Viewport): boolean;
  56930. /** @hidden */
  56931. _isVisible(): boolean;
  56932. /**
  56933. * @hidden
  56934. */
  56935. render(): boolean;
  56936. /**
  56937. * Dispose and release the lens flare with its associated resources.
  56938. */
  56939. dispose(): void;
  56940. /**
  56941. * Parse a lens flare system from a JSON repressentation
  56942. * @param parsedLensFlareSystem Define the JSON to parse
  56943. * @param scene Define the scene the parsed system should be instantiated in
  56944. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  56945. * @returns the parsed system
  56946. */
  56947. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  56948. /**
  56949. * Serialize the current Lens Flare System into a JSON representation.
  56950. * @returns the serialized JSON
  56951. */
  56952. serialize(): any;
  56953. }
  56954. }
  56955. declare module "babylonjs/LensFlares/lensFlare" {
  56956. import { Nullable } from "babylonjs/types";
  56957. import { Color3 } from "babylonjs/Maths/math.color";
  56958. import { Texture } from "babylonjs/Materials/Textures/texture";
  56959. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56960. /**
  56961. * This represents one of the lens effect in a `lensFlareSystem`.
  56962. * It controls one of the indiviual texture used in the effect.
  56963. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56964. */
  56965. export class LensFlare {
  56966. /**
  56967. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56968. */
  56969. size: number;
  56970. /**
  56971. * 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.
  56972. */
  56973. position: number;
  56974. /**
  56975. * Define the lens color.
  56976. */
  56977. color: Color3;
  56978. /**
  56979. * Define the lens texture.
  56980. */
  56981. texture: Nullable<Texture>;
  56982. /**
  56983. * Define the alpha mode to render this particular lens.
  56984. */
  56985. alphaMode: number;
  56986. private _system;
  56987. /**
  56988. * Creates a new Lens Flare.
  56989. * This represents one of the lens effect in a `lensFlareSystem`.
  56990. * It controls one of the indiviual texture used in the effect.
  56991. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56992. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  56993. * @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.
  56994. * @param color Define the lens color
  56995. * @param imgUrl Define the lens texture url
  56996. * @param system Define the `lensFlareSystem` this flare is part of
  56997. * @returns The newly created Lens Flare
  56998. */
  56999. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  57000. /**
  57001. * Instantiates a new Lens Flare.
  57002. * This represents one of the lens effect in a `lensFlareSystem`.
  57003. * It controls one of the indiviual texture used in the effect.
  57004. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57005. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  57006. * @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.
  57007. * @param color Define the lens color
  57008. * @param imgUrl Define the lens texture url
  57009. * @param system Define the `lensFlareSystem` this flare is part of
  57010. */
  57011. constructor(
  57012. /**
  57013. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57014. */
  57015. size: number,
  57016. /**
  57017. * 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.
  57018. */
  57019. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  57020. /**
  57021. * Dispose and release the lens flare with its associated resources.
  57022. */
  57023. dispose(): void;
  57024. }
  57025. }
  57026. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  57027. import { Nullable } from "babylonjs/types";
  57028. import { Scene } from "babylonjs/scene";
  57029. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  57030. import { AbstractScene } from "babylonjs/abstractScene";
  57031. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  57032. module "babylonjs/abstractScene" {
  57033. interface AbstractScene {
  57034. /**
  57035. * The list of lens flare system added to the scene
  57036. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57037. */
  57038. lensFlareSystems: Array<LensFlareSystem>;
  57039. /**
  57040. * Removes the given lens flare system from this scene.
  57041. * @param toRemove The lens flare system to remove
  57042. * @returns The index of the removed lens flare system
  57043. */
  57044. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  57045. /**
  57046. * Adds the given lens flare system to this scene
  57047. * @param newLensFlareSystem The lens flare system to add
  57048. */
  57049. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  57050. /**
  57051. * Gets a lens flare system using its name
  57052. * @param name defines the name to look for
  57053. * @returns the lens flare system or null if not found
  57054. */
  57055. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  57056. /**
  57057. * Gets a lens flare system using its id
  57058. * @param id defines the id to look for
  57059. * @returns the lens flare system or null if not found
  57060. */
  57061. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  57062. }
  57063. }
  57064. /**
  57065. * Defines the lens flare scene component responsible to manage any lens flares
  57066. * in a given scene.
  57067. */
  57068. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  57069. /**
  57070. * The component name helpfull to identify the component in the list of scene components.
  57071. */
  57072. readonly name: string;
  57073. /**
  57074. * The scene the component belongs to.
  57075. */
  57076. scene: Scene;
  57077. /**
  57078. * Creates a new instance of the component for the given scene
  57079. * @param scene Defines the scene to register the component in
  57080. */
  57081. constructor(scene: Scene);
  57082. /**
  57083. * Registers the component in a given scene
  57084. */
  57085. register(): void;
  57086. /**
  57087. * Rebuilds the elements related to this component in case of
  57088. * context lost for instance.
  57089. */
  57090. rebuild(): void;
  57091. /**
  57092. * Adds all the elements from the container to the scene
  57093. * @param container the container holding the elements
  57094. */
  57095. addFromContainer(container: AbstractScene): void;
  57096. /**
  57097. * Removes all the elements in the container from the scene
  57098. * @param container contains the elements to remove
  57099. * @param dispose if the removed element should be disposed (default: false)
  57100. */
  57101. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57102. /**
  57103. * Serializes the component data to the specified json object
  57104. * @param serializationObject The object to serialize to
  57105. */
  57106. serialize(serializationObject: any): void;
  57107. /**
  57108. * Disposes the component and the associated ressources.
  57109. */
  57110. dispose(): void;
  57111. private _draw;
  57112. }
  57113. }
  57114. declare module "babylonjs/LensFlares/index" {
  57115. export * from "babylonjs/LensFlares/lensFlare";
  57116. export * from "babylonjs/LensFlares/lensFlareSystem";
  57117. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  57118. }
  57119. declare module "babylonjs/Shaders/depth.fragment" {
  57120. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  57121. /** @hidden */
  57122. export var depthPixelShader: {
  57123. name: string;
  57124. shader: string;
  57125. };
  57126. }
  57127. declare module "babylonjs/Shaders/depth.vertex" {
  57128. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57129. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57130. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57131. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57132. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  57133. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57134. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57135. /** @hidden */
  57136. export var depthVertexShader: {
  57137. name: string;
  57138. shader: string;
  57139. };
  57140. }
  57141. declare module "babylonjs/Rendering/depthRenderer" {
  57142. import { Nullable } from "babylonjs/types";
  57143. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57144. import { Scene } from "babylonjs/scene";
  57145. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57146. import { Camera } from "babylonjs/Cameras/camera";
  57147. import "babylonjs/Shaders/depth.fragment";
  57148. import "babylonjs/Shaders/depth.vertex";
  57149. /**
  57150. * This represents a depth renderer in Babylon.
  57151. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57152. */
  57153. export class DepthRenderer {
  57154. private _scene;
  57155. private _depthMap;
  57156. private _effect;
  57157. private readonly _storeNonLinearDepth;
  57158. private readonly _clearColor;
  57159. /** Get if the depth renderer is using packed depth or not */
  57160. readonly isPacked: boolean;
  57161. private _cachedDefines;
  57162. private _camera;
  57163. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  57164. enabled: boolean;
  57165. /**
  57166. * Specifiess that the depth renderer will only be used within
  57167. * the camera it is created for.
  57168. * This can help forcing its rendering during the camera processing.
  57169. */
  57170. useOnlyInActiveCamera: boolean;
  57171. /** @hidden */
  57172. static _SceneComponentInitialization: (scene: Scene) => void;
  57173. /**
  57174. * Instantiates a depth renderer
  57175. * @param scene The scene the renderer belongs to
  57176. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57177. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57178. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  57179. */
  57180. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  57181. /**
  57182. * Creates the depth rendering effect and checks if the effect is ready.
  57183. * @param subMesh The submesh to be used to render the depth map of
  57184. * @param useInstances If multiple world instances should be used
  57185. * @returns if the depth renderer is ready to render the depth map
  57186. */
  57187. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57188. /**
  57189. * Gets the texture which the depth map will be written to.
  57190. * @returns The depth map texture
  57191. */
  57192. getDepthMap(): RenderTargetTexture;
  57193. /**
  57194. * Disposes of the depth renderer.
  57195. */
  57196. dispose(): void;
  57197. }
  57198. }
  57199. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  57200. /** @hidden */
  57201. export var minmaxReduxPixelShader: {
  57202. name: string;
  57203. shader: string;
  57204. };
  57205. }
  57206. declare module "babylonjs/Misc/minMaxReducer" {
  57207. import { Nullable } from "babylonjs/types";
  57208. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57209. import { Camera } from "babylonjs/Cameras/camera";
  57210. import { Observer } from "babylonjs/Misc/observable";
  57211. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57212. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  57213. import { Observable } from "babylonjs/Misc/observable";
  57214. import "babylonjs/Shaders/minmaxRedux.fragment";
  57215. /**
  57216. * This class computes a min/max reduction from a texture: it means it computes the minimum
  57217. * and maximum values from all values of the texture.
  57218. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  57219. * The source values are read from the red channel of the texture.
  57220. */
  57221. export class MinMaxReducer {
  57222. /**
  57223. * Observable triggered when the computation has been performed
  57224. */
  57225. onAfterReductionPerformed: Observable<{
  57226. min: number;
  57227. max: number;
  57228. }>;
  57229. protected _camera: Camera;
  57230. protected _sourceTexture: Nullable<RenderTargetTexture>;
  57231. protected _reductionSteps: Nullable<Array<PostProcess>>;
  57232. protected _postProcessManager: PostProcessManager;
  57233. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  57234. protected _forceFullscreenViewport: boolean;
  57235. /**
  57236. * Creates a min/max reducer
  57237. * @param camera The camera to use for the post processes
  57238. */
  57239. constructor(camera: Camera);
  57240. /**
  57241. * Gets the texture used to read the values from.
  57242. */
  57243. get sourceTexture(): Nullable<RenderTargetTexture>;
  57244. /**
  57245. * Sets the source texture to read the values from.
  57246. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  57247. * because in such textures '1' value must not be taken into account to compute the maximum
  57248. * as this value is used to clear the texture.
  57249. * Note that the computation is not activated by calling this function, you must call activate() for that!
  57250. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  57251. * @param depthRedux Indicates if the texture is a depth texture or not
  57252. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  57253. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57254. */
  57255. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57256. /**
  57257. * Defines the refresh rate of the computation.
  57258. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57259. */
  57260. get refreshRate(): number;
  57261. set refreshRate(value: number);
  57262. protected _activated: boolean;
  57263. /**
  57264. * Gets the activation status of the reducer
  57265. */
  57266. get activated(): boolean;
  57267. /**
  57268. * Activates the reduction computation.
  57269. * When activated, the observers registered in onAfterReductionPerformed are
  57270. * called after the compuation is performed
  57271. */
  57272. activate(): void;
  57273. /**
  57274. * Deactivates the reduction computation.
  57275. */
  57276. deactivate(): void;
  57277. /**
  57278. * Disposes the min/max reducer
  57279. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  57280. */
  57281. dispose(disposeAll?: boolean): void;
  57282. }
  57283. }
  57284. declare module "babylonjs/Misc/depthReducer" {
  57285. import { Nullable } from "babylonjs/types";
  57286. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57287. import { Camera } from "babylonjs/Cameras/camera";
  57288. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57289. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  57290. /**
  57291. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  57292. */
  57293. export class DepthReducer extends MinMaxReducer {
  57294. private _depthRenderer;
  57295. private _depthRendererId;
  57296. /**
  57297. * Gets the depth renderer used for the computation.
  57298. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  57299. */
  57300. get depthRenderer(): Nullable<DepthRenderer>;
  57301. /**
  57302. * Creates a depth reducer
  57303. * @param camera The camera used to render the depth texture
  57304. */
  57305. constructor(camera: Camera);
  57306. /**
  57307. * Sets the depth renderer to use to generate the depth map
  57308. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  57309. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  57310. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57311. */
  57312. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  57313. /** @hidden */
  57314. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57315. /**
  57316. * Activates the reduction computation.
  57317. * When activated, the observers registered in onAfterReductionPerformed are
  57318. * called after the compuation is performed
  57319. */
  57320. activate(): void;
  57321. /**
  57322. * Deactivates the reduction computation.
  57323. */
  57324. deactivate(): void;
  57325. /**
  57326. * Disposes the depth reducer
  57327. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  57328. */
  57329. dispose(disposeAll?: boolean): void;
  57330. }
  57331. }
  57332. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  57333. import { Nullable } from "babylonjs/types";
  57334. import { Scene } from "babylonjs/scene";
  57335. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57336. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57338. import { Effect } from "babylonjs/Materials/effect";
  57339. import "babylonjs/Shaders/shadowMap.fragment";
  57340. import "babylonjs/Shaders/shadowMap.vertex";
  57341. import "babylonjs/Shaders/depthBoxBlur.fragment";
  57342. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  57343. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  57344. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  57345. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57346. /**
  57347. * A CSM implementation allowing casting shadows on large scenes.
  57348. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57349. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  57350. */
  57351. export class CascadedShadowGenerator extends ShadowGenerator {
  57352. private static readonly frustumCornersNDCSpace;
  57353. /**
  57354. * Name of the CSM class
  57355. */
  57356. static CLASSNAME: string;
  57357. /**
  57358. * Defines the default number of cascades used by the CSM.
  57359. */
  57360. static readonly DEFAULT_CASCADES_COUNT: number;
  57361. /**
  57362. * Defines the minimum number of cascades used by the CSM.
  57363. */
  57364. static readonly MIN_CASCADES_COUNT: number;
  57365. /**
  57366. * Defines the maximum number of cascades used by the CSM.
  57367. */
  57368. static readonly MAX_CASCADES_COUNT: number;
  57369. protected _validateFilter(filter: number): number;
  57370. /**
  57371. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  57372. */
  57373. penumbraDarkness: number;
  57374. private _numCascades;
  57375. /**
  57376. * Gets or set the number of cascades used by the CSM.
  57377. */
  57378. get numCascades(): number;
  57379. set numCascades(value: number);
  57380. /**
  57381. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  57382. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  57383. */
  57384. stabilizeCascades: boolean;
  57385. private _freezeShadowCastersBoundingInfo;
  57386. private _freezeShadowCastersBoundingInfoObservable;
  57387. /**
  57388. * Enables or disables the shadow casters bounding info computation.
  57389. * If your shadow casters don't move, you can disable this feature.
  57390. * If it is enabled, the bounding box computation is done every frame.
  57391. */
  57392. get freezeShadowCastersBoundingInfo(): boolean;
  57393. set freezeShadowCastersBoundingInfo(freeze: boolean);
  57394. private _scbiMin;
  57395. private _scbiMax;
  57396. protected _computeShadowCastersBoundingInfo(): void;
  57397. protected _shadowCastersBoundingInfo: BoundingInfo;
  57398. /**
  57399. * Gets or sets the shadow casters bounding info.
  57400. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  57401. * so that the system won't overwrite the bounds you provide
  57402. */
  57403. get shadowCastersBoundingInfo(): BoundingInfo;
  57404. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  57405. protected _breaksAreDirty: boolean;
  57406. protected _minDistance: number;
  57407. protected _maxDistance: number;
  57408. /**
  57409. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  57410. *
  57411. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  57412. * If you don't know these values, simply leave them to their defaults and don't call this function.
  57413. * @param min minimal distance for the breaks (default to 0.)
  57414. * @param max maximal distance for the breaks (default to 1.)
  57415. */
  57416. setMinMaxDistance(min: number, max: number): void;
  57417. /** Gets the minimal distance used in the cascade break computation */
  57418. get minDistance(): number;
  57419. /** Gets the maximal distance used in the cascade break computation */
  57420. get maxDistance(): number;
  57421. /**
  57422. * Gets the class name of that object
  57423. * @returns "CascadedShadowGenerator"
  57424. */
  57425. getClassName(): string;
  57426. private _cascadeMinExtents;
  57427. private _cascadeMaxExtents;
  57428. /**
  57429. * Gets a cascade minimum extents
  57430. * @param cascadeIndex index of the cascade
  57431. * @returns the minimum cascade extents
  57432. */
  57433. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  57434. /**
  57435. * Gets a cascade maximum extents
  57436. * @param cascadeIndex index of the cascade
  57437. * @returns the maximum cascade extents
  57438. */
  57439. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  57440. private _cascades;
  57441. private _currentLayer;
  57442. private _viewSpaceFrustumsZ;
  57443. private _viewMatrices;
  57444. private _projectionMatrices;
  57445. private _transformMatrices;
  57446. private _transformMatricesAsArray;
  57447. private _frustumLengths;
  57448. private _lightSizeUVCorrection;
  57449. private _depthCorrection;
  57450. private _frustumCornersWorldSpace;
  57451. private _frustumCenter;
  57452. private _shadowCameraPos;
  57453. private _shadowMaxZ;
  57454. /**
  57455. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  57456. * It defaults to camera.maxZ
  57457. */
  57458. get shadowMaxZ(): number;
  57459. /**
  57460. * Sets the shadow max z distance.
  57461. */
  57462. set shadowMaxZ(value: number);
  57463. protected _debug: boolean;
  57464. /**
  57465. * Gets or sets the debug flag.
  57466. * When enabled, the cascades are materialized by different colors on the screen.
  57467. */
  57468. get debug(): boolean;
  57469. set debug(dbg: boolean);
  57470. private _depthClamp;
  57471. /**
  57472. * Gets or sets the depth clamping value.
  57473. *
  57474. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  57475. * to account for the shadow casters far away.
  57476. *
  57477. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  57478. */
  57479. get depthClamp(): boolean;
  57480. set depthClamp(value: boolean);
  57481. private _cascadeBlendPercentage;
  57482. /**
  57483. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  57484. * It defaults to 0.1 (10% blending).
  57485. */
  57486. get cascadeBlendPercentage(): number;
  57487. set cascadeBlendPercentage(value: number);
  57488. private _lambda;
  57489. /**
  57490. * Gets or set the lambda parameter.
  57491. * This parameter is used to split the camera frustum and create the cascades.
  57492. * It's a value between 0. and 1.: If 0, the split is a uniform split of the frustum, if 1 it is a logarithmic split.
  57493. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  57494. */
  57495. get lambda(): number;
  57496. set lambda(value: number);
  57497. /**
  57498. * Gets the view matrix corresponding to a given cascade
  57499. * @param cascadeNum cascade to retrieve the view matrix from
  57500. * @returns the cascade view matrix
  57501. */
  57502. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  57503. /**
  57504. * Gets the projection matrix corresponding to a given cascade
  57505. * @param cascadeNum cascade to retrieve the projection matrix from
  57506. * @returns the cascade projection matrix
  57507. */
  57508. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  57509. /**
  57510. * Gets the transformation matrix corresponding to a given cascade
  57511. * @param cascadeNum cascade to retrieve the transformation matrix from
  57512. * @returns the cascade transformation matrix
  57513. */
  57514. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  57515. private _depthRenderer;
  57516. /**
  57517. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  57518. *
  57519. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  57520. *
  57521. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  57522. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  57523. * @param depthRenderer The depth renderer to use when autoCalcDepthBounds is enabled. If you pass null or don't call this function at all, a depth renderer will be automatically created
  57524. */
  57525. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  57526. private _depthReducer;
  57527. private _autoCalcDepthBounds;
  57528. /**
  57529. * Gets or sets the autoCalcDepthBounds property.
  57530. *
  57531. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  57532. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  57533. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  57534. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  57535. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  57536. */
  57537. get autoCalcDepthBounds(): boolean;
  57538. set autoCalcDepthBounds(value: boolean);
  57539. /**
  57540. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  57541. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57542. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  57543. * for setting the refresh rate on the renderer yourself!
  57544. */
  57545. get autoCalcDepthBoundsRefreshRate(): number;
  57546. set autoCalcDepthBoundsRefreshRate(value: number);
  57547. /**
  57548. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  57549. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  57550. * you change the camera near/far planes!
  57551. */
  57552. splitFrustum(): void;
  57553. private _splitFrustum;
  57554. private _computeMatrices;
  57555. private _computeFrustumInWorldSpace;
  57556. private _computeCascadeFrustum;
  57557. /**
  57558. * Support test.
  57559. */
  57560. static get IsSupported(): boolean;
  57561. /** @hidden */
  57562. static _SceneComponentInitialization: (scene: Scene) => void;
  57563. /**
  57564. * Creates a Cascaded Shadow Generator object.
  57565. * A ShadowGenerator is the required tool to use the shadows.
  57566. * Each directional light casting shadows needs to use its own ShadowGenerator.
  57567. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57568. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  57569. * @param light The directional light object generating the shadows.
  57570. * @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.
  57571. */
  57572. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  57573. protected _initializeGenerator(): void;
  57574. protected _createTargetRenderTexture(): void;
  57575. protected _initializeShadowMap(): void;
  57576. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  57577. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  57578. /**
  57579. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  57580. * @param defines Defines of the material we want to update
  57581. * @param lightIndex Index of the light in the enabled light list of the material
  57582. */
  57583. prepareDefines(defines: any, lightIndex: number): void;
  57584. /**
  57585. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  57586. * defined in the generator but impacting the effect).
  57587. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  57588. * @param effect The effect we are binfing the information for
  57589. */
  57590. bindShadowLight(lightIndex: string, effect: Effect): void;
  57591. /**
  57592. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  57593. * (eq to view projection * shadow projection matrices)
  57594. * @returns The transform matrix used to create the shadow map
  57595. */
  57596. getTransformMatrix(): Matrix;
  57597. /**
  57598. * Disposes the ShadowGenerator.
  57599. * Returns nothing.
  57600. */
  57601. dispose(): void;
  57602. /**
  57603. * Serializes the shadow generator setup to a json object.
  57604. * @returns The serialized JSON object
  57605. */
  57606. serialize(): any;
  57607. /**
  57608. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  57609. * @param parsedShadowGenerator The JSON object to parse
  57610. * @param scene The scene to create the shadow map for
  57611. * @returns The parsed shadow generator
  57612. */
  57613. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  57614. }
  57615. }
  57616. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  57617. import { Scene } from "babylonjs/scene";
  57618. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  57619. import { AbstractScene } from "babylonjs/abstractScene";
  57620. /**
  57621. * Defines the shadow generator component responsible to manage any shadow generators
  57622. * in a given scene.
  57623. */
  57624. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  57625. /**
  57626. * The component name helpfull to identify the component in the list of scene components.
  57627. */
  57628. readonly name: string;
  57629. /**
  57630. * The scene the component belongs to.
  57631. */
  57632. scene: Scene;
  57633. /**
  57634. * Creates a new instance of the component for the given scene
  57635. * @param scene Defines the scene to register the component in
  57636. */
  57637. constructor(scene: Scene);
  57638. /**
  57639. * Registers the component in a given scene
  57640. */
  57641. register(): void;
  57642. /**
  57643. * Rebuilds the elements related to this component in case of
  57644. * context lost for instance.
  57645. */
  57646. rebuild(): void;
  57647. /**
  57648. * Serializes the component data to the specified json object
  57649. * @param serializationObject The object to serialize to
  57650. */
  57651. serialize(serializationObject: any): void;
  57652. /**
  57653. * Adds all the elements from the container to the scene
  57654. * @param container the container holding the elements
  57655. */
  57656. addFromContainer(container: AbstractScene): void;
  57657. /**
  57658. * Removes all the elements in the container from the scene
  57659. * @param container contains the elements to remove
  57660. * @param dispose if the removed element should be disposed (default: false)
  57661. */
  57662. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57663. /**
  57664. * Rebuilds the elements related to this component in case of
  57665. * context lost for instance.
  57666. */
  57667. dispose(): void;
  57668. private _gatherRenderTargets;
  57669. }
  57670. }
  57671. declare module "babylonjs/Lights/Shadows/index" {
  57672. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  57673. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  57674. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  57675. }
  57676. declare module "babylonjs/Lights/pointLight" {
  57677. import { Scene } from "babylonjs/scene";
  57678. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57679. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57680. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  57681. import { Effect } from "babylonjs/Materials/effect";
  57682. /**
  57683. * A point light is a light defined by an unique point in world space.
  57684. * The light is emitted in every direction from this point.
  57685. * A good example of a point light is a standard light bulb.
  57686. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57687. */
  57688. export class PointLight extends ShadowLight {
  57689. private _shadowAngle;
  57690. /**
  57691. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57692. * This specifies what angle the shadow will use to be created.
  57693. *
  57694. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57695. */
  57696. get shadowAngle(): number;
  57697. /**
  57698. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57699. * This specifies what angle the shadow will use to be created.
  57700. *
  57701. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57702. */
  57703. set shadowAngle(value: number);
  57704. /**
  57705. * Gets the direction if it has been set.
  57706. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57707. */
  57708. get direction(): Vector3;
  57709. /**
  57710. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57711. */
  57712. set direction(value: Vector3);
  57713. /**
  57714. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  57715. * A PointLight emits the light in every direction.
  57716. * It can cast shadows.
  57717. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  57718. * ```javascript
  57719. * var pointLight = new PointLight("pl", camera.position, scene);
  57720. * ```
  57721. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57722. * @param name The light friendly name
  57723. * @param position The position of the point light in the scene
  57724. * @param scene The scene the lights belongs to
  57725. */
  57726. constructor(name: string, position: Vector3, scene: Scene);
  57727. /**
  57728. * Returns the string "PointLight"
  57729. * @returns the class name
  57730. */
  57731. getClassName(): string;
  57732. /**
  57733. * Returns the integer 0.
  57734. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57735. */
  57736. getTypeID(): number;
  57737. /**
  57738. * Specifies wether or not the shadowmap should be a cube texture.
  57739. * @returns true if the shadowmap needs to be a cube texture.
  57740. */
  57741. needCube(): boolean;
  57742. /**
  57743. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  57744. * @param faceIndex The index of the face we are computed the direction to generate shadow
  57745. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  57746. */
  57747. getShadowDirection(faceIndex?: number): Vector3;
  57748. /**
  57749. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  57750. * - fov = PI / 2
  57751. * - aspect ratio : 1.0
  57752. * - z-near and far equal to the active camera minZ and maxZ.
  57753. * Returns the PointLight.
  57754. */
  57755. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57756. protected _buildUniformLayout(): void;
  57757. /**
  57758. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  57759. * @param effect The effect to update
  57760. * @param lightIndex The index of the light in the effect to update
  57761. * @returns The point light
  57762. */
  57763. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  57764. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57765. /**
  57766. * Prepares the list of defines specific to the light type.
  57767. * @param defines the list of defines
  57768. * @param lightIndex defines the index of the light for the effect
  57769. */
  57770. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57771. }
  57772. }
  57773. declare module "babylonjs/Lights/index" {
  57774. export * from "babylonjs/Lights/light";
  57775. export * from "babylonjs/Lights/shadowLight";
  57776. export * from "babylonjs/Lights/Shadows/index";
  57777. export * from "babylonjs/Lights/directionalLight";
  57778. export * from "babylonjs/Lights/hemisphericLight";
  57779. export * from "babylonjs/Lights/pointLight";
  57780. export * from "babylonjs/Lights/spotLight";
  57781. }
  57782. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  57783. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57784. /**
  57785. * Header information of HDR texture files.
  57786. */
  57787. export interface HDRInfo {
  57788. /**
  57789. * The height of the texture in pixels.
  57790. */
  57791. height: number;
  57792. /**
  57793. * The width of the texture in pixels.
  57794. */
  57795. width: number;
  57796. /**
  57797. * The index of the beginning of the data in the binary file.
  57798. */
  57799. dataPosition: number;
  57800. }
  57801. /**
  57802. * This groups tools to convert HDR texture to native colors array.
  57803. */
  57804. export class HDRTools {
  57805. private static Ldexp;
  57806. private static Rgbe2float;
  57807. private static readStringLine;
  57808. /**
  57809. * Reads header information from an RGBE texture stored in a native array.
  57810. * More information on this format are available here:
  57811. * https://en.wikipedia.org/wiki/RGBE_image_format
  57812. *
  57813. * @param uint8array The binary file stored in native array.
  57814. * @return The header information.
  57815. */
  57816. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  57817. /**
  57818. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  57819. * This RGBE texture needs to store the information as a panorama.
  57820. *
  57821. * More information on this format are available here:
  57822. * https://en.wikipedia.org/wiki/RGBE_image_format
  57823. *
  57824. * @param buffer The binary file stored in an array buffer.
  57825. * @param size The expected size of the extracted cubemap.
  57826. * @return The Cube Map information.
  57827. */
  57828. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  57829. /**
  57830. * Returns the pixels data extracted from an RGBE texture.
  57831. * This pixels will be stored left to right up to down in the R G B order in one array.
  57832. *
  57833. * More information on this format are available here:
  57834. * https://en.wikipedia.org/wiki/RGBE_image_format
  57835. *
  57836. * @param uint8array The binary file stored in an array buffer.
  57837. * @param hdrInfo The header information of the file.
  57838. * @return The pixels data in RGB right to left up to down order.
  57839. */
  57840. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57841. private static RGBE_ReadPixels_RLE;
  57842. }
  57843. }
  57844. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57845. import { Nullable } from "babylonjs/types";
  57846. import { Scene } from "babylonjs/scene";
  57847. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57848. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57849. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57850. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57851. /**
  57852. * This represents a texture coming from an HDR input.
  57853. *
  57854. * The only supported format is currently panorama picture stored in RGBE format.
  57855. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57856. */
  57857. export class HDRCubeTexture extends BaseTexture {
  57858. private static _facesMapping;
  57859. private _generateHarmonics;
  57860. private _noMipmap;
  57861. private _textureMatrix;
  57862. private _size;
  57863. private _onLoad;
  57864. private _onError;
  57865. /**
  57866. * The texture URL.
  57867. */
  57868. url: string;
  57869. /**
  57870. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57871. */
  57872. coordinatesMode: number;
  57873. protected _isBlocking: boolean;
  57874. /**
  57875. * Sets wether or not the texture is blocking during loading.
  57876. */
  57877. set isBlocking(value: boolean);
  57878. /**
  57879. * Gets wether or not the texture is blocking during loading.
  57880. */
  57881. get isBlocking(): boolean;
  57882. protected _rotationY: number;
  57883. /**
  57884. * Sets texture matrix rotation angle around Y axis in radians.
  57885. */
  57886. set rotationY(value: number);
  57887. /**
  57888. * Gets texture matrix rotation angle around Y axis radians.
  57889. */
  57890. get rotationY(): number;
  57891. /**
  57892. * Gets or sets the center of the bounding box associated with the cube texture
  57893. * It must define where the camera used to render the texture was set
  57894. */
  57895. boundingBoxPosition: Vector3;
  57896. private _boundingBoxSize;
  57897. /**
  57898. * Gets or sets the size of the bounding box associated with the cube texture
  57899. * When defined, the cubemap will switch to local mode
  57900. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57901. * @example https://www.babylonjs-playground.com/#RNASML
  57902. */
  57903. set boundingBoxSize(value: Vector3);
  57904. get boundingBoxSize(): Vector3;
  57905. /**
  57906. * Instantiates an HDRTexture from the following parameters.
  57907. *
  57908. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  57909. * @param scene The scene the texture will be used in
  57910. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57911. * @param noMipmap Forces to not generate the mipmap if true
  57912. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  57913. * @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)
  57914. * @param reserved Reserved flag for internal use.
  57915. */
  57916. 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>);
  57917. /**
  57918. * Get the current class name of the texture useful for serialization or dynamic coding.
  57919. * @returns "HDRCubeTexture"
  57920. */
  57921. getClassName(): string;
  57922. /**
  57923. * Occurs when the file is raw .hdr file.
  57924. */
  57925. private loadTexture;
  57926. clone(): HDRCubeTexture;
  57927. delayLoad(): void;
  57928. /**
  57929. * Get the texture reflection matrix used to rotate/transform the reflection.
  57930. * @returns the reflection matrix
  57931. */
  57932. getReflectionTextureMatrix(): Matrix;
  57933. /**
  57934. * Set the texture reflection matrix used to rotate/transform the reflection.
  57935. * @param value Define the reflection matrix to set
  57936. */
  57937. setReflectionTextureMatrix(value: Matrix): void;
  57938. /**
  57939. * Parses a JSON representation of an HDR Texture in order to create the texture
  57940. * @param parsedTexture Define the JSON representation
  57941. * @param scene Define the scene the texture should be created in
  57942. * @param rootUrl Define the root url in case we need to load relative dependencies
  57943. * @returns the newly created texture after parsing
  57944. */
  57945. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  57946. serialize(): any;
  57947. }
  57948. }
  57949. declare module "babylonjs/Physics/physicsEngine" {
  57950. import { Nullable } from "babylonjs/types";
  57951. import { Vector3 } from "babylonjs/Maths/math.vector";
  57952. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57953. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  57954. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  57955. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57956. /**
  57957. * Class used to control physics engine
  57958. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57959. */
  57960. export class PhysicsEngine implements IPhysicsEngine {
  57961. private _physicsPlugin;
  57962. /**
  57963. * Global value used to control the smallest number supported by the simulation
  57964. */
  57965. static Epsilon: number;
  57966. private _impostors;
  57967. private _joints;
  57968. private _subTimeStep;
  57969. /**
  57970. * Gets the gravity vector used by the simulation
  57971. */
  57972. gravity: Vector3;
  57973. /**
  57974. * Factory used to create the default physics plugin.
  57975. * @returns The default physics plugin
  57976. */
  57977. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  57978. /**
  57979. * Creates a new Physics Engine
  57980. * @param gravity defines the gravity vector used by the simulation
  57981. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  57982. */
  57983. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  57984. /**
  57985. * Sets the gravity vector used by the simulation
  57986. * @param gravity defines the gravity vector to use
  57987. */
  57988. setGravity(gravity: Vector3): void;
  57989. /**
  57990. * Set the time step of the physics engine.
  57991. * Default is 1/60.
  57992. * To slow it down, enter 1/600 for example.
  57993. * To speed it up, 1/30
  57994. * @param newTimeStep defines the new timestep to apply to this world.
  57995. */
  57996. setTimeStep(newTimeStep?: number): void;
  57997. /**
  57998. * Get the time step of the physics engine.
  57999. * @returns the current time step
  58000. */
  58001. getTimeStep(): number;
  58002. /**
  58003. * Set the sub time step of the physics engine.
  58004. * Default is 0 meaning there is no sub steps
  58005. * To increase physics resolution precision, set a small value (like 1 ms)
  58006. * @param subTimeStep defines the new sub timestep used for physics resolution.
  58007. */
  58008. setSubTimeStep(subTimeStep?: number): void;
  58009. /**
  58010. * Get the sub time step of the physics engine.
  58011. * @returns the current sub time step
  58012. */
  58013. getSubTimeStep(): number;
  58014. /**
  58015. * Release all resources
  58016. */
  58017. dispose(): void;
  58018. /**
  58019. * Gets the name of the current physics plugin
  58020. * @returns the name of the plugin
  58021. */
  58022. getPhysicsPluginName(): string;
  58023. /**
  58024. * Adding a new impostor for the impostor tracking.
  58025. * This will be done by the impostor itself.
  58026. * @param impostor the impostor to add
  58027. */
  58028. addImpostor(impostor: PhysicsImpostor): void;
  58029. /**
  58030. * Remove an impostor from the engine.
  58031. * This impostor and its mesh will not longer be updated by the physics engine.
  58032. * @param impostor the impostor to remove
  58033. */
  58034. removeImpostor(impostor: PhysicsImpostor): void;
  58035. /**
  58036. * Add a joint to the physics engine
  58037. * @param mainImpostor defines the main impostor to which the joint is added.
  58038. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  58039. * @param joint defines the joint that will connect both impostors.
  58040. */
  58041. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58042. /**
  58043. * Removes a joint from the simulation
  58044. * @param mainImpostor defines the impostor used with the joint
  58045. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  58046. * @param joint defines the joint to remove
  58047. */
  58048. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58049. /**
  58050. * Called by the scene. No need to call it.
  58051. * @param delta defines the timespam between frames
  58052. */
  58053. _step(delta: number): void;
  58054. /**
  58055. * Gets the current plugin used to run the simulation
  58056. * @returns current plugin
  58057. */
  58058. getPhysicsPlugin(): IPhysicsEnginePlugin;
  58059. /**
  58060. * Gets the list of physic impostors
  58061. * @returns an array of PhysicsImpostor
  58062. */
  58063. getImpostors(): Array<PhysicsImpostor>;
  58064. /**
  58065. * Gets the impostor for a physics enabled object
  58066. * @param object defines the object impersonated by the impostor
  58067. * @returns the PhysicsImpostor or null if not found
  58068. */
  58069. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  58070. /**
  58071. * Gets the impostor for a physics body object
  58072. * @param body defines physics body used by the impostor
  58073. * @returns the PhysicsImpostor or null if not found
  58074. */
  58075. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  58076. /**
  58077. * Does a raycast in the physics world
  58078. * @param from when should the ray start?
  58079. * @param to when should the ray end?
  58080. * @returns PhysicsRaycastResult
  58081. */
  58082. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58083. }
  58084. }
  58085. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  58086. import { Nullable } from "babylonjs/types";
  58087. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  58088. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58089. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  58090. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58091. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  58092. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  58093. /** @hidden */
  58094. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  58095. private _useDeltaForWorldStep;
  58096. world: any;
  58097. name: string;
  58098. private _physicsMaterials;
  58099. private _fixedTimeStep;
  58100. private _cannonRaycastResult;
  58101. private _raycastResult;
  58102. private _physicsBodysToRemoveAfterStep;
  58103. BJSCANNON: any;
  58104. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  58105. setGravity(gravity: Vector3): void;
  58106. setTimeStep(timeStep: number): void;
  58107. getTimeStep(): number;
  58108. executeStep(delta: number): void;
  58109. private _removeMarkedPhysicsBodiesFromWorld;
  58110. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58111. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58112. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58113. private _processChildMeshes;
  58114. removePhysicsBody(impostor: PhysicsImpostor): void;
  58115. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58116. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58117. private _addMaterial;
  58118. private _checkWithEpsilon;
  58119. private _createShape;
  58120. private _createHeightmap;
  58121. private _minus90X;
  58122. private _plus90X;
  58123. private _tmpPosition;
  58124. private _tmpDeltaPosition;
  58125. private _tmpUnityRotation;
  58126. private _updatePhysicsBodyTransformation;
  58127. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58128. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58129. isSupported(): boolean;
  58130. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58131. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58132. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58133. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58134. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58135. getBodyMass(impostor: PhysicsImpostor): number;
  58136. getBodyFriction(impostor: PhysicsImpostor): number;
  58137. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58138. getBodyRestitution(impostor: PhysicsImpostor): number;
  58139. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58140. sleepBody(impostor: PhysicsImpostor): void;
  58141. wakeUpBody(impostor: PhysicsImpostor): void;
  58142. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  58143. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58144. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58145. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58146. getRadius(impostor: PhysicsImpostor): number;
  58147. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58148. dispose(): void;
  58149. private _extendNamespace;
  58150. /**
  58151. * Does a raycast in the physics world
  58152. * @param from when should the ray start?
  58153. * @param to when should the ray end?
  58154. * @returns PhysicsRaycastResult
  58155. */
  58156. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58157. }
  58158. }
  58159. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  58160. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  58161. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58162. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  58163. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58164. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  58165. import { Nullable } from "babylonjs/types";
  58166. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  58167. /** @hidden */
  58168. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  58169. private _useDeltaForWorldStep;
  58170. world: any;
  58171. name: string;
  58172. BJSOIMO: any;
  58173. private _raycastResult;
  58174. private _fixedTimeStep;
  58175. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  58176. setGravity(gravity: Vector3): void;
  58177. setTimeStep(timeStep: number): void;
  58178. getTimeStep(): number;
  58179. private _tmpImpostorsArray;
  58180. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58181. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58182. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58183. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58184. private _tmpPositionVector;
  58185. removePhysicsBody(impostor: PhysicsImpostor): void;
  58186. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58187. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58188. isSupported(): boolean;
  58189. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58190. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58191. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58192. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58193. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58194. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58195. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58196. getBodyMass(impostor: PhysicsImpostor): number;
  58197. getBodyFriction(impostor: PhysicsImpostor): number;
  58198. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58199. getBodyRestitution(impostor: PhysicsImpostor): number;
  58200. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58201. sleepBody(impostor: PhysicsImpostor): void;
  58202. wakeUpBody(impostor: PhysicsImpostor): void;
  58203. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58204. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  58205. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  58206. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58207. getRadius(impostor: PhysicsImpostor): number;
  58208. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58209. dispose(): void;
  58210. /**
  58211. * Does a raycast in the physics world
  58212. * @param from when should the ray start?
  58213. * @param to when should the ray end?
  58214. * @returns PhysicsRaycastResult
  58215. */
  58216. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58217. }
  58218. }
  58219. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  58220. import { Nullable } from "babylonjs/types";
  58221. import { Scene } from "babylonjs/scene";
  58222. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  58223. import { Color4 } from "babylonjs/Maths/math.color";
  58224. import { Mesh } from "babylonjs/Meshes/mesh";
  58225. /**
  58226. * Class containing static functions to help procedurally build meshes
  58227. */
  58228. export class RibbonBuilder {
  58229. /**
  58230. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58231. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58232. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58233. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58234. * * 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
  58235. * * 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
  58236. * * 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
  58237. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58238. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58239. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58240. * * 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
  58241. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58242. * * 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
  58243. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58245. * @param name defines the name of the mesh
  58246. * @param options defines the options used to create the mesh
  58247. * @param scene defines the hosting scene
  58248. * @returns the ribbon mesh
  58249. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58250. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58251. */
  58252. static CreateRibbon(name: string, options: {
  58253. pathArray: Vector3[][];
  58254. closeArray?: boolean;
  58255. closePath?: boolean;
  58256. offset?: number;
  58257. updatable?: boolean;
  58258. sideOrientation?: number;
  58259. frontUVs?: Vector4;
  58260. backUVs?: Vector4;
  58261. instance?: Mesh;
  58262. invertUV?: boolean;
  58263. uvs?: Vector2[];
  58264. colors?: Color4[];
  58265. }, scene?: Nullable<Scene>): Mesh;
  58266. }
  58267. }
  58268. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  58269. import { Nullable } from "babylonjs/types";
  58270. import { Scene } from "babylonjs/scene";
  58271. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58272. import { Mesh } from "babylonjs/Meshes/mesh";
  58273. /**
  58274. * Class containing static functions to help procedurally build meshes
  58275. */
  58276. export class ShapeBuilder {
  58277. /**
  58278. * 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.
  58279. * * 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.
  58280. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58281. * * 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.
  58282. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58283. * * 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
  58284. * * 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
  58285. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58286. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58287. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58288. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58290. * @param name defines the name of the mesh
  58291. * @param options defines the options used to create the mesh
  58292. * @param scene defines the hosting scene
  58293. * @returns the extruded shape mesh
  58294. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58295. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58296. */
  58297. static ExtrudeShape(name: string, options: {
  58298. shape: Vector3[];
  58299. path: Vector3[];
  58300. scale?: number;
  58301. rotation?: number;
  58302. cap?: number;
  58303. updatable?: boolean;
  58304. sideOrientation?: number;
  58305. frontUVs?: Vector4;
  58306. backUVs?: Vector4;
  58307. instance?: Mesh;
  58308. invertUV?: boolean;
  58309. }, scene?: Nullable<Scene>): Mesh;
  58310. /**
  58311. * Creates an custom extruded shape mesh.
  58312. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58313. * * 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.
  58314. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58315. * * 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
  58316. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58317. * * 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
  58318. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58319. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58320. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58321. * * 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
  58322. * * 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
  58323. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58324. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58325. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58326. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58327. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58328. * @param name defines the name of the mesh
  58329. * @param options defines the options used to create the mesh
  58330. * @param scene defines the hosting scene
  58331. * @returns the custom extruded shape mesh
  58332. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58333. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58334. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58335. */
  58336. static ExtrudeShapeCustom(name: string, options: {
  58337. shape: Vector3[];
  58338. path: Vector3[];
  58339. scaleFunction?: any;
  58340. rotationFunction?: any;
  58341. ribbonCloseArray?: boolean;
  58342. ribbonClosePath?: boolean;
  58343. cap?: number;
  58344. updatable?: boolean;
  58345. sideOrientation?: number;
  58346. frontUVs?: Vector4;
  58347. backUVs?: Vector4;
  58348. instance?: Mesh;
  58349. invertUV?: boolean;
  58350. }, scene?: Nullable<Scene>): Mesh;
  58351. private static _ExtrudeShapeGeneric;
  58352. }
  58353. }
  58354. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  58355. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  58356. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  58357. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58358. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  58359. import { Nullable } from "babylonjs/types";
  58360. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58361. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  58362. /**
  58363. * AmmoJS Physics plugin
  58364. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  58365. * @see https://github.com/kripken/ammo.js/
  58366. */
  58367. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  58368. private _useDeltaForWorldStep;
  58369. /**
  58370. * Reference to the Ammo library
  58371. */
  58372. bjsAMMO: any;
  58373. /**
  58374. * Created ammoJS world which physics bodies are added to
  58375. */
  58376. world: any;
  58377. /**
  58378. * Name of the plugin
  58379. */
  58380. name: string;
  58381. private _timeStep;
  58382. private _fixedTimeStep;
  58383. private _maxSteps;
  58384. private _tmpQuaternion;
  58385. private _tmpAmmoTransform;
  58386. private _tmpAmmoQuaternion;
  58387. private _tmpAmmoConcreteContactResultCallback;
  58388. private _collisionConfiguration;
  58389. private _dispatcher;
  58390. private _overlappingPairCache;
  58391. private _solver;
  58392. private _softBodySolver;
  58393. private _tmpAmmoVectorA;
  58394. private _tmpAmmoVectorB;
  58395. private _tmpAmmoVectorC;
  58396. private _tmpAmmoVectorD;
  58397. private _tmpContactCallbackResult;
  58398. private _tmpAmmoVectorRCA;
  58399. private _tmpAmmoVectorRCB;
  58400. private _raycastResult;
  58401. private static readonly DISABLE_COLLISION_FLAG;
  58402. private static readonly KINEMATIC_FLAG;
  58403. private static readonly DISABLE_DEACTIVATION_FLAG;
  58404. /**
  58405. * Initializes the ammoJS plugin
  58406. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  58407. * @param ammoInjection can be used to inject your own ammo reference
  58408. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  58409. */
  58410. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  58411. /**
  58412. * Sets the gravity of the physics world (m/(s^2))
  58413. * @param gravity Gravity to set
  58414. */
  58415. setGravity(gravity: Vector3): void;
  58416. /**
  58417. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  58418. * @param timeStep timestep to use in seconds
  58419. */
  58420. setTimeStep(timeStep: number): void;
  58421. /**
  58422. * 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)
  58423. * @param fixedTimeStep fixedTimeStep to use in seconds
  58424. */
  58425. setFixedTimeStep(fixedTimeStep: number): void;
  58426. /**
  58427. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  58428. * @param maxSteps the maximum number of steps by the physics engine per frame
  58429. */
  58430. setMaxSteps(maxSteps: number): void;
  58431. /**
  58432. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  58433. * @returns the current timestep in seconds
  58434. */
  58435. getTimeStep(): number;
  58436. /**
  58437. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  58438. */
  58439. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  58440. private _isImpostorInContact;
  58441. private _isImpostorPairInContact;
  58442. private _stepSimulation;
  58443. /**
  58444. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  58445. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  58446. * After the step the babylon meshes are set to the position of the physics imposters
  58447. * @param delta amount of time to step forward
  58448. * @param impostors array of imposters to update before/after the step
  58449. */
  58450. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58451. /**
  58452. * Update babylon mesh to match physics world object
  58453. * @param impostor imposter to match
  58454. */
  58455. private _afterSoftStep;
  58456. /**
  58457. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  58458. * @param impostor imposter to match
  58459. */
  58460. private _ropeStep;
  58461. /**
  58462. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  58463. * @param impostor imposter to match
  58464. */
  58465. private _softbodyOrClothStep;
  58466. private _tmpMatrix;
  58467. /**
  58468. * Applies an impulse on the imposter
  58469. * @param impostor imposter to apply impulse to
  58470. * @param force amount of force to be applied to the imposter
  58471. * @param contactPoint the location to apply the impulse on the imposter
  58472. */
  58473. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58474. /**
  58475. * Applies a force on the imposter
  58476. * @param impostor imposter to apply force
  58477. * @param force amount of force to be applied to the imposter
  58478. * @param contactPoint the location to apply the force on the imposter
  58479. */
  58480. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58481. /**
  58482. * Creates a physics body using the plugin
  58483. * @param impostor the imposter to create the physics body on
  58484. */
  58485. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58486. /**
  58487. * Removes the physics body from the imposter and disposes of the body's memory
  58488. * @param impostor imposter to remove the physics body from
  58489. */
  58490. removePhysicsBody(impostor: PhysicsImpostor): void;
  58491. /**
  58492. * Generates a joint
  58493. * @param impostorJoint the imposter joint to create the joint with
  58494. */
  58495. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58496. /**
  58497. * Removes a joint
  58498. * @param impostorJoint the imposter joint to remove the joint from
  58499. */
  58500. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58501. private _addMeshVerts;
  58502. /**
  58503. * Initialise the soft body vertices to match its object's (mesh) vertices
  58504. * Softbody vertices (nodes) are in world space and to match this
  58505. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  58506. * @param impostor to create the softbody for
  58507. */
  58508. private _softVertexData;
  58509. /**
  58510. * Create an impostor's soft body
  58511. * @param impostor to create the softbody for
  58512. */
  58513. private _createSoftbody;
  58514. /**
  58515. * Create cloth for an impostor
  58516. * @param impostor to create the softbody for
  58517. */
  58518. private _createCloth;
  58519. /**
  58520. * Create rope for an impostor
  58521. * @param impostor to create the softbody for
  58522. */
  58523. private _createRope;
  58524. /**
  58525. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  58526. * @param impostor to create the custom physics shape for
  58527. */
  58528. private _createCustom;
  58529. private _addHullVerts;
  58530. private _createShape;
  58531. /**
  58532. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  58533. * @param impostor imposter containing the physics body and babylon object
  58534. */
  58535. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58536. /**
  58537. * Sets the babylon object's position/rotation from the physics body's position/rotation
  58538. * @param impostor imposter containing the physics body and babylon object
  58539. * @param newPosition new position
  58540. * @param newRotation new rotation
  58541. */
  58542. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58543. /**
  58544. * If this plugin is supported
  58545. * @returns true if its supported
  58546. */
  58547. isSupported(): boolean;
  58548. /**
  58549. * Sets the linear velocity of the physics body
  58550. * @param impostor imposter to set the velocity on
  58551. * @param velocity velocity to set
  58552. */
  58553. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58554. /**
  58555. * Sets the angular velocity of the physics body
  58556. * @param impostor imposter to set the velocity on
  58557. * @param velocity velocity to set
  58558. */
  58559. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58560. /**
  58561. * gets the linear velocity
  58562. * @param impostor imposter to get linear velocity from
  58563. * @returns linear velocity
  58564. */
  58565. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58566. /**
  58567. * gets the angular velocity
  58568. * @param impostor imposter to get angular velocity from
  58569. * @returns angular velocity
  58570. */
  58571. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58572. /**
  58573. * Sets the mass of physics body
  58574. * @param impostor imposter to set the mass on
  58575. * @param mass mass to set
  58576. */
  58577. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58578. /**
  58579. * Gets the mass of the physics body
  58580. * @param impostor imposter to get the mass from
  58581. * @returns mass
  58582. */
  58583. getBodyMass(impostor: PhysicsImpostor): number;
  58584. /**
  58585. * Gets friction of the impostor
  58586. * @param impostor impostor to get friction from
  58587. * @returns friction value
  58588. */
  58589. getBodyFriction(impostor: PhysicsImpostor): number;
  58590. /**
  58591. * Sets friction of the impostor
  58592. * @param impostor impostor to set friction on
  58593. * @param friction friction value
  58594. */
  58595. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58596. /**
  58597. * Gets restitution of the impostor
  58598. * @param impostor impostor to get restitution from
  58599. * @returns restitution value
  58600. */
  58601. getBodyRestitution(impostor: PhysicsImpostor): number;
  58602. /**
  58603. * Sets resitution of the impostor
  58604. * @param impostor impostor to set resitution on
  58605. * @param restitution resitution value
  58606. */
  58607. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58608. /**
  58609. * Gets pressure inside the impostor
  58610. * @param impostor impostor to get pressure from
  58611. * @returns pressure value
  58612. */
  58613. getBodyPressure(impostor: PhysicsImpostor): number;
  58614. /**
  58615. * Sets pressure inside a soft body impostor
  58616. * Cloth and rope must remain 0 pressure
  58617. * @param impostor impostor to set pressure on
  58618. * @param pressure pressure value
  58619. */
  58620. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  58621. /**
  58622. * Gets stiffness of the impostor
  58623. * @param impostor impostor to get stiffness from
  58624. * @returns pressure value
  58625. */
  58626. getBodyStiffness(impostor: PhysicsImpostor): number;
  58627. /**
  58628. * Sets stiffness of the impostor
  58629. * @param impostor impostor to set stiffness on
  58630. * @param stiffness stiffness value from 0 to 1
  58631. */
  58632. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  58633. /**
  58634. * Gets velocityIterations of the impostor
  58635. * @param impostor impostor to get velocity iterations from
  58636. * @returns velocityIterations value
  58637. */
  58638. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  58639. /**
  58640. * Sets velocityIterations of the impostor
  58641. * @param impostor impostor to set velocity iterations on
  58642. * @param velocityIterations velocityIterations value
  58643. */
  58644. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  58645. /**
  58646. * Gets positionIterations of the impostor
  58647. * @param impostor impostor to get position iterations from
  58648. * @returns positionIterations value
  58649. */
  58650. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  58651. /**
  58652. * Sets positionIterations of the impostor
  58653. * @param impostor impostor to set position on
  58654. * @param positionIterations positionIterations value
  58655. */
  58656. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  58657. /**
  58658. * Append an anchor to a cloth object
  58659. * @param impostor is the cloth impostor to add anchor to
  58660. * @param otherImpostor is the rigid impostor to anchor to
  58661. * @param width ratio across width from 0 to 1
  58662. * @param height ratio up height from 0 to 1
  58663. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  58664. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58665. */
  58666. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58667. /**
  58668. * Append an hook to a rope object
  58669. * @param impostor is the rope impostor to add hook to
  58670. * @param otherImpostor is the rigid impostor to hook to
  58671. * @param length ratio along the rope from 0 to 1
  58672. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  58673. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58674. */
  58675. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58676. /**
  58677. * Sleeps the physics body and stops it from being active
  58678. * @param impostor impostor to sleep
  58679. */
  58680. sleepBody(impostor: PhysicsImpostor): void;
  58681. /**
  58682. * Activates the physics body
  58683. * @param impostor impostor to activate
  58684. */
  58685. wakeUpBody(impostor: PhysicsImpostor): void;
  58686. /**
  58687. * Updates the distance parameters of the joint
  58688. * @param joint joint to update
  58689. * @param maxDistance maximum distance of the joint
  58690. * @param minDistance minimum distance of the joint
  58691. */
  58692. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58693. /**
  58694. * Sets a motor on the joint
  58695. * @param joint joint to set motor on
  58696. * @param speed speed of the motor
  58697. * @param maxForce maximum force of the motor
  58698. * @param motorIndex index of the motor
  58699. */
  58700. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58701. /**
  58702. * Sets the motors limit
  58703. * @param joint joint to set limit on
  58704. * @param upperLimit upper limit
  58705. * @param lowerLimit lower limit
  58706. */
  58707. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58708. /**
  58709. * Syncs the position and rotation of a mesh with the impostor
  58710. * @param mesh mesh to sync
  58711. * @param impostor impostor to update the mesh with
  58712. */
  58713. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58714. /**
  58715. * Gets the radius of the impostor
  58716. * @param impostor impostor to get radius from
  58717. * @returns the radius
  58718. */
  58719. getRadius(impostor: PhysicsImpostor): number;
  58720. /**
  58721. * Gets the box size of the impostor
  58722. * @param impostor impostor to get box size from
  58723. * @param result the resulting box size
  58724. */
  58725. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58726. /**
  58727. * Disposes of the impostor
  58728. */
  58729. dispose(): void;
  58730. /**
  58731. * Does a raycast in the physics world
  58732. * @param from when should the ray start?
  58733. * @param to when should the ray end?
  58734. * @returns PhysicsRaycastResult
  58735. */
  58736. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58737. }
  58738. }
  58739. declare module "babylonjs/Probes/reflectionProbe" {
  58740. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58741. import { Vector3 } from "babylonjs/Maths/math.vector";
  58742. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58743. import { Nullable } from "babylonjs/types";
  58744. import { Scene } from "babylonjs/scene";
  58745. module "babylonjs/abstractScene" {
  58746. interface AbstractScene {
  58747. /**
  58748. * The list of reflection probes added to the scene
  58749. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58750. */
  58751. reflectionProbes: Array<ReflectionProbe>;
  58752. /**
  58753. * Removes the given reflection probe from this scene.
  58754. * @param toRemove The reflection probe to remove
  58755. * @returns The index of the removed reflection probe
  58756. */
  58757. removeReflectionProbe(toRemove: ReflectionProbe): number;
  58758. /**
  58759. * Adds the given reflection probe to this scene.
  58760. * @param newReflectionProbe The reflection probe to add
  58761. */
  58762. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  58763. }
  58764. }
  58765. /**
  58766. * Class used to generate realtime reflection / refraction cube textures
  58767. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58768. */
  58769. export class ReflectionProbe {
  58770. /** defines the name of the probe */
  58771. name: string;
  58772. private _scene;
  58773. private _renderTargetTexture;
  58774. private _projectionMatrix;
  58775. private _viewMatrix;
  58776. private _target;
  58777. private _add;
  58778. private _attachedMesh;
  58779. private _invertYAxis;
  58780. /** Gets or sets probe position (center of the cube map) */
  58781. position: Vector3;
  58782. /**
  58783. * Creates a new reflection probe
  58784. * @param name defines the name of the probe
  58785. * @param size defines the texture resolution (for each face)
  58786. * @param scene defines the hosting scene
  58787. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  58788. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  58789. */
  58790. constructor(
  58791. /** defines the name of the probe */
  58792. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  58793. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  58794. get samples(): number;
  58795. set samples(value: number);
  58796. /** Gets or sets the refresh rate to use (on every frame by default) */
  58797. get refreshRate(): number;
  58798. set refreshRate(value: number);
  58799. /**
  58800. * Gets the hosting scene
  58801. * @returns a Scene
  58802. */
  58803. getScene(): Scene;
  58804. /** Gets the internal CubeTexture used to render to */
  58805. get cubeTexture(): RenderTargetTexture;
  58806. /** Gets the list of meshes to render */
  58807. get renderList(): Nullable<AbstractMesh[]>;
  58808. /**
  58809. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  58810. * @param mesh defines the mesh to attach to
  58811. */
  58812. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58813. /**
  58814. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  58815. * @param renderingGroupId The rendering group id corresponding to its index
  58816. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58817. */
  58818. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  58819. /**
  58820. * Clean all associated resources
  58821. */
  58822. dispose(): void;
  58823. /**
  58824. * Converts the reflection probe information to a readable string for debug purpose.
  58825. * @param fullDetails Supports for multiple levels of logging within scene loading
  58826. * @returns the human readable reflection probe info
  58827. */
  58828. toString(fullDetails?: boolean): string;
  58829. /**
  58830. * Get the class name of the relfection probe.
  58831. * @returns "ReflectionProbe"
  58832. */
  58833. getClassName(): string;
  58834. /**
  58835. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  58836. * @returns The JSON representation of the texture
  58837. */
  58838. serialize(): any;
  58839. /**
  58840. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  58841. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  58842. * @param scene Define the scene the parsed reflection probe should be instantiated in
  58843. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58844. * @returns The parsed reflection probe if successful
  58845. */
  58846. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  58847. }
  58848. }
  58849. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  58850. /** @hidden */
  58851. export var _BabylonLoaderRegistered: boolean;
  58852. /**
  58853. * Helps setting up some configuration for the babylon file loader.
  58854. */
  58855. export class BabylonFileLoaderConfiguration {
  58856. /**
  58857. * The loader does not allow injecting custom physix engine into the plugins.
  58858. * Unfortunately in ES6, we need to manually inject them into the plugin.
  58859. * So you could set this variable to your engine import to make it work.
  58860. */
  58861. static LoaderInjectedPhysicsEngine: any;
  58862. }
  58863. }
  58864. declare module "babylonjs/Loading/Plugins/index" {
  58865. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  58866. }
  58867. declare module "babylonjs/Loading/index" {
  58868. export * from "babylonjs/Loading/loadingScreen";
  58869. export * from "babylonjs/Loading/Plugins/index";
  58870. export * from "babylonjs/Loading/sceneLoader";
  58871. export * from "babylonjs/Loading/sceneLoaderFlags";
  58872. }
  58873. declare module "babylonjs/Materials/Background/index" {
  58874. export * from "babylonjs/Materials/Background/backgroundMaterial";
  58875. }
  58876. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  58877. import { Scene } from "babylonjs/scene";
  58878. import { Color3 } from "babylonjs/Maths/math.color";
  58879. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58880. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58881. /**
  58882. * The Physically based simple base material of BJS.
  58883. *
  58884. * This enables better naming and convention enforcements on top of the pbrMaterial.
  58885. * It is used as the base class for both the specGloss and metalRough conventions.
  58886. */
  58887. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  58888. /**
  58889. * Number of Simultaneous lights allowed on the material.
  58890. */
  58891. maxSimultaneousLights: number;
  58892. /**
  58893. * If sets to true, disables all the lights affecting the material.
  58894. */
  58895. disableLighting: boolean;
  58896. /**
  58897. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  58898. */
  58899. environmentTexture: BaseTexture;
  58900. /**
  58901. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58902. */
  58903. invertNormalMapX: boolean;
  58904. /**
  58905. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58906. */
  58907. invertNormalMapY: boolean;
  58908. /**
  58909. * Normal map used in the model.
  58910. */
  58911. normalTexture: BaseTexture;
  58912. /**
  58913. * Emissivie color used to self-illuminate the model.
  58914. */
  58915. emissiveColor: Color3;
  58916. /**
  58917. * Emissivie texture used to self-illuminate the model.
  58918. */
  58919. emissiveTexture: BaseTexture;
  58920. /**
  58921. * Occlusion Channel Strenght.
  58922. */
  58923. occlusionStrength: number;
  58924. /**
  58925. * Occlusion Texture of the material (adding extra occlusion effects).
  58926. */
  58927. occlusionTexture: BaseTexture;
  58928. /**
  58929. * Defines the alpha limits in alpha test mode.
  58930. */
  58931. alphaCutOff: number;
  58932. /**
  58933. * Gets the current double sided mode.
  58934. */
  58935. get doubleSided(): boolean;
  58936. /**
  58937. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58938. */
  58939. set doubleSided(value: boolean);
  58940. /**
  58941. * Stores the pre-calculated light information of a mesh in a texture.
  58942. */
  58943. lightmapTexture: BaseTexture;
  58944. /**
  58945. * If true, the light map contains occlusion information instead of lighting info.
  58946. */
  58947. useLightmapAsShadowmap: boolean;
  58948. /**
  58949. * Instantiates a new PBRMaterial instance.
  58950. *
  58951. * @param name The material name
  58952. * @param scene The scene the material will be use in.
  58953. */
  58954. constructor(name: string, scene: Scene);
  58955. getClassName(): string;
  58956. }
  58957. }
  58958. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  58959. import { Scene } from "babylonjs/scene";
  58960. import { Color3 } from "babylonjs/Maths/math.color";
  58961. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58962. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58963. /**
  58964. * The PBR material of BJS following the metal roughness convention.
  58965. *
  58966. * This fits to the PBR convention in the GLTF definition:
  58967. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  58968. */
  58969. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  58970. /**
  58971. * The base color has two different interpretations depending on the value of metalness.
  58972. * When the material is a metal, the base color is the specific measured reflectance value
  58973. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  58974. * of the material.
  58975. */
  58976. baseColor: Color3;
  58977. /**
  58978. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  58979. * well as opacity information in the alpha channel.
  58980. */
  58981. baseTexture: BaseTexture;
  58982. /**
  58983. * Specifies the metallic scalar value of the material.
  58984. * Can also be used to scale the metalness values of the metallic texture.
  58985. */
  58986. metallic: number;
  58987. /**
  58988. * Specifies the roughness scalar value of the material.
  58989. * Can also be used to scale the roughness values of the metallic texture.
  58990. */
  58991. roughness: number;
  58992. /**
  58993. * Texture containing both the metallic value in the B channel and the
  58994. * roughness value in the G channel to keep better precision.
  58995. */
  58996. metallicRoughnessTexture: BaseTexture;
  58997. /**
  58998. * Instantiates a new PBRMetalRoughnessMaterial instance.
  58999. *
  59000. * @param name The material name
  59001. * @param scene The scene the material will be use in.
  59002. */
  59003. constructor(name: string, scene: Scene);
  59004. /**
  59005. * Return the currrent class name of the material.
  59006. */
  59007. getClassName(): string;
  59008. /**
  59009. * Makes a duplicate of the current material.
  59010. * @param name - name to use for the new material.
  59011. */
  59012. clone(name: string): PBRMetallicRoughnessMaterial;
  59013. /**
  59014. * Serialize the material to a parsable JSON object.
  59015. */
  59016. serialize(): any;
  59017. /**
  59018. * Parses a JSON object correponding to the serialize function.
  59019. */
  59020. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  59021. }
  59022. }
  59023. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  59024. import { Scene } from "babylonjs/scene";
  59025. import { Color3 } from "babylonjs/Maths/math.color";
  59026. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59027. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  59028. /**
  59029. * The PBR material of BJS following the specular glossiness convention.
  59030. *
  59031. * This fits to the PBR convention in the GLTF definition:
  59032. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  59033. */
  59034. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  59035. /**
  59036. * Specifies the diffuse color of the material.
  59037. */
  59038. diffuseColor: Color3;
  59039. /**
  59040. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  59041. * channel.
  59042. */
  59043. diffuseTexture: BaseTexture;
  59044. /**
  59045. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  59046. */
  59047. specularColor: Color3;
  59048. /**
  59049. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  59050. */
  59051. glossiness: number;
  59052. /**
  59053. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  59054. */
  59055. specularGlossinessTexture: BaseTexture;
  59056. /**
  59057. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  59058. *
  59059. * @param name The material name
  59060. * @param scene The scene the material will be use in.
  59061. */
  59062. constructor(name: string, scene: Scene);
  59063. /**
  59064. * Return the currrent class name of the material.
  59065. */
  59066. getClassName(): string;
  59067. /**
  59068. * Makes a duplicate of the current material.
  59069. * @param name - name to use for the new material.
  59070. */
  59071. clone(name: string): PBRSpecularGlossinessMaterial;
  59072. /**
  59073. * Serialize the material to a parsable JSON object.
  59074. */
  59075. serialize(): any;
  59076. /**
  59077. * Parses a JSON object correponding to the serialize function.
  59078. */
  59079. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  59080. }
  59081. }
  59082. declare module "babylonjs/Materials/PBR/index" {
  59083. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59084. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  59085. export * from "babylonjs/Materials/PBR/pbrMaterial";
  59086. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  59087. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  59088. }
  59089. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  59090. import { Nullable } from "babylonjs/types";
  59091. import { Scene } from "babylonjs/scene";
  59092. import { Matrix } from "babylonjs/Maths/math.vector";
  59093. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59094. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59095. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59096. /**
  59097. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  59098. * It can help converting any input color in a desired output one. This can then be used to create effects
  59099. * from sepia, black and white to sixties or futuristic rendering...
  59100. *
  59101. * The only supported format is currently 3dl.
  59102. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  59103. */
  59104. export class ColorGradingTexture extends BaseTexture {
  59105. /**
  59106. * The texture URL.
  59107. */
  59108. url: string;
  59109. /**
  59110. * Empty line regex stored for GC.
  59111. */
  59112. private static _noneEmptyLineRegex;
  59113. private _textureMatrix;
  59114. private _engine;
  59115. private _onLoad;
  59116. /**
  59117. * Instantiates a ColorGradingTexture from the following parameters.
  59118. *
  59119. * @param url The location of the color gradind data (currently only supporting 3dl)
  59120. * @param sceneOrEngine The scene or engine the texture will be used in
  59121. * @param onLoad defines a callback triggered when the texture has been loaded
  59122. */
  59123. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  59124. /**
  59125. * Fires the onload event from the constructor if requested.
  59126. */
  59127. private _triggerOnLoad;
  59128. /**
  59129. * Returns the texture matrix used in most of the material.
  59130. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  59131. */
  59132. getTextureMatrix(): Matrix;
  59133. /**
  59134. * Occurs when the file being loaded is a .3dl LUT file.
  59135. */
  59136. private load3dlTexture;
  59137. /**
  59138. * Starts the loading process of the texture.
  59139. */
  59140. private loadTexture;
  59141. /**
  59142. * Clones the color gradind texture.
  59143. */
  59144. clone(): ColorGradingTexture;
  59145. /**
  59146. * Called during delayed load for textures.
  59147. */
  59148. delayLoad(): void;
  59149. /**
  59150. * Parses a color grading texture serialized by Babylon.
  59151. * @param parsedTexture The texture information being parsedTexture
  59152. * @param scene The scene to load the texture in
  59153. * @param rootUrl The root url of the data assets to load
  59154. * @return A color gradind texture
  59155. */
  59156. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  59157. /**
  59158. * Serializes the LUT texture to json format.
  59159. */
  59160. serialize(): any;
  59161. /**
  59162. * Returns true if the passed parameter is a scene object (can be use for typings)
  59163. * @param sceneOrEngine The object to test.
  59164. */
  59165. private static _isScene;
  59166. }
  59167. }
  59168. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  59169. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59170. import { Scene } from "babylonjs/scene";
  59171. import { Nullable } from "babylonjs/types";
  59172. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59173. /**
  59174. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  59175. */
  59176. export class EquiRectangularCubeTexture extends BaseTexture {
  59177. /** The six faces of the cube. */
  59178. private static _FacesMapping;
  59179. private _noMipmap;
  59180. private _onLoad;
  59181. private _onError;
  59182. /** The size of the cubemap. */
  59183. private _size;
  59184. /** The buffer of the image. */
  59185. private _buffer;
  59186. /** The width of the input image. */
  59187. private _width;
  59188. /** The height of the input image. */
  59189. private _height;
  59190. /** The URL to the image. */
  59191. url: string;
  59192. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  59193. coordinatesMode: number;
  59194. /**
  59195. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  59196. * @param url The location of the image
  59197. * @param scene The scene the texture will be used in
  59198. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59199. * @param noMipmap Forces to not generate the mipmap if true
  59200. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  59201. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  59202. * @param onLoad — defines a callback called when texture is loaded
  59203. * @param onError — defines a callback called if there is an error
  59204. */
  59205. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  59206. /**
  59207. * Load the image data, by putting the image on a canvas and extracting its buffer.
  59208. */
  59209. private loadImage;
  59210. /**
  59211. * Convert the image buffer into a cubemap and create a CubeTexture.
  59212. */
  59213. private loadTexture;
  59214. /**
  59215. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  59216. * @param buffer The ArrayBuffer that should be converted.
  59217. * @returns The buffer as Float32Array.
  59218. */
  59219. private getFloat32ArrayFromArrayBuffer;
  59220. /**
  59221. * Get the current class name of the texture useful for serialization or dynamic coding.
  59222. * @returns "EquiRectangularCubeTexture"
  59223. */
  59224. getClassName(): string;
  59225. /**
  59226. * Create a clone of the current EquiRectangularCubeTexture and return it.
  59227. * @returns A clone of the current EquiRectangularCubeTexture.
  59228. */
  59229. clone(): EquiRectangularCubeTexture;
  59230. }
  59231. }
  59232. declare module "babylonjs/Misc/tga" {
  59233. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59234. /**
  59235. * Based on jsTGALoader - Javascript loader for TGA file
  59236. * By Vincent Thibault
  59237. * @see http://blog.robrowser.com/javascript-tga-loader.html
  59238. */
  59239. export class TGATools {
  59240. private static _TYPE_INDEXED;
  59241. private static _TYPE_RGB;
  59242. private static _TYPE_GREY;
  59243. private static _TYPE_RLE_INDEXED;
  59244. private static _TYPE_RLE_RGB;
  59245. private static _TYPE_RLE_GREY;
  59246. private static _ORIGIN_MASK;
  59247. private static _ORIGIN_SHIFT;
  59248. private static _ORIGIN_BL;
  59249. private static _ORIGIN_BR;
  59250. private static _ORIGIN_UL;
  59251. private static _ORIGIN_UR;
  59252. /**
  59253. * Gets the header of a TGA file
  59254. * @param data defines the TGA data
  59255. * @returns the header
  59256. */
  59257. static GetTGAHeader(data: Uint8Array): any;
  59258. /**
  59259. * Uploads TGA content to a Babylon Texture
  59260. * @hidden
  59261. */
  59262. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  59263. /** @hidden */
  59264. 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;
  59265. /** @hidden */
  59266. 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;
  59267. /** @hidden */
  59268. 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;
  59269. /** @hidden */
  59270. 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;
  59271. /** @hidden */
  59272. 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;
  59273. /** @hidden */
  59274. 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;
  59275. }
  59276. }
  59277. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  59278. import { Nullable } from "babylonjs/types";
  59279. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59280. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59281. /**
  59282. * Implementation of the TGA Texture Loader.
  59283. * @hidden
  59284. */
  59285. export class _TGATextureLoader implements IInternalTextureLoader {
  59286. /**
  59287. * Defines wether the loader supports cascade loading the different faces.
  59288. */
  59289. readonly supportCascades: boolean;
  59290. /**
  59291. * This returns if the loader support the current file information.
  59292. * @param extension defines the file extension of the file being loaded
  59293. * @returns true if the loader can load the specified file
  59294. */
  59295. canLoad(extension: string): boolean;
  59296. /**
  59297. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59298. * @param data contains the texture data
  59299. * @param texture defines the BabylonJS internal texture
  59300. * @param createPolynomials will be true if polynomials have been requested
  59301. * @param onLoad defines the callback to trigger once the texture is ready
  59302. * @param onError defines the callback to trigger in case of error
  59303. */
  59304. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59305. /**
  59306. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59307. * @param data contains the texture data
  59308. * @param texture defines the BabylonJS internal texture
  59309. * @param callback defines the method to call once ready to upload
  59310. */
  59311. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59312. }
  59313. }
  59314. declare module "babylonjs/Misc/basis" {
  59315. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59316. /**
  59317. * Info about the .basis files
  59318. */
  59319. class BasisFileInfo {
  59320. /**
  59321. * If the file has alpha
  59322. */
  59323. hasAlpha: boolean;
  59324. /**
  59325. * Info about each image of the basis file
  59326. */
  59327. images: Array<{
  59328. levels: Array<{
  59329. width: number;
  59330. height: number;
  59331. transcodedPixels: ArrayBufferView;
  59332. }>;
  59333. }>;
  59334. }
  59335. /**
  59336. * Result of transcoding a basis file
  59337. */
  59338. class TranscodeResult {
  59339. /**
  59340. * Info about the .basis file
  59341. */
  59342. fileInfo: BasisFileInfo;
  59343. /**
  59344. * Format to use when loading the file
  59345. */
  59346. format: number;
  59347. }
  59348. /**
  59349. * Configuration options for the Basis transcoder
  59350. */
  59351. export class BasisTranscodeConfiguration {
  59352. /**
  59353. * Supported compression formats used to determine the supported output format of the transcoder
  59354. */
  59355. supportedCompressionFormats?: {
  59356. /**
  59357. * etc1 compression format
  59358. */
  59359. etc1?: boolean;
  59360. /**
  59361. * s3tc compression format
  59362. */
  59363. s3tc?: boolean;
  59364. /**
  59365. * pvrtc compression format
  59366. */
  59367. pvrtc?: boolean;
  59368. /**
  59369. * etc2 compression format
  59370. */
  59371. etc2?: boolean;
  59372. };
  59373. /**
  59374. * If mipmap levels should be loaded for transcoded images (Default: true)
  59375. */
  59376. loadMipmapLevels?: boolean;
  59377. /**
  59378. * Index of a single image to load (Default: all images)
  59379. */
  59380. loadSingleImage?: number;
  59381. }
  59382. /**
  59383. * Used to load .Basis files
  59384. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  59385. */
  59386. export class BasisTools {
  59387. private static _IgnoreSupportedFormats;
  59388. /**
  59389. * URL to use when loading the basis transcoder
  59390. */
  59391. static JSModuleURL: string;
  59392. /**
  59393. * URL to use when loading the wasm module for the transcoder
  59394. */
  59395. static WasmModuleURL: string;
  59396. /**
  59397. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  59398. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  59399. * @returns internal format corresponding to the Basis format
  59400. */
  59401. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  59402. private static _WorkerPromise;
  59403. private static _Worker;
  59404. private static _actionId;
  59405. private static _CreateWorkerAsync;
  59406. /**
  59407. * Transcodes a loaded image file to compressed pixel data
  59408. * @param data image data to transcode
  59409. * @param config configuration options for the transcoding
  59410. * @returns a promise resulting in the transcoded image
  59411. */
  59412. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  59413. /**
  59414. * Loads a texture from the transcode result
  59415. * @param texture texture load to
  59416. * @param transcodeResult the result of transcoding the basis file to load from
  59417. */
  59418. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  59419. }
  59420. }
  59421. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  59422. import { Nullable } from "babylonjs/types";
  59423. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59424. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59425. /**
  59426. * Loader for .basis file format
  59427. */
  59428. export class _BasisTextureLoader implements IInternalTextureLoader {
  59429. /**
  59430. * Defines whether the loader supports cascade loading the different faces.
  59431. */
  59432. readonly supportCascades: boolean;
  59433. /**
  59434. * This returns if the loader support the current file information.
  59435. * @param extension defines the file extension of the file being loaded
  59436. * @returns true if the loader can load the specified file
  59437. */
  59438. canLoad(extension: string): boolean;
  59439. /**
  59440. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59441. * @param data contains the texture data
  59442. * @param texture defines the BabylonJS internal texture
  59443. * @param createPolynomials will be true if polynomials have been requested
  59444. * @param onLoad defines the callback to trigger once the texture is ready
  59445. * @param onError defines the callback to trigger in case of error
  59446. */
  59447. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59448. /**
  59449. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59450. * @param data contains the texture data
  59451. * @param texture defines the BabylonJS internal texture
  59452. * @param callback defines the method to call once ready to upload
  59453. */
  59454. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59455. }
  59456. }
  59457. declare module "babylonjs/Materials/Textures/Loaders/index" {
  59458. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  59459. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  59460. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  59461. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  59462. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  59463. }
  59464. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  59465. import { Scene } from "babylonjs/scene";
  59466. import { Texture } from "babylonjs/Materials/Textures/texture";
  59467. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59468. /**
  59469. * 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.
  59470. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  59471. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  59472. */
  59473. export class CustomProceduralTexture extends ProceduralTexture {
  59474. private _animate;
  59475. private _time;
  59476. private _config;
  59477. private _texturePath;
  59478. /**
  59479. * Instantiates a new Custom Procedural Texture.
  59480. * 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.
  59481. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  59482. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  59483. * @param name Define the name of the texture
  59484. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  59485. * @param size Define the size of the texture to create
  59486. * @param scene Define the scene the texture belongs to
  59487. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  59488. * @param generateMipMaps Define if the texture should creates mip maps or not
  59489. */
  59490. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  59491. private _loadJson;
  59492. /**
  59493. * Is the texture ready to be used ? (rendered at least once)
  59494. * @returns true if ready, otherwise, false.
  59495. */
  59496. isReady(): boolean;
  59497. /**
  59498. * Render the texture to its associated render target.
  59499. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  59500. */
  59501. render(useCameraPostProcess?: boolean): void;
  59502. /**
  59503. * Update the list of dependant textures samplers in the shader.
  59504. */
  59505. updateTextures(): void;
  59506. /**
  59507. * Update the uniform values of the procedural texture in the shader.
  59508. */
  59509. updateShaderUniforms(): void;
  59510. /**
  59511. * Define if the texture animates or not.
  59512. */
  59513. get animate(): boolean;
  59514. set animate(value: boolean);
  59515. }
  59516. }
  59517. declare module "babylonjs/Shaders/noise.fragment" {
  59518. /** @hidden */
  59519. export var noisePixelShader: {
  59520. name: string;
  59521. shader: string;
  59522. };
  59523. }
  59524. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  59525. import { Nullable } from "babylonjs/types";
  59526. import { Scene } from "babylonjs/scene";
  59527. import { Texture } from "babylonjs/Materials/Textures/texture";
  59528. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59529. import "babylonjs/Shaders/noise.fragment";
  59530. /**
  59531. * Class used to generate noise procedural textures
  59532. */
  59533. export class NoiseProceduralTexture extends ProceduralTexture {
  59534. private _time;
  59535. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  59536. brightness: number;
  59537. /** Defines the number of octaves to process */
  59538. octaves: number;
  59539. /** Defines the level of persistence (0.8 by default) */
  59540. persistence: number;
  59541. /** Gets or sets animation speed factor (default is 1) */
  59542. animationSpeedFactor: number;
  59543. /**
  59544. * Creates a new NoiseProceduralTexture
  59545. * @param name defines the name fo the texture
  59546. * @param size defines the size of the texture (default is 256)
  59547. * @param scene defines the hosting scene
  59548. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  59549. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  59550. */
  59551. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  59552. private _updateShaderUniforms;
  59553. protected _getDefines(): string;
  59554. /** Generate the current state of the procedural texture */
  59555. render(useCameraPostProcess?: boolean): void;
  59556. /**
  59557. * Serializes this noise procedural texture
  59558. * @returns a serialized noise procedural texture object
  59559. */
  59560. serialize(): any;
  59561. /**
  59562. * Clone the texture.
  59563. * @returns the cloned texture
  59564. */
  59565. clone(): NoiseProceduralTexture;
  59566. /**
  59567. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  59568. * @param parsedTexture defines parsed texture data
  59569. * @param scene defines the current scene
  59570. * @param rootUrl defines the root URL containing noise procedural texture information
  59571. * @returns a parsed NoiseProceduralTexture
  59572. */
  59573. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  59574. }
  59575. }
  59576. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  59577. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  59578. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  59579. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59580. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  59581. }
  59582. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  59583. import { Nullable } from "babylonjs/types";
  59584. import { Scene } from "babylonjs/scene";
  59585. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59586. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59587. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  59588. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59589. /**
  59590. * Raw cube texture where the raw buffers are passed in
  59591. */
  59592. export class RawCubeTexture extends CubeTexture {
  59593. /**
  59594. * Creates a cube texture where the raw buffers are passed in.
  59595. * @param scene defines the scene the texture is attached to
  59596. * @param data defines the array of data to use to create each face
  59597. * @param size defines the size of the textures
  59598. * @param format defines the format of the data
  59599. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  59600. * @param generateMipMaps defines if the engine should generate the mip levels
  59601. * @param invertY defines if data must be stored with Y axis inverted
  59602. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  59603. * @param compression defines the compression used (null by default)
  59604. */
  59605. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  59606. /**
  59607. * Updates the raw cube texture.
  59608. * @param data defines the data to store
  59609. * @param format defines the data format
  59610. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59611. * @param invertY defines if data must be stored with Y axis inverted
  59612. * @param compression defines the compression used (null by default)
  59613. * @param level defines which level of the texture to update
  59614. */
  59615. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  59616. /**
  59617. * Updates a raw cube texture with RGBD encoded data.
  59618. * @param data defines the array of data [mipmap][face] to use to create each face
  59619. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  59620. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  59621. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  59622. * @returns a promsie that resolves when the operation is complete
  59623. */
  59624. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  59625. /**
  59626. * Clones the raw cube texture.
  59627. * @return a new cube texture
  59628. */
  59629. clone(): CubeTexture;
  59630. /** @hidden */
  59631. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  59632. }
  59633. }
  59634. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  59635. import { Scene } from "babylonjs/scene";
  59636. import { Texture } from "babylonjs/Materials/Textures/texture";
  59637. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59638. /**
  59639. * Class used to store 3D textures containing user data
  59640. */
  59641. export class RawTexture3D extends Texture {
  59642. /** Gets or sets the texture format to use */
  59643. format: number;
  59644. private _engine;
  59645. /**
  59646. * Create a new RawTexture3D
  59647. * @param data defines the data of the texture
  59648. * @param width defines the width of the texture
  59649. * @param height defines the height of the texture
  59650. * @param depth defines the depth of the texture
  59651. * @param format defines the texture format to use
  59652. * @param scene defines the hosting scene
  59653. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59654. * @param invertY defines if texture must be stored with Y axis inverted
  59655. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59656. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59657. */
  59658. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59659. /** Gets or sets the texture format to use */
  59660. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59661. /**
  59662. * Update the texture with new data
  59663. * @param data defines the data to store in the texture
  59664. */
  59665. update(data: ArrayBufferView): void;
  59666. }
  59667. }
  59668. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  59669. import { Scene } from "babylonjs/scene";
  59670. import { Texture } from "babylonjs/Materials/Textures/texture";
  59671. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59672. /**
  59673. * Class used to store 2D array textures containing user data
  59674. */
  59675. export class RawTexture2DArray extends Texture {
  59676. /** Gets or sets the texture format to use */
  59677. format: number;
  59678. private _engine;
  59679. /**
  59680. * Create a new RawTexture2DArray
  59681. * @param data defines the data of the texture
  59682. * @param width defines the width of the texture
  59683. * @param height defines the height of the texture
  59684. * @param depth defines the number of layers of the texture
  59685. * @param format defines the texture format to use
  59686. * @param scene defines the hosting scene
  59687. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59688. * @param invertY defines if texture must be stored with Y axis inverted
  59689. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59690. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59691. */
  59692. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59693. /** Gets or sets the texture format to use */
  59694. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59695. /**
  59696. * Update the texture with new data
  59697. * @param data defines the data to store in the texture
  59698. */
  59699. update(data: ArrayBufferView): void;
  59700. }
  59701. }
  59702. declare module "babylonjs/Materials/Textures/refractionTexture" {
  59703. import { Scene } from "babylonjs/scene";
  59704. import { Plane } from "babylonjs/Maths/math.plane";
  59705. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59706. /**
  59707. * Creates a refraction texture used by refraction channel of the standard material.
  59708. * It is like a mirror but to see through a material.
  59709. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59710. */
  59711. export class RefractionTexture extends RenderTargetTexture {
  59712. /**
  59713. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  59714. * 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.
  59715. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59716. */
  59717. refractionPlane: Plane;
  59718. /**
  59719. * Define how deep under the surface we should see.
  59720. */
  59721. depth: number;
  59722. /**
  59723. * Creates a refraction texture used by refraction channel of the standard material.
  59724. * It is like a mirror but to see through a material.
  59725. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59726. * @param name Define the texture name
  59727. * @param size Define the size of the underlying texture
  59728. * @param scene Define the scene the refraction belongs to
  59729. * @param generateMipMaps Define if we need to generate mips level for the refraction
  59730. */
  59731. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  59732. /**
  59733. * Clone the refraction texture.
  59734. * @returns the cloned texture
  59735. */
  59736. clone(): RefractionTexture;
  59737. /**
  59738. * Serialize the texture to a JSON representation you could use in Parse later on
  59739. * @returns the serialized JSON representation
  59740. */
  59741. serialize(): any;
  59742. }
  59743. }
  59744. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  59745. import { Nullable } from "babylonjs/types";
  59746. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59747. import { Matrix } from "babylonjs/Maths/math.vector";
  59748. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  59749. import "babylonjs/Engines/Extensions/engine.videoTexture";
  59750. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59751. import { Scene } from "babylonjs/scene";
  59752. /**
  59753. * Defines the options related to the creation of an HtmlElementTexture
  59754. */
  59755. export interface IHtmlElementTextureOptions {
  59756. /**
  59757. * Defines wether mip maps should be created or not.
  59758. */
  59759. generateMipMaps?: boolean;
  59760. /**
  59761. * Defines the sampling mode of the texture.
  59762. */
  59763. samplingMode?: number;
  59764. /**
  59765. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59766. */
  59767. engine: Nullable<ThinEngine>;
  59768. /**
  59769. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59770. */
  59771. scene: Nullable<Scene>;
  59772. }
  59773. /**
  59774. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59775. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59776. * is automatically managed.
  59777. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59778. * in your application.
  59779. *
  59780. * As the update is not automatic, you need to call them manually.
  59781. */
  59782. export class HtmlElementTexture extends BaseTexture {
  59783. /**
  59784. * The texture URL.
  59785. */
  59786. element: HTMLVideoElement | HTMLCanvasElement;
  59787. private static readonly DefaultOptions;
  59788. private _textureMatrix;
  59789. private _engine;
  59790. private _isVideo;
  59791. private _generateMipMaps;
  59792. private _samplingMode;
  59793. /**
  59794. * Instantiates a HtmlElementTexture from the following parameters.
  59795. *
  59796. * @param name Defines the name of the texture
  59797. * @param element Defines the video or canvas the texture is filled with
  59798. * @param options Defines the other none mandatory texture creation options
  59799. */
  59800. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59801. private _createInternalTexture;
  59802. /**
  59803. * Returns the texture matrix used in most of the material.
  59804. */
  59805. getTextureMatrix(): Matrix;
  59806. /**
  59807. * Updates the content of the texture.
  59808. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59809. */
  59810. update(invertY?: Nullable<boolean>): void;
  59811. }
  59812. }
  59813. declare module "babylonjs/Materials/Textures/Packer/frame" {
  59814. import { Vector2 } from "babylonjs/Maths/math.vector";
  59815. /**
  59816. * Defines the basic options interface of a TexturePacker Frame
  59817. */
  59818. export interface ITexturePackerFrame {
  59819. /**
  59820. * The frame ID
  59821. */
  59822. id: number;
  59823. /**
  59824. * The frames Scale
  59825. */
  59826. scale: Vector2;
  59827. /**
  59828. * The Frames offset
  59829. */
  59830. offset: Vector2;
  59831. }
  59832. /**
  59833. * This is a support class for frame Data on texture packer sets.
  59834. */
  59835. export class TexturePackerFrame implements ITexturePackerFrame {
  59836. /**
  59837. * The frame ID
  59838. */
  59839. id: number;
  59840. /**
  59841. * The frames Scale
  59842. */
  59843. scale: Vector2;
  59844. /**
  59845. * The Frames offset
  59846. */
  59847. offset: Vector2;
  59848. /**
  59849. * Initializes a texture package frame.
  59850. * @param id The numerical frame identifier
  59851. * @param scale Scalar Vector2 for UV frame
  59852. * @param offset Vector2 for the frame position in UV units.
  59853. * @returns TexturePackerFrame
  59854. */
  59855. constructor(id: number, scale: Vector2, offset: Vector2);
  59856. }
  59857. }
  59858. declare module "babylonjs/Materials/Textures/Packer/packer" {
  59859. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59860. import { Scene } from "babylonjs/scene";
  59861. import { Nullable } from "babylonjs/types";
  59862. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  59863. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  59864. /**
  59865. * Defines the basic options interface of a TexturePacker
  59866. */
  59867. export interface ITexturePackerOptions {
  59868. /**
  59869. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  59870. */
  59871. map?: string[];
  59872. /**
  59873. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59874. */
  59875. uvsIn?: string;
  59876. /**
  59877. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59878. */
  59879. uvsOut?: string;
  59880. /**
  59881. * number representing the layout style. Defaults to LAYOUT_STRIP
  59882. */
  59883. layout?: number;
  59884. /**
  59885. * number of columns if using custom column count layout(2). This defaults to 4.
  59886. */
  59887. colnum?: number;
  59888. /**
  59889. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  59890. */
  59891. updateInputMeshes?: boolean;
  59892. /**
  59893. * boolean flag to dispose all the source textures. Defaults to true.
  59894. */
  59895. disposeSources?: boolean;
  59896. /**
  59897. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  59898. */
  59899. fillBlanks?: boolean;
  59900. /**
  59901. * string value representing the context fill style color. Defaults to 'black'.
  59902. */
  59903. customFillColor?: string;
  59904. /**
  59905. * Width and Height Value of each Frame in the TexturePacker Sets
  59906. */
  59907. frameSize?: number;
  59908. /**
  59909. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  59910. */
  59911. paddingRatio?: number;
  59912. /**
  59913. * Number that declares the fill method for the padding gutter.
  59914. */
  59915. paddingMode?: number;
  59916. /**
  59917. * If in SUBUV_COLOR padding mode what color to use.
  59918. */
  59919. paddingColor?: Color3 | Color4;
  59920. }
  59921. /**
  59922. * Defines the basic interface of a TexturePacker JSON File
  59923. */
  59924. export interface ITexturePackerJSON {
  59925. /**
  59926. * The frame ID
  59927. */
  59928. name: string;
  59929. /**
  59930. * The base64 channel data
  59931. */
  59932. sets: any;
  59933. /**
  59934. * The options of the Packer
  59935. */
  59936. options: ITexturePackerOptions;
  59937. /**
  59938. * The frame data of the Packer
  59939. */
  59940. frames: Array<number>;
  59941. }
  59942. /**
  59943. * This is a support class that generates a series of packed texture sets.
  59944. * @see https://doc.babylonjs.com/babylon101/materials
  59945. */
  59946. export class TexturePacker {
  59947. /** Packer Layout Constant 0 */
  59948. static readonly LAYOUT_STRIP: number;
  59949. /** Packer Layout Constant 1 */
  59950. static readonly LAYOUT_POWER2: number;
  59951. /** Packer Layout Constant 2 */
  59952. static readonly LAYOUT_COLNUM: number;
  59953. /** Packer Layout Constant 0 */
  59954. static readonly SUBUV_WRAP: number;
  59955. /** Packer Layout Constant 1 */
  59956. static readonly SUBUV_EXTEND: number;
  59957. /** Packer Layout Constant 2 */
  59958. static readonly SUBUV_COLOR: number;
  59959. /** The Name of the Texture Package */
  59960. name: string;
  59961. /** The scene scope of the TexturePacker */
  59962. scene: Scene;
  59963. /** The Meshes to target */
  59964. meshes: AbstractMesh[];
  59965. /** Arguments passed with the Constructor */
  59966. options: ITexturePackerOptions;
  59967. /** The promise that is started upon initialization */
  59968. promise: Nullable<Promise<TexturePacker | string>>;
  59969. /** The Container object for the channel sets that are generated */
  59970. sets: object;
  59971. /** The Container array for the frames that are generated */
  59972. frames: TexturePackerFrame[];
  59973. /** The expected number of textures the system is parsing. */
  59974. private _expecting;
  59975. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  59976. private _paddingValue;
  59977. /**
  59978. * Initializes a texture package series from an array of meshes or a single mesh.
  59979. * @param name The name of the package
  59980. * @param meshes The target meshes to compose the package from
  59981. * @param options The arguments that texture packer should follow while building.
  59982. * @param scene The scene which the textures are scoped to.
  59983. * @returns TexturePacker
  59984. */
  59985. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  59986. /**
  59987. * Starts the package process
  59988. * @param resolve The promises resolution function
  59989. * @returns TexturePacker
  59990. */
  59991. private _createFrames;
  59992. /**
  59993. * Calculates the Size of the Channel Sets
  59994. * @returns Vector2
  59995. */
  59996. private _calculateSize;
  59997. /**
  59998. * Calculates the UV data for the frames.
  59999. * @param baseSize the base frameSize
  60000. * @param padding the base frame padding
  60001. * @param dtSize size of the Dynamic Texture for that channel
  60002. * @param dtUnits is 1/dtSize
  60003. * @param update flag to update the input meshes
  60004. */
  60005. private _calculateMeshUVFrames;
  60006. /**
  60007. * Calculates the frames Offset.
  60008. * @param index of the frame
  60009. * @returns Vector2
  60010. */
  60011. private _getFrameOffset;
  60012. /**
  60013. * Updates a Mesh to the frame data
  60014. * @param mesh that is the target
  60015. * @param frameID or the frame index
  60016. */
  60017. private _updateMeshUV;
  60018. /**
  60019. * Updates a Meshes materials to use the texture packer channels
  60020. * @param m is the mesh to target
  60021. * @param force all channels on the packer to be set.
  60022. */
  60023. private _updateTextureReferences;
  60024. /**
  60025. * Public method to set a Mesh to a frame
  60026. * @param m that is the target
  60027. * @param frameID or the frame index
  60028. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  60029. */
  60030. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  60031. /**
  60032. * Starts the async promise to compile the texture packer.
  60033. * @returns Promise<void>
  60034. */
  60035. processAsync(): Promise<void>;
  60036. /**
  60037. * Disposes all textures associated with this packer
  60038. */
  60039. dispose(): void;
  60040. /**
  60041. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  60042. * @param imageType is the image type to use.
  60043. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  60044. */
  60045. download(imageType?: string, quality?: number): void;
  60046. /**
  60047. * Public method to load a texturePacker JSON file.
  60048. * @param data of the JSON file in string format.
  60049. */
  60050. updateFromJSON(data: string): void;
  60051. }
  60052. }
  60053. declare module "babylonjs/Materials/Textures/Packer/index" {
  60054. export * from "babylonjs/Materials/Textures/Packer/packer";
  60055. export * from "babylonjs/Materials/Textures/Packer/frame";
  60056. }
  60057. declare module "babylonjs/Materials/Textures/index" {
  60058. export * from "babylonjs/Materials/Textures/baseTexture";
  60059. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  60060. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  60061. export * from "babylonjs/Materials/Textures/cubeTexture";
  60062. export * from "babylonjs/Materials/Textures/dynamicTexture";
  60063. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  60064. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  60065. export * from "babylonjs/Materials/Textures/internalTexture";
  60066. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  60067. export * from "babylonjs/Materials/Textures/Loaders/index";
  60068. export * from "babylonjs/Materials/Textures/mirrorTexture";
  60069. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  60070. export * from "babylonjs/Materials/Textures/Procedurals/index";
  60071. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  60072. export * from "babylonjs/Materials/Textures/rawTexture";
  60073. export * from "babylonjs/Materials/Textures/rawTexture3D";
  60074. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  60075. export * from "babylonjs/Materials/Textures/refractionTexture";
  60076. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  60077. export * from "babylonjs/Materials/Textures/texture";
  60078. export * from "babylonjs/Materials/Textures/videoTexture";
  60079. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  60080. export * from "babylonjs/Materials/Textures/Packer/index";
  60081. }
  60082. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  60083. /**
  60084. * Enum used to define the target of a block
  60085. */
  60086. export enum NodeMaterialBlockTargets {
  60087. /** Vertex shader */
  60088. Vertex = 1,
  60089. /** Fragment shader */
  60090. Fragment = 2,
  60091. /** Neutral */
  60092. Neutral = 4,
  60093. /** Vertex and Fragment */
  60094. VertexAndFragment = 3
  60095. }
  60096. }
  60097. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  60098. /**
  60099. * Defines the kind of connection point for node based material
  60100. */
  60101. export enum NodeMaterialBlockConnectionPointTypes {
  60102. /** Float */
  60103. Float = 1,
  60104. /** Int */
  60105. Int = 2,
  60106. /** Vector2 */
  60107. Vector2 = 4,
  60108. /** Vector3 */
  60109. Vector3 = 8,
  60110. /** Vector4 */
  60111. Vector4 = 16,
  60112. /** Color3 */
  60113. Color3 = 32,
  60114. /** Color4 */
  60115. Color4 = 64,
  60116. /** Matrix */
  60117. Matrix = 128,
  60118. /** Detect type based on connection */
  60119. AutoDetect = 1024,
  60120. /** Output type that will be defined by input type */
  60121. BasedOnInput = 2048
  60122. }
  60123. }
  60124. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  60125. /**
  60126. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  60127. */
  60128. export enum NodeMaterialBlockConnectionPointMode {
  60129. /** Value is an uniform */
  60130. Uniform = 0,
  60131. /** Value is a mesh attribute */
  60132. Attribute = 1,
  60133. /** Value is a varying between vertex and fragment shaders */
  60134. Varying = 2,
  60135. /** Mode is undefined */
  60136. Undefined = 3
  60137. }
  60138. }
  60139. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  60140. /**
  60141. * Enum used to define system values e.g. values automatically provided by the system
  60142. */
  60143. export enum NodeMaterialSystemValues {
  60144. /** World */
  60145. World = 1,
  60146. /** View */
  60147. View = 2,
  60148. /** Projection */
  60149. Projection = 3,
  60150. /** ViewProjection */
  60151. ViewProjection = 4,
  60152. /** WorldView */
  60153. WorldView = 5,
  60154. /** WorldViewProjection */
  60155. WorldViewProjection = 6,
  60156. /** CameraPosition */
  60157. CameraPosition = 7,
  60158. /** Fog Color */
  60159. FogColor = 8,
  60160. /** Delta time */
  60161. DeltaTime = 9
  60162. }
  60163. }
  60164. declare module "babylonjs/Materials/Node/Enums/index" {
  60165. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60166. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60167. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  60168. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60169. }
  60170. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  60171. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60172. /**
  60173. * Root class for all node material optimizers
  60174. */
  60175. export class NodeMaterialOptimizer {
  60176. /**
  60177. * Function used to optimize a NodeMaterial graph
  60178. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  60179. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  60180. */
  60181. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  60182. }
  60183. }
  60184. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  60185. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60186. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60187. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60188. import { Scene } from "babylonjs/scene";
  60189. /**
  60190. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  60191. */
  60192. export class TransformBlock extends NodeMaterialBlock {
  60193. /**
  60194. * Defines the value to use to complement W value to transform it to a Vector4
  60195. */
  60196. complementW: number;
  60197. /**
  60198. * Defines the value to use to complement z value to transform it to a Vector4
  60199. */
  60200. complementZ: number;
  60201. /**
  60202. * Creates a new TransformBlock
  60203. * @param name defines the block name
  60204. */
  60205. constructor(name: string);
  60206. /**
  60207. * Gets the current class name
  60208. * @returns the class name
  60209. */
  60210. getClassName(): string;
  60211. /**
  60212. * Gets the vector input
  60213. */
  60214. get vector(): NodeMaterialConnectionPoint;
  60215. /**
  60216. * Gets the output component
  60217. */
  60218. get output(): NodeMaterialConnectionPoint;
  60219. /**
  60220. * Gets the xyz output component
  60221. */
  60222. get xyz(): NodeMaterialConnectionPoint;
  60223. /**
  60224. * Gets the matrix transform input
  60225. */
  60226. get transform(): NodeMaterialConnectionPoint;
  60227. protected _buildBlock(state: NodeMaterialBuildState): this;
  60228. serialize(): any;
  60229. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60230. protected _dumpPropertiesCode(): string;
  60231. }
  60232. }
  60233. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  60234. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60235. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60236. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60237. /**
  60238. * Block used to output the vertex position
  60239. */
  60240. export class VertexOutputBlock extends NodeMaterialBlock {
  60241. /**
  60242. * Creates a new VertexOutputBlock
  60243. * @param name defines the block name
  60244. */
  60245. constructor(name: string);
  60246. /**
  60247. * Gets the current class name
  60248. * @returns the class name
  60249. */
  60250. getClassName(): string;
  60251. /**
  60252. * Gets the vector input component
  60253. */
  60254. get vector(): NodeMaterialConnectionPoint;
  60255. protected _buildBlock(state: NodeMaterialBuildState): this;
  60256. }
  60257. }
  60258. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  60259. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60260. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60261. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60262. /**
  60263. * Block used to output the final color
  60264. */
  60265. export class FragmentOutputBlock extends NodeMaterialBlock {
  60266. /**
  60267. * Create a new FragmentOutputBlock
  60268. * @param name defines the block name
  60269. */
  60270. constructor(name: string);
  60271. /**
  60272. * Gets the current class name
  60273. * @returns the class name
  60274. */
  60275. getClassName(): string;
  60276. /**
  60277. * Gets the rgba input component
  60278. */
  60279. get rgba(): NodeMaterialConnectionPoint;
  60280. /**
  60281. * Gets the rgb input component
  60282. */
  60283. get rgb(): NodeMaterialConnectionPoint;
  60284. /**
  60285. * Gets the a input component
  60286. */
  60287. get a(): NodeMaterialConnectionPoint;
  60288. protected _buildBlock(state: NodeMaterialBuildState): this;
  60289. }
  60290. }
  60291. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  60292. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60293. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60294. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60295. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60296. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60297. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60298. import { Effect } from "babylonjs/Materials/effect";
  60299. import { Mesh } from "babylonjs/Meshes/mesh";
  60300. import { Nullable } from "babylonjs/types";
  60301. import { Scene } from "babylonjs/scene";
  60302. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  60303. /**
  60304. * Block used to read a reflection texture from a sampler
  60305. */
  60306. export class ReflectionTextureBlock extends NodeMaterialBlock {
  60307. private _define3DName;
  60308. private _defineCubicName;
  60309. private _defineExplicitName;
  60310. private _defineProjectionName;
  60311. private _defineLocalCubicName;
  60312. private _defineSphericalName;
  60313. private _definePlanarName;
  60314. private _defineEquirectangularName;
  60315. private _defineMirroredEquirectangularFixedName;
  60316. private _defineEquirectangularFixedName;
  60317. private _defineSkyboxName;
  60318. private _cubeSamplerName;
  60319. private _2DSamplerName;
  60320. private _positionUVWName;
  60321. private _directionWName;
  60322. private _reflectionCoordsName;
  60323. private _reflection2DCoordsName;
  60324. private _reflectionColorName;
  60325. private _reflectionMatrixName;
  60326. /**
  60327. * Gets or sets the texture associated with the node
  60328. */
  60329. texture: Nullable<BaseTexture>;
  60330. /**
  60331. * Create a new TextureBlock
  60332. * @param name defines the block name
  60333. */
  60334. constructor(name: string);
  60335. /**
  60336. * Gets the current class name
  60337. * @returns the class name
  60338. */
  60339. getClassName(): string;
  60340. /**
  60341. * Gets the world position input component
  60342. */
  60343. get position(): NodeMaterialConnectionPoint;
  60344. /**
  60345. * Gets the world position input component
  60346. */
  60347. get worldPosition(): NodeMaterialConnectionPoint;
  60348. /**
  60349. * Gets the world normal input component
  60350. */
  60351. get worldNormal(): NodeMaterialConnectionPoint;
  60352. /**
  60353. * Gets the world input component
  60354. */
  60355. get world(): NodeMaterialConnectionPoint;
  60356. /**
  60357. * Gets the camera (or eye) position component
  60358. */
  60359. get cameraPosition(): NodeMaterialConnectionPoint;
  60360. /**
  60361. * Gets the view input component
  60362. */
  60363. get view(): NodeMaterialConnectionPoint;
  60364. /**
  60365. * Gets the rgb output component
  60366. */
  60367. get rgb(): NodeMaterialConnectionPoint;
  60368. /**
  60369. * Gets the r output component
  60370. */
  60371. get r(): NodeMaterialConnectionPoint;
  60372. /**
  60373. * Gets the g output component
  60374. */
  60375. get g(): NodeMaterialConnectionPoint;
  60376. /**
  60377. * Gets the b output component
  60378. */
  60379. get b(): NodeMaterialConnectionPoint;
  60380. autoConfigure(material: NodeMaterial): void;
  60381. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60382. isReady(): boolean;
  60383. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60384. private _injectVertexCode;
  60385. private _writeOutput;
  60386. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60387. protected _dumpPropertiesCode(): string;
  60388. serialize(): any;
  60389. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60390. }
  60391. }
  60392. declare module "babylonjs/Materials/Node/nodeMaterial" {
  60393. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60394. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  60395. import { Scene } from "babylonjs/scene";
  60396. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60397. import { Matrix } from "babylonjs/Maths/math.vector";
  60398. import { Mesh } from "babylonjs/Meshes/mesh";
  60399. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60400. import { Observable } from "babylonjs/Misc/observable";
  60401. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60402. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  60403. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  60404. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  60405. import { Nullable } from "babylonjs/types";
  60406. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60407. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60408. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60409. /**
  60410. * Interface used to configure the node material editor
  60411. */
  60412. export interface INodeMaterialEditorOptions {
  60413. /** Define the URl to load node editor script */
  60414. editorURL?: string;
  60415. }
  60416. /** @hidden */
  60417. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  60418. NORMAL: boolean;
  60419. TANGENT: boolean;
  60420. UV1: boolean;
  60421. /** BONES */
  60422. NUM_BONE_INFLUENCERS: number;
  60423. BonesPerMesh: number;
  60424. BONETEXTURE: boolean;
  60425. /** MORPH TARGETS */
  60426. MORPHTARGETS: boolean;
  60427. MORPHTARGETS_NORMAL: boolean;
  60428. MORPHTARGETS_TANGENT: boolean;
  60429. MORPHTARGETS_UV: boolean;
  60430. NUM_MORPH_INFLUENCERS: number;
  60431. /** IMAGE PROCESSING */
  60432. IMAGEPROCESSING: boolean;
  60433. VIGNETTE: boolean;
  60434. VIGNETTEBLENDMODEMULTIPLY: boolean;
  60435. VIGNETTEBLENDMODEOPAQUE: boolean;
  60436. TONEMAPPING: boolean;
  60437. TONEMAPPING_ACES: boolean;
  60438. CONTRAST: boolean;
  60439. EXPOSURE: boolean;
  60440. COLORCURVES: boolean;
  60441. COLORGRADING: boolean;
  60442. COLORGRADING3D: boolean;
  60443. SAMPLER3DGREENDEPTH: boolean;
  60444. SAMPLER3DBGRMAP: boolean;
  60445. IMAGEPROCESSINGPOSTPROCESS: boolean;
  60446. /** MISC. */
  60447. BUMPDIRECTUV: number;
  60448. constructor();
  60449. setValue(name: string, value: boolean): void;
  60450. }
  60451. /**
  60452. * Class used to configure NodeMaterial
  60453. */
  60454. export interface INodeMaterialOptions {
  60455. /**
  60456. * Defines if blocks should emit comments
  60457. */
  60458. emitComments: boolean;
  60459. }
  60460. /**
  60461. * Class used to create a node based material built by assembling shader blocks
  60462. */
  60463. export class NodeMaterial extends PushMaterial {
  60464. private static _BuildIdGenerator;
  60465. private _options;
  60466. private _vertexCompilationState;
  60467. private _fragmentCompilationState;
  60468. private _sharedData;
  60469. private _buildId;
  60470. private _buildWasSuccessful;
  60471. private _cachedWorldViewMatrix;
  60472. private _cachedWorldViewProjectionMatrix;
  60473. private _optimizers;
  60474. private _animationFrame;
  60475. /** Define the Url to load node editor script */
  60476. static EditorURL: string;
  60477. /** Define the Url to load snippets */
  60478. static SnippetUrl: string;
  60479. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  60480. static IgnoreTexturesAtLoadTime: boolean;
  60481. private BJSNODEMATERIALEDITOR;
  60482. /** Get the inspector from bundle or global */
  60483. private _getGlobalNodeMaterialEditor;
  60484. /**
  60485. * Snippet ID if the material was created from the snippet server
  60486. */
  60487. snippetId: string;
  60488. /**
  60489. * Gets or sets data used by visual editor
  60490. * @see https://nme.babylonjs.com
  60491. */
  60492. editorData: any;
  60493. /**
  60494. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  60495. */
  60496. ignoreAlpha: boolean;
  60497. /**
  60498. * Defines the maximum number of lights that can be used in the material
  60499. */
  60500. maxSimultaneousLights: number;
  60501. /**
  60502. * Observable raised when the material is built
  60503. */
  60504. onBuildObservable: Observable<NodeMaterial>;
  60505. /**
  60506. * Gets or sets the root nodes of the material vertex shader
  60507. */
  60508. _vertexOutputNodes: NodeMaterialBlock[];
  60509. /**
  60510. * Gets or sets the root nodes of the material fragment (pixel) shader
  60511. */
  60512. _fragmentOutputNodes: NodeMaterialBlock[];
  60513. /** Gets or sets options to control the node material overall behavior */
  60514. get options(): INodeMaterialOptions;
  60515. set options(options: INodeMaterialOptions);
  60516. /**
  60517. * Default configuration related to image processing available in the standard Material.
  60518. */
  60519. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  60520. /**
  60521. * Gets the image processing configuration used either in this material.
  60522. */
  60523. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  60524. /**
  60525. * Sets the Default image processing configuration used either in the this material.
  60526. *
  60527. * If sets to null, the scene one is in use.
  60528. */
  60529. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  60530. /**
  60531. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  60532. */
  60533. attachedBlocks: NodeMaterialBlock[];
  60534. /**
  60535. * Create a new node based material
  60536. * @param name defines the material name
  60537. * @param scene defines the hosting scene
  60538. * @param options defines creation option
  60539. */
  60540. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  60541. /**
  60542. * Gets the current class name of the material e.g. "NodeMaterial"
  60543. * @returns the class name
  60544. */
  60545. getClassName(): string;
  60546. /**
  60547. * Keep track of the image processing observer to allow dispose and replace.
  60548. */
  60549. private _imageProcessingObserver;
  60550. /**
  60551. * Attaches a new image processing configuration to the Standard Material.
  60552. * @param configuration
  60553. */
  60554. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  60555. /**
  60556. * Get a block by its name
  60557. * @param name defines the name of the block to retrieve
  60558. * @returns the required block or null if not found
  60559. */
  60560. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  60561. /**
  60562. * Get a block by its name
  60563. * @param predicate defines the predicate used to find the good candidate
  60564. * @returns the required block or null if not found
  60565. */
  60566. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  60567. /**
  60568. * Get an input block by its name
  60569. * @param predicate defines the predicate used to find the good candidate
  60570. * @returns the required input block or null if not found
  60571. */
  60572. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  60573. /**
  60574. * Gets the list of input blocks attached to this material
  60575. * @returns an array of InputBlocks
  60576. */
  60577. getInputBlocks(): InputBlock[];
  60578. /**
  60579. * Adds a new optimizer to the list of optimizers
  60580. * @param optimizer defines the optimizers to add
  60581. * @returns the current material
  60582. */
  60583. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  60584. /**
  60585. * Remove an optimizer from the list of optimizers
  60586. * @param optimizer defines the optimizers to remove
  60587. * @returns the current material
  60588. */
  60589. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  60590. /**
  60591. * Add a new block to the list of output nodes
  60592. * @param node defines the node to add
  60593. * @returns the current material
  60594. */
  60595. addOutputNode(node: NodeMaterialBlock): this;
  60596. /**
  60597. * Remove a block from the list of root nodes
  60598. * @param node defines the node to remove
  60599. * @returns the current material
  60600. */
  60601. removeOutputNode(node: NodeMaterialBlock): this;
  60602. private _addVertexOutputNode;
  60603. private _removeVertexOutputNode;
  60604. private _addFragmentOutputNode;
  60605. private _removeFragmentOutputNode;
  60606. /**
  60607. * Specifies if the material will require alpha blending
  60608. * @returns a boolean specifying if alpha blending is needed
  60609. */
  60610. needAlphaBlending(): boolean;
  60611. /**
  60612. * Specifies if this material should be rendered in alpha test mode
  60613. * @returns a boolean specifying if an alpha test is needed.
  60614. */
  60615. needAlphaTesting(): boolean;
  60616. private _initializeBlock;
  60617. private _resetDualBlocks;
  60618. /**
  60619. * Remove a block from the current node material
  60620. * @param block defines the block to remove
  60621. */
  60622. removeBlock(block: NodeMaterialBlock): void;
  60623. /**
  60624. * Build the material and generates the inner effect
  60625. * @param verbose defines if the build should log activity
  60626. */
  60627. build(verbose?: boolean): void;
  60628. /**
  60629. * Runs an otpimization phase to try to improve the shader code
  60630. */
  60631. optimize(): void;
  60632. private _prepareDefinesForAttributes;
  60633. /**
  60634. * Get if the submesh is ready to be used and all its information available.
  60635. * Child classes can use it to update shaders
  60636. * @param mesh defines the mesh to check
  60637. * @param subMesh defines which submesh to check
  60638. * @param useInstances specifies that instances should be used
  60639. * @returns a boolean indicating that the submesh is ready or not
  60640. */
  60641. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  60642. /**
  60643. * Get a string representing the shaders built by the current node graph
  60644. */
  60645. get compiledShaders(): string;
  60646. /**
  60647. * Binds the world matrix to the material
  60648. * @param world defines the world transformation matrix
  60649. */
  60650. bindOnlyWorldMatrix(world: Matrix): void;
  60651. /**
  60652. * Binds the submesh to this material by preparing the effect and shader to draw
  60653. * @param world defines the world transformation matrix
  60654. * @param mesh defines the mesh containing the submesh
  60655. * @param subMesh defines the submesh to bind the material to
  60656. */
  60657. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  60658. /**
  60659. * Gets the active textures from the material
  60660. * @returns an array of textures
  60661. */
  60662. getActiveTextures(): BaseTexture[];
  60663. /**
  60664. * Gets the list of texture blocks
  60665. * @returns an array of texture blocks
  60666. */
  60667. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  60668. /**
  60669. * Specifies if the material uses a texture
  60670. * @param texture defines the texture to check against the material
  60671. * @returns a boolean specifying if the material uses the texture
  60672. */
  60673. hasTexture(texture: BaseTexture): boolean;
  60674. /**
  60675. * Disposes the material
  60676. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  60677. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  60678. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  60679. */
  60680. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  60681. /** Creates the node editor window. */
  60682. private _createNodeEditor;
  60683. /**
  60684. * Launch the node material editor
  60685. * @param config Define the configuration of the editor
  60686. * @return a promise fulfilled when the node editor is visible
  60687. */
  60688. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  60689. /**
  60690. * Clear the current material
  60691. */
  60692. clear(): void;
  60693. /**
  60694. * Clear the current material and set it to a default state
  60695. */
  60696. setToDefault(): void;
  60697. /**
  60698. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  60699. * @param url defines the url to load from
  60700. * @returns a promise that will fullfil when the material is fully loaded
  60701. */
  60702. loadAsync(url: string): Promise<void>;
  60703. private _gatherBlocks;
  60704. /**
  60705. * Generate a string containing the code declaration required to create an equivalent of this material
  60706. * @returns a string
  60707. */
  60708. generateCode(): string;
  60709. /**
  60710. * Serializes this material in a JSON representation
  60711. * @returns the serialized material object
  60712. */
  60713. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  60714. private _restoreConnections;
  60715. /**
  60716. * Clear the current graph and load a new one from a serialization object
  60717. * @param source defines the JSON representation of the material
  60718. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60719. */
  60720. loadFromSerialization(source: any, rootUrl?: string): void;
  60721. /**
  60722. * Makes a duplicate of the current material.
  60723. * @param name - name to use for the new material.
  60724. */
  60725. clone(name: string): NodeMaterial;
  60726. /**
  60727. * Creates a node material from parsed material data
  60728. * @param source defines the JSON representation of the material
  60729. * @param scene defines the hosting scene
  60730. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60731. * @returns a new node material
  60732. */
  60733. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  60734. /**
  60735. * Creates a node material from a snippet saved in a remote file
  60736. * @param name defines the name of the material to create
  60737. * @param url defines the url to load from
  60738. * @param scene defines the hosting scene
  60739. * @returns a promise that will resolve to the new node material
  60740. */
  60741. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  60742. /**
  60743. * Creates a node material from a snippet saved by the node material editor
  60744. * @param snippetId defines the snippet to load
  60745. * @param scene defines the hosting scene
  60746. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60747. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  60748. * @returns a promise that will resolve to the new node material
  60749. */
  60750. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  60751. /**
  60752. * Creates a new node material set to default basic configuration
  60753. * @param name defines the name of the material
  60754. * @param scene defines the hosting scene
  60755. * @returns a new NodeMaterial
  60756. */
  60757. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  60758. }
  60759. }
  60760. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  60761. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60762. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60763. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60764. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60765. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60766. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60767. import { Effect } from "babylonjs/Materials/effect";
  60768. import { Mesh } from "babylonjs/Meshes/mesh";
  60769. import { Nullable } from "babylonjs/types";
  60770. import { Texture } from "babylonjs/Materials/Textures/texture";
  60771. import { Scene } from "babylonjs/scene";
  60772. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60773. /**
  60774. * Block used to read a texture from a sampler
  60775. */
  60776. export class TextureBlock extends NodeMaterialBlock {
  60777. private _defineName;
  60778. private _linearDefineName;
  60779. private _tempTextureRead;
  60780. private _samplerName;
  60781. private _transformedUVName;
  60782. private _textureTransformName;
  60783. private _textureInfoName;
  60784. private _mainUVName;
  60785. private _mainUVDefineName;
  60786. /**
  60787. * Gets or sets the texture associated with the node
  60788. */
  60789. texture: Nullable<Texture>;
  60790. /**
  60791. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  60792. */
  60793. convertToGammaSpace: boolean;
  60794. /**
  60795. * Create a new TextureBlock
  60796. * @param name defines the block name
  60797. */
  60798. constructor(name: string);
  60799. /**
  60800. * Gets the current class name
  60801. * @returns the class name
  60802. */
  60803. getClassName(): string;
  60804. /**
  60805. * Gets the uv input component
  60806. */
  60807. get uv(): NodeMaterialConnectionPoint;
  60808. /**
  60809. * Gets the rgba output component
  60810. */
  60811. get rgba(): NodeMaterialConnectionPoint;
  60812. /**
  60813. * Gets the rgb output component
  60814. */
  60815. get rgb(): NodeMaterialConnectionPoint;
  60816. /**
  60817. * Gets the r output component
  60818. */
  60819. get r(): NodeMaterialConnectionPoint;
  60820. /**
  60821. * Gets the g output component
  60822. */
  60823. get g(): NodeMaterialConnectionPoint;
  60824. /**
  60825. * Gets the b output component
  60826. */
  60827. get b(): NodeMaterialConnectionPoint;
  60828. /**
  60829. * Gets the a output component
  60830. */
  60831. get a(): NodeMaterialConnectionPoint;
  60832. get target(): NodeMaterialBlockTargets;
  60833. autoConfigure(material: NodeMaterial): void;
  60834. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60835. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60836. isReady(): boolean;
  60837. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60838. private get _isMixed();
  60839. private _injectVertexCode;
  60840. private _writeTextureRead;
  60841. private _writeOutput;
  60842. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60843. protected _dumpPropertiesCode(): string;
  60844. serialize(): any;
  60845. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60846. }
  60847. }
  60848. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  60849. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60850. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60851. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60852. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60853. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60854. import { Scene } from "babylonjs/scene";
  60855. /**
  60856. * Class used to store shared data between 2 NodeMaterialBuildState
  60857. */
  60858. export class NodeMaterialBuildStateSharedData {
  60859. /**
  60860. * Gets the list of emitted varyings
  60861. */
  60862. temps: string[];
  60863. /**
  60864. * Gets the list of emitted varyings
  60865. */
  60866. varyings: string[];
  60867. /**
  60868. * Gets the varying declaration string
  60869. */
  60870. varyingDeclaration: string;
  60871. /**
  60872. * Input blocks
  60873. */
  60874. inputBlocks: InputBlock[];
  60875. /**
  60876. * Input blocks
  60877. */
  60878. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  60879. /**
  60880. * Bindable blocks (Blocks that need to set data to the effect)
  60881. */
  60882. bindableBlocks: NodeMaterialBlock[];
  60883. /**
  60884. * List of blocks that can provide a compilation fallback
  60885. */
  60886. blocksWithFallbacks: NodeMaterialBlock[];
  60887. /**
  60888. * List of blocks that can provide a define update
  60889. */
  60890. blocksWithDefines: NodeMaterialBlock[];
  60891. /**
  60892. * List of blocks that can provide a repeatable content
  60893. */
  60894. repeatableContentBlocks: NodeMaterialBlock[];
  60895. /**
  60896. * List of blocks that can provide a dynamic list of uniforms
  60897. */
  60898. dynamicUniformBlocks: NodeMaterialBlock[];
  60899. /**
  60900. * List of blocks that can block the isReady function for the material
  60901. */
  60902. blockingBlocks: NodeMaterialBlock[];
  60903. /**
  60904. * Gets the list of animated inputs
  60905. */
  60906. animatedInputs: InputBlock[];
  60907. /**
  60908. * Build Id used to avoid multiple recompilations
  60909. */
  60910. buildId: number;
  60911. /** List of emitted variables */
  60912. variableNames: {
  60913. [key: string]: number;
  60914. };
  60915. /** List of emitted defines */
  60916. defineNames: {
  60917. [key: string]: number;
  60918. };
  60919. /** Should emit comments? */
  60920. emitComments: boolean;
  60921. /** Emit build activity */
  60922. verbose: boolean;
  60923. /** Gets or sets the hosting scene */
  60924. scene: Scene;
  60925. /**
  60926. * Gets the compilation hints emitted at compilation time
  60927. */
  60928. hints: {
  60929. needWorldViewMatrix: boolean;
  60930. needWorldViewProjectionMatrix: boolean;
  60931. needAlphaBlending: boolean;
  60932. needAlphaTesting: boolean;
  60933. };
  60934. /**
  60935. * List of compilation checks
  60936. */
  60937. checks: {
  60938. emitVertex: boolean;
  60939. emitFragment: boolean;
  60940. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  60941. };
  60942. /** Creates a new shared data */
  60943. constructor();
  60944. /**
  60945. * Emits console errors and exceptions if there is a failing check
  60946. */
  60947. emitErrors(): void;
  60948. }
  60949. }
  60950. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  60951. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60952. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60953. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  60954. /**
  60955. * Class used to store node based material build state
  60956. */
  60957. export class NodeMaterialBuildState {
  60958. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  60959. supportUniformBuffers: boolean;
  60960. /**
  60961. * Gets the list of emitted attributes
  60962. */
  60963. attributes: string[];
  60964. /**
  60965. * Gets the list of emitted uniforms
  60966. */
  60967. uniforms: string[];
  60968. /**
  60969. * Gets the list of emitted constants
  60970. */
  60971. constants: string[];
  60972. /**
  60973. * Gets the list of emitted samplers
  60974. */
  60975. samplers: string[];
  60976. /**
  60977. * Gets the list of emitted functions
  60978. */
  60979. functions: {
  60980. [key: string]: string;
  60981. };
  60982. /**
  60983. * Gets the list of emitted extensions
  60984. */
  60985. extensions: {
  60986. [key: string]: string;
  60987. };
  60988. /**
  60989. * Gets the target of the compilation state
  60990. */
  60991. target: NodeMaterialBlockTargets;
  60992. /**
  60993. * Gets the list of emitted counters
  60994. */
  60995. counters: {
  60996. [key: string]: number;
  60997. };
  60998. /**
  60999. * Shared data between multiple NodeMaterialBuildState instances
  61000. */
  61001. sharedData: NodeMaterialBuildStateSharedData;
  61002. /** @hidden */
  61003. _vertexState: NodeMaterialBuildState;
  61004. /** @hidden */
  61005. _attributeDeclaration: string;
  61006. /** @hidden */
  61007. _uniformDeclaration: string;
  61008. /** @hidden */
  61009. _constantDeclaration: string;
  61010. /** @hidden */
  61011. _samplerDeclaration: string;
  61012. /** @hidden */
  61013. _varyingTransfer: string;
  61014. private _repeatableContentAnchorIndex;
  61015. /** @hidden */
  61016. _builtCompilationString: string;
  61017. /**
  61018. * Gets the emitted compilation strings
  61019. */
  61020. compilationString: string;
  61021. /**
  61022. * Finalize the compilation strings
  61023. * @param state defines the current compilation state
  61024. */
  61025. finalize(state: NodeMaterialBuildState): void;
  61026. /** @hidden */
  61027. get _repeatableContentAnchor(): string;
  61028. /** @hidden */
  61029. _getFreeVariableName(prefix: string): string;
  61030. /** @hidden */
  61031. _getFreeDefineName(prefix: string): string;
  61032. /** @hidden */
  61033. _excludeVariableName(name: string): void;
  61034. /** @hidden */
  61035. _emit2DSampler(name: string): void;
  61036. /** @hidden */
  61037. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  61038. /** @hidden */
  61039. _emitExtension(name: string, extension: string): void;
  61040. /** @hidden */
  61041. _emitFunction(name: string, code: string, comments: string): void;
  61042. /** @hidden */
  61043. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  61044. replaceStrings?: {
  61045. search: RegExp;
  61046. replace: string;
  61047. }[];
  61048. repeatKey?: string;
  61049. }): string;
  61050. /** @hidden */
  61051. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  61052. repeatKey?: string;
  61053. removeAttributes?: boolean;
  61054. removeUniforms?: boolean;
  61055. removeVaryings?: boolean;
  61056. removeIfDef?: boolean;
  61057. replaceStrings?: {
  61058. search: RegExp;
  61059. replace: string;
  61060. }[];
  61061. }, storeKey?: string): void;
  61062. /** @hidden */
  61063. _registerTempVariable(name: string): boolean;
  61064. /** @hidden */
  61065. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  61066. /** @hidden */
  61067. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  61068. /** @hidden */
  61069. _emitFloat(value: number): string;
  61070. }
  61071. }
  61072. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  61073. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61074. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61075. import { Nullable } from "babylonjs/types";
  61076. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61077. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61078. import { Effect } from "babylonjs/Materials/effect";
  61079. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61080. import { Mesh } from "babylonjs/Meshes/mesh";
  61081. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61082. import { Scene } from "babylonjs/scene";
  61083. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61084. /**
  61085. * Defines a block that can be used inside a node based material
  61086. */
  61087. export class NodeMaterialBlock {
  61088. private _buildId;
  61089. private _buildTarget;
  61090. private _target;
  61091. private _isFinalMerger;
  61092. private _isInput;
  61093. protected _isUnique: boolean;
  61094. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  61095. inputsAreExclusive: boolean;
  61096. /** @hidden */
  61097. _codeVariableName: string;
  61098. /** @hidden */
  61099. _inputs: NodeMaterialConnectionPoint[];
  61100. /** @hidden */
  61101. _outputs: NodeMaterialConnectionPoint[];
  61102. /** @hidden */
  61103. _preparationId: number;
  61104. /**
  61105. * Gets or sets the name of the block
  61106. */
  61107. name: string;
  61108. /**
  61109. * Gets or sets the unique id of the node
  61110. */
  61111. uniqueId: number;
  61112. /**
  61113. * Gets or sets the comments associated with this block
  61114. */
  61115. comments: string;
  61116. /**
  61117. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  61118. */
  61119. get isUnique(): boolean;
  61120. /**
  61121. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  61122. */
  61123. get isFinalMerger(): boolean;
  61124. /**
  61125. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  61126. */
  61127. get isInput(): boolean;
  61128. /**
  61129. * Gets or sets the build Id
  61130. */
  61131. get buildId(): number;
  61132. set buildId(value: number);
  61133. /**
  61134. * Gets or sets the target of the block
  61135. */
  61136. get target(): NodeMaterialBlockTargets;
  61137. set target(value: NodeMaterialBlockTargets);
  61138. /**
  61139. * Gets the list of input points
  61140. */
  61141. get inputs(): NodeMaterialConnectionPoint[];
  61142. /** Gets the list of output points */
  61143. get outputs(): NodeMaterialConnectionPoint[];
  61144. /**
  61145. * Find an input by its name
  61146. * @param name defines the name of the input to look for
  61147. * @returns the input or null if not found
  61148. */
  61149. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  61150. /**
  61151. * Find an output by its name
  61152. * @param name defines the name of the outputto look for
  61153. * @returns the output or null if not found
  61154. */
  61155. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  61156. /**
  61157. * Creates a new NodeMaterialBlock
  61158. * @param name defines the block name
  61159. * @param target defines the target of that block (Vertex by default)
  61160. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  61161. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  61162. */
  61163. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  61164. /**
  61165. * Initialize the block and prepare the context for build
  61166. * @param state defines the state that will be used for the build
  61167. */
  61168. initialize(state: NodeMaterialBuildState): void;
  61169. /**
  61170. * Bind data to effect. Will only be called for blocks with isBindable === true
  61171. * @param effect defines the effect to bind data to
  61172. * @param nodeMaterial defines the hosting NodeMaterial
  61173. * @param mesh defines the mesh that will be rendered
  61174. */
  61175. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61176. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  61177. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  61178. protected _writeFloat(value: number): string;
  61179. /**
  61180. * Gets the current class name e.g. "NodeMaterialBlock"
  61181. * @returns the class name
  61182. */
  61183. getClassName(): string;
  61184. /**
  61185. * Register a new input. Must be called inside a block constructor
  61186. * @param name defines the connection point name
  61187. * @param type defines the connection point type
  61188. * @param isOptional defines a boolean indicating that this input can be omitted
  61189. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  61190. * @returns the current block
  61191. */
  61192. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  61193. /**
  61194. * Register a new output. Must be called inside a block constructor
  61195. * @param name defines the connection point name
  61196. * @param type defines the connection point type
  61197. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  61198. * @returns the current block
  61199. */
  61200. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  61201. /**
  61202. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  61203. * @param forOutput defines an optional connection point to check compatibility with
  61204. * @returns the first available input or null
  61205. */
  61206. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  61207. /**
  61208. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  61209. * @param forBlock defines an optional block to check compatibility with
  61210. * @returns the first available input or null
  61211. */
  61212. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  61213. /**
  61214. * Gets the sibling of the given output
  61215. * @param current defines the current output
  61216. * @returns the next output in the list or null
  61217. */
  61218. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  61219. /**
  61220. * Connect current block with another block
  61221. * @param other defines the block to connect with
  61222. * @param options define the various options to help pick the right connections
  61223. * @returns the current block
  61224. */
  61225. connectTo(other: NodeMaterialBlock, options?: {
  61226. input?: string;
  61227. output?: string;
  61228. outputSwizzle?: string;
  61229. }): this | undefined;
  61230. protected _buildBlock(state: NodeMaterialBuildState): void;
  61231. /**
  61232. * Add uniforms, samplers and uniform buffers at compilation time
  61233. * @param state defines the state to update
  61234. * @param nodeMaterial defines the node material requesting the update
  61235. * @param defines defines the material defines to update
  61236. * @param uniformBuffers defines the list of uniform buffer names
  61237. */
  61238. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61239. /**
  61240. * Add potential fallbacks if shader compilation fails
  61241. * @param mesh defines the mesh to be rendered
  61242. * @param fallbacks defines the current prioritized list of fallbacks
  61243. */
  61244. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61245. /**
  61246. * Initialize defines for shader compilation
  61247. * @param mesh defines the mesh to be rendered
  61248. * @param nodeMaterial defines the node material requesting the update
  61249. * @param defines defines the material defines to update
  61250. * @param useInstances specifies that instances should be used
  61251. */
  61252. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61253. /**
  61254. * Update defines for shader compilation
  61255. * @param mesh defines the mesh to be rendered
  61256. * @param nodeMaterial defines the node material requesting the update
  61257. * @param defines defines the material defines to update
  61258. * @param useInstances specifies that instances should be used
  61259. */
  61260. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61261. /**
  61262. * Lets the block try to connect some inputs automatically
  61263. * @param material defines the hosting NodeMaterial
  61264. */
  61265. autoConfigure(material: NodeMaterial): void;
  61266. /**
  61267. * Function called when a block is declared as repeatable content generator
  61268. * @param vertexShaderState defines the current compilation state for the vertex shader
  61269. * @param fragmentShaderState defines the current compilation state for the fragment shader
  61270. * @param mesh defines the mesh to be rendered
  61271. * @param defines defines the material defines to update
  61272. */
  61273. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61274. /**
  61275. * Checks if the block is ready
  61276. * @param mesh defines the mesh to be rendered
  61277. * @param nodeMaterial defines the node material requesting the update
  61278. * @param defines defines the material defines to update
  61279. * @param useInstances specifies that instances should be used
  61280. * @returns true if the block is ready
  61281. */
  61282. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  61283. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  61284. private _processBuild;
  61285. /**
  61286. * Compile the current node and generate the shader code
  61287. * @param state defines the current compilation state (uniforms, samplers, current string)
  61288. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  61289. * @returns true if already built
  61290. */
  61291. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  61292. protected _inputRename(name: string): string;
  61293. protected _outputRename(name: string): string;
  61294. protected _dumpPropertiesCode(): string;
  61295. /** @hidden */
  61296. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  61297. /** @hidden */
  61298. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  61299. /**
  61300. * Clone the current block to a new identical block
  61301. * @param scene defines the hosting scene
  61302. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  61303. * @returns a copy of the current block
  61304. */
  61305. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  61306. /**
  61307. * Serializes this block in a JSON representation
  61308. * @returns the serialized block object
  61309. */
  61310. serialize(): any;
  61311. /** @hidden */
  61312. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61313. /**
  61314. * Release resources
  61315. */
  61316. dispose(): void;
  61317. }
  61318. }
  61319. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  61320. /**
  61321. * Enum defining the type of animations supported by InputBlock
  61322. */
  61323. export enum AnimatedInputBlockTypes {
  61324. /** No animation */
  61325. None = 0,
  61326. /** Time based animation. Will only work for floats */
  61327. Time = 1
  61328. }
  61329. }
  61330. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  61331. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61332. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61333. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  61334. import { Nullable } from "babylonjs/types";
  61335. import { Effect } from "babylonjs/Materials/effect";
  61336. import { Matrix } from "babylonjs/Maths/math.vector";
  61337. import { Scene } from "babylonjs/scene";
  61338. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61339. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61340. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61341. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61342. import { Observable } from "babylonjs/Misc/observable";
  61343. /**
  61344. * Block used to expose an input value
  61345. */
  61346. export class InputBlock extends NodeMaterialBlock {
  61347. private _mode;
  61348. private _associatedVariableName;
  61349. private _storedValue;
  61350. private _valueCallback;
  61351. private _type;
  61352. private _animationType;
  61353. /** Gets or set a value used to limit the range of float values */
  61354. min: number;
  61355. /** Gets or set a value used to limit the range of float values */
  61356. max: number;
  61357. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  61358. isBoolean: boolean;
  61359. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  61360. matrixMode: number;
  61361. /** @hidden */
  61362. _systemValue: Nullable<NodeMaterialSystemValues>;
  61363. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  61364. visibleInInspector: boolean;
  61365. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  61366. isConstant: boolean;
  61367. /** Gets or sets the group to use to display this block in the Inspector */
  61368. groupInInspector: string;
  61369. /** Gets an observable raised when the value is changed */
  61370. onValueChangedObservable: Observable<InputBlock>;
  61371. /**
  61372. * Gets or sets the connection point type (default is float)
  61373. */
  61374. get type(): NodeMaterialBlockConnectionPointTypes;
  61375. /**
  61376. * Creates a new InputBlock
  61377. * @param name defines the block name
  61378. * @param target defines the target of that block (Vertex by default)
  61379. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  61380. */
  61381. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  61382. /**
  61383. * Gets the output component
  61384. */
  61385. get output(): NodeMaterialConnectionPoint;
  61386. /**
  61387. * Set the source of this connection point to a vertex attribute
  61388. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  61389. * @returns the current connection point
  61390. */
  61391. setAsAttribute(attributeName?: string): InputBlock;
  61392. /**
  61393. * Set the source of this connection point to a system value
  61394. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  61395. * @returns the current connection point
  61396. */
  61397. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  61398. /**
  61399. * Gets or sets the value of that point.
  61400. * Please note that this value will be ignored if valueCallback is defined
  61401. */
  61402. get value(): any;
  61403. set value(value: any);
  61404. /**
  61405. * Gets or sets a callback used to get the value of that point.
  61406. * Please note that setting this value will force the connection point to ignore the value property
  61407. */
  61408. get valueCallback(): () => any;
  61409. set valueCallback(value: () => any);
  61410. /**
  61411. * Gets or sets the associated variable name in the shader
  61412. */
  61413. get associatedVariableName(): string;
  61414. set associatedVariableName(value: string);
  61415. /** Gets or sets the type of animation applied to the input */
  61416. get animationType(): AnimatedInputBlockTypes;
  61417. set animationType(value: AnimatedInputBlockTypes);
  61418. /**
  61419. * Gets a boolean indicating that this connection point not defined yet
  61420. */
  61421. get isUndefined(): boolean;
  61422. /**
  61423. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  61424. * In this case the connection point name must be the name of the uniform to use.
  61425. * Can only be set on inputs
  61426. */
  61427. get isUniform(): boolean;
  61428. set isUniform(value: boolean);
  61429. /**
  61430. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  61431. * In this case the connection point name must be the name of the attribute to use
  61432. * Can only be set on inputs
  61433. */
  61434. get isAttribute(): boolean;
  61435. set isAttribute(value: boolean);
  61436. /**
  61437. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  61438. * Can only be set on exit points
  61439. */
  61440. get isVarying(): boolean;
  61441. set isVarying(value: boolean);
  61442. /**
  61443. * Gets a boolean indicating that the current connection point is a system value
  61444. */
  61445. get isSystemValue(): boolean;
  61446. /**
  61447. * Gets or sets the current well known value or null if not defined as a system value
  61448. */
  61449. get systemValue(): Nullable<NodeMaterialSystemValues>;
  61450. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  61451. /**
  61452. * Gets the current class name
  61453. * @returns the class name
  61454. */
  61455. getClassName(): string;
  61456. /**
  61457. * Animate the input if animationType !== None
  61458. * @param scene defines the rendering scene
  61459. */
  61460. animate(scene: Scene): void;
  61461. private _emitDefine;
  61462. initialize(state: NodeMaterialBuildState): void;
  61463. /**
  61464. * Set the input block to its default value (based on its type)
  61465. */
  61466. setDefaultValue(): void;
  61467. private _emitConstant;
  61468. private _emit;
  61469. /** @hidden */
  61470. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  61471. /** @hidden */
  61472. _transmit(effect: Effect, scene: Scene): void;
  61473. protected _buildBlock(state: NodeMaterialBuildState): void;
  61474. protected _dumpPropertiesCode(): string;
  61475. dispose(): void;
  61476. serialize(): any;
  61477. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61478. }
  61479. }
  61480. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  61481. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61482. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61483. import { Nullable } from "babylonjs/types";
  61484. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61485. import { Observable } from "babylonjs/Misc/observable";
  61486. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61487. /**
  61488. * Enum used to define the compatibility state between two connection points
  61489. */
  61490. export enum NodeMaterialConnectionPointCompatibilityStates {
  61491. /** Points are compatibles */
  61492. Compatible = 0,
  61493. /** Points are incompatible because of their types */
  61494. TypeIncompatible = 1,
  61495. /** Points are incompatible because of their targets (vertex vs fragment) */
  61496. TargetIncompatible = 2
  61497. }
  61498. /**
  61499. * Defines the direction of a connection point
  61500. */
  61501. export enum NodeMaterialConnectionPointDirection {
  61502. /** Input */
  61503. Input = 0,
  61504. /** Output */
  61505. Output = 1
  61506. }
  61507. /**
  61508. * Defines a connection point for a block
  61509. */
  61510. export class NodeMaterialConnectionPoint {
  61511. /** @hidden */
  61512. _ownerBlock: NodeMaterialBlock;
  61513. /** @hidden */
  61514. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  61515. private _endpoints;
  61516. private _associatedVariableName;
  61517. private _direction;
  61518. /** @hidden */
  61519. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  61520. /** @hidden */
  61521. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  61522. private _type;
  61523. /** @hidden */
  61524. _enforceAssociatedVariableName: boolean;
  61525. /** Gets the direction of the point */
  61526. get direction(): NodeMaterialConnectionPointDirection;
  61527. /**
  61528. * Gets or sets the additional types supported by this connection point
  61529. */
  61530. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  61531. /**
  61532. * Gets or sets the additional types excluded by this connection point
  61533. */
  61534. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  61535. /**
  61536. * Observable triggered when this point is connected
  61537. */
  61538. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  61539. /**
  61540. * Gets or sets the associated variable name in the shader
  61541. */
  61542. get associatedVariableName(): string;
  61543. set associatedVariableName(value: string);
  61544. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  61545. get innerType(): NodeMaterialBlockConnectionPointTypes;
  61546. /**
  61547. * Gets or sets the connection point type (default is float)
  61548. */
  61549. get type(): NodeMaterialBlockConnectionPointTypes;
  61550. set type(value: NodeMaterialBlockConnectionPointTypes);
  61551. /**
  61552. * Gets or sets the connection point name
  61553. */
  61554. name: string;
  61555. /**
  61556. * Gets or sets a boolean indicating that this connection point can be omitted
  61557. */
  61558. isOptional: boolean;
  61559. /**
  61560. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  61561. */
  61562. define: string;
  61563. /** @hidden */
  61564. _prioritizeVertex: boolean;
  61565. private _target;
  61566. /** Gets or sets the target of that connection point */
  61567. get target(): NodeMaterialBlockTargets;
  61568. set target(value: NodeMaterialBlockTargets);
  61569. /**
  61570. * Gets a boolean indicating that the current point is connected
  61571. */
  61572. get isConnected(): boolean;
  61573. /**
  61574. * Gets a boolean indicating that the current point is connected to an input block
  61575. */
  61576. get isConnectedToInputBlock(): boolean;
  61577. /**
  61578. * Gets a the connected input block (if any)
  61579. */
  61580. get connectInputBlock(): Nullable<InputBlock>;
  61581. /** Get the other side of the connection (if any) */
  61582. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  61583. /** Get the block that owns this connection point */
  61584. get ownerBlock(): NodeMaterialBlock;
  61585. /** Get the block connected on the other side of this connection (if any) */
  61586. get sourceBlock(): Nullable<NodeMaterialBlock>;
  61587. /** Get the block connected on the endpoints of this connection (if any) */
  61588. get connectedBlocks(): Array<NodeMaterialBlock>;
  61589. /** Gets the list of connected endpoints */
  61590. get endpoints(): NodeMaterialConnectionPoint[];
  61591. /** Gets a boolean indicating if that output point is connected to at least one input */
  61592. get hasEndpoints(): boolean;
  61593. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  61594. get isConnectedInVertexShader(): boolean;
  61595. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  61596. get isConnectedInFragmentShader(): boolean;
  61597. /**
  61598. * Creates a new connection point
  61599. * @param name defines the connection point name
  61600. * @param ownerBlock defines the block hosting this connection point
  61601. * @param direction defines the direction of the connection point
  61602. */
  61603. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  61604. /**
  61605. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  61606. * @returns the class name
  61607. */
  61608. getClassName(): string;
  61609. /**
  61610. * Gets a boolean indicating if the current point can be connected to another point
  61611. * @param connectionPoint defines the other connection point
  61612. * @returns a boolean
  61613. */
  61614. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  61615. /**
  61616. * Gets a number indicating if the current point can be connected to another point
  61617. * @param connectionPoint defines the other connection point
  61618. * @returns a number defining the compatibility state
  61619. */
  61620. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  61621. /**
  61622. * Connect this point to another connection point
  61623. * @param connectionPoint defines the other connection point
  61624. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  61625. * @returns the current connection point
  61626. */
  61627. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  61628. /**
  61629. * Disconnect this point from one of his endpoint
  61630. * @param endpoint defines the other connection point
  61631. * @returns the current connection point
  61632. */
  61633. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  61634. /**
  61635. * Serializes this point in a JSON representation
  61636. * @returns the serialized point object
  61637. */
  61638. serialize(): any;
  61639. /**
  61640. * Release resources
  61641. */
  61642. dispose(): void;
  61643. }
  61644. }
  61645. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  61646. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61647. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61648. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61649. import { Mesh } from "babylonjs/Meshes/mesh";
  61650. import { Effect } from "babylonjs/Materials/effect";
  61651. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61652. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61653. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61654. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61655. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61656. /**
  61657. * Block used to add support for vertex skinning (bones)
  61658. */
  61659. export class BonesBlock extends NodeMaterialBlock {
  61660. /**
  61661. * Creates a new BonesBlock
  61662. * @param name defines the block name
  61663. */
  61664. constructor(name: string);
  61665. /**
  61666. * Initialize the block and prepare the context for build
  61667. * @param state defines the state that will be used for the build
  61668. */
  61669. initialize(state: NodeMaterialBuildState): void;
  61670. /**
  61671. * Gets the current class name
  61672. * @returns the class name
  61673. */
  61674. getClassName(): string;
  61675. /**
  61676. * Gets the matrix indices input component
  61677. */
  61678. get matricesIndices(): NodeMaterialConnectionPoint;
  61679. /**
  61680. * Gets the matrix weights input component
  61681. */
  61682. get matricesWeights(): NodeMaterialConnectionPoint;
  61683. /**
  61684. * Gets the extra matrix indices input component
  61685. */
  61686. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  61687. /**
  61688. * Gets the extra matrix weights input component
  61689. */
  61690. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  61691. /**
  61692. * Gets the world input component
  61693. */
  61694. get world(): NodeMaterialConnectionPoint;
  61695. /**
  61696. * Gets the output component
  61697. */
  61698. get output(): NodeMaterialConnectionPoint;
  61699. autoConfigure(material: NodeMaterial): void;
  61700. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61701. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61702. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61703. protected _buildBlock(state: NodeMaterialBuildState): this;
  61704. }
  61705. }
  61706. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  61707. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61708. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61709. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61710. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61711. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61712. /**
  61713. * Block used to add support for instances
  61714. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  61715. */
  61716. export class InstancesBlock extends NodeMaterialBlock {
  61717. /**
  61718. * Creates a new InstancesBlock
  61719. * @param name defines the block name
  61720. */
  61721. constructor(name: string);
  61722. /**
  61723. * Gets the current class name
  61724. * @returns the class name
  61725. */
  61726. getClassName(): string;
  61727. /**
  61728. * Gets the first world row input component
  61729. */
  61730. get world0(): NodeMaterialConnectionPoint;
  61731. /**
  61732. * Gets the second world row input component
  61733. */
  61734. get world1(): NodeMaterialConnectionPoint;
  61735. /**
  61736. * Gets the third world row input component
  61737. */
  61738. get world2(): NodeMaterialConnectionPoint;
  61739. /**
  61740. * Gets the forth world row input component
  61741. */
  61742. get world3(): NodeMaterialConnectionPoint;
  61743. /**
  61744. * Gets the world input component
  61745. */
  61746. get world(): NodeMaterialConnectionPoint;
  61747. /**
  61748. * Gets the output component
  61749. */
  61750. get output(): NodeMaterialConnectionPoint;
  61751. /**
  61752. * Gets the isntanceID component
  61753. */
  61754. get instanceID(): NodeMaterialConnectionPoint;
  61755. autoConfigure(material: NodeMaterial): void;
  61756. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61757. protected _buildBlock(state: NodeMaterialBuildState): this;
  61758. }
  61759. }
  61760. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  61761. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61762. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61763. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61764. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61765. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61766. import { Effect } from "babylonjs/Materials/effect";
  61767. import { Mesh } from "babylonjs/Meshes/mesh";
  61768. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61769. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61770. /**
  61771. * Block used to add morph targets support to vertex shader
  61772. */
  61773. export class MorphTargetsBlock extends NodeMaterialBlock {
  61774. private _repeatableContentAnchor;
  61775. /**
  61776. * Create a new MorphTargetsBlock
  61777. * @param name defines the block name
  61778. */
  61779. constructor(name: string);
  61780. /**
  61781. * Gets the current class name
  61782. * @returns the class name
  61783. */
  61784. getClassName(): string;
  61785. /**
  61786. * Gets the position input component
  61787. */
  61788. get position(): NodeMaterialConnectionPoint;
  61789. /**
  61790. * Gets the normal input component
  61791. */
  61792. get normal(): NodeMaterialConnectionPoint;
  61793. /**
  61794. * Gets the tangent input component
  61795. */
  61796. get tangent(): NodeMaterialConnectionPoint;
  61797. /**
  61798. * Gets the tangent input component
  61799. */
  61800. get uv(): NodeMaterialConnectionPoint;
  61801. /**
  61802. * Gets the position output component
  61803. */
  61804. get positionOutput(): NodeMaterialConnectionPoint;
  61805. /**
  61806. * Gets the normal output component
  61807. */
  61808. get normalOutput(): NodeMaterialConnectionPoint;
  61809. /**
  61810. * Gets the tangent output component
  61811. */
  61812. get tangentOutput(): NodeMaterialConnectionPoint;
  61813. /**
  61814. * Gets the tangent output component
  61815. */
  61816. get uvOutput(): NodeMaterialConnectionPoint;
  61817. initialize(state: NodeMaterialBuildState): void;
  61818. autoConfigure(material: NodeMaterial): void;
  61819. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61820. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61821. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61822. protected _buildBlock(state: NodeMaterialBuildState): this;
  61823. }
  61824. }
  61825. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  61826. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61827. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61828. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61829. import { Nullable } from "babylonjs/types";
  61830. import { Scene } from "babylonjs/scene";
  61831. import { Effect } from "babylonjs/Materials/effect";
  61832. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61833. import { Mesh } from "babylonjs/Meshes/mesh";
  61834. import { Light } from "babylonjs/Lights/light";
  61835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61836. /**
  61837. * Block used to get data information from a light
  61838. */
  61839. export class LightInformationBlock extends NodeMaterialBlock {
  61840. private _lightDataUniformName;
  61841. private _lightColorUniformName;
  61842. private _lightTypeDefineName;
  61843. /**
  61844. * Gets or sets the light associated with this block
  61845. */
  61846. light: Nullable<Light>;
  61847. /**
  61848. * Creates a new LightInformationBlock
  61849. * @param name defines the block name
  61850. */
  61851. constructor(name: string);
  61852. /**
  61853. * Gets the current class name
  61854. * @returns the class name
  61855. */
  61856. getClassName(): string;
  61857. /**
  61858. * Gets the world position input component
  61859. */
  61860. get worldPosition(): NodeMaterialConnectionPoint;
  61861. /**
  61862. * Gets the direction output component
  61863. */
  61864. get direction(): NodeMaterialConnectionPoint;
  61865. /**
  61866. * Gets the direction output component
  61867. */
  61868. get color(): NodeMaterialConnectionPoint;
  61869. /**
  61870. * Gets the direction output component
  61871. */
  61872. get intensity(): NodeMaterialConnectionPoint;
  61873. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61874. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61875. protected _buildBlock(state: NodeMaterialBuildState): this;
  61876. serialize(): any;
  61877. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61878. }
  61879. }
  61880. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  61881. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  61882. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  61883. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  61884. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  61885. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  61886. }
  61887. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  61888. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61889. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61890. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61891. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61892. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61893. import { Effect } from "babylonjs/Materials/effect";
  61894. import { Mesh } from "babylonjs/Meshes/mesh";
  61895. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61896. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61897. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61898. /**
  61899. * Block used to add image processing support to fragment shader
  61900. */
  61901. export class ImageProcessingBlock extends NodeMaterialBlock {
  61902. /**
  61903. * Create a new ImageProcessingBlock
  61904. * @param name defines the block name
  61905. */
  61906. constructor(name: string);
  61907. /**
  61908. * Gets the current class name
  61909. * @returns the class name
  61910. */
  61911. getClassName(): string;
  61912. /**
  61913. * Gets the color input component
  61914. */
  61915. get color(): NodeMaterialConnectionPoint;
  61916. /**
  61917. * Gets the output component
  61918. */
  61919. get output(): NodeMaterialConnectionPoint;
  61920. /**
  61921. * Initialize the block and prepare the context for build
  61922. * @param state defines the state that will be used for the build
  61923. */
  61924. initialize(state: NodeMaterialBuildState): void;
  61925. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61926. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61927. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61928. protected _buildBlock(state: NodeMaterialBuildState): this;
  61929. }
  61930. }
  61931. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  61932. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61933. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61934. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61935. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61936. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61937. import { Effect } from "babylonjs/Materials/effect";
  61938. import { Mesh } from "babylonjs/Meshes/mesh";
  61939. import { Scene } from "babylonjs/scene";
  61940. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  61941. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  61942. /**
  61943. * Block used to pertub normals based on a normal map
  61944. */
  61945. export class PerturbNormalBlock extends NodeMaterialBlock {
  61946. private _tangentSpaceParameterName;
  61947. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61948. invertX: boolean;
  61949. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61950. invertY: boolean;
  61951. /**
  61952. * Create a new PerturbNormalBlock
  61953. * @param name defines the block name
  61954. */
  61955. constructor(name: string);
  61956. /**
  61957. * Gets the current class name
  61958. * @returns the class name
  61959. */
  61960. getClassName(): string;
  61961. /**
  61962. * Gets the world position input component
  61963. */
  61964. get worldPosition(): NodeMaterialConnectionPoint;
  61965. /**
  61966. * Gets the world normal input component
  61967. */
  61968. get worldNormal(): NodeMaterialConnectionPoint;
  61969. /**
  61970. * Gets the world tangent input component
  61971. */
  61972. get worldTangent(): NodeMaterialConnectionPoint;
  61973. /**
  61974. * Gets the uv input component
  61975. */
  61976. get uv(): NodeMaterialConnectionPoint;
  61977. /**
  61978. * Gets the normal map color input component
  61979. */
  61980. get normalMapColor(): NodeMaterialConnectionPoint;
  61981. /**
  61982. * Gets the strength input component
  61983. */
  61984. get strength(): NodeMaterialConnectionPoint;
  61985. /**
  61986. * Gets the output component
  61987. */
  61988. get output(): NodeMaterialConnectionPoint;
  61989. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61990. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61991. autoConfigure(material: NodeMaterial): void;
  61992. protected _buildBlock(state: NodeMaterialBuildState): this;
  61993. protected _dumpPropertiesCode(): string;
  61994. serialize(): any;
  61995. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61996. }
  61997. }
  61998. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  61999. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62000. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62001. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62002. /**
  62003. * Block used to discard a pixel if a value is smaller than a cutoff
  62004. */
  62005. export class DiscardBlock extends NodeMaterialBlock {
  62006. /**
  62007. * Create a new DiscardBlock
  62008. * @param name defines the block name
  62009. */
  62010. constructor(name: string);
  62011. /**
  62012. * Gets the current class name
  62013. * @returns the class name
  62014. */
  62015. getClassName(): string;
  62016. /**
  62017. * Gets the color input component
  62018. */
  62019. get value(): NodeMaterialConnectionPoint;
  62020. /**
  62021. * Gets the cutoff input component
  62022. */
  62023. get cutoff(): NodeMaterialConnectionPoint;
  62024. protected _buildBlock(state: NodeMaterialBuildState): this;
  62025. }
  62026. }
  62027. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  62028. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62029. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62030. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62031. /**
  62032. * Block used to test if the fragment shader is front facing
  62033. */
  62034. export class FrontFacingBlock extends NodeMaterialBlock {
  62035. /**
  62036. * Creates a new FrontFacingBlock
  62037. * @param name defines the block name
  62038. */
  62039. constructor(name: string);
  62040. /**
  62041. * Gets the current class name
  62042. * @returns the class name
  62043. */
  62044. getClassName(): string;
  62045. /**
  62046. * Gets the output component
  62047. */
  62048. get output(): NodeMaterialConnectionPoint;
  62049. protected _buildBlock(state: NodeMaterialBuildState): this;
  62050. }
  62051. }
  62052. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  62053. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62054. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62055. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62056. /**
  62057. * Block used to get the derivative value on x and y of a given input
  62058. */
  62059. export class DerivativeBlock extends NodeMaterialBlock {
  62060. /**
  62061. * Create a new DerivativeBlock
  62062. * @param name defines the block name
  62063. */
  62064. constructor(name: string);
  62065. /**
  62066. * Gets the current class name
  62067. * @returns the class name
  62068. */
  62069. getClassName(): string;
  62070. /**
  62071. * Gets the input component
  62072. */
  62073. get input(): NodeMaterialConnectionPoint;
  62074. /**
  62075. * Gets the derivative output on x
  62076. */
  62077. get dx(): NodeMaterialConnectionPoint;
  62078. /**
  62079. * Gets the derivative output on y
  62080. */
  62081. get dy(): NodeMaterialConnectionPoint;
  62082. protected _buildBlock(state: NodeMaterialBuildState): this;
  62083. }
  62084. }
  62085. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  62086. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  62087. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  62088. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  62089. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  62090. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  62091. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  62092. }
  62093. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  62094. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62095. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62096. import { Mesh } from "babylonjs/Meshes/mesh";
  62097. import { Effect } from "babylonjs/Materials/effect";
  62098. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62099. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62100. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62101. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  62102. /**
  62103. * Block used to add support for scene fog
  62104. */
  62105. export class FogBlock extends NodeMaterialBlock {
  62106. private _fogDistanceName;
  62107. private _fogParameters;
  62108. /**
  62109. * Create a new FogBlock
  62110. * @param name defines the block name
  62111. */
  62112. constructor(name: string);
  62113. /**
  62114. * Gets the current class name
  62115. * @returns the class name
  62116. */
  62117. getClassName(): string;
  62118. /**
  62119. * Gets the world position input component
  62120. */
  62121. get worldPosition(): NodeMaterialConnectionPoint;
  62122. /**
  62123. * Gets the view input component
  62124. */
  62125. get view(): NodeMaterialConnectionPoint;
  62126. /**
  62127. * Gets the color input component
  62128. */
  62129. get input(): NodeMaterialConnectionPoint;
  62130. /**
  62131. * Gets the fog color input component
  62132. */
  62133. get fogColor(): NodeMaterialConnectionPoint;
  62134. /**
  62135. * Gets the output component
  62136. */
  62137. get output(): NodeMaterialConnectionPoint;
  62138. autoConfigure(material: NodeMaterial): void;
  62139. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62140. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62141. protected _buildBlock(state: NodeMaterialBuildState): this;
  62142. }
  62143. }
  62144. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  62145. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62146. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62147. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62148. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62149. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62150. import { Effect } from "babylonjs/Materials/effect";
  62151. import { Mesh } from "babylonjs/Meshes/mesh";
  62152. import { Light } from "babylonjs/Lights/light";
  62153. import { Nullable } from "babylonjs/types";
  62154. import { Scene } from "babylonjs/scene";
  62155. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  62156. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  62157. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  62158. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62159. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  62160. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  62161. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  62162. /**
  62163. * Block used to add light in the fragment shader
  62164. */
  62165. export class LightBlock extends NodeMaterialBlock {
  62166. private _lightId;
  62167. /**
  62168. * Gets or sets the light associated with this block
  62169. */
  62170. light: Nullable<Light>;
  62171. /**
  62172. * Create a new LightBlock
  62173. * @param name defines the block name
  62174. */
  62175. constructor(name: string);
  62176. /**
  62177. * Gets the current class name
  62178. * @returns the class name
  62179. */
  62180. getClassName(): string;
  62181. /**
  62182. * Gets the world position input component
  62183. */
  62184. get worldPosition(): NodeMaterialConnectionPoint;
  62185. /**
  62186. * Gets the world normal input component
  62187. */
  62188. get worldNormal(): NodeMaterialConnectionPoint;
  62189. /**
  62190. * Gets the camera (or eye) position component
  62191. */
  62192. get cameraPosition(): NodeMaterialConnectionPoint;
  62193. /**
  62194. * Gets the glossiness component
  62195. */
  62196. get glossiness(): NodeMaterialConnectionPoint;
  62197. /**
  62198. * Gets the glossinness power component
  62199. */
  62200. get glossPower(): NodeMaterialConnectionPoint;
  62201. /**
  62202. * Gets the diffuse color component
  62203. */
  62204. get diffuseColor(): NodeMaterialConnectionPoint;
  62205. /**
  62206. * Gets the specular color component
  62207. */
  62208. get specularColor(): NodeMaterialConnectionPoint;
  62209. /**
  62210. * Gets the diffuse output component
  62211. */
  62212. get diffuseOutput(): NodeMaterialConnectionPoint;
  62213. /**
  62214. * Gets the specular output component
  62215. */
  62216. get specularOutput(): NodeMaterialConnectionPoint;
  62217. /**
  62218. * Gets the shadow output component
  62219. */
  62220. get shadow(): NodeMaterialConnectionPoint;
  62221. autoConfigure(material: NodeMaterial): void;
  62222. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62223. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62224. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62225. private _injectVertexCode;
  62226. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62227. serialize(): any;
  62228. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62229. }
  62230. }
  62231. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  62232. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  62233. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  62234. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  62235. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  62236. }
  62237. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  62238. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  62239. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  62240. }
  62241. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  62242. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62243. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62244. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62245. /**
  62246. * Block used to multiply 2 values
  62247. */
  62248. export class MultiplyBlock extends NodeMaterialBlock {
  62249. /**
  62250. * Creates a new MultiplyBlock
  62251. * @param name defines the block name
  62252. */
  62253. constructor(name: string);
  62254. /**
  62255. * Gets the current class name
  62256. * @returns the class name
  62257. */
  62258. getClassName(): string;
  62259. /**
  62260. * Gets the left operand input component
  62261. */
  62262. get left(): NodeMaterialConnectionPoint;
  62263. /**
  62264. * Gets the right operand input component
  62265. */
  62266. get right(): NodeMaterialConnectionPoint;
  62267. /**
  62268. * Gets the output component
  62269. */
  62270. get output(): NodeMaterialConnectionPoint;
  62271. protected _buildBlock(state: NodeMaterialBuildState): this;
  62272. }
  62273. }
  62274. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  62275. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62276. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62277. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62278. /**
  62279. * Block used to add 2 vectors
  62280. */
  62281. export class AddBlock extends NodeMaterialBlock {
  62282. /**
  62283. * Creates a new AddBlock
  62284. * @param name defines the block name
  62285. */
  62286. constructor(name: string);
  62287. /**
  62288. * Gets the current class name
  62289. * @returns the class name
  62290. */
  62291. getClassName(): string;
  62292. /**
  62293. * Gets the left operand input component
  62294. */
  62295. get left(): NodeMaterialConnectionPoint;
  62296. /**
  62297. * Gets the right operand input component
  62298. */
  62299. get right(): NodeMaterialConnectionPoint;
  62300. /**
  62301. * Gets the output component
  62302. */
  62303. get output(): NodeMaterialConnectionPoint;
  62304. protected _buildBlock(state: NodeMaterialBuildState): this;
  62305. }
  62306. }
  62307. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  62308. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62309. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62310. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62311. /**
  62312. * Block used to scale a vector by a float
  62313. */
  62314. export class ScaleBlock extends NodeMaterialBlock {
  62315. /**
  62316. * Creates a new ScaleBlock
  62317. * @param name defines the block name
  62318. */
  62319. constructor(name: string);
  62320. /**
  62321. * Gets the current class name
  62322. * @returns the class name
  62323. */
  62324. getClassName(): string;
  62325. /**
  62326. * Gets the input component
  62327. */
  62328. get input(): NodeMaterialConnectionPoint;
  62329. /**
  62330. * Gets the factor input component
  62331. */
  62332. get factor(): NodeMaterialConnectionPoint;
  62333. /**
  62334. * Gets the output component
  62335. */
  62336. get output(): NodeMaterialConnectionPoint;
  62337. protected _buildBlock(state: NodeMaterialBuildState): this;
  62338. }
  62339. }
  62340. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  62341. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62342. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62343. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62344. import { Scene } from "babylonjs/scene";
  62345. /**
  62346. * Block used to clamp a float
  62347. */
  62348. export class ClampBlock extends NodeMaterialBlock {
  62349. /** Gets or sets the minimum range */
  62350. minimum: number;
  62351. /** Gets or sets the maximum range */
  62352. maximum: number;
  62353. /**
  62354. * Creates a new ClampBlock
  62355. * @param name defines the block name
  62356. */
  62357. constructor(name: string);
  62358. /**
  62359. * Gets the current class name
  62360. * @returns the class name
  62361. */
  62362. getClassName(): string;
  62363. /**
  62364. * Gets the value input component
  62365. */
  62366. get value(): NodeMaterialConnectionPoint;
  62367. /**
  62368. * Gets the output component
  62369. */
  62370. get output(): NodeMaterialConnectionPoint;
  62371. protected _buildBlock(state: NodeMaterialBuildState): this;
  62372. protected _dumpPropertiesCode(): string;
  62373. serialize(): any;
  62374. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62375. }
  62376. }
  62377. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  62378. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62379. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62380. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62381. /**
  62382. * Block used to apply a cross product between 2 vectors
  62383. */
  62384. export class CrossBlock extends NodeMaterialBlock {
  62385. /**
  62386. * Creates a new CrossBlock
  62387. * @param name defines the block name
  62388. */
  62389. constructor(name: string);
  62390. /**
  62391. * Gets the current class name
  62392. * @returns the class name
  62393. */
  62394. getClassName(): string;
  62395. /**
  62396. * Gets the left operand input component
  62397. */
  62398. get left(): NodeMaterialConnectionPoint;
  62399. /**
  62400. * Gets the right operand input component
  62401. */
  62402. get right(): NodeMaterialConnectionPoint;
  62403. /**
  62404. * Gets the output component
  62405. */
  62406. get output(): NodeMaterialConnectionPoint;
  62407. protected _buildBlock(state: NodeMaterialBuildState): this;
  62408. }
  62409. }
  62410. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  62411. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62412. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62413. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62414. /**
  62415. * Block used to apply a dot product between 2 vectors
  62416. */
  62417. export class DotBlock extends NodeMaterialBlock {
  62418. /**
  62419. * Creates a new DotBlock
  62420. * @param name defines the block name
  62421. */
  62422. constructor(name: string);
  62423. /**
  62424. * Gets the current class name
  62425. * @returns the class name
  62426. */
  62427. getClassName(): string;
  62428. /**
  62429. * Gets the left operand input component
  62430. */
  62431. get left(): NodeMaterialConnectionPoint;
  62432. /**
  62433. * Gets the right operand input component
  62434. */
  62435. get right(): NodeMaterialConnectionPoint;
  62436. /**
  62437. * Gets the output component
  62438. */
  62439. get output(): NodeMaterialConnectionPoint;
  62440. protected _buildBlock(state: NodeMaterialBuildState): this;
  62441. }
  62442. }
  62443. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  62444. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62445. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62446. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62447. import { Vector2 } from "babylonjs/Maths/math.vector";
  62448. import { Scene } from "babylonjs/scene";
  62449. /**
  62450. * Block used to remap a float from a range to a new one
  62451. */
  62452. export class RemapBlock extends NodeMaterialBlock {
  62453. /**
  62454. * Gets or sets the source range
  62455. */
  62456. sourceRange: Vector2;
  62457. /**
  62458. * Gets or sets the target range
  62459. */
  62460. targetRange: Vector2;
  62461. /**
  62462. * Creates a new RemapBlock
  62463. * @param name defines the block name
  62464. */
  62465. constructor(name: string);
  62466. /**
  62467. * Gets the current class name
  62468. * @returns the class name
  62469. */
  62470. getClassName(): string;
  62471. /**
  62472. * Gets the input component
  62473. */
  62474. get input(): NodeMaterialConnectionPoint;
  62475. /**
  62476. * Gets the source min input component
  62477. */
  62478. get sourceMin(): NodeMaterialConnectionPoint;
  62479. /**
  62480. * Gets the source max input component
  62481. */
  62482. get sourceMax(): NodeMaterialConnectionPoint;
  62483. /**
  62484. * Gets the target min input component
  62485. */
  62486. get targetMin(): NodeMaterialConnectionPoint;
  62487. /**
  62488. * Gets the target max input component
  62489. */
  62490. get targetMax(): NodeMaterialConnectionPoint;
  62491. /**
  62492. * Gets the output component
  62493. */
  62494. get output(): NodeMaterialConnectionPoint;
  62495. protected _buildBlock(state: NodeMaterialBuildState): this;
  62496. protected _dumpPropertiesCode(): string;
  62497. serialize(): any;
  62498. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62499. }
  62500. }
  62501. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  62502. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62503. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62504. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62505. /**
  62506. * Block used to normalize a vector
  62507. */
  62508. export class NormalizeBlock extends NodeMaterialBlock {
  62509. /**
  62510. * Creates a new NormalizeBlock
  62511. * @param name defines the block name
  62512. */
  62513. constructor(name: string);
  62514. /**
  62515. * Gets the current class name
  62516. * @returns the class name
  62517. */
  62518. getClassName(): string;
  62519. /**
  62520. * Gets the input component
  62521. */
  62522. get input(): NodeMaterialConnectionPoint;
  62523. /**
  62524. * Gets the output component
  62525. */
  62526. get output(): NodeMaterialConnectionPoint;
  62527. protected _buildBlock(state: NodeMaterialBuildState): this;
  62528. }
  62529. }
  62530. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  62531. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62532. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62533. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62534. import { Scene } from "babylonjs/scene";
  62535. /**
  62536. * Operations supported by the Trigonometry block
  62537. */
  62538. export enum TrigonometryBlockOperations {
  62539. /** Cos */
  62540. Cos = 0,
  62541. /** Sin */
  62542. Sin = 1,
  62543. /** Abs */
  62544. Abs = 2,
  62545. /** Exp */
  62546. Exp = 3,
  62547. /** Exp2 */
  62548. Exp2 = 4,
  62549. /** Round */
  62550. Round = 5,
  62551. /** Floor */
  62552. Floor = 6,
  62553. /** Ceiling */
  62554. Ceiling = 7,
  62555. /** Square root */
  62556. Sqrt = 8,
  62557. /** Log */
  62558. Log = 9,
  62559. /** Tangent */
  62560. Tan = 10,
  62561. /** Arc tangent */
  62562. ArcTan = 11,
  62563. /** Arc cosinus */
  62564. ArcCos = 12,
  62565. /** Arc sinus */
  62566. ArcSin = 13,
  62567. /** Fraction */
  62568. Fract = 14,
  62569. /** Sign */
  62570. Sign = 15,
  62571. /** To radians (from degrees) */
  62572. Radians = 16,
  62573. /** To degrees (from radians) */
  62574. Degrees = 17
  62575. }
  62576. /**
  62577. * Block used to apply trigonometry operation to floats
  62578. */
  62579. export class TrigonometryBlock extends NodeMaterialBlock {
  62580. /**
  62581. * Gets or sets the operation applied by the block
  62582. */
  62583. operation: TrigonometryBlockOperations;
  62584. /**
  62585. * Creates a new TrigonometryBlock
  62586. * @param name defines the block name
  62587. */
  62588. constructor(name: string);
  62589. /**
  62590. * Gets the current class name
  62591. * @returns the class name
  62592. */
  62593. getClassName(): string;
  62594. /**
  62595. * Gets the input component
  62596. */
  62597. get input(): NodeMaterialConnectionPoint;
  62598. /**
  62599. * Gets the output component
  62600. */
  62601. get output(): NodeMaterialConnectionPoint;
  62602. protected _buildBlock(state: NodeMaterialBuildState): this;
  62603. serialize(): any;
  62604. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62605. protected _dumpPropertiesCode(): string;
  62606. }
  62607. }
  62608. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  62609. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62610. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62611. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62612. /**
  62613. * Block used to create a Color3/4 out of individual inputs (one for each component)
  62614. */
  62615. export class ColorMergerBlock extends NodeMaterialBlock {
  62616. /**
  62617. * Create a new ColorMergerBlock
  62618. * @param name defines the block name
  62619. */
  62620. constructor(name: string);
  62621. /**
  62622. * Gets the current class name
  62623. * @returns the class name
  62624. */
  62625. getClassName(): string;
  62626. /**
  62627. * Gets the rgb component (input)
  62628. */
  62629. get rgbIn(): NodeMaterialConnectionPoint;
  62630. /**
  62631. * Gets the r component (input)
  62632. */
  62633. get r(): NodeMaterialConnectionPoint;
  62634. /**
  62635. * Gets the g component (input)
  62636. */
  62637. get g(): NodeMaterialConnectionPoint;
  62638. /**
  62639. * Gets the b component (input)
  62640. */
  62641. get b(): NodeMaterialConnectionPoint;
  62642. /**
  62643. * Gets the a component (input)
  62644. */
  62645. get a(): NodeMaterialConnectionPoint;
  62646. /**
  62647. * Gets the rgba component (output)
  62648. */
  62649. get rgba(): NodeMaterialConnectionPoint;
  62650. /**
  62651. * Gets the rgb component (output)
  62652. */
  62653. get rgbOut(): NodeMaterialConnectionPoint;
  62654. /**
  62655. * Gets the rgb component (output)
  62656. * @deprecated Please use rgbOut instead.
  62657. */
  62658. get rgb(): NodeMaterialConnectionPoint;
  62659. protected _buildBlock(state: NodeMaterialBuildState): this;
  62660. }
  62661. }
  62662. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  62663. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62664. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62665. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62666. /**
  62667. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  62668. */
  62669. export class VectorMergerBlock extends NodeMaterialBlock {
  62670. /**
  62671. * Create a new VectorMergerBlock
  62672. * @param name defines the block name
  62673. */
  62674. constructor(name: string);
  62675. /**
  62676. * Gets the current class name
  62677. * @returns the class name
  62678. */
  62679. getClassName(): string;
  62680. /**
  62681. * Gets the xyz component (input)
  62682. */
  62683. get xyzIn(): NodeMaterialConnectionPoint;
  62684. /**
  62685. * Gets the xy component (input)
  62686. */
  62687. get xyIn(): NodeMaterialConnectionPoint;
  62688. /**
  62689. * Gets the x component (input)
  62690. */
  62691. get x(): NodeMaterialConnectionPoint;
  62692. /**
  62693. * Gets the y component (input)
  62694. */
  62695. get y(): NodeMaterialConnectionPoint;
  62696. /**
  62697. * Gets the z component (input)
  62698. */
  62699. get z(): NodeMaterialConnectionPoint;
  62700. /**
  62701. * Gets the w component (input)
  62702. */
  62703. get w(): NodeMaterialConnectionPoint;
  62704. /**
  62705. * Gets the xyzw component (output)
  62706. */
  62707. get xyzw(): NodeMaterialConnectionPoint;
  62708. /**
  62709. * Gets the xyz component (output)
  62710. */
  62711. get xyzOut(): NodeMaterialConnectionPoint;
  62712. /**
  62713. * Gets the xy component (output)
  62714. */
  62715. get xyOut(): NodeMaterialConnectionPoint;
  62716. /**
  62717. * Gets the xy component (output)
  62718. * @deprecated Please use xyOut instead.
  62719. */
  62720. get xy(): NodeMaterialConnectionPoint;
  62721. /**
  62722. * Gets the xyz component (output)
  62723. * @deprecated Please use xyzOut instead.
  62724. */
  62725. get xyz(): NodeMaterialConnectionPoint;
  62726. protected _buildBlock(state: NodeMaterialBuildState): this;
  62727. }
  62728. }
  62729. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  62730. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62731. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62732. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62733. /**
  62734. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  62735. */
  62736. export class ColorSplitterBlock extends NodeMaterialBlock {
  62737. /**
  62738. * Create a new ColorSplitterBlock
  62739. * @param name defines the block name
  62740. */
  62741. constructor(name: string);
  62742. /**
  62743. * Gets the current class name
  62744. * @returns the class name
  62745. */
  62746. getClassName(): string;
  62747. /**
  62748. * Gets the rgba component (input)
  62749. */
  62750. get rgba(): NodeMaterialConnectionPoint;
  62751. /**
  62752. * Gets the rgb component (input)
  62753. */
  62754. get rgbIn(): NodeMaterialConnectionPoint;
  62755. /**
  62756. * Gets the rgb component (output)
  62757. */
  62758. get rgbOut(): NodeMaterialConnectionPoint;
  62759. /**
  62760. * Gets the r component (output)
  62761. */
  62762. get r(): NodeMaterialConnectionPoint;
  62763. /**
  62764. * Gets the g component (output)
  62765. */
  62766. get g(): NodeMaterialConnectionPoint;
  62767. /**
  62768. * Gets the b component (output)
  62769. */
  62770. get b(): NodeMaterialConnectionPoint;
  62771. /**
  62772. * Gets the a component (output)
  62773. */
  62774. get a(): NodeMaterialConnectionPoint;
  62775. protected _inputRename(name: string): string;
  62776. protected _outputRename(name: string): string;
  62777. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62778. }
  62779. }
  62780. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  62781. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62782. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62783. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62784. /**
  62785. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  62786. */
  62787. export class VectorSplitterBlock extends NodeMaterialBlock {
  62788. /**
  62789. * Create a new VectorSplitterBlock
  62790. * @param name defines the block name
  62791. */
  62792. constructor(name: string);
  62793. /**
  62794. * Gets the current class name
  62795. * @returns the class name
  62796. */
  62797. getClassName(): string;
  62798. /**
  62799. * Gets the xyzw component (input)
  62800. */
  62801. get xyzw(): NodeMaterialConnectionPoint;
  62802. /**
  62803. * Gets the xyz component (input)
  62804. */
  62805. get xyzIn(): NodeMaterialConnectionPoint;
  62806. /**
  62807. * Gets the xy component (input)
  62808. */
  62809. get xyIn(): NodeMaterialConnectionPoint;
  62810. /**
  62811. * Gets the xyz component (output)
  62812. */
  62813. get xyzOut(): NodeMaterialConnectionPoint;
  62814. /**
  62815. * Gets the xy component (output)
  62816. */
  62817. get xyOut(): NodeMaterialConnectionPoint;
  62818. /**
  62819. * Gets the x component (output)
  62820. */
  62821. get x(): NodeMaterialConnectionPoint;
  62822. /**
  62823. * Gets the y component (output)
  62824. */
  62825. get y(): NodeMaterialConnectionPoint;
  62826. /**
  62827. * Gets the z component (output)
  62828. */
  62829. get z(): NodeMaterialConnectionPoint;
  62830. /**
  62831. * Gets the w component (output)
  62832. */
  62833. get w(): NodeMaterialConnectionPoint;
  62834. protected _inputRename(name: string): string;
  62835. protected _outputRename(name: string): string;
  62836. protected _buildBlock(state: NodeMaterialBuildState): this;
  62837. }
  62838. }
  62839. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  62840. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62841. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62842. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62843. /**
  62844. * Block used to lerp between 2 values
  62845. */
  62846. export class LerpBlock extends NodeMaterialBlock {
  62847. /**
  62848. * Creates a new LerpBlock
  62849. * @param name defines the block name
  62850. */
  62851. constructor(name: string);
  62852. /**
  62853. * Gets the current class name
  62854. * @returns the class name
  62855. */
  62856. getClassName(): string;
  62857. /**
  62858. * Gets the left operand input component
  62859. */
  62860. get left(): NodeMaterialConnectionPoint;
  62861. /**
  62862. * Gets the right operand input component
  62863. */
  62864. get right(): NodeMaterialConnectionPoint;
  62865. /**
  62866. * Gets the gradient operand input component
  62867. */
  62868. get gradient(): NodeMaterialConnectionPoint;
  62869. /**
  62870. * Gets the output component
  62871. */
  62872. get output(): NodeMaterialConnectionPoint;
  62873. protected _buildBlock(state: NodeMaterialBuildState): this;
  62874. }
  62875. }
  62876. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  62877. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62878. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62879. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62880. /**
  62881. * Block used to divide 2 vectors
  62882. */
  62883. export class DivideBlock extends NodeMaterialBlock {
  62884. /**
  62885. * Creates a new DivideBlock
  62886. * @param name defines the block name
  62887. */
  62888. constructor(name: string);
  62889. /**
  62890. * Gets the current class name
  62891. * @returns the class name
  62892. */
  62893. getClassName(): string;
  62894. /**
  62895. * Gets the left operand input component
  62896. */
  62897. get left(): NodeMaterialConnectionPoint;
  62898. /**
  62899. * Gets the right operand input component
  62900. */
  62901. get right(): NodeMaterialConnectionPoint;
  62902. /**
  62903. * Gets the output component
  62904. */
  62905. get output(): NodeMaterialConnectionPoint;
  62906. protected _buildBlock(state: NodeMaterialBuildState): this;
  62907. }
  62908. }
  62909. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  62910. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62911. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62912. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62913. /**
  62914. * Block used to subtract 2 vectors
  62915. */
  62916. export class SubtractBlock extends NodeMaterialBlock {
  62917. /**
  62918. * Creates a new SubtractBlock
  62919. * @param name defines the block name
  62920. */
  62921. constructor(name: string);
  62922. /**
  62923. * Gets the current class name
  62924. * @returns the class name
  62925. */
  62926. getClassName(): string;
  62927. /**
  62928. * Gets the left operand input component
  62929. */
  62930. get left(): NodeMaterialConnectionPoint;
  62931. /**
  62932. * Gets the right operand input component
  62933. */
  62934. get right(): NodeMaterialConnectionPoint;
  62935. /**
  62936. * Gets the output component
  62937. */
  62938. get output(): NodeMaterialConnectionPoint;
  62939. protected _buildBlock(state: NodeMaterialBuildState): this;
  62940. }
  62941. }
  62942. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  62943. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62944. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62945. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62946. /**
  62947. * Block used to step a value
  62948. */
  62949. export class StepBlock extends NodeMaterialBlock {
  62950. /**
  62951. * Creates a new StepBlock
  62952. * @param name defines the block name
  62953. */
  62954. constructor(name: string);
  62955. /**
  62956. * Gets the current class name
  62957. * @returns the class name
  62958. */
  62959. getClassName(): string;
  62960. /**
  62961. * Gets the value operand input component
  62962. */
  62963. get value(): NodeMaterialConnectionPoint;
  62964. /**
  62965. * Gets the edge operand input component
  62966. */
  62967. get edge(): NodeMaterialConnectionPoint;
  62968. /**
  62969. * Gets the output component
  62970. */
  62971. get output(): NodeMaterialConnectionPoint;
  62972. protected _buildBlock(state: NodeMaterialBuildState): this;
  62973. }
  62974. }
  62975. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  62976. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62977. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62978. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62979. /**
  62980. * Block used to get the opposite (1 - x) of a value
  62981. */
  62982. export class OneMinusBlock extends NodeMaterialBlock {
  62983. /**
  62984. * Creates a new OneMinusBlock
  62985. * @param name defines the block name
  62986. */
  62987. constructor(name: string);
  62988. /**
  62989. * Gets the current class name
  62990. * @returns the class name
  62991. */
  62992. getClassName(): string;
  62993. /**
  62994. * Gets the input component
  62995. */
  62996. get input(): NodeMaterialConnectionPoint;
  62997. /**
  62998. * Gets the output component
  62999. */
  63000. get output(): NodeMaterialConnectionPoint;
  63001. protected _buildBlock(state: NodeMaterialBuildState): this;
  63002. }
  63003. }
  63004. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  63005. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63006. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63007. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63008. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  63009. /**
  63010. * Block used to get the view direction
  63011. */
  63012. export class ViewDirectionBlock extends NodeMaterialBlock {
  63013. /**
  63014. * Creates a new ViewDirectionBlock
  63015. * @param name defines the block name
  63016. */
  63017. constructor(name: string);
  63018. /**
  63019. * Gets the current class name
  63020. * @returns the class name
  63021. */
  63022. getClassName(): string;
  63023. /**
  63024. * Gets the world position component
  63025. */
  63026. get worldPosition(): NodeMaterialConnectionPoint;
  63027. /**
  63028. * Gets the camera position component
  63029. */
  63030. get cameraPosition(): NodeMaterialConnectionPoint;
  63031. /**
  63032. * Gets the output component
  63033. */
  63034. get output(): NodeMaterialConnectionPoint;
  63035. autoConfigure(material: NodeMaterial): void;
  63036. protected _buildBlock(state: NodeMaterialBuildState): this;
  63037. }
  63038. }
  63039. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  63040. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63041. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63042. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63043. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  63044. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  63045. /**
  63046. * Block used to compute fresnel value
  63047. */
  63048. export class FresnelBlock extends NodeMaterialBlock {
  63049. /**
  63050. * Create a new FresnelBlock
  63051. * @param name defines the block name
  63052. */
  63053. constructor(name: string);
  63054. /**
  63055. * Gets the current class name
  63056. * @returns the class name
  63057. */
  63058. getClassName(): string;
  63059. /**
  63060. * Gets the world normal input component
  63061. */
  63062. get worldNormal(): NodeMaterialConnectionPoint;
  63063. /**
  63064. * Gets the view direction input component
  63065. */
  63066. get viewDirection(): NodeMaterialConnectionPoint;
  63067. /**
  63068. * Gets the bias input component
  63069. */
  63070. get bias(): NodeMaterialConnectionPoint;
  63071. /**
  63072. * Gets the camera (or eye) position component
  63073. */
  63074. get power(): NodeMaterialConnectionPoint;
  63075. /**
  63076. * Gets the fresnel output component
  63077. */
  63078. get fresnel(): NodeMaterialConnectionPoint;
  63079. autoConfigure(material: NodeMaterial): void;
  63080. protected _buildBlock(state: NodeMaterialBuildState): this;
  63081. }
  63082. }
  63083. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  63084. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63085. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63086. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63087. /**
  63088. * Block used to get the max of 2 values
  63089. */
  63090. export class MaxBlock extends NodeMaterialBlock {
  63091. /**
  63092. * Creates a new MaxBlock
  63093. * @param name defines the block name
  63094. */
  63095. constructor(name: string);
  63096. /**
  63097. * Gets the current class name
  63098. * @returns the class name
  63099. */
  63100. getClassName(): string;
  63101. /**
  63102. * Gets the left operand input component
  63103. */
  63104. get left(): NodeMaterialConnectionPoint;
  63105. /**
  63106. * Gets the right operand input component
  63107. */
  63108. get right(): NodeMaterialConnectionPoint;
  63109. /**
  63110. * Gets the output component
  63111. */
  63112. get output(): NodeMaterialConnectionPoint;
  63113. protected _buildBlock(state: NodeMaterialBuildState): this;
  63114. }
  63115. }
  63116. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  63117. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63118. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63119. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63120. /**
  63121. * Block used to get the min of 2 values
  63122. */
  63123. export class MinBlock extends NodeMaterialBlock {
  63124. /**
  63125. * Creates a new MinBlock
  63126. * @param name defines the block name
  63127. */
  63128. constructor(name: string);
  63129. /**
  63130. * Gets the current class name
  63131. * @returns the class name
  63132. */
  63133. getClassName(): string;
  63134. /**
  63135. * Gets the left operand input component
  63136. */
  63137. get left(): NodeMaterialConnectionPoint;
  63138. /**
  63139. * Gets the right operand input component
  63140. */
  63141. get right(): NodeMaterialConnectionPoint;
  63142. /**
  63143. * Gets the output component
  63144. */
  63145. get output(): NodeMaterialConnectionPoint;
  63146. protected _buildBlock(state: NodeMaterialBuildState): this;
  63147. }
  63148. }
  63149. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  63150. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63151. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63152. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63153. /**
  63154. * Block used to get the distance between 2 values
  63155. */
  63156. export class DistanceBlock extends NodeMaterialBlock {
  63157. /**
  63158. * Creates a new DistanceBlock
  63159. * @param name defines the block name
  63160. */
  63161. constructor(name: string);
  63162. /**
  63163. * Gets the current class name
  63164. * @returns the class name
  63165. */
  63166. getClassName(): string;
  63167. /**
  63168. * Gets the left operand input component
  63169. */
  63170. get left(): NodeMaterialConnectionPoint;
  63171. /**
  63172. * Gets the right operand input component
  63173. */
  63174. get right(): NodeMaterialConnectionPoint;
  63175. /**
  63176. * Gets the output component
  63177. */
  63178. get output(): NodeMaterialConnectionPoint;
  63179. protected _buildBlock(state: NodeMaterialBuildState): this;
  63180. }
  63181. }
  63182. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  63183. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63184. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63185. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63186. /**
  63187. * Block used to get the length of a vector
  63188. */
  63189. export class LengthBlock extends NodeMaterialBlock {
  63190. /**
  63191. * Creates a new LengthBlock
  63192. * @param name defines the block name
  63193. */
  63194. constructor(name: string);
  63195. /**
  63196. * Gets the current class name
  63197. * @returns the class name
  63198. */
  63199. getClassName(): string;
  63200. /**
  63201. * Gets the value input component
  63202. */
  63203. get value(): NodeMaterialConnectionPoint;
  63204. /**
  63205. * Gets the output component
  63206. */
  63207. get output(): NodeMaterialConnectionPoint;
  63208. protected _buildBlock(state: NodeMaterialBuildState): this;
  63209. }
  63210. }
  63211. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  63212. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63213. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63214. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63215. /**
  63216. * Block used to get negative version of a value (i.e. x * -1)
  63217. */
  63218. export class NegateBlock extends NodeMaterialBlock {
  63219. /**
  63220. * Creates a new NegateBlock
  63221. * @param name defines the block name
  63222. */
  63223. constructor(name: string);
  63224. /**
  63225. * Gets the current class name
  63226. * @returns the class name
  63227. */
  63228. getClassName(): string;
  63229. /**
  63230. * Gets the value input component
  63231. */
  63232. get value(): NodeMaterialConnectionPoint;
  63233. /**
  63234. * Gets the output component
  63235. */
  63236. get output(): NodeMaterialConnectionPoint;
  63237. protected _buildBlock(state: NodeMaterialBuildState): this;
  63238. }
  63239. }
  63240. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  63241. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63242. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63243. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63244. /**
  63245. * Block used to get the value of the first parameter raised to the power of the second
  63246. */
  63247. export class PowBlock extends NodeMaterialBlock {
  63248. /**
  63249. * Creates a new PowBlock
  63250. * @param name defines the block name
  63251. */
  63252. constructor(name: string);
  63253. /**
  63254. * Gets the current class name
  63255. * @returns the class name
  63256. */
  63257. getClassName(): string;
  63258. /**
  63259. * Gets the value operand input component
  63260. */
  63261. get value(): NodeMaterialConnectionPoint;
  63262. /**
  63263. * Gets the power operand input component
  63264. */
  63265. get power(): NodeMaterialConnectionPoint;
  63266. /**
  63267. * Gets the output component
  63268. */
  63269. get output(): NodeMaterialConnectionPoint;
  63270. protected _buildBlock(state: NodeMaterialBuildState): this;
  63271. }
  63272. }
  63273. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  63274. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63275. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63276. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63277. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63278. /**
  63279. * Block used to get a random number
  63280. */
  63281. export class RandomNumberBlock extends NodeMaterialBlock {
  63282. /**
  63283. * Creates a new RandomNumberBlock
  63284. * @param name defines the block name
  63285. */
  63286. constructor(name: string);
  63287. /**
  63288. * Gets the current class name
  63289. * @returns the class name
  63290. */
  63291. getClassName(): string;
  63292. /**
  63293. * Gets the seed input component
  63294. */
  63295. get seed(): NodeMaterialConnectionPoint;
  63296. /**
  63297. * Gets the output component
  63298. */
  63299. get output(): NodeMaterialConnectionPoint;
  63300. protected _buildBlock(state: NodeMaterialBuildState): this;
  63301. }
  63302. }
  63303. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  63304. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63305. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63306. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63307. /**
  63308. * Block used to compute arc tangent of 2 values
  63309. */
  63310. export class ArcTan2Block extends NodeMaterialBlock {
  63311. /**
  63312. * Creates a new ArcTan2Block
  63313. * @param name defines the block name
  63314. */
  63315. constructor(name: string);
  63316. /**
  63317. * Gets the current class name
  63318. * @returns the class name
  63319. */
  63320. getClassName(): string;
  63321. /**
  63322. * Gets the x operand input component
  63323. */
  63324. get x(): NodeMaterialConnectionPoint;
  63325. /**
  63326. * Gets the y operand input component
  63327. */
  63328. get y(): NodeMaterialConnectionPoint;
  63329. /**
  63330. * Gets the output component
  63331. */
  63332. get output(): NodeMaterialConnectionPoint;
  63333. protected _buildBlock(state: NodeMaterialBuildState): this;
  63334. }
  63335. }
  63336. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  63337. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63338. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63339. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63340. /**
  63341. * Block used to smooth step a value
  63342. */
  63343. export class SmoothStepBlock extends NodeMaterialBlock {
  63344. /**
  63345. * Creates a new SmoothStepBlock
  63346. * @param name defines the block name
  63347. */
  63348. constructor(name: string);
  63349. /**
  63350. * Gets the current class name
  63351. * @returns the class name
  63352. */
  63353. getClassName(): string;
  63354. /**
  63355. * Gets the value operand input component
  63356. */
  63357. get value(): NodeMaterialConnectionPoint;
  63358. /**
  63359. * Gets the first edge operand input component
  63360. */
  63361. get edge0(): NodeMaterialConnectionPoint;
  63362. /**
  63363. * Gets the second edge operand input component
  63364. */
  63365. get edge1(): NodeMaterialConnectionPoint;
  63366. /**
  63367. * Gets the output component
  63368. */
  63369. get output(): NodeMaterialConnectionPoint;
  63370. protected _buildBlock(state: NodeMaterialBuildState): this;
  63371. }
  63372. }
  63373. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  63374. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63375. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63376. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63377. /**
  63378. * Block used to get the reciprocal (1 / x) of a value
  63379. */
  63380. export class ReciprocalBlock extends NodeMaterialBlock {
  63381. /**
  63382. * Creates a new ReciprocalBlock
  63383. * @param name defines the block name
  63384. */
  63385. constructor(name: string);
  63386. /**
  63387. * Gets the current class name
  63388. * @returns the class name
  63389. */
  63390. getClassName(): string;
  63391. /**
  63392. * Gets the input component
  63393. */
  63394. get input(): NodeMaterialConnectionPoint;
  63395. /**
  63396. * Gets the output component
  63397. */
  63398. get output(): NodeMaterialConnectionPoint;
  63399. protected _buildBlock(state: NodeMaterialBuildState): this;
  63400. }
  63401. }
  63402. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  63403. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63404. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63405. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63406. /**
  63407. * Block used to replace a color by another one
  63408. */
  63409. export class ReplaceColorBlock extends NodeMaterialBlock {
  63410. /**
  63411. * Creates a new ReplaceColorBlock
  63412. * @param name defines the block name
  63413. */
  63414. constructor(name: string);
  63415. /**
  63416. * Gets the current class name
  63417. * @returns the class name
  63418. */
  63419. getClassName(): string;
  63420. /**
  63421. * Gets the value input component
  63422. */
  63423. get value(): NodeMaterialConnectionPoint;
  63424. /**
  63425. * Gets the reference input component
  63426. */
  63427. get reference(): NodeMaterialConnectionPoint;
  63428. /**
  63429. * Gets the distance input component
  63430. */
  63431. get distance(): NodeMaterialConnectionPoint;
  63432. /**
  63433. * Gets the replacement input component
  63434. */
  63435. get replacement(): NodeMaterialConnectionPoint;
  63436. /**
  63437. * Gets the output component
  63438. */
  63439. get output(): NodeMaterialConnectionPoint;
  63440. protected _buildBlock(state: NodeMaterialBuildState): this;
  63441. }
  63442. }
  63443. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  63444. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63445. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63446. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63447. /**
  63448. * Block used to posterize a value
  63449. * @see https://en.wikipedia.org/wiki/Posterization
  63450. */
  63451. export class PosterizeBlock extends NodeMaterialBlock {
  63452. /**
  63453. * Creates a new PosterizeBlock
  63454. * @param name defines the block name
  63455. */
  63456. constructor(name: string);
  63457. /**
  63458. * Gets the current class name
  63459. * @returns the class name
  63460. */
  63461. getClassName(): string;
  63462. /**
  63463. * Gets the value input component
  63464. */
  63465. get value(): NodeMaterialConnectionPoint;
  63466. /**
  63467. * Gets the steps input component
  63468. */
  63469. get steps(): NodeMaterialConnectionPoint;
  63470. /**
  63471. * Gets the output component
  63472. */
  63473. get output(): NodeMaterialConnectionPoint;
  63474. protected _buildBlock(state: NodeMaterialBuildState): this;
  63475. }
  63476. }
  63477. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  63478. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63479. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63480. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63481. import { Scene } from "babylonjs/scene";
  63482. /**
  63483. * Operations supported by the Wave block
  63484. */
  63485. export enum WaveBlockKind {
  63486. /** SawTooth */
  63487. SawTooth = 0,
  63488. /** Square */
  63489. Square = 1,
  63490. /** Triangle */
  63491. Triangle = 2
  63492. }
  63493. /**
  63494. * Block used to apply wave operation to floats
  63495. */
  63496. export class WaveBlock extends NodeMaterialBlock {
  63497. /**
  63498. * Gets or sets the kibnd of wave to be applied by the block
  63499. */
  63500. kind: WaveBlockKind;
  63501. /**
  63502. * Creates a new WaveBlock
  63503. * @param name defines the block name
  63504. */
  63505. constructor(name: string);
  63506. /**
  63507. * Gets the current class name
  63508. * @returns the class name
  63509. */
  63510. getClassName(): string;
  63511. /**
  63512. * Gets the input component
  63513. */
  63514. get input(): NodeMaterialConnectionPoint;
  63515. /**
  63516. * Gets the output component
  63517. */
  63518. get output(): NodeMaterialConnectionPoint;
  63519. protected _buildBlock(state: NodeMaterialBuildState): this;
  63520. serialize(): any;
  63521. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63522. }
  63523. }
  63524. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  63525. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63526. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63527. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63528. import { Color3 } from "babylonjs/Maths/math.color";
  63529. import { Scene } from "babylonjs/scene";
  63530. /**
  63531. * Class used to store a color step for the GradientBlock
  63532. */
  63533. export class GradientBlockColorStep {
  63534. /**
  63535. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63536. */
  63537. step: number;
  63538. /**
  63539. * Gets or sets the color associated with this step
  63540. */
  63541. color: Color3;
  63542. /**
  63543. * Creates a new GradientBlockColorStep
  63544. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  63545. * @param color defines the color associated with this step
  63546. */
  63547. constructor(
  63548. /**
  63549. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63550. */
  63551. step: number,
  63552. /**
  63553. * Gets or sets the color associated with this step
  63554. */
  63555. color: Color3);
  63556. }
  63557. /**
  63558. * Block used to return a color from a gradient based on an input value between 0 and 1
  63559. */
  63560. export class GradientBlock extends NodeMaterialBlock {
  63561. /**
  63562. * Gets or sets the list of color steps
  63563. */
  63564. colorSteps: GradientBlockColorStep[];
  63565. /**
  63566. * Creates a new GradientBlock
  63567. * @param name defines the block name
  63568. */
  63569. constructor(name: string);
  63570. /**
  63571. * Gets the current class name
  63572. * @returns the class name
  63573. */
  63574. getClassName(): string;
  63575. /**
  63576. * Gets the gradient input component
  63577. */
  63578. get gradient(): NodeMaterialConnectionPoint;
  63579. /**
  63580. * Gets the output component
  63581. */
  63582. get output(): NodeMaterialConnectionPoint;
  63583. private _writeColorConstant;
  63584. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63585. serialize(): any;
  63586. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63587. protected _dumpPropertiesCode(): string;
  63588. }
  63589. }
  63590. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  63591. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63592. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63593. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63594. /**
  63595. * Block used to normalize lerp between 2 values
  63596. */
  63597. export class NLerpBlock extends NodeMaterialBlock {
  63598. /**
  63599. * Creates a new NLerpBlock
  63600. * @param name defines the block name
  63601. */
  63602. constructor(name: string);
  63603. /**
  63604. * Gets the current class name
  63605. * @returns the class name
  63606. */
  63607. getClassName(): string;
  63608. /**
  63609. * Gets the left operand input component
  63610. */
  63611. get left(): NodeMaterialConnectionPoint;
  63612. /**
  63613. * Gets the right operand input component
  63614. */
  63615. get right(): NodeMaterialConnectionPoint;
  63616. /**
  63617. * Gets the gradient operand input component
  63618. */
  63619. get gradient(): NodeMaterialConnectionPoint;
  63620. /**
  63621. * Gets the output component
  63622. */
  63623. get output(): NodeMaterialConnectionPoint;
  63624. protected _buildBlock(state: NodeMaterialBuildState): this;
  63625. }
  63626. }
  63627. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  63628. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63629. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63630. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63631. import { Scene } from "babylonjs/scene";
  63632. /**
  63633. * block used to Generate a Worley Noise 3D Noise Pattern
  63634. */
  63635. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  63636. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63637. manhattanDistance: boolean;
  63638. /**
  63639. * Creates a new WorleyNoise3DBlock
  63640. * @param name defines the block name
  63641. */
  63642. constructor(name: string);
  63643. /**
  63644. * Gets the current class name
  63645. * @returns the class name
  63646. */
  63647. getClassName(): string;
  63648. /**
  63649. * Gets the seed input component
  63650. */
  63651. get seed(): NodeMaterialConnectionPoint;
  63652. /**
  63653. * Gets the jitter input component
  63654. */
  63655. get jitter(): NodeMaterialConnectionPoint;
  63656. /**
  63657. * Gets the output component
  63658. */
  63659. get output(): NodeMaterialConnectionPoint;
  63660. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63661. /**
  63662. * Exposes the properties to the UI?
  63663. */
  63664. protected _dumpPropertiesCode(): string;
  63665. /**
  63666. * Exposes the properties to the Seralize?
  63667. */
  63668. serialize(): any;
  63669. /**
  63670. * Exposes the properties to the deseralize?
  63671. */
  63672. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63673. }
  63674. }
  63675. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  63676. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63677. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63678. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63679. /**
  63680. * block used to Generate a Simplex Perlin 3d Noise Pattern
  63681. */
  63682. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  63683. /**
  63684. * Creates a new SimplexPerlin3DBlock
  63685. * @param name defines the block name
  63686. */
  63687. constructor(name: string);
  63688. /**
  63689. * Gets the current class name
  63690. * @returns the class name
  63691. */
  63692. getClassName(): string;
  63693. /**
  63694. * Gets the seed operand input component
  63695. */
  63696. get seed(): NodeMaterialConnectionPoint;
  63697. /**
  63698. * Gets the output component
  63699. */
  63700. get output(): NodeMaterialConnectionPoint;
  63701. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63702. }
  63703. }
  63704. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  63705. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63706. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63707. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63708. /**
  63709. * Block used to blend normals
  63710. */
  63711. export class NormalBlendBlock extends NodeMaterialBlock {
  63712. /**
  63713. * Creates a new NormalBlendBlock
  63714. * @param name defines the block name
  63715. */
  63716. constructor(name: string);
  63717. /**
  63718. * Gets the current class name
  63719. * @returns the class name
  63720. */
  63721. getClassName(): string;
  63722. /**
  63723. * Gets the first input component
  63724. */
  63725. get normalMap0(): NodeMaterialConnectionPoint;
  63726. /**
  63727. * Gets the second input component
  63728. */
  63729. get normalMap1(): NodeMaterialConnectionPoint;
  63730. /**
  63731. * Gets the output component
  63732. */
  63733. get output(): NodeMaterialConnectionPoint;
  63734. protected _buildBlock(state: NodeMaterialBuildState): this;
  63735. }
  63736. }
  63737. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  63738. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63739. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63740. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63741. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  63742. /**
  63743. * Block used to rotate a 2d vector by a given angle
  63744. */
  63745. export class Rotate2dBlock extends NodeMaterialBlock {
  63746. /**
  63747. * Creates a new Rotate2dBlock
  63748. * @param name defines the block name
  63749. */
  63750. constructor(name: string);
  63751. /**
  63752. * Gets the current class name
  63753. * @returns the class name
  63754. */
  63755. getClassName(): string;
  63756. /**
  63757. * Gets the input vector
  63758. */
  63759. get input(): NodeMaterialConnectionPoint;
  63760. /**
  63761. * Gets the input angle
  63762. */
  63763. get angle(): NodeMaterialConnectionPoint;
  63764. /**
  63765. * Gets the output component
  63766. */
  63767. get output(): NodeMaterialConnectionPoint;
  63768. autoConfigure(material: NodeMaterial): void;
  63769. protected _buildBlock(state: NodeMaterialBuildState): this;
  63770. }
  63771. }
  63772. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  63773. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63774. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63775. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63776. /**
  63777. * Block used to get the reflected vector from a direction and a normal
  63778. */
  63779. export class ReflectBlock extends NodeMaterialBlock {
  63780. /**
  63781. * Creates a new ReflectBlock
  63782. * @param name defines the block name
  63783. */
  63784. constructor(name: string);
  63785. /**
  63786. * Gets the current class name
  63787. * @returns the class name
  63788. */
  63789. getClassName(): string;
  63790. /**
  63791. * Gets the incident component
  63792. */
  63793. get incident(): NodeMaterialConnectionPoint;
  63794. /**
  63795. * Gets the normal component
  63796. */
  63797. get normal(): NodeMaterialConnectionPoint;
  63798. /**
  63799. * Gets the output component
  63800. */
  63801. get output(): NodeMaterialConnectionPoint;
  63802. protected _buildBlock(state: NodeMaterialBuildState): this;
  63803. }
  63804. }
  63805. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  63806. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63807. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63808. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63809. /**
  63810. * Block used to get the refracted vector from a direction and a normal
  63811. */
  63812. export class RefractBlock extends NodeMaterialBlock {
  63813. /**
  63814. * Creates a new RefractBlock
  63815. * @param name defines the block name
  63816. */
  63817. constructor(name: string);
  63818. /**
  63819. * Gets the current class name
  63820. * @returns the class name
  63821. */
  63822. getClassName(): string;
  63823. /**
  63824. * Gets the incident component
  63825. */
  63826. get incident(): NodeMaterialConnectionPoint;
  63827. /**
  63828. * Gets the normal component
  63829. */
  63830. get normal(): NodeMaterialConnectionPoint;
  63831. /**
  63832. * Gets the index of refraction component
  63833. */
  63834. get ior(): NodeMaterialConnectionPoint;
  63835. /**
  63836. * Gets the output component
  63837. */
  63838. get output(): NodeMaterialConnectionPoint;
  63839. protected _buildBlock(state: NodeMaterialBuildState): this;
  63840. }
  63841. }
  63842. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  63843. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63844. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63845. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63846. /**
  63847. * Block used to desaturate a color
  63848. */
  63849. export class DesaturateBlock extends NodeMaterialBlock {
  63850. /**
  63851. * Creates a new DesaturateBlock
  63852. * @param name defines the block name
  63853. */
  63854. constructor(name: string);
  63855. /**
  63856. * Gets the current class name
  63857. * @returns the class name
  63858. */
  63859. getClassName(): string;
  63860. /**
  63861. * Gets the color operand input component
  63862. */
  63863. get color(): NodeMaterialConnectionPoint;
  63864. /**
  63865. * Gets the level operand input component
  63866. */
  63867. get level(): NodeMaterialConnectionPoint;
  63868. /**
  63869. * Gets the output component
  63870. */
  63871. get output(): NodeMaterialConnectionPoint;
  63872. protected _buildBlock(state: NodeMaterialBuildState): this;
  63873. }
  63874. }
  63875. declare module "babylonjs/Materials/Node/Blocks/index" {
  63876. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  63877. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  63878. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  63879. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  63880. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  63881. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  63882. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  63883. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  63884. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  63885. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  63886. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  63887. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  63888. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  63889. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  63890. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  63891. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  63892. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  63893. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  63894. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  63895. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  63896. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  63897. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  63898. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  63899. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  63900. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  63901. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  63902. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  63903. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  63904. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  63905. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  63906. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  63907. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  63908. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  63909. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  63910. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  63911. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  63912. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  63913. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  63914. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  63915. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  63916. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  63917. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  63918. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  63919. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  63920. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  63921. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  63922. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  63923. }
  63924. declare module "babylonjs/Materials/Node/Optimizers/index" {
  63925. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  63926. }
  63927. declare module "babylonjs/Materials/Node/index" {
  63928. export * from "babylonjs/Materials/Node/Enums/index";
  63929. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63930. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  63931. export * from "babylonjs/Materials/Node/nodeMaterial";
  63932. export * from "babylonjs/Materials/Node/Blocks/index";
  63933. export * from "babylonjs/Materials/Node/Optimizers/index";
  63934. }
  63935. declare module "babylonjs/Materials/effectRenderer" {
  63936. import { Nullable } from "babylonjs/types";
  63937. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63938. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63939. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63940. import { Viewport } from "babylonjs/Maths/math.viewport";
  63941. import { Observable } from "babylonjs/Misc/observable";
  63942. import { Effect } from "babylonjs/Materials/effect";
  63943. import "babylonjs/Shaders/postprocess.vertex";
  63944. /**
  63945. * Effect Render Options
  63946. */
  63947. export interface IEffectRendererOptions {
  63948. /**
  63949. * Defines the vertices positions.
  63950. */
  63951. positions?: number[];
  63952. /**
  63953. * Defines the indices.
  63954. */
  63955. indices?: number[];
  63956. }
  63957. /**
  63958. * Helper class to render one or more effects.
  63959. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  63960. */
  63961. export class EffectRenderer {
  63962. private engine;
  63963. private static _DefaultOptions;
  63964. private _vertexBuffers;
  63965. private _indexBuffer;
  63966. private _fullscreenViewport;
  63967. /**
  63968. * Creates an effect renderer
  63969. * @param engine the engine to use for rendering
  63970. * @param options defines the options of the effect renderer
  63971. */
  63972. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63973. /**
  63974. * Sets the current viewport in normalized coordinates 0-1
  63975. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63976. */
  63977. setViewport(viewport?: Viewport): void;
  63978. /**
  63979. * Binds the embedded attributes buffer to the effect.
  63980. * @param effect Defines the effect to bind the attributes for
  63981. */
  63982. bindBuffers(effect: Effect): void;
  63983. /**
  63984. * Sets the current effect wrapper to use during draw.
  63985. * The effect needs to be ready before calling this api.
  63986. * This also sets the default full screen position attribute.
  63987. * @param effectWrapper Defines the effect to draw with
  63988. */
  63989. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63990. /**
  63991. * Draws a full screen quad.
  63992. */
  63993. draw(): void;
  63994. private isRenderTargetTexture;
  63995. /**
  63996. * renders one or more effects to a specified texture
  63997. * @param effectWrapper the effect to renderer
  63998. * @param outputTexture texture to draw to, if null it will render to the screen.
  63999. */
  64000. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  64001. /**
  64002. * Disposes of the effect renderer
  64003. */
  64004. dispose(): void;
  64005. }
  64006. /**
  64007. * Options to create an EffectWrapper
  64008. */
  64009. interface EffectWrapperCreationOptions {
  64010. /**
  64011. * Engine to use to create the effect
  64012. */
  64013. engine: ThinEngine;
  64014. /**
  64015. * Fragment shader for the effect
  64016. */
  64017. fragmentShader: string;
  64018. /**
  64019. * Vertex shader for the effect
  64020. */
  64021. vertexShader?: string;
  64022. /**
  64023. * Attributes to use in the shader
  64024. */
  64025. attributeNames?: Array<string>;
  64026. /**
  64027. * Uniforms to use in the shader
  64028. */
  64029. uniformNames?: Array<string>;
  64030. /**
  64031. * Texture sampler names to use in the shader
  64032. */
  64033. samplerNames?: Array<string>;
  64034. /**
  64035. * The friendly name of the effect displayed in Spector.
  64036. */
  64037. name?: string;
  64038. }
  64039. /**
  64040. * Wraps an effect to be used for rendering
  64041. */
  64042. export class EffectWrapper {
  64043. /**
  64044. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  64045. */
  64046. onApplyObservable: Observable<{}>;
  64047. /**
  64048. * The underlying effect
  64049. */
  64050. effect: Effect;
  64051. /**
  64052. * Creates an effect to be renderer
  64053. * @param creationOptions options to create the effect
  64054. */
  64055. constructor(creationOptions: EffectWrapperCreationOptions);
  64056. /**
  64057. * Disposes of the effect wrapper
  64058. */
  64059. dispose(): void;
  64060. }
  64061. }
  64062. declare module "babylonjs/Materials/index" {
  64063. export * from "babylonjs/Materials/Background/index";
  64064. export * from "babylonjs/Materials/colorCurves";
  64065. export * from "babylonjs/Materials/iEffectFallbacks";
  64066. export * from "babylonjs/Materials/effectFallbacks";
  64067. export * from "babylonjs/Materials/effect";
  64068. export * from "babylonjs/Materials/fresnelParameters";
  64069. export * from "babylonjs/Materials/imageProcessingConfiguration";
  64070. export * from "babylonjs/Materials/material";
  64071. export * from "babylonjs/Materials/materialDefines";
  64072. export * from "babylonjs/Materials/materialHelper";
  64073. export * from "babylonjs/Materials/multiMaterial";
  64074. export * from "babylonjs/Materials/PBR/index";
  64075. export * from "babylonjs/Materials/pushMaterial";
  64076. export * from "babylonjs/Materials/shaderMaterial";
  64077. export * from "babylonjs/Materials/standardMaterial";
  64078. export * from "babylonjs/Materials/Textures/index";
  64079. export * from "babylonjs/Materials/uniformBuffer";
  64080. export * from "babylonjs/Materials/materialFlags";
  64081. export * from "babylonjs/Materials/Node/index";
  64082. export * from "babylonjs/Materials/effectRenderer";
  64083. export * from "babylonjs/Materials/shadowDepthWrapper";
  64084. }
  64085. declare module "babylonjs/Maths/index" {
  64086. export * from "babylonjs/Maths/math.scalar";
  64087. export * from "babylonjs/Maths/math";
  64088. export * from "babylonjs/Maths/sphericalPolynomial";
  64089. }
  64090. declare module "babylonjs/Misc/workerPool" {
  64091. import { IDisposable } from "babylonjs/scene";
  64092. /**
  64093. * Helper class to push actions to a pool of workers.
  64094. */
  64095. export class WorkerPool implements IDisposable {
  64096. private _workerInfos;
  64097. private _pendingActions;
  64098. /**
  64099. * Constructor
  64100. * @param workers Array of workers to use for actions
  64101. */
  64102. constructor(workers: Array<Worker>);
  64103. /**
  64104. * Terminates all workers and clears any pending actions.
  64105. */
  64106. dispose(): void;
  64107. /**
  64108. * Pushes an action to the worker pool. If all the workers are active, the action will be
  64109. * pended until a worker has completed its action.
  64110. * @param action The action to perform. Call onComplete when the action is complete.
  64111. */
  64112. push(action: (worker: Worker, onComplete: () => void) => void): void;
  64113. private _execute;
  64114. }
  64115. }
  64116. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  64117. import { IDisposable } from "babylonjs/scene";
  64118. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  64119. /**
  64120. * Configuration for Draco compression
  64121. */
  64122. export interface IDracoCompressionConfiguration {
  64123. /**
  64124. * Configuration for the decoder.
  64125. */
  64126. decoder: {
  64127. /**
  64128. * The url to the WebAssembly module.
  64129. */
  64130. wasmUrl?: string;
  64131. /**
  64132. * The url to the WebAssembly binary.
  64133. */
  64134. wasmBinaryUrl?: string;
  64135. /**
  64136. * The url to the fallback JavaScript module.
  64137. */
  64138. fallbackUrl?: string;
  64139. };
  64140. }
  64141. /**
  64142. * Draco compression (https://google.github.io/draco/)
  64143. *
  64144. * This class wraps the Draco module.
  64145. *
  64146. * **Encoder**
  64147. *
  64148. * The encoder is not currently implemented.
  64149. *
  64150. * **Decoder**
  64151. *
  64152. * 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.
  64153. *
  64154. * To update the configuration, use the following code:
  64155. * ```javascript
  64156. * DracoCompression.Configuration = {
  64157. * decoder: {
  64158. * wasmUrl: "<url to the WebAssembly library>",
  64159. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  64160. * fallbackUrl: "<url to the fallback JavaScript library>",
  64161. * }
  64162. * };
  64163. * ```
  64164. *
  64165. * 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.
  64166. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  64167. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  64168. *
  64169. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  64170. * ```javascript
  64171. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  64172. * ```
  64173. *
  64174. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  64175. */
  64176. export class DracoCompression implements IDisposable {
  64177. private _workerPoolPromise?;
  64178. private _decoderModulePromise?;
  64179. /**
  64180. * The configuration. Defaults to the following urls:
  64181. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  64182. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  64183. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  64184. */
  64185. static Configuration: IDracoCompressionConfiguration;
  64186. /**
  64187. * Returns true if the decoder configuration is available.
  64188. */
  64189. static get DecoderAvailable(): boolean;
  64190. /**
  64191. * Default number of workers to create when creating the draco compression object.
  64192. */
  64193. static DefaultNumWorkers: number;
  64194. private static GetDefaultNumWorkers;
  64195. private static _Default;
  64196. /**
  64197. * Default instance for the draco compression object.
  64198. */
  64199. static get Default(): DracoCompression;
  64200. /**
  64201. * Constructor
  64202. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  64203. */
  64204. constructor(numWorkers?: number);
  64205. /**
  64206. * Stop all async operations and release resources.
  64207. */
  64208. dispose(): void;
  64209. /**
  64210. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  64211. * @returns a promise that resolves when ready
  64212. */
  64213. whenReadyAsync(): Promise<void>;
  64214. /**
  64215. * Decode Draco compressed mesh data to vertex data.
  64216. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  64217. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  64218. * @returns A promise that resolves with the decoded vertex data
  64219. */
  64220. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  64221. [kind: string]: number;
  64222. }): Promise<VertexData>;
  64223. }
  64224. }
  64225. declare module "babylonjs/Meshes/Compression/index" {
  64226. export * from "babylonjs/Meshes/Compression/dracoCompression";
  64227. }
  64228. declare module "babylonjs/Meshes/csg" {
  64229. import { Nullable } from "babylonjs/types";
  64230. import { Scene } from "babylonjs/scene";
  64231. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  64232. import { Mesh } from "babylonjs/Meshes/mesh";
  64233. import { Material } from "babylonjs/Materials/material";
  64234. /**
  64235. * Class for building Constructive Solid Geometry
  64236. */
  64237. export class CSG {
  64238. private polygons;
  64239. /**
  64240. * The world matrix
  64241. */
  64242. matrix: Matrix;
  64243. /**
  64244. * Stores the position
  64245. */
  64246. position: Vector3;
  64247. /**
  64248. * Stores the rotation
  64249. */
  64250. rotation: Vector3;
  64251. /**
  64252. * Stores the rotation quaternion
  64253. */
  64254. rotationQuaternion: Nullable<Quaternion>;
  64255. /**
  64256. * Stores the scaling vector
  64257. */
  64258. scaling: Vector3;
  64259. /**
  64260. * Convert the Mesh to CSG
  64261. * @param mesh The Mesh to convert to CSG
  64262. * @returns A new CSG from the Mesh
  64263. */
  64264. static FromMesh(mesh: Mesh): CSG;
  64265. /**
  64266. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  64267. * @param polygons Polygons used to construct a CSG solid
  64268. */
  64269. private static FromPolygons;
  64270. /**
  64271. * Clones, or makes a deep copy, of the CSG
  64272. * @returns A new CSG
  64273. */
  64274. clone(): CSG;
  64275. /**
  64276. * Unions this CSG with another CSG
  64277. * @param csg The CSG to union against this CSG
  64278. * @returns The unioned CSG
  64279. */
  64280. union(csg: CSG): CSG;
  64281. /**
  64282. * Unions this CSG with another CSG in place
  64283. * @param csg The CSG to union against this CSG
  64284. */
  64285. unionInPlace(csg: CSG): void;
  64286. /**
  64287. * Subtracts this CSG with another CSG
  64288. * @param csg The CSG to subtract against this CSG
  64289. * @returns A new CSG
  64290. */
  64291. subtract(csg: CSG): CSG;
  64292. /**
  64293. * Subtracts this CSG with another CSG in place
  64294. * @param csg The CSG to subtact against this CSG
  64295. */
  64296. subtractInPlace(csg: CSG): void;
  64297. /**
  64298. * Intersect this CSG with another CSG
  64299. * @param csg The CSG to intersect against this CSG
  64300. * @returns A new CSG
  64301. */
  64302. intersect(csg: CSG): CSG;
  64303. /**
  64304. * Intersects this CSG with another CSG in place
  64305. * @param csg The CSG to intersect against this CSG
  64306. */
  64307. intersectInPlace(csg: CSG): void;
  64308. /**
  64309. * Return a new CSG solid with solid and empty space switched. This solid is
  64310. * not modified.
  64311. * @returns A new CSG solid with solid and empty space switched
  64312. */
  64313. inverse(): CSG;
  64314. /**
  64315. * Inverses the CSG in place
  64316. */
  64317. inverseInPlace(): void;
  64318. /**
  64319. * This is used to keep meshes transformations so they can be restored
  64320. * when we build back a Babylon Mesh
  64321. * NB : All CSG operations are performed in world coordinates
  64322. * @param csg The CSG to copy the transform attributes from
  64323. * @returns This CSG
  64324. */
  64325. copyTransformAttributes(csg: CSG): CSG;
  64326. /**
  64327. * Build Raw mesh from CSG
  64328. * Coordinates here are in world space
  64329. * @param name The name of the mesh geometry
  64330. * @param scene The Scene
  64331. * @param keepSubMeshes Specifies if the submeshes should be kept
  64332. * @returns A new Mesh
  64333. */
  64334. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64335. /**
  64336. * Build Mesh from CSG taking material and transforms into account
  64337. * @param name The name of the Mesh
  64338. * @param material The material of the Mesh
  64339. * @param scene The Scene
  64340. * @param keepSubMeshes Specifies if submeshes should be kept
  64341. * @returns The new Mesh
  64342. */
  64343. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64344. }
  64345. }
  64346. declare module "babylonjs/Meshes/trailMesh" {
  64347. import { Mesh } from "babylonjs/Meshes/mesh";
  64348. import { Scene } from "babylonjs/scene";
  64349. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64350. /**
  64351. * Class used to create a trail following a mesh
  64352. */
  64353. export class TrailMesh extends Mesh {
  64354. private _generator;
  64355. private _autoStart;
  64356. private _running;
  64357. private _diameter;
  64358. private _length;
  64359. private _sectionPolygonPointsCount;
  64360. private _sectionVectors;
  64361. private _sectionNormalVectors;
  64362. private _beforeRenderObserver;
  64363. /**
  64364. * @constructor
  64365. * @param name The value used by scene.getMeshByName() to do a lookup.
  64366. * @param generator The mesh or transform node to generate a trail.
  64367. * @param scene The scene to add this mesh to.
  64368. * @param diameter Diameter of trailing mesh. Default is 1.
  64369. * @param length Length of trailing mesh. Default is 60.
  64370. * @param autoStart Automatically start trailing mesh. Default true.
  64371. */
  64372. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  64373. /**
  64374. * "TrailMesh"
  64375. * @returns "TrailMesh"
  64376. */
  64377. getClassName(): string;
  64378. private _createMesh;
  64379. /**
  64380. * Start trailing mesh.
  64381. */
  64382. start(): void;
  64383. /**
  64384. * Stop trailing mesh.
  64385. */
  64386. stop(): void;
  64387. /**
  64388. * Update trailing mesh geometry.
  64389. */
  64390. update(): void;
  64391. /**
  64392. * Returns a new TrailMesh object.
  64393. * @param name is a string, the name given to the new mesh
  64394. * @param newGenerator use new generator object for cloned trail mesh
  64395. * @returns a new mesh
  64396. */
  64397. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  64398. /**
  64399. * Serializes this trail mesh
  64400. * @param serializationObject object to write serialization to
  64401. */
  64402. serialize(serializationObject: any): void;
  64403. /**
  64404. * Parses a serialized trail mesh
  64405. * @param parsedMesh the serialized mesh
  64406. * @param scene the scene to create the trail mesh in
  64407. * @returns the created trail mesh
  64408. */
  64409. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  64410. }
  64411. }
  64412. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  64413. import { Nullable } from "babylonjs/types";
  64414. import { Scene } from "babylonjs/scene";
  64415. import { Vector4 } from "babylonjs/Maths/math.vector";
  64416. import { Color4 } from "babylonjs/Maths/math.color";
  64417. import { Mesh } from "babylonjs/Meshes/mesh";
  64418. /**
  64419. * Class containing static functions to help procedurally build meshes
  64420. */
  64421. export class TiledBoxBuilder {
  64422. /**
  64423. * Creates a box mesh
  64424. * 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)
  64425. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64426. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64427. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64429. * @param name defines the name of the mesh
  64430. * @param options defines the options used to create the mesh
  64431. * @param scene defines the hosting scene
  64432. * @returns the box mesh
  64433. */
  64434. static CreateTiledBox(name: string, options: {
  64435. pattern?: number;
  64436. width?: number;
  64437. height?: number;
  64438. depth?: number;
  64439. tileSize?: number;
  64440. tileWidth?: number;
  64441. tileHeight?: number;
  64442. alignHorizontal?: number;
  64443. alignVertical?: number;
  64444. faceUV?: Vector4[];
  64445. faceColors?: Color4[];
  64446. sideOrientation?: number;
  64447. updatable?: boolean;
  64448. }, scene?: Nullable<Scene>): Mesh;
  64449. }
  64450. }
  64451. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  64452. import { Vector4 } from "babylonjs/Maths/math.vector";
  64453. import { Mesh } from "babylonjs/Meshes/mesh";
  64454. /**
  64455. * Class containing static functions to help procedurally build meshes
  64456. */
  64457. export class TorusKnotBuilder {
  64458. /**
  64459. * Creates a torus knot mesh
  64460. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64461. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64462. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64463. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64464. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64465. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64467. * @param name defines the name of the mesh
  64468. * @param options defines the options used to create the mesh
  64469. * @param scene defines the hosting scene
  64470. * @returns the torus knot mesh
  64471. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64472. */
  64473. static CreateTorusKnot(name: string, options: {
  64474. radius?: number;
  64475. tube?: number;
  64476. radialSegments?: number;
  64477. tubularSegments?: number;
  64478. p?: number;
  64479. q?: number;
  64480. updatable?: boolean;
  64481. sideOrientation?: number;
  64482. frontUVs?: Vector4;
  64483. backUVs?: Vector4;
  64484. }, scene: any): Mesh;
  64485. }
  64486. }
  64487. declare module "babylonjs/Meshes/polygonMesh" {
  64488. import { Scene } from "babylonjs/scene";
  64489. import { Vector2 } from "babylonjs/Maths/math.vector";
  64490. import { Mesh } from "babylonjs/Meshes/mesh";
  64491. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  64492. import { Path2 } from "babylonjs/Maths/math.path";
  64493. /**
  64494. * Polygon
  64495. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  64496. */
  64497. export class Polygon {
  64498. /**
  64499. * Creates a rectangle
  64500. * @param xmin bottom X coord
  64501. * @param ymin bottom Y coord
  64502. * @param xmax top X coord
  64503. * @param ymax top Y coord
  64504. * @returns points that make the resulting rectation
  64505. */
  64506. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  64507. /**
  64508. * Creates a circle
  64509. * @param radius radius of circle
  64510. * @param cx scale in x
  64511. * @param cy scale in y
  64512. * @param numberOfSides number of sides that make up the circle
  64513. * @returns points that make the resulting circle
  64514. */
  64515. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  64516. /**
  64517. * Creates a polygon from input string
  64518. * @param input Input polygon data
  64519. * @returns the parsed points
  64520. */
  64521. static Parse(input: string): Vector2[];
  64522. /**
  64523. * Starts building a polygon from x and y coordinates
  64524. * @param x x coordinate
  64525. * @param y y coordinate
  64526. * @returns the started path2
  64527. */
  64528. static StartingAt(x: number, y: number): Path2;
  64529. }
  64530. /**
  64531. * Builds a polygon
  64532. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  64533. */
  64534. export class PolygonMeshBuilder {
  64535. private _points;
  64536. private _outlinepoints;
  64537. private _holes;
  64538. private _name;
  64539. private _scene;
  64540. private _epoints;
  64541. private _eholes;
  64542. private _addToepoint;
  64543. /**
  64544. * Babylon reference to the earcut plugin.
  64545. */
  64546. bjsEarcut: any;
  64547. /**
  64548. * Creates a PolygonMeshBuilder
  64549. * @param name name of the builder
  64550. * @param contours Path of the polygon
  64551. * @param scene scene to add to when creating the mesh
  64552. * @param earcutInjection can be used to inject your own earcut reference
  64553. */
  64554. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  64555. /**
  64556. * Adds a whole within the polygon
  64557. * @param hole Array of points defining the hole
  64558. * @returns this
  64559. */
  64560. addHole(hole: Vector2[]): PolygonMeshBuilder;
  64561. /**
  64562. * Creates the polygon
  64563. * @param updatable If the mesh should be updatable
  64564. * @param depth The depth of the mesh created
  64565. * @returns the created mesh
  64566. */
  64567. build(updatable?: boolean, depth?: number): Mesh;
  64568. /**
  64569. * Creates the polygon
  64570. * @param depth The depth of the mesh created
  64571. * @returns the created VertexData
  64572. */
  64573. buildVertexData(depth?: number): VertexData;
  64574. /**
  64575. * Adds a side to the polygon
  64576. * @param positions points that make the polygon
  64577. * @param normals normals of the polygon
  64578. * @param uvs uvs of the polygon
  64579. * @param indices indices of the polygon
  64580. * @param bounds bounds of the polygon
  64581. * @param points points of the polygon
  64582. * @param depth depth of the polygon
  64583. * @param flip flip of the polygon
  64584. */
  64585. private addSide;
  64586. }
  64587. }
  64588. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  64589. import { Scene } from "babylonjs/scene";
  64590. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  64591. import { Color4 } from "babylonjs/Maths/math.color";
  64592. import { Mesh } from "babylonjs/Meshes/mesh";
  64593. import { Nullable } from "babylonjs/types";
  64594. /**
  64595. * Class containing static functions to help procedurally build meshes
  64596. */
  64597. export class PolygonBuilder {
  64598. /**
  64599. * Creates a polygon mesh
  64600. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64601. * * 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
  64602. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64604. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  64605. * * Remember you can only change the shape positions, not their number when updating a polygon
  64606. * @param name defines the name of the mesh
  64607. * @param options defines the options used to create the mesh
  64608. * @param scene defines the hosting scene
  64609. * @param earcutInjection can be used to inject your own earcut reference
  64610. * @returns the polygon mesh
  64611. */
  64612. static CreatePolygon(name: string, options: {
  64613. shape: Vector3[];
  64614. holes?: Vector3[][];
  64615. depth?: number;
  64616. faceUV?: Vector4[];
  64617. faceColors?: Color4[];
  64618. updatable?: boolean;
  64619. sideOrientation?: number;
  64620. frontUVs?: Vector4;
  64621. backUVs?: Vector4;
  64622. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64623. /**
  64624. * Creates an extruded polygon mesh, with depth in the Y direction.
  64625. * * 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)
  64626. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64627. * @param name defines the name of the mesh
  64628. * @param options defines the options used to create the mesh
  64629. * @param scene defines the hosting scene
  64630. * @param earcutInjection can be used to inject your own earcut reference
  64631. * @returns the polygon mesh
  64632. */
  64633. static ExtrudePolygon(name: string, options: {
  64634. shape: Vector3[];
  64635. holes?: Vector3[][];
  64636. depth?: number;
  64637. faceUV?: Vector4[];
  64638. faceColors?: Color4[];
  64639. updatable?: boolean;
  64640. sideOrientation?: number;
  64641. frontUVs?: Vector4;
  64642. backUVs?: Vector4;
  64643. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64644. }
  64645. }
  64646. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  64647. import { Scene } from "babylonjs/scene";
  64648. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  64649. import { Mesh } from "babylonjs/Meshes/mesh";
  64650. import { Nullable } from "babylonjs/types";
  64651. /**
  64652. * Class containing static functions to help procedurally build meshes
  64653. */
  64654. export class LatheBuilder {
  64655. /**
  64656. * Creates lathe mesh.
  64657. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64658. * * 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
  64659. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64660. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64661. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64662. * * 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
  64663. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64664. * * 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
  64665. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64666. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64667. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64669. * @param name defines the name of the mesh
  64670. * @param options defines the options used to create the mesh
  64671. * @param scene defines the hosting scene
  64672. * @returns the lathe mesh
  64673. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64674. */
  64675. static CreateLathe(name: string, options: {
  64676. shape: Vector3[];
  64677. radius?: number;
  64678. tessellation?: number;
  64679. clip?: number;
  64680. arc?: number;
  64681. closed?: boolean;
  64682. updatable?: boolean;
  64683. sideOrientation?: number;
  64684. frontUVs?: Vector4;
  64685. backUVs?: Vector4;
  64686. cap?: number;
  64687. invertUV?: boolean;
  64688. }, scene?: Nullable<Scene>): Mesh;
  64689. }
  64690. }
  64691. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  64692. import { Nullable } from "babylonjs/types";
  64693. import { Scene } from "babylonjs/scene";
  64694. import { Vector4 } from "babylonjs/Maths/math.vector";
  64695. import { Mesh } from "babylonjs/Meshes/mesh";
  64696. /**
  64697. * Class containing static functions to help procedurally build meshes
  64698. */
  64699. export class TiledPlaneBuilder {
  64700. /**
  64701. * Creates a tiled plane mesh
  64702. * * The parameter `pattern` will, depending on value, do nothing or
  64703. * * * flip (reflect about central vertical) alternate tiles across and up
  64704. * * * flip every tile on alternate rows
  64705. * * * rotate (180 degs) alternate tiles across and up
  64706. * * * rotate every tile on alternate rows
  64707. * * * flip and rotate alternate tiles across and up
  64708. * * * flip and rotate every tile on alternate rows
  64709. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  64710. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  64711. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64712. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64713. * * 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)
  64714. * * 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)
  64715. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64716. * @param name defines the name of the mesh
  64717. * @param options defines the options used to create the mesh
  64718. * @param scene defines the hosting scene
  64719. * @returns the box mesh
  64720. */
  64721. static CreateTiledPlane(name: string, options: {
  64722. pattern?: number;
  64723. tileSize?: number;
  64724. tileWidth?: number;
  64725. tileHeight?: number;
  64726. size?: number;
  64727. width?: number;
  64728. height?: number;
  64729. alignHorizontal?: number;
  64730. alignVertical?: number;
  64731. sideOrientation?: number;
  64732. frontUVs?: Vector4;
  64733. backUVs?: Vector4;
  64734. updatable?: boolean;
  64735. }, scene?: Nullable<Scene>): Mesh;
  64736. }
  64737. }
  64738. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  64739. import { Nullable } from "babylonjs/types";
  64740. import { Scene } from "babylonjs/scene";
  64741. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  64742. import { Mesh } from "babylonjs/Meshes/mesh";
  64743. /**
  64744. * Class containing static functions to help procedurally build meshes
  64745. */
  64746. export class TubeBuilder {
  64747. /**
  64748. * Creates a tube mesh.
  64749. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64750. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64751. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64752. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64753. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64754. * * 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)
  64755. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64756. * * 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
  64757. * * 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
  64758. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64759. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64760. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64762. * @param name defines the name of the mesh
  64763. * @param options defines the options used to create the mesh
  64764. * @param scene defines the hosting scene
  64765. * @returns the tube mesh
  64766. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64767. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64768. */
  64769. static CreateTube(name: string, options: {
  64770. path: Vector3[];
  64771. radius?: number;
  64772. tessellation?: number;
  64773. radiusFunction?: {
  64774. (i: number, distance: number): number;
  64775. };
  64776. cap?: number;
  64777. arc?: number;
  64778. updatable?: boolean;
  64779. sideOrientation?: number;
  64780. frontUVs?: Vector4;
  64781. backUVs?: Vector4;
  64782. instance?: Mesh;
  64783. invertUV?: boolean;
  64784. }, scene?: Nullable<Scene>): Mesh;
  64785. }
  64786. }
  64787. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  64788. import { Scene } from "babylonjs/scene";
  64789. import { Vector4 } from "babylonjs/Maths/math.vector";
  64790. import { Mesh } from "babylonjs/Meshes/mesh";
  64791. import { Nullable } from "babylonjs/types";
  64792. /**
  64793. * Class containing static functions to help procedurally build meshes
  64794. */
  64795. export class IcoSphereBuilder {
  64796. /**
  64797. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64798. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64799. * * 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`)
  64800. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64801. * * 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
  64802. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64803. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64805. * @param name defines the name of the mesh
  64806. * @param options defines the options used to create the mesh
  64807. * @param scene defines the hosting scene
  64808. * @returns the icosahedron mesh
  64809. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64810. */
  64811. static CreateIcoSphere(name: string, options: {
  64812. radius?: number;
  64813. radiusX?: number;
  64814. radiusY?: number;
  64815. radiusZ?: number;
  64816. flat?: boolean;
  64817. subdivisions?: number;
  64818. sideOrientation?: number;
  64819. frontUVs?: Vector4;
  64820. backUVs?: Vector4;
  64821. updatable?: boolean;
  64822. }, scene?: Nullable<Scene>): Mesh;
  64823. }
  64824. }
  64825. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  64826. import { Vector3 } from "babylonjs/Maths/math.vector";
  64827. import { Mesh } from "babylonjs/Meshes/mesh";
  64828. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64829. /**
  64830. * Class containing static functions to help procedurally build meshes
  64831. */
  64832. export class DecalBuilder {
  64833. /**
  64834. * Creates a decal mesh.
  64835. * 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
  64836. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64837. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64838. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64839. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64840. * @param name defines the name of the mesh
  64841. * @param sourceMesh defines the mesh where the decal must be applied
  64842. * @param options defines the options used to create the mesh
  64843. * @param scene defines the hosting scene
  64844. * @returns the decal mesh
  64845. * @see https://doc.babylonjs.com/how_to/decals
  64846. */
  64847. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64848. position?: Vector3;
  64849. normal?: Vector3;
  64850. size?: Vector3;
  64851. angle?: number;
  64852. }): Mesh;
  64853. }
  64854. }
  64855. declare module "babylonjs/Meshes/meshBuilder" {
  64856. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  64857. import { Nullable } from "babylonjs/types";
  64858. import { Scene } from "babylonjs/scene";
  64859. import { Mesh } from "babylonjs/Meshes/mesh";
  64860. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  64861. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  64862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64863. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  64864. import { Plane } from "babylonjs/Maths/math.plane";
  64865. /**
  64866. * Class containing static functions to help procedurally build meshes
  64867. */
  64868. export class MeshBuilder {
  64869. /**
  64870. * Creates a box mesh
  64871. * * The parameter `size` sets the size (float) of each box side (default 1)
  64872. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64873. * * 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)
  64874. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64875. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64876. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64877. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64878. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64879. * @param name defines the name of the mesh
  64880. * @param options defines the options used to create the mesh
  64881. * @param scene defines the hosting scene
  64882. * @returns the box mesh
  64883. */
  64884. static CreateBox(name: string, options: {
  64885. size?: number;
  64886. width?: number;
  64887. height?: number;
  64888. depth?: number;
  64889. faceUV?: Vector4[];
  64890. faceColors?: Color4[];
  64891. sideOrientation?: number;
  64892. frontUVs?: Vector4;
  64893. backUVs?: Vector4;
  64894. wrap?: boolean;
  64895. topBaseAt?: number;
  64896. bottomBaseAt?: number;
  64897. updatable?: boolean;
  64898. }, scene?: Nullable<Scene>): Mesh;
  64899. /**
  64900. * Creates a tiled box mesh
  64901. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64903. * @param name defines the name of the mesh
  64904. * @param options defines the options used to create the mesh
  64905. * @param scene defines the hosting scene
  64906. * @returns the tiled box mesh
  64907. */
  64908. static CreateTiledBox(name: string, options: {
  64909. pattern?: number;
  64910. size?: number;
  64911. width?: number;
  64912. height?: number;
  64913. depth: number;
  64914. tileSize?: number;
  64915. tileWidth?: number;
  64916. tileHeight?: number;
  64917. faceUV?: Vector4[];
  64918. faceColors?: Color4[];
  64919. alignHorizontal?: number;
  64920. alignVertical?: number;
  64921. sideOrientation?: number;
  64922. updatable?: boolean;
  64923. }, scene?: Nullable<Scene>): Mesh;
  64924. /**
  64925. * Creates a sphere mesh
  64926. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64927. * * 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`)
  64928. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64929. * * 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
  64930. * * 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)
  64931. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64932. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64933. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64934. * @param name defines the name of the mesh
  64935. * @param options defines the options used to create the mesh
  64936. * @param scene defines the hosting scene
  64937. * @returns the sphere mesh
  64938. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64939. */
  64940. static CreateSphere(name: string, options: {
  64941. segments?: number;
  64942. diameter?: number;
  64943. diameterX?: number;
  64944. diameterY?: number;
  64945. diameterZ?: number;
  64946. arc?: number;
  64947. slice?: number;
  64948. sideOrientation?: number;
  64949. frontUVs?: Vector4;
  64950. backUVs?: Vector4;
  64951. updatable?: boolean;
  64952. }, scene?: Nullable<Scene>): Mesh;
  64953. /**
  64954. * Creates a plane polygonal mesh. By default, this is a disc
  64955. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64956. * * 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
  64957. * * 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
  64958. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64959. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64961. * @param name defines the name of the mesh
  64962. * @param options defines the options used to create the mesh
  64963. * @param scene defines the hosting scene
  64964. * @returns the plane polygonal mesh
  64965. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64966. */
  64967. static CreateDisc(name: string, options: {
  64968. radius?: number;
  64969. tessellation?: number;
  64970. arc?: number;
  64971. updatable?: boolean;
  64972. sideOrientation?: number;
  64973. frontUVs?: Vector4;
  64974. backUVs?: Vector4;
  64975. }, scene?: Nullable<Scene>): Mesh;
  64976. /**
  64977. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64978. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64979. * * 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`)
  64980. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64981. * * 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
  64982. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64983. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64985. * @param name defines the name of the mesh
  64986. * @param options defines the options used to create the mesh
  64987. * @param scene defines the hosting scene
  64988. * @returns the icosahedron mesh
  64989. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64990. */
  64991. static CreateIcoSphere(name: string, options: {
  64992. radius?: number;
  64993. radiusX?: number;
  64994. radiusY?: number;
  64995. radiusZ?: number;
  64996. flat?: boolean;
  64997. subdivisions?: number;
  64998. sideOrientation?: number;
  64999. frontUVs?: Vector4;
  65000. backUVs?: Vector4;
  65001. updatable?: boolean;
  65002. }, scene?: Nullable<Scene>): Mesh;
  65003. /**
  65004. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65005. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  65006. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  65007. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  65008. * * 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
  65009. * * 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
  65010. * * 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
  65011. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65012. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65013. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65014. * * 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
  65015. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  65016. * * 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
  65017. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  65018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65019. * @param name defines the name of the mesh
  65020. * @param options defines the options used to create the mesh
  65021. * @param scene defines the hosting scene
  65022. * @returns the ribbon mesh
  65023. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  65024. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65025. */
  65026. static CreateRibbon(name: string, options: {
  65027. pathArray: Vector3[][];
  65028. closeArray?: boolean;
  65029. closePath?: boolean;
  65030. offset?: number;
  65031. updatable?: boolean;
  65032. sideOrientation?: number;
  65033. frontUVs?: Vector4;
  65034. backUVs?: Vector4;
  65035. instance?: Mesh;
  65036. invertUV?: boolean;
  65037. uvs?: Vector2[];
  65038. colors?: Color4[];
  65039. }, scene?: Nullable<Scene>): Mesh;
  65040. /**
  65041. * Creates a cylinder or a cone mesh
  65042. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  65043. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  65044. * * 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.
  65045. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  65046. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  65047. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  65048. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  65049. * * 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).
  65050. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  65051. * * 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).
  65052. * * 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
  65053. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  65054. * * 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
  65055. * * 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.
  65056. * * If `enclose` is false, a ring surface is one element.
  65057. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  65058. * * 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
  65059. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65060. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65061. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65062. * @param name defines the name of the mesh
  65063. * @param options defines the options used to create the mesh
  65064. * @param scene defines the hosting scene
  65065. * @returns the cylinder mesh
  65066. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  65067. */
  65068. static CreateCylinder(name: string, options: {
  65069. height?: number;
  65070. diameterTop?: number;
  65071. diameterBottom?: number;
  65072. diameter?: number;
  65073. tessellation?: number;
  65074. subdivisions?: number;
  65075. arc?: number;
  65076. faceColors?: Color4[];
  65077. faceUV?: Vector4[];
  65078. updatable?: boolean;
  65079. hasRings?: boolean;
  65080. enclose?: boolean;
  65081. cap?: number;
  65082. sideOrientation?: number;
  65083. frontUVs?: Vector4;
  65084. backUVs?: Vector4;
  65085. }, scene?: Nullable<Scene>): Mesh;
  65086. /**
  65087. * Creates a torus mesh
  65088. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  65089. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  65090. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  65091. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65092. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65094. * @param name defines the name of the mesh
  65095. * @param options defines the options used to create the mesh
  65096. * @param scene defines the hosting scene
  65097. * @returns the torus mesh
  65098. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  65099. */
  65100. static CreateTorus(name: string, options: {
  65101. diameter?: number;
  65102. thickness?: number;
  65103. tessellation?: number;
  65104. updatable?: boolean;
  65105. sideOrientation?: number;
  65106. frontUVs?: Vector4;
  65107. backUVs?: Vector4;
  65108. }, scene?: Nullable<Scene>): Mesh;
  65109. /**
  65110. * Creates a torus knot mesh
  65111. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65112. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65113. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65114. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65115. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65116. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65118. * @param name defines the name of the mesh
  65119. * @param options defines the options used to create the mesh
  65120. * @param scene defines the hosting scene
  65121. * @returns the torus knot mesh
  65122. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65123. */
  65124. static CreateTorusKnot(name: string, options: {
  65125. radius?: number;
  65126. tube?: number;
  65127. radialSegments?: number;
  65128. tubularSegments?: number;
  65129. p?: number;
  65130. q?: number;
  65131. updatable?: boolean;
  65132. sideOrientation?: number;
  65133. frontUVs?: Vector4;
  65134. backUVs?: Vector4;
  65135. }, scene?: Nullable<Scene>): Mesh;
  65136. /**
  65137. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  65138. * * 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
  65139. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  65140. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  65141. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  65142. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  65143. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  65144. * * 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
  65145. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  65146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65147. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  65148. * @param name defines the name of the new line system
  65149. * @param options defines the options used to create the line system
  65150. * @param scene defines the hosting scene
  65151. * @returns a new line system mesh
  65152. */
  65153. static CreateLineSystem(name: string, options: {
  65154. lines: Vector3[][];
  65155. updatable?: boolean;
  65156. instance?: Nullable<LinesMesh>;
  65157. colors?: Nullable<Color4[][]>;
  65158. useVertexAlpha?: boolean;
  65159. }, scene: Nullable<Scene>): LinesMesh;
  65160. /**
  65161. * Creates a line mesh
  65162. * 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
  65163. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65164. * * The parameter `points` is an array successive Vector3
  65165. * * 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
  65166. * * The optional parameter `colors` is an array of successive Color4, one per line point
  65167. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  65168. * * When updating an instance, remember that only point positions can change, not the number of points
  65169. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65170. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  65171. * @param name defines the name of the new line system
  65172. * @param options defines the options used to create the line system
  65173. * @param scene defines the hosting scene
  65174. * @returns a new line mesh
  65175. */
  65176. static CreateLines(name: string, options: {
  65177. points: Vector3[];
  65178. updatable?: boolean;
  65179. instance?: Nullable<LinesMesh>;
  65180. colors?: Color4[];
  65181. useVertexAlpha?: boolean;
  65182. }, scene?: Nullable<Scene>): LinesMesh;
  65183. /**
  65184. * Creates a dashed line mesh
  65185. * * 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
  65186. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65187. * * The parameter `points` is an array successive Vector3
  65188. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  65189. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  65190. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  65191. * * 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
  65192. * * When updating an instance, remember that only point positions can change, not the number of points
  65193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65194. * @param name defines the name of the mesh
  65195. * @param options defines the options used to create the mesh
  65196. * @param scene defines the hosting scene
  65197. * @returns the dashed line mesh
  65198. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  65199. */
  65200. static CreateDashedLines(name: string, options: {
  65201. points: Vector3[];
  65202. dashSize?: number;
  65203. gapSize?: number;
  65204. dashNb?: number;
  65205. updatable?: boolean;
  65206. instance?: LinesMesh;
  65207. }, scene?: Nullable<Scene>): LinesMesh;
  65208. /**
  65209. * 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.
  65210. * * 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.
  65211. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65212. * * 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.
  65213. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  65214. * * 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
  65215. * * 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
  65216. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  65217. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65218. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65219. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  65220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65221. * @param name defines the name of the mesh
  65222. * @param options defines the options used to create the mesh
  65223. * @param scene defines the hosting scene
  65224. * @returns the extruded shape mesh
  65225. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65226. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65227. */
  65228. static ExtrudeShape(name: string, options: {
  65229. shape: Vector3[];
  65230. path: Vector3[];
  65231. scale?: number;
  65232. rotation?: number;
  65233. cap?: number;
  65234. updatable?: boolean;
  65235. sideOrientation?: number;
  65236. frontUVs?: Vector4;
  65237. backUVs?: Vector4;
  65238. instance?: Mesh;
  65239. invertUV?: boolean;
  65240. }, scene?: Nullable<Scene>): Mesh;
  65241. /**
  65242. * Creates an custom extruded shape mesh.
  65243. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  65244. * * 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.
  65245. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65246. * * 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
  65247. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  65248. * * 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
  65249. * * It must returns a float value that will be the scale value applied to the shape on each path point
  65250. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  65251. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  65252. * * 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
  65253. * * 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
  65254. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  65255. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65256. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65257. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65259. * @param name defines the name of the mesh
  65260. * @param options defines the options used to create the mesh
  65261. * @param scene defines the hosting scene
  65262. * @returns the custom extruded shape mesh
  65263. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  65264. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65265. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65266. */
  65267. static ExtrudeShapeCustom(name: string, options: {
  65268. shape: Vector3[];
  65269. path: Vector3[];
  65270. scaleFunction?: any;
  65271. rotationFunction?: any;
  65272. ribbonCloseArray?: boolean;
  65273. ribbonClosePath?: boolean;
  65274. cap?: number;
  65275. updatable?: boolean;
  65276. sideOrientation?: number;
  65277. frontUVs?: Vector4;
  65278. backUVs?: Vector4;
  65279. instance?: Mesh;
  65280. invertUV?: boolean;
  65281. }, scene?: Nullable<Scene>): Mesh;
  65282. /**
  65283. * Creates lathe mesh.
  65284. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65285. * * 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
  65286. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65287. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65288. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65289. * * 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
  65290. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65291. * * 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
  65292. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65293. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65294. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65296. * @param name defines the name of the mesh
  65297. * @param options defines the options used to create the mesh
  65298. * @param scene defines the hosting scene
  65299. * @returns the lathe mesh
  65300. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65301. */
  65302. static CreateLathe(name: string, options: {
  65303. shape: Vector3[];
  65304. radius?: number;
  65305. tessellation?: number;
  65306. clip?: number;
  65307. arc?: number;
  65308. closed?: boolean;
  65309. updatable?: boolean;
  65310. sideOrientation?: number;
  65311. frontUVs?: Vector4;
  65312. backUVs?: Vector4;
  65313. cap?: number;
  65314. invertUV?: boolean;
  65315. }, scene?: Nullable<Scene>): Mesh;
  65316. /**
  65317. * Creates a tiled plane mesh
  65318. * * You can set a limited pattern arrangement with the tiles
  65319. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65320. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65322. * @param name defines the name of the mesh
  65323. * @param options defines the options used to create the mesh
  65324. * @param scene defines the hosting scene
  65325. * @returns the plane mesh
  65326. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65327. */
  65328. static CreateTiledPlane(name: string, options: {
  65329. pattern?: number;
  65330. tileSize?: number;
  65331. tileWidth?: number;
  65332. tileHeight?: number;
  65333. size?: number;
  65334. width?: number;
  65335. height?: number;
  65336. alignHorizontal?: number;
  65337. alignVertical?: number;
  65338. sideOrientation?: number;
  65339. frontUVs?: Vector4;
  65340. backUVs?: Vector4;
  65341. updatable?: boolean;
  65342. }, scene?: Nullable<Scene>): Mesh;
  65343. /**
  65344. * Creates a plane mesh
  65345. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  65346. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  65347. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  65348. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65349. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65351. * @param name defines the name of the mesh
  65352. * @param options defines the options used to create the mesh
  65353. * @param scene defines the hosting scene
  65354. * @returns the plane mesh
  65355. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65356. */
  65357. static CreatePlane(name: string, options: {
  65358. size?: number;
  65359. width?: number;
  65360. height?: number;
  65361. sideOrientation?: number;
  65362. frontUVs?: Vector4;
  65363. backUVs?: Vector4;
  65364. updatable?: boolean;
  65365. sourcePlane?: Plane;
  65366. }, scene?: Nullable<Scene>): Mesh;
  65367. /**
  65368. * Creates a ground mesh
  65369. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  65370. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  65371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65372. * @param name defines the name of the mesh
  65373. * @param options defines the options used to create the mesh
  65374. * @param scene defines the hosting scene
  65375. * @returns the ground mesh
  65376. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  65377. */
  65378. static CreateGround(name: string, options: {
  65379. width?: number;
  65380. height?: number;
  65381. subdivisions?: number;
  65382. subdivisionsX?: number;
  65383. subdivisionsY?: number;
  65384. updatable?: boolean;
  65385. }, scene?: Nullable<Scene>): Mesh;
  65386. /**
  65387. * Creates a tiled ground mesh
  65388. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  65389. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  65390. * * 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
  65391. * * 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
  65392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65393. * @param name defines the name of the mesh
  65394. * @param options defines the options used to create the mesh
  65395. * @param scene defines the hosting scene
  65396. * @returns the tiled ground mesh
  65397. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  65398. */
  65399. static CreateTiledGround(name: string, options: {
  65400. xmin: number;
  65401. zmin: number;
  65402. xmax: number;
  65403. zmax: number;
  65404. subdivisions?: {
  65405. w: number;
  65406. h: number;
  65407. };
  65408. precision?: {
  65409. w: number;
  65410. h: number;
  65411. };
  65412. updatable?: boolean;
  65413. }, scene?: Nullable<Scene>): Mesh;
  65414. /**
  65415. * Creates a ground mesh from a height map
  65416. * * The parameter `url` sets the URL of the height map image resource.
  65417. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  65418. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  65419. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  65420. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  65421. * * 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.
  65422. * * 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).
  65423. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  65424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65425. * @param name defines the name of the mesh
  65426. * @param url defines the url to the height map
  65427. * @param options defines the options used to create the mesh
  65428. * @param scene defines the hosting scene
  65429. * @returns the ground mesh
  65430. * @see https://doc.babylonjs.com/babylon101/height_map
  65431. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  65432. */
  65433. static CreateGroundFromHeightMap(name: string, url: string, options: {
  65434. width?: number;
  65435. height?: number;
  65436. subdivisions?: number;
  65437. minHeight?: number;
  65438. maxHeight?: number;
  65439. colorFilter?: Color3;
  65440. alphaFilter?: number;
  65441. updatable?: boolean;
  65442. onReady?: (mesh: GroundMesh) => void;
  65443. }, scene?: Nullable<Scene>): GroundMesh;
  65444. /**
  65445. * Creates a polygon mesh
  65446. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65447. * * 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
  65448. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65449. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65450. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  65451. * * Remember you can only change the shape positions, not their number when updating a polygon
  65452. * @param name defines the name of the mesh
  65453. * @param options defines the options used to create the mesh
  65454. * @param scene defines the hosting scene
  65455. * @param earcutInjection can be used to inject your own earcut reference
  65456. * @returns the polygon mesh
  65457. */
  65458. static CreatePolygon(name: string, options: {
  65459. shape: Vector3[];
  65460. holes?: Vector3[][];
  65461. depth?: number;
  65462. faceUV?: Vector4[];
  65463. faceColors?: Color4[];
  65464. updatable?: boolean;
  65465. sideOrientation?: number;
  65466. frontUVs?: Vector4;
  65467. backUVs?: Vector4;
  65468. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65469. /**
  65470. * Creates an extruded polygon mesh, with depth in the Y direction.
  65471. * * 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)
  65472. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65473. * @param name defines the name of the mesh
  65474. * @param options defines the options used to create the mesh
  65475. * @param scene defines the hosting scene
  65476. * @param earcutInjection can be used to inject your own earcut reference
  65477. * @returns the polygon mesh
  65478. */
  65479. static ExtrudePolygon(name: string, options: {
  65480. shape: Vector3[];
  65481. holes?: Vector3[][];
  65482. depth?: number;
  65483. faceUV?: Vector4[];
  65484. faceColors?: Color4[];
  65485. updatable?: boolean;
  65486. sideOrientation?: number;
  65487. frontUVs?: Vector4;
  65488. backUVs?: Vector4;
  65489. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65490. /**
  65491. * Creates a tube mesh.
  65492. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65493. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65494. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65495. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65496. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65497. * * 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)
  65498. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65499. * * 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
  65500. * * 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
  65501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65502. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65503. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65504. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65505. * @param name defines the name of the mesh
  65506. * @param options defines the options used to create the mesh
  65507. * @param scene defines the hosting scene
  65508. * @returns the tube mesh
  65509. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65510. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65511. */
  65512. static CreateTube(name: string, options: {
  65513. path: Vector3[];
  65514. radius?: number;
  65515. tessellation?: number;
  65516. radiusFunction?: {
  65517. (i: number, distance: number): number;
  65518. };
  65519. cap?: number;
  65520. arc?: number;
  65521. updatable?: boolean;
  65522. sideOrientation?: number;
  65523. frontUVs?: Vector4;
  65524. backUVs?: Vector4;
  65525. instance?: Mesh;
  65526. invertUV?: boolean;
  65527. }, scene?: Nullable<Scene>): Mesh;
  65528. /**
  65529. * Creates a polyhedron mesh
  65530. * * 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
  65531. * * The parameter `size` (positive float, default 1) sets the polygon size
  65532. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  65533. * * 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`
  65534. * * 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
  65535. * * 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)`)
  65536. * * 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
  65537. * * 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
  65538. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65539. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65541. * @param name defines the name of the mesh
  65542. * @param options defines the options used to create the mesh
  65543. * @param scene defines the hosting scene
  65544. * @returns the polyhedron mesh
  65545. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  65546. */
  65547. static CreatePolyhedron(name: string, options: {
  65548. type?: number;
  65549. size?: number;
  65550. sizeX?: number;
  65551. sizeY?: number;
  65552. sizeZ?: number;
  65553. custom?: any;
  65554. faceUV?: Vector4[];
  65555. faceColors?: Color4[];
  65556. flat?: boolean;
  65557. updatable?: boolean;
  65558. sideOrientation?: number;
  65559. frontUVs?: Vector4;
  65560. backUVs?: Vector4;
  65561. }, scene?: Nullable<Scene>): Mesh;
  65562. /**
  65563. * Creates a decal mesh.
  65564. * 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
  65565. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65566. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65567. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65568. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65569. * @param name defines the name of the mesh
  65570. * @param sourceMesh defines the mesh where the decal must be applied
  65571. * @param options defines the options used to create the mesh
  65572. * @param scene defines the hosting scene
  65573. * @returns the decal mesh
  65574. * @see https://doc.babylonjs.com/how_to/decals
  65575. */
  65576. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65577. position?: Vector3;
  65578. normal?: Vector3;
  65579. size?: Vector3;
  65580. angle?: number;
  65581. }): Mesh;
  65582. }
  65583. }
  65584. declare module "babylonjs/Meshes/meshSimplification" {
  65585. import { Mesh } from "babylonjs/Meshes/mesh";
  65586. /**
  65587. * A simplifier interface for future simplification implementations
  65588. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65589. */
  65590. export interface ISimplifier {
  65591. /**
  65592. * Simplification of a given mesh according to the given settings.
  65593. * Since this requires computation, it is assumed that the function runs async.
  65594. * @param settings The settings of the simplification, including quality and distance
  65595. * @param successCallback A callback that will be called after the mesh was simplified.
  65596. * @param errorCallback in case of an error, this callback will be called. optional.
  65597. */
  65598. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  65599. }
  65600. /**
  65601. * Expected simplification settings.
  65602. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  65603. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65604. */
  65605. export interface ISimplificationSettings {
  65606. /**
  65607. * Gets or sets the expected quality
  65608. */
  65609. quality: number;
  65610. /**
  65611. * Gets or sets the distance when this optimized version should be used
  65612. */
  65613. distance: number;
  65614. /**
  65615. * Gets an already optimized mesh
  65616. */
  65617. optimizeMesh?: boolean;
  65618. }
  65619. /**
  65620. * Class used to specify simplification options
  65621. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65622. */
  65623. export class SimplificationSettings implements ISimplificationSettings {
  65624. /** expected quality */
  65625. quality: number;
  65626. /** distance when this optimized version should be used */
  65627. distance: number;
  65628. /** already optimized mesh */
  65629. optimizeMesh?: boolean | undefined;
  65630. /**
  65631. * Creates a SimplificationSettings
  65632. * @param quality expected quality
  65633. * @param distance distance when this optimized version should be used
  65634. * @param optimizeMesh already optimized mesh
  65635. */
  65636. constructor(
  65637. /** expected quality */
  65638. quality: number,
  65639. /** distance when this optimized version should be used */
  65640. distance: number,
  65641. /** already optimized mesh */
  65642. optimizeMesh?: boolean | undefined);
  65643. }
  65644. /**
  65645. * Interface used to define a simplification task
  65646. */
  65647. export interface ISimplificationTask {
  65648. /**
  65649. * Array of settings
  65650. */
  65651. settings: Array<ISimplificationSettings>;
  65652. /**
  65653. * Simplification type
  65654. */
  65655. simplificationType: SimplificationType;
  65656. /**
  65657. * Mesh to simplify
  65658. */
  65659. mesh: Mesh;
  65660. /**
  65661. * Callback called on success
  65662. */
  65663. successCallback?: () => void;
  65664. /**
  65665. * Defines if parallel processing can be used
  65666. */
  65667. parallelProcessing: boolean;
  65668. }
  65669. /**
  65670. * Queue used to order the simplification tasks
  65671. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65672. */
  65673. export class SimplificationQueue {
  65674. private _simplificationArray;
  65675. /**
  65676. * Gets a boolean indicating that the process is still running
  65677. */
  65678. running: boolean;
  65679. /**
  65680. * Creates a new queue
  65681. */
  65682. constructor();
  65683. /**
  65684. * Adds a new simplification task
  65685. * @param task defines a task to add
  65686. */
  65687. addTask(task: ISimplificationTask): void;
  65688. /**
  65689. * Execute next task
  65690. */
  65691. executeNext(): void;
  65692. /**
  65693. * Execute a simplification task
  65694. * @param task defines the task to run
  65695. */
  65696. runSimplification(task: ISimplificationTask): void;
  65697. private getSimplifier;
  65698. }
  65699. /**
  65700. * The implemented types of simplification
  65701. * At the moment only Quadratic Error Decimation is implemented
  65702. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65703. */
  65704. export enum SimplificationType {
  65705. /** Quadratic error decimation */
  65706. QUADRATIC = 0
  65707. }
  65708. /**
  65709. * An implementation of the Quadratic Error simplification algorithm.
  65710. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  65711. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  65712. * @author RaananW
  65713. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65714. */
  65715. export class QuadraticErrorSimplification implements ISimplifier {
  65716. private _mesh;
  65717. private triangles;
  65718. private vertices;
  65719. private references;
  65720. private _reconstructedMesh;
  65721. /** Gets or sets the number pf sync interations */
  65722. syncIterations: number;
  65723. /** Gets or sets the aggressiveness of the simplifier */
  65724. aggressiveness: number;
  65725. /** Gets or sets the number of allowed iterations for decimation */
  65726. decimationIterations: number;
  65727. /** Gets or sets the espilon to use for bounding box computation */
  65728. boundingBoxEpsilon: number;
  65729. /**
  65730. * Creates a new QuadraticErrorSimplification
  65731. * @param _mesh defines the target mesh
  65732. */
  65733. constructor(_mesh: Mesh);
  65734. /**
  65735. * Simplification of a given mesh according to the given settings.
  65736. * Since this requires computation, it is assumed that the function runs async.
  65737. * @param settings The settings of the simplification, including quality and distance
  65738. * @param successCallback A callback that will be called after the mesh was simplified.
  65739. */
  65740. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  65741. private runDecimation;
  65742. private initWithMesh;
  65743. private init;
  65744. private reconstructMesh;
  65745. private initDecimatedMesh;
  65746. private isFlipped;
  65747. private updateTriangles;
  65748. private identifyBorder;
  65749. private updateMesh;
  65750. private vertexError;
  65751. private calculateError;
  65752. }
  65753. }
  65754. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  65755. import { Scene } from "babylonjs/scene";
  65756. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  65757. import { ISceneComponent } from "babylonjs/sceneComponent";
  65758. module "babylonjs/scene" {
  65759. interface Scene {
  65760. /** @hidden (Backing field) */
  65761. _simplificationQueue: SimplificationQueue;
  65762. /**
  65763. * Gets or sets the simplification queue attached to the scene
  65764. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65765. */
  65766. simplificationQueue: SimplificationQueue;
  65767. }
  65768. }
  65769. module "babylonjs/Meshes/mesh" {
  65770. interface Mesh {
  65771. /**
  65772. * Simplify the mesh according to the given array of settings.
  65773. * Function will return immediately and will simplify async
  65774. * @param settings a collection of simplification settings
  65775. * @param parallelProcessing should all levels calculate parallel or one after the other
  65776. * @param simplificationType the type of simplification to run
  65777. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  65778. * @returns the current mesh
  65779. */
  65780. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  65781. }
  65782. }
  65783. /**
  65784. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  65785. * created in a scene
  65786. */
  65787. export class SimplicationQueueSceneComponent implements ISceneComponent {
  65788. /**
  65789. * The component name helpfull to identify the component in the list of scene components.
  65790. */
  65791. readonly name: string;
  65792. /**
  65793. * The scene the component belongs to.
  65794. */
  65795. scene: Scene;
  65796. /**
  65797. * Creates a new instance of the component for the given scene
  65798. * @param scene Defines the scene to register the component in
  65799. */
  65800. constructor(scene: Scene);
  65801. /**
  65802. * Registers the component in a given scene
  65803. */
  65804. register(): void;
  65805. /**
  65806. * Rebuilds the elements related to this component in case of
  65807. * context lost for instance.
  65808. */
  65809. rebuild(): void;
  65810. /**
  65811. * Disposes the component and the associated ressources
  65812. */
  65813. dispose(): void;
  65814. private _beforeCameraUpdate;
  65815. }
  65816. }
  65817. declare module "babylonjs/Meshes/Builders/index" {
  65818. export * from "babylonjs/Meshes/Builders/boxBuilder";
  65819. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  65820. export * from "babylonjs/Meshes/Builders/discBuilder";
  65821. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  65822. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  65823. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  65824. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  65825. export * from "babylonjs/Meshes/Builders/torusBuilder";
  65826. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  65827. export * from "babylonjs/Meshes/Builders/linesBuilder";
  65828. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  65829. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  65830. export * from "babylonjs/Meshes/Builders/latheBuilder";
  65831. export * from "babylonjs/Meshes/Builders/planeBuilder";
  65832. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  65833. export * from "babylonjs/Meshes/Builders/groundBuilder";
  65834. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  65835. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  65836. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  65837. export * from "babylonjs/Meshes/Builders/decalBuilder";
  65838. }
  65839. declare module "babylonjs/Meshes/index" {
  65840. export * from "babylonjs/Meshes/abstractMesh";
  65841. export * from "babylonjs/Meshes/buffer";
  65842. export * from "babylonjs/Meshes/Compression/index";
  65843. export * from "babylonjs/Meshes/csg";
  65844. export * from "babylonjs/Meshes/geometry";
  65845. export * from "babylonjs/Meshes/groundMesh";
  65846. export * from "babylonjs/Meshes/trailMesh";
  65847. export * from "babylonjs/Meshes/instancedMesh";
  65848. export * from "babylonjs/Meshes/linesMesh";
  65849. export * from "babylonjs/Meshes/mesh";
  65850. export * from "babylonjs/Meshes/mesh.vertexData";
  65851. export * from "babylonjs/Meshes/meshBuilder";
  65852. export * from "babylonjs/Meshes/meshSimplification";
  65853. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  65854. export * from "babylonjs/Meshes/polygonMesh";
  65855. export * from "babylonjs/Meshes/subMesh";
  65856. export * from "babylonjs/Meshes/meshLODLevel";
  65857. export * from "babylonjs/Meshes/transformNode";
  65858. export * from "babylonjs/Meshes/Builders/index";
  65859. export * from "babylonjs/Meshes/dataBuffer";
  65860. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  65861. }
  65862. declare module "babylonjs/Morph/index" {
  65863. export * from "babylonjs/Morph/morphTarget";
  65864. export * from "babylonjs/Morph/morphTargetManager";
  65865. }
  65866. declare module "babylonjs/Navigation/INavigationEngine" {
  65867. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65868. import { Vector3 } from "babylonjs/Maths/math";
  65869. import { Mesh } from "babylonjs/Meshes/mesh";
  65870. import { Scene } from "babylonjs/scene";
  65871. /**
  65872. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65873. */
  65874. export interface INavigationEnginePlugin {
  65875. /**
  65876. * plugin name
  65877. */
  65878. name: string;
  65879. /**
  65880. * Creates a navigation mesh
  65881. * @param meshes array of all the geometry used to compute the navigatio mesh
  65882. * @param parameters bunch of parameters used to filter geometry
  65883. */
  65884. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65885. /**
  65886. * Create a navigation mesh debug mesh
  65887. * @param scene is where the mesh will be added
  65888. * @returns debug display mesh
  65889. */
  65890. createDebugNavMesh(scene: Scene): Mesh;
  65891. /**
  65892. * Get a navigation mesh constrained position, closest to the parameter position
  65893. * @param position world position
  65894. * @returns the closest point to position constrained by the navigation mesh
  65895. */
  65896. getClosestPoint(position: Vector3): Vector3;
  65897. /**
  65898. * Get a navigation mesh constrained position, closest to the parameter position
  65899. * @param position world position
  65900. * @param result output the closest point to position constrained by the navigation mesh
  65901. */
  65902. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65903. /**
  65904. * Get a navigation mesh constrained position, within a particular radius
  65905. * @param position world position
  65906. * @param maxRadius the maximum distance to the constrained world position
  65907. * @returns the closest point to position constrained by the navigation mesh
  65908. */
  65909. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65910. /**
  65911. * Get a navigation mesh constrained position, within a particular radius
  65912. * @param position world position
  65913. * @param maxRadius the maximum distance to the constrained world position
  65914. * @param result output the closest point to position constrained by the navigation mesh
  65915. */
  65916. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65917. /**
  65918. * Compute the final position from a segment made of destination-position
  65919. * @param position world position
  65920. * @param destination world position
  65921. * @returns the resulting point along the navmesh
  65922. */
  65923. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65924. /**
  65925. * Compute the final position from a segment made of destination-position
  65926. * @param position world position
  65927. * @param destination world position
  65928. * @param result output the resulting point along the navmesh
  65929. */
  65930. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65931. /**
  65932. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65933. * @param start world position
  65934. * @param end world position
  65935. * @returns array containing world position composing the path
  65936. */
  65937. computePath(start: Vector3, end: Vector3): Vector3[];
  65938. /**
  65939. * If this plugin is supported
  65940. * @returns true if plugin is supported
  65941. */
  65942. isSupported(): boolean;
  65943. /**
  65944. * Create a new Crowd so you can add agents
  65945. * @param maxAgents the maximum agent count in the crowd
  65946. * @param maxAgentRadius the maximum radius an agent can have
  65947. * @param scene to attach the crowd to
  65948. * @returns the crowd you can add agents to
  65949. */
  65950. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65951. /**
  65952. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65953. * The queries will try to find a solution within those bounds
  65954. * default is (1,1,1)
  65955. * @param extent x,y,z value that define the extent around the queries point of reference
  65956. */
  65957. setDefaultQueryExtent(extent: Vector3): void;
  65958. /**
  65959. * Get the Bounding box extent specified by setDefaultQueryExtent
  65960. * @returns the box extent values
  65961. */
  65962. getDefaultQueryExtent(): Vector3;
  65963. /**
  65964. * build the navmesh from a previously saved state using getNavmeshData
  65965. * @param data the Uint8Array returned by getNavmeshData
  65966. */
  65967. buildFromNavmeshData(data: Uint8Array): void;
  65968. /**
  65969. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65970. * @returns data the Uint8Array that can be saved and reused
  65971. */
  65972. getNavmeshData(): Uint8Array;
  65973. /**
  65974. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65975. * @param result output the box extent values
  65976. */
  65977. getDefaultQueryExtentToRef(result: Vector3): void;
  65978. /**
  65979. * Release all resources
  65980. */
  65981. dispose(): void;
  65982. }
  65983. /**
  65984. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65985. */
  65986. export interface ICrowd {
  65987. /**
  65988. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65989. * You can attach anything to that node. The node position is updated in the scene update tick.
  65990. * @param pos world position that will be constrained by the navigation mesh
  65991. * @param parameters agent parameters
  65992. * @param transform hooked to the agent that will be update by the scene
  65993. * @returns agent index
  65994. */
  65995. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65996. /**
  65997. * Returns the agent position in world space
  65998. * @param index agent index returned by addAgent
  65999. * @returns world space position
  66000. */
  66001. getAgentPosition(index: number): Vector3;
  66002. /**
  66003. * Gets the agent position result in world space
  66004. * @param index agent index returned by addAgent
  66005. * @param result output world space position
  66006. */
  66007. getAgentPositionToRef(index: number, result: Vector3): void;
  66008. /**
  66009. * Gets the agent velocity in world space
  66010. * @param index agent index returned by addAgent
  66011. * @returns world space velocity
  66012. */
  66013. getAgentVelocity(index: number): Vector3;
  66014. /**
  66015. * Gets the agent velocity result in world space
  66016. * @param index agent index returned by addAgent
  66017. * @param result output world space velocity
  66018. */
  66019. getAgentVelocityToRef(index: number, result: Vector3): void;
  66020. /**
  66021. * remove a particular agent previously created
  66022. * @param index agent index returned by addAgent
  66023. */
  66024. removeAgent(index: number): void;
  66025. /**
  66026. * get the list of all agents attached to this crowd
  66027. * @returns list of agent indices
  66028. */
  66029. getAgents(): number[];
  66030. /**
  66031. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66032. * @param deltaTime in seconds
  66033. */
  66034. update(deltaTime: number): void;
  66035. /**
  66036. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66037. * @param index agent index returned by addAgent
  66038. * @param destination targeted world position
  66039. */
  66040. agentGoto(index: number, destination: Vector3): void;
  66041. /**
  66042. * Teleport the agent to a new position
  66043. * @param index agent index returned by addAgent
  66044. * @param destination targeted world position
  66045. */
  66046. agentTeleport(index: number, destination: Vector3): void;
  66047. /**
  66048. * Update agent parameters
  66049. * @param index agent index returned by addAgent
  66050. * @param parameters agent parameters
  66051. */
  66052. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66053. /**
  66054. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66055. * The queries will try to find a solution within those bounds
  66056. * default is (1,1,1)
  66057. * @param extent x,y,z value that define the extent around the queries point of reference
  66058. */
  66059. setDefaultQueryExtent(extent: Vector3): void;
  66060. /**
  66061. * Get the Bounding box extent specified by setDefaultQueryExtent
  66062. * @returns the box extent values
  66063. */
  66064. getDefaultQueryExtent(): Vector3;
  66065. /**
  66066. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66067. * @param result output the box extent values
  66068. */
  66069. getDefaultQueryExtentToRef(result: Vector3): void;
  66070. /**
  66071. * Release all resources
  66072. */
  66073. dispose(): void;
  66074. }
  66075. /**
  66076. * Configures an agent
  66077. */
  66078. export interface IAgentParameters {
  66079. /**
  66080. * Agent radius. [Limit: >= 0]
  66081. */
  66082. radius: number;
  66083. /**
  66084. * Agent height. [Limit: > 0]
  66085. */
  66086. height: number;
  66087. /**
  66088. * Maximum allowed acceleration. [Limit: >= 0]
  66089. */
  66090. maxAcceleration: number;
  66091. /**
  66092. * Maximum allowed speed. [Limit: >= 0]
  66093. */
  66094. maxSpeed: number;
  66095. /**
  66096. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  66097. */
  66098. collisionQueryRange: number;
  66099. /**
  66100. * The path visibility optimization range. [Limit: > 0]
  66101. */
  66102. pathOptimizationRange: number;
  66103. /**
  66104. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  66105. */
  66106. separationWeight: number;
  66107. }
  66108. /**
  66109. * Configures the navigation mesh creation
  66110. */
  66111. export interface INavMeshParameters {
  66112. /**
  66113. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  66114. */
  66115. cs: number;
  66116. /**
  66117. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  66118. */
  66119. ch: number;
  66120. /**
  66121. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  66122. */
  66123. walkableSlopeAngle: number;
  66124. /**
  66125. * Minimum floor to 'ceiling' height that will still allow the floor area to
  66126. * be considered walkable. [Limit: >= 3] [Units: vx]
  66127. */
  66128. walkableHeight: number;
  66129. /**
  66130. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  66131. */
  66132. walkableClimb: number;
  66133. /**
  66134. * The distance to erode/shrink the walkable area of the heightfield away from
  66135. * obstructions. [Limit: >=0] [Units: vx]
  66136. */
  66137. walkableRadius: number;
  66138. /**
  66139. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  66140. */
  66141. maxEdgeLen: number;
  66142. /**
  66143. * The maximum distance a simplfied contour's border edges should deviate
  66144. * the original raw contour. [Limit: >=0] [Units: vx]
  66145. */
  66146. maxSimplificationError: number;
  66147. /**
  66148. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  66149. */
  66150. minRegionArea: number;
  66151. /**
  66152. * Any regions with a span count smaller than this value will, if possible,
  66153. * be merged with larger regions. [Limit: >=0] [Units: vx]
  66154. */
  66155. mergeRegionArea: number;
  66156. /**
  66157. * The maximum number of vertices allowed for polygons generated during the
  66158. * contour to polygon conversion process. [Limit: >= 3]
  66159. */
  66160. maxVertsPerPoly: number;
  66161. /**
  66162. * Sets the sampling distance to use when generating the detail mesh.
  66163. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  66164. */
  66165. detailSampleDist: number;
  66166. /**
  66167. * The maximum distance the detail mesh surface should deviate from heightfield
  66168. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  66169. */
  66170. detailSampleMaxError: number;
  66171. }
  66172. }
  66173. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  66174. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  66175. import { Mesh } from "babylonjs/Meshes/mesh";
  66176. import { Scene } from "babylonjs/scene";
  66177. import { Vector3 } from "babylonjs/Maths/math";
  66178. import { TransformNode } from "babylonjs/Meshes/transformNode";
  66179. /**
  66180. * RecastJS navigation plugin
  66181. */
  66182. export class RecastJSPlugin implements INavigationEnginePlugin {
  66183. /**
  66184. * Reference to the Recast library
  66185. */
  66186. bjsRECAST: any;
  66187. /**
  66188. * plugin name
  66189. */
  66190. name: string;
  66191. /**
  66192. * the first navmesh created. We might extend this to support multiple navmeshes
  66193. */
  66194. navMesh: any;
  66195. /**
  66196. * Initializes the recastJS plugin
  66197. * @param recastInjection can be used to inject your own recast reference
  66198. */
  66199. constructor(recastInjection?: any);
  66200. /**
  66201. * Creates a navigation mesh
  66202. * @param meshes array of all the geometry used to compute the navigatio mesh
  66203. * @param parameters bunch of parameters used to filter geometry
  66204. */
  66205. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66206. /**
  66207. * Create a navigation mesh debug mesh
  66208. * @param scene is where the mesh will be added
  66209. * @returns debug display mesh
  66210. */
  66211. createDebugNavMesh(scene: Scene): Mesh;
  66212. /**
  66213. * Get a navigation mesh constrained position, closest to the parameter position
  66214. * @param position world position
  66215. * @returns the closest point to position constrained by the navigation mesh
  66216. */
  66217. getClosestPoint(position: Vector3): Vector3;
  66218. /**
  66219. * Get a navigation mesh constrained position, closest to the parameter position
  66220. * @param position world position
  66221. * @param result output the closest point to position constrained by the navigation mesh
  66222. */
  66223. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66224. /**
  66225. * Get a navigation mesh constrained position, within a particular radius
  66226. * @param position world position
  66227. * @param maxRadius the maximum distance to the constrained world position
  66228. * @returns the closest point to position constrained by the navigation mesh
  66229. */
  66230. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66231. /**
  66232. * Get a navigation mesh constrained position, within a particular radius
  66233. * @param position world position
  66234. * @param maxRadius the maximum distance to the constrained world position
  66235. * @param result output the closest point to position constrained by the navigation mesh
  66236. */
  66237. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66238. /**
  66239. * Compute the final position from a segment made of destination-position
  66240. * @param position world position
  66241. * @param destination world position
  66242. * @returns the resulting point along the navmesh
  66243. */
  66244. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66245. /**
  66246. * Compute the final position from a segment made of destination-position
  66247. * @param position world position
  66248. * @param destination world position
  66249. * @param result output the resulting point along the navmesh
  66250. */
  66251. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66252. /**
  66253. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66254. * @param start world position
  66255. * @param end world position
  66256. * @returns array containing world position composing the path
  66257. */
  66258. computePath(start: Vector3, end: Vector3): Vector3[];
  66259. /**
  66260. * Create a new Crowd so you can add agents
  66261. * @param maxAgents the maximum agent count in the crowd
  66262. * @param maxAgentRadius the maximum radius an agent can have
  66263. * @param scene to attach the crowd to
  66264. * @returns the crowd you can add agents to
  66265. */
  66266. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66267. /**
  66268. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66269. * The queries will try to find a solution within those bounds
  66270. * default is (1,1,1)
  66271. * @param extent x,y,z value that define the extent around the queries point of reference
  66272. */
  66273. setDefaultQueryExtent(extent: Vector3): void;
  66274. /**
  66275. * Get the Bounding box extent specified by setDefaultQueryExtent
  66276. * @returns the box extent values
  66277. */
  66278. getDefaultQueryExtent(): Vector3;
  66279. /**
  66280. * build the navmesh from a previously saved state using getNavmeshData
  66281. * @param data the Uint8Array returned by getNavmeshData
  66282. */
  66283. buildFromNavmeshData(data: Uint8Array): void;
  66284. /**
  66285. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66286. * @returns data the Uint8Array that can be saved and reused
  66287. */
  66288. getNavmeshData(): Uint8Array;
  66289. /**
  66290. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66291. * @param result output the box extent values
  66292. */
  66293. getDefaultQueryExtentToRef(result: Vector3): void;
  66294. /**
  66295. * Disposes
  66296. */
  66297. dispose(): void;
  66298. /**
  66299. * If this plugin is supported
  66300. * @returns true if plugin is supported
  66301. */
  66302. isSupported(): boolean;
  66303. }
  66304. /**
  66305. * Recast detour crowd implementation
  66306. */
  66307. export class RecastJSCrowd implements ICrowd {
  66308. /**
  66309. * Recast/detour plugin
  66310. */
  66311. bjsRECASTPlugin: RecastJSPlugin;
  66312. /**
  66313. * Link to the detour crowd
  66314. */
  66315. recastCrowd: any;
  66316. /**
  66317. * One transform per agent
  66318. */
  66319. transforms: TransformNode[];
  66320. /**
  66321. * All agents created
  66322. */
  66323. agents: number[];
  66324. /**
  66325. * Link to the scene is kept to unregister the crowd from the scene
  66326. */
  66327. private _scene;
  66328. /**
  66329. * Observer for crowd updates
  66330. */
  66331. private _onBeforeAnimationsObserver;
  66332. /**
  66333. * Constructor
  66334. * @param plugin recastJS plugin
  66335. * @param maxAgents the maximum agent count in the crowd
  66336. * @param maxAgentRadius the maximum radius an agent can have
  66337. * @param scene to attach the crowd to
  66338. * @returns the crowd you can add agents to
  66339. */
  66340. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  66341. /**
  66342. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66343. * You can attach anything to that node. The node position is updated in the scene update tick.
  66344. * @param pos world position that will be constrained by the navigation mesh
  66345. * @param parameters agent parameters
  66346. * @param transform hooked to the agent that will be update by the scene
  66347. * @returns agent index
  66348. */
  66349. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66350. /**
  66351. * Returns the agent position in world space
  66352. * @param index agent index returned by addAgent
  66353. * @returns world space position
  66354. */
  66355. getAgentPosition(index: number): Vector3;
  66356. /**
  66357. * Returns the agent position result in world space
  66358. * @param index agent index returned by addAgent
  66359. * @param result output world space position
  66360. */
  66361. getAgentPositionToRef(index: number, result: Vector3): void;
  66362. /**
  66363. * Returns the agent velocity in world space
  66364. * @param index agent index returned by addAgent
  66365. * @returns world space velocity
  66366. */
  66367. getAgentVelocity(index: number): Vector3;
  66368. /**
  66369. * Returns the agent velocity result in world space
  66370. * @param index agent index returned by addAgent
  66371. * @param result output world space velocity
  66372. */
  66373. getAgentVelocityToRef(index: number, result: Vector3): void;
  66374. /**
  66375. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66376. * @param index agent index returned by addAgent
  66377. * @param destination targeted world position
  66378. */
  66379. agentGoto(index: number, destination: Vector3): void;
  66380. /**
  66381. * Teleport the agent to a new position
  66382. * @param index agent index returned by addAgent
  66383. * @param destination targeted world position
  66384. */
  66385. agentTeleport(index: number, destination: Vector3): void;
  66386. /**
  66387. * Update agent parameters
  66388. * @param index agent index returned by addAgent
  66389. * @param parameters agent parameters
  66390. */
  66391. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66392. /**
  66393. * remove a particular agent previously created
  66394. * @param index agent index returned by addAgent
  66395. */
  66396. removeAgent(index: number): void;
  66397. /**
  66398. * get the list of all agents attached to this crowd
  66399. * @returns list of agent indices
  66400. */
  66401. getAgents(): number[];
  66402. /**
  66403. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66404. * @param deltaTime in seconds
  66405. */
  66406. update(deltaTime: number): void;
  66407. /**
  66408. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66409. * The queries will try to find a solution within those bounds
  66410. * default is (1,1,1)
  66411. * @param extent x,y,z value that define the extent around the queries point of reference
  66412. */
  66413. setDefaultQueryExtent(extent: Vector3): void;
  66414. /**
  66415. * Get the Bounding box extent specified by setDefaultQueryExtent
  66416. * @returns the box extent values
  66417. */
  66418. getDefaultQueryExtent(): Vector3;
  66419. /**
  66420. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66421. * @param result output the box extent values
  66422. */
  66423. getDefaultQueryExtentToRef(result: Vector3): void;
  66424. /**
  66425. * Release all resources
  66426. */
  66427. dispose(): void;
  66428. }
  66429. }
  66430. declare module "babylonjs/Navigation/Plugins/index" {
  66431. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  66432. }
  66433. declare module "babylonjs/Navigation/index" {
  66434. export * from "babylonjs/Navigation/INavigationEngine";
  66435. export * from "babylonjs/Navigation/Plugins/index";
  66436. }
  66437. declare module "babylonjs/Offline/database" {
  66438. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  66439. /**
  66440. * Class used to enable access to IndexedDB
  66441. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66442. */
  66443. export class Database implements IOfflineProvider {
  66444. private _callbackManifestChecked;
  66445. private _currentSceneUrl;
  66446. private _db;
  66447. private _enableSceneOffline;
  66448. private _enableTexturesOffline;
  66449. private _manifestVersionFound;
  66450. private _mustUpdateRessources;
  66451. private _hasReachedQuota;
  66452. private _isSupported;
  66453. private _idbFactory;
  66454. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  66455. private static IsUASupportingBlobStorage;
  66456. /**
  66457. * Gets a boolean indicating if Database storate is enabled (off by default)
  66458. */
  66459. static IDBStorageEnabled: boolean;
  66460. /**
  66461. * Gets a boolean indicating if scene must be saved in the database
  66462. */
  66463. get enableSceneOffline(): boolean;
  66464. /**
  66465. * Gets a boolean indicating if textures must be saved in the database
  66466. */
  66467. get enableTexturesOffline(): boolean;
  66468. /**
  66469. * Creates a new Database
  66470. * @param urlToScene defines the url to load the scene
  66471. * @param callbackManifestChecked defines the callback to use when manifest is checked
  66472. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  66473. */
  66474. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  66475. private static _ParseURL;
  66476. private static _ReturnFullUrlLocation;
  66477. private _checkManifestFile;
  66478. /**
  66479. * Open the database and make it available
  66480. * @param successCallback defines the callback to call on success
  66481. * @param errorCallback defines the callback to call on error
  66482. */
  66483. open(successCallback: () => void, errorCallback: () => void): void;
  66484. /**
  66485. * Loads an image from the database
  66486. * @param url defines the url to load from
  66487. * @param image defines the target DOM image
  66488. */
  66489. loadImage(url: string, image: HTMLImageElement): void;
  66490. private _loadImageFromDBAsync;
  66491. private _saveImageIntoDBAsync;
  66492. private _checkVersionFromDB;
  66493. private _loadVersionFromDBAsync;
  66494. private _saveVersionIntoDBAsync;
  66495. /**
  66496. * Loads a file from database
  66497. * @param url defines the URL to load from
  66498. * @param sceneLoaded defines a callback to call on success
  66499. * @param progressCallBack defines a callback to call when progress changed
  66500. * @param errorCallback defines a callback to call on error
  66501. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66502. */
  66503. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66504. private _loadFileAsync;
  66505. private _saveFileAsync;
  66506. /**
  66507. * Validates if xhr data is correct
  66508. * @param xhr defines the request to validate
  66509. * @param dataType defines the expected data type
  66510. * @returns true if data is correct
  66511. */
  66512. private static _ValidateXHRData;
  66513. }
  66514. }
  66515. declare module "babylonjs/Offline/index" {
  66516. export * from "babylonjs/Offline/database";
  66517. export * from "babylonjs/Offline/IOfflineProvider";
  66518. }
  66519. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  66520. /** @hidden */
  66521. export var gpuUpdateParticlesPixelShader: {
  66522. name: string;
  66523. shader: string;
  66524. };
  66525. }
  66526. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  66527. /** @hidden */
  66528. export var gpuUpdateParticlesVertexShader: {
  66529. name: string;
  66530. shader: string;
  66531. };
  66532. }
  66533. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  66534. /** @hidden */
  66535. export var clipPlaneFragmentDeclaration2: {
  66536. name: string;
  66537. shader: string;
  66538. };
  66539. }
  66540. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  66541. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  66542. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  66543. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66544. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  66545. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  66546. /** @hidden */
  66547. export var gpuRenderParticlesPixelShader: {
  66548. name: string;
  66549. shader: string;
  66550. };
  66551. }
  66552. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  66553. /** @hidden */
  66554. export var clipPlaneVertexDeclaration2: {
  66555. name: string;
  66556. shader: string;
  66557. };
  66558. }
  66559. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  66560. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  66561. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  66562. /** @hidden */
  66563. export var gpuRenderParticlesVertexShader: {
  66564. name: string;
  66565. shader: string;
  66566. };
  66567. }
  66568. declare module "babylonjs/Particles/gpuParticleSystem" {
  66569. import { Nullable } from "babylonjs/types";
  66570. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  66571. import { Observable } from "babylonjs/Misc/observable";
  66572. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  66573. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66574. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  66575. import { Scene, IDisposable } from "babylonjs/scene";
  66576. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  66577. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  66578. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  66579. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  66580. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  66581. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  66582. /**
  66583. * This represents a GPU particle system in Babylon
  66584. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  66585. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  66586. */
  66587. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  66588. /**
  66589. * The layer mask we are rendering the particles through.
  66590. */
  66591. layerMask: number;
  66592. private _capacity;
  66593. private _activeCount;
  66594. private _currentActiveCount;
  66595. private _accumulatedCount;
  66596. private _renderEffect;
  66597. private _updateEffect;
  66598. private _buffer0;
  66599. private _buffer1;
  66600. private _spriteBuffer;
  66601. private _updateVAO;
  66602. private _renderVAO;
  66603. private _targetIndex;
  66604. private _sourceBuffer;
  66605. private _targetBuffer;
  66606. private _engine;
  66607. private _currentRenderId;
  66608. private _started;
  66609. private _stopped;
  66610. private _timeDelta;
  66611. private _randomTexture;
  66612. private _randomTexture2;
  66613. private _attributesStrideSize;
  66614. private _updateEffectOptions;
  66615. private _randomTextureSize;
  66616. private _actualFrame;
  66617. private readonly _rawTextureWidth;
  66618. /**
  66619. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  66620. */
  66621. static get IsSupported(): boolean;
  66622. /**
  66623. * An event triggered when the system is disposed.
  66624. */
  66625. onDisposeObservable: Observable<GPUParticleSystem>;
  66626. /**
  66627. * Gets the maximum number of particles active at the same time.
  66628. * @returns The max number of active particles.
  66629. */
  66630. getCapacity(): number;
  66631. /**
  66632. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  66633. * to override the particles.
  66634. */
  66635. forceDepthWrite: boolean;
  66636. /**
  66637. * Gets or set the number of active particles
  66638. */
  66639. get activeParticleCount(): number;
  66640. set activeParticleCount(value: number);
  66641. private _preWarmDone;
  66642. /**
  66643. * Specifies if the particles are updated in emitter local space or world space.
  66644. * This is always false for GPU particles
  66645. */
  66646. get isLocal(): boolean;
  66647. set isLocal(value: boolean);
  66648. /**
  66649. * Is this system ready to be used/rendered
  66650. * @return true if the system is ready
  66651. */
  66652. isReady(): boolean;
  66653. /**
  66654. * Gets if the system has been started. (Note: this will still be true after stop is called)
  66655. * @returns True if it has been started, otherwise false.
  66656. */
  66657. isStarted(): boolean;
  66658. /**
  66659. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  66660. * @returns True if it has been stopped, otherwise false.
  66661. */
  66662. isStopped(): boolean;
  66663. /**
  66664. * Gets a boolean indicating that the system is stopping
  66665. * @returns true if the system is currently stopping
  66666. */
  66667. isStopping(): boolean;
  66668. /**
  66669. * Gets the number of particles active at the same time.
  66670. * @returns The number of active particles.
  66671. */
  66672. getActiveCount(): number;
  66673. /**
  66674. * Starts the particle system and begins to emit
  66675. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  66676. */
  66677. start(delay?: number): void;
  66678. /**
  66679. * Stops the particle system.
  66680. */
  66681. stop(): void;
  66682. /**
  66683. * Remove all active particles
  66684. */
  66685. reset(): void;
  66686. /**
  66687. * Returns the string "GPUParticleSystem"
  66688. * @returns a string containing the class name
  66689. */
  66690. getClassName(): string;
  66691. private _colorGradientsTexture;
  66692. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  66693. /**
  66694. * Adds a new color gradient
  66695. * @param gradient defines the gradient to use (between 0 and 1)
  66696. * @param color1 defines the color to affect to the specified gradient
  66697. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  66698. * @returns the current particle system
  66699. */
  66700. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  66701. private _refreshColorGradient;
  66702. /** Force the system to rebuild all gradients that need to be resync */
  66703. forceRefreshGradients(): void;
  66704. /**
  66705. * Remove a specific color gradient
  66706. * @param gradient defines the gradient to remove
  66707. * @returns the current particle system
  66708. */
  66709. removeColorGradient(gradient: number): GPUParticleSystem;
  66710. private _angularSpeedGradientsTexture;
  66711. private _sizeGradientsTexture;
  66712. private _velocityGradientsTexture;
  66713. private _limitVelocityGradientsTexture;
  66714. private _dragGradientsTexture;
  66715. private _addFactorGradient;
  66716. /**
  66717. * Adds a new size gradient
  66718. * @param gradient defines the gradient to use (between 0 and 1)
  66719. * @param factor defines the size factor to affect to the specified gradient
  66720. * @returns the current particle system
  66721. */
  66722. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  66723. /**
  66724. * Remove a specific size gradient
  66725. * @param gradient defines the gradient to remove
  66726. * @returns the current particle system
  66727. */
  66728. removeSizeGradient(gradient: number): GPUParticleSystem;
  66729. private _refreshFactorGradient;
  66730. /**
  66731. * Adds a new angular speed gradient
  66732. * @param gradient defines the gradient to use (between 0 and 1)
  66733. * @param factor defines the angular speed to affect to the specified gradient
  66734. * @returns the current particle system
  66735. */
  66736. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  66737. /**
  66738. * Remove a specific angular speed gradient
  66739. * @param gradient defines the gradient to remove
  66740. * @returns the current particle system
  66741. */
  66742. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  66743. /**
  66744. * Adds a new velocity gradient
  66745. * @param gradient defines the gradient to use (between 0 and 1)
  66746. * @param factor defines the velocity to affect to the specified gradient
  66747. * @returns the current particle system
  66748. */
  66749. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66750. /**
  66751. * Remove a specific velocity gradient
  66752. * @param gradient defines the gradient to remove
  66753. * @returns the current particle system
  66754. */
  66755. removeVelocityGradient(gradient: number): GPUParticleSystem;
  66756. /**
  66757. * Adds a new limit velocity gradient
  66758. * @param gradient defines the gradient to use (between 0 and 1)
  66759. * @param factor defines the limit velocity value to affect to the specified gradient
  66760. * @returns the current particle system
  66761. */
  66762. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66763. /**
  66764. * Remove a specific limit velocity gradient
  66765. * @param gradient defines the gradient to remove
  66766. * @returns the current particle system
  66767. */
  66768. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  66769. /**
  66770. * Adds a new drag gradient
  66771. * @param gradient defines the gradient to use (between 0 and 1)
  66772. * @param factor defines the drag value to affect to the specified gradient
  66773. * @returns the current particle system
  66774. */
  66775. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  66776. /**
  66777. * Remove a specific drag gradient
  66778. * @param gradient defines the gradient to remove
  66779. * @returns the current particle system
  66780. */
  66781. removeDragGradient(gradient: number): GPUParticleSystem;
  66782. /**
  66783. * Not supported by GPUParticleSystem
  66784. * @param gradient defines the gradient to use (between 0 and 1)
  66785. * @param factor defines the emit rate value to affect to the specified gradient
  66786. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66787. * @returns the current particle system
  66788. */
  66789. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66790. /**
  66791. * Not supported by GPUParticleSystem
  66792. * @param gradient defines the gradient to remove
  66793. * @returns the current particle system
  66794. */
  66795. removeEmitRateGradient(gradient: number): IParticleSystem;
  66796. /**
  66797. * Not supported by GPUParticleSystem
  66798. * @param gradient defines the gradient to use (between 0 and 1)
  66799. * @param factor defines the start size value to affect to the specified gradient
  66800. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66801. * @returns the current particle system
  66802. */
  66803. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66804. /**
  66805. * Not supported by GPUParticleSystem
  66806. * @param gradient defines the gradient to remove
  66807. * @returns the current particle system
  66808. */
  66809. removeStartSizeGradient(gradient: number): IParticleSystem;
  66810. /**
  66811. * Not supported by GPUParticleSystem
  66812. * @param gradient defines the gradient to use (between 0 and 1)
  66813. * @param min defines the color remap minimal range
  66814. * @param max defines the color remap maximal range
  66815. * @returns the current particle system
  66816. */
  66817. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66818. /**
  66819. * Not supported by GPUParticleSystem
  66820. * @param gradient defines the gradient to remove
  66821. * @returns the current particle system
  66822. */
  66823. removeColorRemapGradient(): IParticleSystem;
  66824. /**
  66825. * Not supported by GPUParticleSystem
  66826. * @param gradient defines the gradient to use (between 0 and 1)
  66827. * @param min defines the alpha remap minimal range
  66828. * @param max defines the alpha remap maximal range
  66829. * @returns the current particle system
  66830. */
  66831. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66832. /**
  66833. * Not supported by GPUParticleSystem
  66834. * @param gradient defines the gradient to remove
  66835. * @returns the current particle system
  66836. */
  66837. removeAlphaRemapGradient(): IParticleSystem;
  66838. /**
  66839. * Not supported by GPUParticleSystem
  66840. * @param gradient defines the gradient to use (between 0 and 1)
  66841. * @param color defines the color to affect to the specified gradient
  66842. * @returns the current particle system
  66843. */
  66844. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  66845. /**
  66846. * Not supported by GPUParticleSystem
  66847. * @param gradient defines the gradient to remove
  66848. * @returns the current particle system
  66849. */
  66850. removeRampGradient(): IParticleSystem;
  66851. /**
  66852. * Not supported by GPUParticleSystem
  66853. * @returns the list of ramp gradients
  66854. */
  66855. getRampGradients(): Nullable<Array<Color3Gradient>>;
  66856. /**
  66857. * Not supported by GPUParticleSystem
  66858. * Gets or sets a boolean indicating that ramp gradients must be used
  66859. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  66860. */
  66861. get useRampGradients(): boolean;
  66862. set useRampGradients(value: boolean);
  66863. /**
  66864. * Not supported by GPUParticleSystem
  66865. * @param gradient defines the gradient to use (between 0 and 1)
  66866. * @param factor defines the life time factor to affect to the specified gradient
  66867. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66868. * @returns the current particle system
  66869. */
  66870. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66871. /**
  66872. * Not supported by GPUParticleSystem
  66873. * @param gradient defines the gradient to remove
  66874. * @returns the current particle system
  66875. */
  66876. removeLifeTimeGradient(gradient: number): IParticleSystem;
  66877. /**
  66878. * Instantiates a GPU particle system.
  66879. * 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.
  66880. * @param name The name of the particle system
  66881. * @param options The options used to create the system
  66882. * @param scene The scene the particle system belongs to
  66883. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  66884. */
  66885. constructor(name: string, options: Partial<{
  66886. capacity: number;
  66887. randomTextureSize: number;
  66888. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  66889. protected _reset(): void;
  66890. private _createUpdateVAO;
  66891. private _createRenderVAO;
  66892. private _initialize;
  66893. /** @hidden */
  66894. _recreateUpdateEffect(): void;
  66895. /** @hidden */
  66896. _recreateRenderEffect(): void;
  66897. /**
  66898. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  66899. * @param preWarm defines if we are in the pre-warmimg phase
  66900. */
  66901. animate(preWarm?: boolean): void;
  66902. private _createFactorGradientTexture;
  66903. private _createSizeGradientTexture;
  66904. private _createAngularSpeedGradientTexture;
  66905. private _createVelocityGradientTexture;
  66906. private _createLimitVelocityGradientTexture;
  66907. private _createDragGradientTexture;
  66908. private _createColorGradientTexture;
  66909. /**
  66910. * Renders the particle system in its current state
  66911. * @param preWarm defines if the system should only update the particles but not render them
  66912. * @returns the current number of particles
  66913. */
  66914. render(preWarm?: boolean): number;
  66915. /**
  66916. * Rebuilds the particle system
  66917. */
  66918. rebuild(): void;
  66919. private _releaseBuffers;
  66920. private _releaseVAOs;
  66921. /**
  66922. * Disposes the particle system and free the associated resources
  66923. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66924. */
  66925. dispose(disposeTexture?: boolean): void;
  66926. /**
  66927. * Clones the particle system.
  66928. * @param name The name of the cloned object
  66929. * @param newEmitter The new emitter to use
  66930. * @returns the cloned particle system
  66931. */
  66932. clone(name: string, newEmitter: any): GPUParticleSystem;
  66933. /**
  66934. * Serializes the particle system to a JSON object
  66935. * @param serializeTexture defines if the texture must be serialized as well
  66936. * @returns the JSON object
  66937. */
  66938. serialize(serializeTexture?: boolean): any;
  66939. /**
  66940. * Parses a JSON object to create a GPU particle system.
  66941. * @param parsedParticleSystem The JSON object to parse
  66942. * @param scene The scene to create the particle system in
  66943. * @param rootUrl The root url to use to load external dependencies like texture
  66944. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66945. * @returns the parsed GPU particle system
  66946. */
  66947. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66948. }
  66949. }
  66950. declare module "babylonjs/Particles/particleSystemSet" {
  66951. import { Nullable } from "babylonjs/types";
  66952. import { Color3 } from "babylonjs/Maths/math.color";
  66953. import { TransformNode } from "babylonjs/Meshes/transformNode";
  66954. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66955. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66956. import { Scene, IDisposable } from "babylonjs/scene";
  66957. /**
  66958. * Represents a set of particle systems working together to create a specific effect
  66959. */
  66960. export class ParticleSystemSet implements IDisposable {
  66961. /**
  66962. * Gets or sets base Assets URL
  66963. */
  66964. static BaseAssetsUrl: string;
  66965. private _emitterCreationOptions;
  66966. private _emitterNode;
  66967. /**
  66968. * Gets the particle system list
  66969. */
  66970. systems: IParticleSystem[];
  66971. /**
  66972. * Gets the emitter node used with this set
  66973. */
  66974. get emitterNode(): Nullable<TransformNode>;
  66975. /**
  66976. * Creates a new emitter mesh as a sphere
  66977. * @param options defines the options used to create the sphere
  66978. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66979. * @param scene defines the hosting scene
  66980. */
  66981. setEmitterAsSphere(options: {
  66982. diameter: number;
  66983. segments: number;
  66984. color: Color3;
  66985. }, renderingGroupId: number, scene: Scene): void;
  66986. /**
  66987. * Starts all particle systems of the set
  66988. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66989. */
  66990. start(emitter?: AbstractMesh): void;
  66991. /**
  66992. * Release all associated resources
  66993. */
  66994. dispose(): void;
  66995. /**
  66996. * Serialize the set into a JSON compatible object
  66997. * @param serializeTexture defines if the texture must be serialized as well
  66998. * @returns a JSON compatible representation of the set
  66999. */
  67000. serialize(serializeTexture?: boolean): any;
  67001. /**
  67002. * Parse a new ParticleSystemSet from a serialized source
  67003. * @param data defines a JSON compatible representation of the set
  67004. * @param scene defines the hosting scene
  67005. * @param gpu defines if we want GPU particles or CPU particles
  67006. * @returns a new ParticleSystemSet
  67007. */
  67008. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  67009. }
  67010. }
  67011. declare module "babylonjs/Particles/particleHelper" {
  67012. import { Nullable } from "babylonjs/types";
  67013. import { Scene } from "babylonjs/scene";
  67014. import { Vector3 } from "babylonjs/Maths/math.vector";
  67015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67016. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  67017. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  67018. /**
  67019. * This class is made for on one-liner static method to help creating particle system set.
  67020. */
  67021. export class ParticleHelper {
  67022. /**
  67023. * Gets or sets base Assets URL
  67024. */
  67025. static BaseAssetsUrl: string;
  67026. /** Define the Url to load snippets */
  67027. static SnippetUrl: string;
  67028. /**
  67029. * Create a default particle system that you can tweak
  67030. * @param emitter defines the emitter to use
  67031. * @param capacity defines the system capacity (default is 500 particles)
  67032. * @param scene defines the hosting scene
  67033. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  67034. * @returns the new Particle system
  67035. */
  67036. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  67037. /**
  67038. * This is the main static method (one-liner) of this helper to create different particle systems
  67039. * @param type This string represents the type to the particle system to create
  67040. * @param scene The scene where the particle system should live
  67041. * @param gpu If the system will use gpu
  67042. * @returns the ParticleSystemSet created
  67043. */
  67044. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  67045. /**
  67046. * Static function used to export a particle system to a ParticleSystemSet variable.
  67047. * Please note that the emitter shape is not exported
  67048. * @param systems defines the particle systems to export
  67049. * @returns the created particle system set
  67050. */
  67051. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  67052. /**
  67053. * Creates a particle system from a snippet saved in a remote file
  67054. * @param name defines the name of the particle system to create
  67055. * @param url defines the url to load from
  67056. * @param scene defines the hosting scene
  67057. * @param gpu If the system will use gpu
  67058. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67059. * @returns a promise that will resolve to the new particle system
  67060. */
  67061. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67062. /**
  67063. * Creates a particle system from a snippet saved by the particle system editor
  67064. * @param snippetId defines the snippet to load
  67065. * @param scene defines the hosting scene
  67066. * @param gpu If the system will use gpu
  67067. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67068. * @returns a promise that will resolve to the new particle system
  67069. */
  67070. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67071. }
  67072. }
  67073. declare module "babylonjs/Particles/particleSystemComponent" {
  67074. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  67075. import { Effect } from "babylonjs/Materials/effect";
  67076. import "babylonjs/Shaders/particles.vertex";
  67077. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  67078. module "babylonjs/Engines/engine" {
  67079. interface Engine {
  67080. /**
  67081. * Create an effect to use with particle systems.
  67082. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  67083. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  67084. * @param uniformsNames defines a list of attribute names
  67085. * @param samplers defines an array of string used to represent textures
  67086. * @param defines defines the string containing the defines to use to compile the shaders
  67087. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  67088. * @param onCompiled defines a function to call when the effect creation is successful
  67089. * @param onError defines a function to call when the effect creation has failed
  67090. * @returns the new Effect
  67091. */
  67092. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  67093. }
  67094. }
  67095. module "babylonjs/Meshes/mesh" {
  67096. interface Mesh {
  67097. /**
  67098. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  67099. * @returns an array of IParticleSystem
  67100. */
  67101. getEmittedParticleSystems(): IParticleSystem[];
  67102. /**
  67103. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  67104. * @returns an array of IParticleSystem
  67105. */
  67106. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  67107. }
  67108. }
  67109. /**
  67110. * @hidden
  67111. */
  67112. export var _IDoNeedToBeInTheBuild: number;
  67113. }
  67114. declare module "babylonjs/Particles/pointsCloudSystem" {
  67115. import { Color4 } from "babylonjs/Maths/math";
  67116. import { Mesh } from "babylonjs/Meshes/mesh";
  67117. import { Scene, IDisposable } from "babylonjs/scene";
  67118. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  67119. /** Defines the 4 color options */
  67120. export enum PointColor {
  67121. /** color value */
  67122. Color = 2,
  67123. /** uv value */
  67124. UV = 1,
  67125. /** random value */
  67126. Random = 0,
  67127. /** stated value */
  67128. Stated = 3
  67129. }
  67130. /**
  67131. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  67132. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  67133. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  67134. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  67135. *
  67136. * Full documentation here : TO BE ENTERED
  67137. */
  67138. export class PointsCloudSystem implements IDisposable {
  67139. /**
  67140. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  67141. * Example : var p = SPS.particles[i];
  67142. */
  67143. particles: CloudPoint[];
  67144. /**
  67145. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  67146. */
  67147. nbParticles: number;
  67148. /**
  67149. * This a counter for your own usage. It's not set by any SPS functions.
  67150. */
  67151. counter: number;
  67152. /**
  67153. * The PCS name. This name is also given to the underlying mesh.
  67154. */
  67155. name: string;
  67156. /**
  67157. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  67158. */
  67159. mesh: Mesh;
  67160. /**
  67161. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  67162. * Please read :
  67163. */
  67164. vars: any;
  67165. /**
  67166. * @hidden
  67167. */
  67168. _size: number;
  67169. private _scene;
  67170. private _promises;
  67171. private _positions;
  67172. private _indices;
  67173. private _normals;
  67174. private _colors;
  67175. private _uvs;
  67176. private _indices32;
  67177. private _positions32;
  67178. private _colors32;
  67179. private _uvs32;
  67180. private _updatable;
  67181. private _isVisibilityBoxLocked;
  67182. private _alwaysVisible;
  67183. private _groups;
  67184. private _groupCounter;
  67185. private _computeParticleColor;
  67186. private _computeParticleTexture;
  67187. private _computeParticleRotation;
  67188. private _computeBoundingBox;
  67189. private _isReady;
  67190. /**
  67191. * Creates a PCS (Points Cloud System) object
  67192. * @param name (String) is the PCS name, this will be the underlying mesh name
  67193. * @param pointSize (number) is the size for each point
  67194. * @param scene (Scene) is the scene in which the PCS is added
  67195. * @param options defines the options of the PCS e.g.
  67196. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  67197. */
  67198. constructor(name: string, pointSize: number, scene: Scene, options?: {
  67199. updatable?: boolean;
  67200. });
  67201. /**
  67202. * Builds the PCS underlying mesh. Returns a standard Mesh.
  67203. * If no points were added to the PCS, the returned mesh is just a single point.
  67204. * @returns a promise for the created mesh
  67205. */
  67206. buildMeshAsync(): Promise<Mesh>;
  67207. /**
  67208. * @hidden
  67209. */
  67210. private _buildMesh;
  67211. private _addParticle;
  67212. private _randomUnitVector;
  67213. private _getColorIndicesForCoord;
  67214. private _setPointsColorOrUV;
  67215. private _colorFromTexture;
  67216. private _calculateDensity;
  67217. /**
  67218. * Adds points to the PCS in random positions within a unit sphere
  67219. * @param nb (positive integer) the number of particles to be created from this model
  67220. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  67221. * @returns the number of groups in the system
  67222. */
  67223. addPoints(nb: number, pointFunction?: any): number;
  67224. /**
  67225. * Adds points to the PCS from the surface of the model shape
  67226. * @param mesh is any Mesh object that will be used as a surface model for the points
  67227. * @param nb (positive integer) the number of particles to be created from this model
  67228. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67229. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67230. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67231. * @returns the number of groups in the system
  67232. */
  67233. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67234. /**
  67235. * Adds points to the PCS inside the model shape
  67236. * @param mesh is any Mesh object that will be used as a surface model for the points
  67237. * @param nb (positive integer) the number of particles to be created from this model
  67238. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67239. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67240. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67241. * @returns the number of groups in the system
  67242. */
  67243. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67244. /**
  67245. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  67246. * This method calls `updateParticle()` for each particle of the SPS.
  67247. * For an animated SPS, it is usually called within the render loop.
  67248. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  67249. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  67250. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  67251. * @returns the PCS.
  67252. */
  67253. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  67254. /**
  67255. * Disposes the PCS.
  67256. */
  67257. dispose(): void;
  67258. /**
  67259. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  67260. * doc :
  67261. * @returns the PCS.
  67262. */
  67263. refreshVisibleSize(): PointsCloudSystem;
  67264. /**
  67265. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  67266. * @param size the size (float) of the visibility box
  67267. * note : this doesn't lock the PCS mesh bounding box.
  67268. * doc :
  67269. */
  67270. setVisibilityBox(size: number): void;
  67271. /**
  67272. * Gets whether the PCS is always visible or not
  67273. * doc :
  67274. */
  67275. get isAlwaysVisible(): boolean;
  67276. /**
  67277. * Sets the PCS as always visible or not
  67278. * doc :
  67279. */
  67280. set isAlwaysVisible(val: boolean);
  67281. /**
  67282. * Tells to `setParticles()` to compute the particle rotations or not
  67283. * Default value : false. The PCS is faster when it's set to false
  67284. * Note : particle rotations are only applied to parent particles
  67285. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  67286. */
  67287. set computeParticleRotation(val: boolean);
  67288. /**
  67289. * Tells to `setParticles()` to compute the particle colors or not.
  67290. * Default value : true. The PCS is faster when it's set to false.
  67291. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67292. */
  67293. set computeParticleColor(val: boolean);
  67294. set computeParticleTexture(val: boolean);
  67295. /**
  67296. * Gets if `setParticles()` computes the particle colors or not.
  67297. * Default value : false. The PCS is faster when it's set to false.
  67298. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67299. */
  67300. get computeParticleColor(): boolean;
  67301. /**
  67302. * Gets if `setParticles()` computes the particle textures or not.
  67303. * Default value : false. The PCS is faster when it's set to false.
  67304. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  67305. */
  67306. get computeParticleTexture(): boolean;
  67307. /**
  67308. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  67309. */
  67310. set computeBoundingBox(val: boolean);
  67311. /**
  67312. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  67313. */
  67314. get computeBoundingBox(): boolean;
  67315. /**
  67316. * This function does nothing. It may be overwritten to set all the particle first values.
  67317. * The PCS doesn't call this function, you may have to call it by your own.
  67318. * doc :
  67319. */
  67320. initParticles(): void;
  67321. /**
  67322. * This function does nothing. It may be overwritten to recycle a particle
  67323. * The PCS doesn't call this function, you can to call it
  67324. * doc :
  67325. * @param particle The particle to recycle
  67326. * @returns the recycled particle
  67327. */
  67328. recycleParticle(particle: CloudPoint): CloudPoint;
  67329. /**
  67330. * Updates a particle : this function should be overwritten by the user.
  67331. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  67332. * doc :
  67333. * @example : just set a particle position or velocity and recycle conditions
  67334. * @param particle The particle to update
  67335. * @returns the updated particle
  67336. */
  67337. updateParticle(particle: CloudPoint): CloudPoint;
  67338. /**
  67339. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  67340. * This does nothing and may be overwritten by the user.
  67341. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67342. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67343. * @param update the boolean update value actually passed to setParticles()
  67344. */
  67345. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67346. /**
  67347. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  67348. * This will be passed three parameters.
  67349. * This does nothing and may be overwritten by the user.
  67350. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67351. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67352. * @param update the boolean update value actually passed to setParticles()
  67353. */
  67354. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67355. }
  67356. }
  67357. declare module "babylonjs/Particles/cloudPoint" {
  67358. import { Nullable } from "babylonjs/types";
  67359. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  67360. import { Mesh } from "babylonjs/Meshes/mesh";
  67361. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  67362. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  67363. /**
  67364. * Represents one particle of a points cloud system.
  67365. */
  67366. export class CloudPoint {
  67367. /**
  67368. * particle global index
  67369. */
  67370. idx: number;
  67371. /**
  67372. * The color of the particle
  67373. */
  67374. color: Nullable<Color4>;
  67375. /**
  67376. * The world space position of the particle.
  67377. */
  67378. position: Vector3;
  67379. /**
  67380. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  67381. */
  67382. rotation: Vector3;
  67383. /**
  67384. * The world space rotation quaternion of the particle.
  67385. */
  67386. rotationQuaternion: Nullable<Quaternion>;
  67387. /**
  67388. * The uv of the particle.
  67389. */
  67390. uv: Nullable<Vector2>;
  67391. /**
  67392. * The current speed of the particle.
  67393. */
  67394. velocity: Vector3;
  67395. /**
  67396. * The pivot point in the particle local space.
  67397. */
  67398. pivot: Vector3;
  67399. /**
  67400. * Must the particle be translated from its pivot point in its local space ?
  67401. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  67402. * Default : false
  67403. */
  67404. translateFromPivot: boolean;
  67405. /**
  67406. * Index of this particle in the global "positions" array (Internal use)
  67407. * @hidden
  67408. */
  67409. _pos: number;
  67410. /**
  67411. * @hidden Index of this particle in the global "indices" array (Internal use)
  67412. */
  67413. _ind: number;
  67414. /**
  67415. * Group this particle belongs to
  67416. */
  67417. _group: PointsGroup;
  67418. /**
  67419. * Group id of this particle
  67420. */
  67421. groupId: number;
  67422. /**
  67423. * Index of the particle in its group id (Internal use)
  67424. */
  67425. idxInGroup: number;
  67426. /**
  67427. * @hidden Particle BoundingInfo object (Internal use)
  67428. */
  67429. _boundingInfo: BoundingInfo;
  67430. /**
  67431. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  67432. */
  67433. _pcs: PointsCloudSystem;
  67434. /**
  67435. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  67436. */
  67437. _stillInvisible: boolean;
  67438. /**
  67439. * @hidden Last computed particle rotation matrix
  67440. */
  67441. _rotationMatrix: number[];
  67442. /**
  67443. * Parent particle Id, if any.
  67444. * Default null.
  67445. */
  67446. parentId: Nullable<number>;
  67447. /**
  67448. * @hidden Internal global position in the PCS.
  67449. */
  67450. _globalPosition: Vector3;
  67451. /**
  67452. * Creates a Point Cloud object.
  67453. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  67454. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  67455. * @param group (PointsGroup) is the group the particle belongs to
  67456. * @param groupId (integer) is the group identifier in the PCS.
  67457. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  67458. * @param pcs defines the PCS it is associated to
  67459. */
  67460. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  67461. /**
  67462. * get point size
  67463. */
  67464. get size(): Vector3;
  67465. /**
  67466. * Set point size
  67467. */
  67468. set size(scale: Vector3);
  67469. /**
  67470. * Legacy support, changed quaternion to rotationQuaternion
  67471. */
  67472. get quaternion(): Nullable<Quaternion>;
  67473. /**
  67474. * Legacy support, changed quaternion to rotationQuaternion
  67475. */
  67476. set quaternion(q: Nullable<Quaternion>);
  67477. /**
  67478. * Returns a boolean. True if the particle intersects a mesh, else false
  67479. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  67480. * @param target is the object (point or mesh) what the intersection is computed against
  67481. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  67482. * @returns true if it intersects
  67483. */
  67484. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  67485. /**
  67486. * get the rotation matrix of the particle
  67487. * @hidden
  67488. */
  67489. getRotationMatrix(m: Matrix): void;
  67490. }
  67491. /**
  67492. * Represents a group of points in a points cloud system
  67493. * * PCS internal tool, don't use it manually.
  67494. */
  67495. export class PointsGroup {
  67496. /**
  67497. * The group id
  67498. * @hidden
  67499. */
  67500. groupID: number;
  67501. /**
  67502. * image data for group (internal use)
  67503. * @hidden
  67504. */
  67505. _groupImageData: Nullable<ArrayBufferView>;
  67506. /**
  67507. * Image Width (internal use)
  67508. * @hidden
  67509. */
  67510. _groupImgWidth: number;
  67511. /**
  67512. * Image Height (internal use)
  67513. * @hidden
  67514. */
  67515. _groupImgHeight: number;
  67516. /**
  67517. * Custom position function (internal use)
  67518. * @hidden
  67519. */
  67520. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  67521. /**
  67522. * density per facet for surface points
  67523. * @hidden
  67524. */
  67525. _groupDensity: number[];
  67526. /**
  67527. * Only when points are colored by texture carries pointer to texture list array
  67528. * @hidden
  67529. */
  67530. _textureNb: number;
  67531. /**
  67532. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  67533. * PCS internal tool, don't use it manually.
  67534. * @hidden
  67535. */
  67536. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  67537. }
  67538. }
  67539. declare module "babylonjs/Particles/index" {
  67540. export * from "babylonjs/Particles/baseParticleSystem";
  67541. export * from "babylonjs/Particles/EmitterTypes/index";
  67542. export * from "babylonjs/Particles/gpuParticleSystem";
  67543. export * from "babylonjs/Particles/IParticleSystem";
  67544. export * from "babylonjs/Particles/particle";
  67545. export * from "babylonjs/Particles/particleHelper";
  67546. export * from "babylonjs/Particles/particleSystem";
  67547. export * from "babylonjs/Particles/particleSystemComponent";
  67548. export * from "babylonjs/Particles/particleSystemSet";
  67549. export * from "babylonjs/Particles/solidParticle";
  67550. export * from "babylonjs/Particles/solidParticleSystem";
  67551. export * from "babylonjs/Particles/cloudPoint";
  67552. export * from "babylonjs/Particles/pointsCloudSystem";
  67553. export * from "babylonjs/Particles/subEmitter";
  67554. }
  67555. declare module "babylonjs/Physics/physicsEngineComponent" {
  67556. import { Nullable } from "babylonjs/types";
  67557. import { Observable, Observer } from "babylonjs/Misc/observable";
  67558. import { Vector3 } from "babylonjs/Maths/math.vector";
  67559. import { Mesh } from "babylonjs/Meshes/mesh";
  67560. import { ISceneComponent } from "babylonjs/sceneComponent";
  67561. import { Scene } from "babylonjs/scene";
  67562. import { Node } from "babylonjs/node";
  67563. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  67564. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  67565. module "babylonjs/scene" {
  67566. interface Scene {
  67567. /** @hidden (Backing field) */
  67568. _physicsEngine: Nullable<IPhysicsEngine>;
  67569. /** @hidden */
  67570. _physicsTimeAccumulator: number;
  67571. /**
  67572. * Gets the current physics engine
  67573. * @returns a IPhysicsEngine or null if none attached
  67574. */
  67575. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  67576. /**
  67577. * Enables physics to the current scene
  67578. * @param gravity defines the scene's gravity for the physics engine
  67579. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  67580. * @return a boolean indicating if the physics engine was initialized
  67581. */
  67582. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  67583. /**
  67584. * Disables and disposes the physics engine associated with the scene
  67585. */
  67586. disablePhysicsEngine(): void;
  67587. /**
  67588. * Gets a boolean indicating if there is an active physics engine
  67589. * @returns a boolean indicating if there is an active physics engine
  67590. */
  67591. isPhysicsEnabled(): boolean;
  67592. /**
  67593. * Deletes a physics compound impostor
  67594. * @param compound defines the compound to delete
  67595. */
  67596. deleteCompoundImpostor(compound: any): void;
  67597. /**
  67598. * An event triggered when physic simulation is about to be run
  67599. */
  67600. onBeforePhysicsObservable: Observable<Scene>;
  67601. /**
  67602. * An event triggered when physic simulation has been done
  67603. */
  67604. onAfterPhysicsObservable: Observable<Scene>;
  67605. }
  67606. }
  67607. module "babylonjs/Meshes/abstractMesh" {
  67608. interface AbstractMesh {
  67609. /** @hidden */
  67610. _physicsImpostor: Nullable<PhysicsImpostor>;
  67611. /**
  67612. * Gets or sets impostor used for physic simulation
  67613. * @see http://doc.babylonjs.com/features/physics_engine
  67614. */
  67615. physicsImpostor: Nullable<PhysicsImpostor>;
  67616. /**
  67617. * Gets the current physics impostor
  67618. * @see http://doc.babylonjs.com/features/physics_engine
  67619. * @returns a physics impostor or null
  67620. */
  67621. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  67622. /** Apply a physic impulse to the mesh
  67623. * @param force defines the force to apply
  67624. * @param contactPoint defines where to apply the force
  67625. * @returns the current mesh
  67626. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  67627. */
  67628. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  67629. /**
  67630. * Creates a physic joint between two meshes
  67631. * @param otherMesh defines the other mesh to use
  67632. * @param pivot1 defines the pivot to use on this mesh
  67633. * @param pivot2 defines the pivot to use on the other mesh
  67634. * @param options defines additional options (can be plugin dependent)
  67635. * @returns the current mesh
  67636. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  67637. */
  67638. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  67639. /** @hidden */
  67640. _disposePhysicsObserver: Nullable<Observer<Node>>;
  67641. }
  67642. }
  67643. /**
  67644. * Defines the physics engine scene component responsible to manage a physics engine
  67645. */
  67646. export class PhysicsEngineSceneComponent implements ISceneComponent {
  67647. /**
  67648. * The component name helpful to identify the component in the list of scene components.
  67649. */
  67650. readonly name: string;
  67651. /**
  67652. * The scene the component belongs to.
  67653. */
  67654. scene: Scene;
  67655. /**
  67656. * Creates a new instance of the component for the given scene
  67657. * @param scene Defines the scene to register the component in
  67658. */
  67659. constructor(scene: Scene);
  67660. /**
  67661. * Registers the component in a given scene
  67662. */
  67663. register(): void;
  67664. /**
  67665. * Rebuilds the elements related to this component in case of
  67666. * context lost for instance.
  67667. */
  67668. rebuild(): void;
  67669. /**
  67670. * Disposes the component and the associated ressources
  67671. */
  67672. dispose(): void;
  67673. }
  67674. }
  67675. declare module "babylonjs/Physics/physicsHelper" {
  67676. import { Nullable } from "babylonjs/types";
  67677. import { Vector3 } from "babylonjs/Maths/math.vector";
  67678. import { Mesh } from "babylonjs/Meshes/mesh";
  67679. import { Scene } from "babylonjs/scene";
  67680. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  67681. /**
  67682. * A helper for physics simulations
  67683. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67684. */
  67685. export class PhysicsHelper {
  67686. private _scene;
  67687. private _physicsEngine;
  67688. /**
  67689. * Initializes the Physics helper
  67690. * @param scene Babylon.js scene
  67691. */
  67692. constructor(scene: Scene);
  67693. /**
  67694. * Applies a radial explosion impulse
  67695. * @param origin the origin of the explosion
  67696. * @param radiusOrEventOptions the radius or the options of radial explosion
  67697. * @param strength the explosion strength
  67698. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67699. * @returns A physics radial explosion event, or null
  67700. */
  67701. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67702. /**
  67703. * Applies a radial explosion force
  67704. * @param origin the origin of the explosion
  67705. * @param radiusOrEventOptions the radius or the options of radial explosion
  67706. * @param strength the explosion strength
  67707. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67708. * @returns A physics radial explosion event, or null
  67709. */
  67710. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67711. /**
  67712. * Creates a gravitational field
  67713. * @param origin the origin of the explosion
  67714. * @param radiusOrEventOptions the radius or the options of radial explosion
  67715. * @param strength the explosion strength
  67716. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67717. * @returns A physics gravitational field event, or null
  67718. */
  67719. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  67720. /**
  67721. * Creates a physics updraft event
  67722. * @param origin the origin of the updraft
  67723. * @param radiusOrEventOptions the radius or the options of the updraft
  67724. * @param strength the strength of the updraft
  67725. * @param height the height of the updraft
  67726. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  67727. * @returns A physics updraft event, or null
  67728. */
  67729. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  67730. /**
  67731. * Creates a physics vortex event
  67732. * @param origin the of the vortex
  67733. * @param radiusOrEventOptions the radius or the options of the vortex
  67734. * @param strength the strength of the vortex
  67735. * @param height the height of the vortex
  67736. * @returns a Physics vortex event, or null
  67737. * A physics vortex event or null
  67738. */
  67739. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  67740. }
  67741. /**
  67742. * Represents a physics radial explosion event
  67743. */
  67744. class PhysicsRadialExplosionEvent {
  67745. private _scene;
  67746. private _options;
  67747. private _sphere;
  67748. private _dataFetched;
  67749. /**
  67750. * Initializes a radial explosioin event
  67751. * @param _scene BabylonJS scene
  67752. * @param _options The options for the vortex event
  67753. */
  67754. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  67755. /**
  67756. * Returns the data related to the radial explosion event (sphere).
  67757. * @returns The radial explosion event data
  67758. */
  67759. getData(): PhysicsRadialExplosionEventData;
  67760. /**
  67761. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  67762. * @param impostor A physics imposter
  67763. * @param origin the origin of the explosion
  67764. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  67765. */
  67766. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  67767. /**
  67768. * Triggers affecterd impostors callbacks
  67769. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  67770. */
  67771. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  67772. /**
  67773. * Disposes the sphere.
  67774. * @param force Specifies if the sphere should be disposed by force
  67775. */
  67776. dispose(force?: boolean): void;
  67777. /*** Helpers ***/
  67778. private _prepareSphere;
  67779. private _intersectsWithSphere;
  67780. }
  67781. /**
  67782. * Represents a gravitational field event
  67783. */
  67784. class PhysicsGravitationalFieldEvent {
  67785. private _physicsHelper;
  67786. private _scene;
  67787. private _origin;
  67788. private _options;
  67789. private _tickCallback;
  67790. private _sphere;
  67791. private _dataFetched;
  67792. /**
  67793. * Initializes the physics gravitational field event
  67794. * @param _physicsHelper A physics helper
  67795. * @param _scene BabylonJS scene
  67796. * @param _origin The origin position of the gravitational field event
  67797. * @param _options The options for the vortex event
  67798. */
  67799. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  67800. /**
  67801. * Returns the data related to the gravitational field event (sphere).
  67802. * @returns A gravitational field event
  67803. */
  67804. getData(): PhysicsGravitationalFieldEventData;
  67805. /**
  67806. * Enables the gravitational field.
  67807. */
  67808. enable(): void;
  67809. /**
  67810. * Disables the gravitational field.
  67811. */
  67812. disable(): void;
  67813. /**
  67814. * Disposes the sphere.
  67815. * @param force The force to dispose from the gravitational field event
  67816. */
  67817. dispose(force?: boolean): void;
  67818. private _tick;
  67819. }
  67820. /**
  67821. * Represents a physics updraft event
  67822. */
  67823. class PhysicsUpdraftEvent {
  67824. private _scene;
  67825. private _origin;
  67826. private _options;
  67827. private _physicsEngine;
  67828. private _originTop;
  67829. private _originDirection;
  67830. private _tickCallback;
  67831. private _cylinder;
  67832. private _cylinderPosition;
  67833. private _dataFetched;
  67834. /**
  67835. * Initializes the physics updraft event
  67836. * @param _scene BabylonJS scene
  67837. * @param _origin The origin position of the updraft
  67838. * @param _options The options for the updraft event
  67839. */
  67840. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  67841. /**
  67842. * Returns the data related to the updraft event (cylinder).
  67843. * @returns A physics updraft event
  67844. */
  67845. getData(): PhysicsUpdraftEventData;
  67846. /**
  67847. * Enables the updraft.
  67848. */
  67849. enable(): void;
  67850. /**
  67851. * Disables the updraft.
  67852. */
  67853. disable(): void;
  67854. /**
  67855. * Disposes the cylinder.
  67856. * @param force Specifies if the updraft should be disposed by force
  67857. */
  67858. dispose(force?: boolean): void;
  67859. private getImpostorHitData;
  67860. private _tick;
  67861. /*** Helpers ***/
  67862. private _prepareCylinder;
  67863. private _intersectsWithCylinder;
  67864. }
  67865. /**
  67866. * Represents a physics vortex event
  67867. */
  67868. class PhysicsVortexEvent {
  67869. private _scene;
  67870. private _origin;
  67871. private _options;
  67872. private _physicsEngine;
  67873. private _originTop;
  67874. private _tickCallback;
  67875. private _cylinder;
  67876. private _cylinderPosition;
  67877. private _dataFetched;
  67878. /**
  67879. * Initializes the physics vortex event
  67880. * @param _scene The BabylonJS scene
  67881. * @param _origin The origin position of the vortex
  67882. * @param _options The options for the vortex event
  67883. */
  67884. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  67885. /**
  67886. * Returns the data related to the vortex event (cylinder).
  67887. * @returns The physics vortex event data
  67888. */
  67889. getData(): PhysicsVortexEventData;
  67890. /**
  67891. * Enables the vortex.
  67892. */
  67893. enable(): void;
  67894. /**
  67895. * Disables the cortex.
  67896. */
  67897. disable(): void;
  67898. /**
  67899. * Disposes the sphere.
  67900. * @param force
  67901. */
  67902. dispose(force?: boolean): void;
  67903. private getImpostorHitData;
  67904. private _tick;
  67905. /*** Helpers ***/
  67906. private _prepareCylinder;
  67907. private _intersectsWithCylinder;
  67908. }
  67909. /**
  67910. * Options fot the radial explosion event
  67911. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67912. */
  67913. export class PhysicsRadialExplosionEventOptions {
  67914. /**
  67915. * The radius of the sphere for the radial explosion.
  67916. */
  67917. radius: number;
  67918. /**
  67919. * The strenth of the explosion.
  67920. */
  67921. strength: number;
  67922. /**
  67923. * The strenght of the force in correspondence to the distance of the affected object
  67924. */
  67925. falloff: PhysicsRadialImpulseFalloff;
  67926. /**
  67927. * Sphere options for the radial explosion.
  67928. */
  67929. sphere: {
  67930. segments: number;
  67931. diameter: number;
  67932. };
  67933. /**
  67934. * Sphere options for the radial explosion.
  67935. */
  67936. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  67937. }
  67938. /**
  67939. * Options fot the updraft event
  67940. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67941. */
  67942. export class PhysicsUpdraftEventOptions {
  67943. /**
  67944. * The radius of the cylinder for the vortex
  67945. */
  67946. radius: number;
  67947. /**
  67948. * The strenth of the updraft.
  67949. */
  67950. strength: number;
  67951. /**
  67952. * The height of the cylinder for the updraft.
  67953. */
  67954. height: number;
  67955. /**
  67956. * The mode for the the updraft.
  67957. */
  67958. updraftMode: PhysicsUpdraftMode;
  67959. }
  67960. /**
  67961. * Options fot the vortex event
  67962. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67963. */
  67964. export class PhysicsVortexEventOptions {
  67965. /**
  67966. * The radius of the cylinder for the vortex
  67967. */
  67968. radius: number;
  67969. /**
  67970. * The strenth of the vortex.
  67971. */
  67972. strength: number;
  67973. /**
  67974. * The height of the cylinder for the vortex.
  67975. */
  67976. height: number;
  67977. /**
  67978. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67979. */
  67980. centripetalForceThreshold: number;
  67981. /**
  67982. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67983. */
  67984. centripetalForceMultiplier: number;
  67985. /**
  67986. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67987. */
  67988. centrifugalForceMultiplier: number;
  67989. /**
  67990. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67991. */
  67992. updraftForceMultiplier: number;
  67993. }
  67994. /**
  67995. * The strenght of the force in correspondence to the distance of the affected object
  67996. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67997. */
  67998. export enum PhysicsRadialImpulseFalloff {
  67999. /** Defines that impulse is constant in strength across it's whole radius */
  68000. Constant = 0,
  68001. /** Defines that impulse gets weaker if it's further from the origin */
  68002. Linear = 1
  68003. }
  68004. /**
  68005. * The strength of the force in correspondence to the distance of the affected object
  68006. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68007. */
  68008. export enum PhysicsUpdraftMode {
  68009. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  68010. Center = 0,
  68011. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  68012. Perpendicular = 1
  68013. }
  68014. /**
  68015. * Interface for a physics hit data
  68016. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68017. */
  68018. export interface PhysicsHitData {
  68019. /**
  68020. * The force applied at the contact point
  68021. */
  68022. force: Vector3;
  68023. /**
  68024. * The contact point
  68025. */
  68026. contactPoint: Vector3;
  68027. /**
  68028. * The distance from the origin to the contact point
  68029. */
  68030. distanceFromOrigin: number;
  68031. }
  68032. /**
  68033. * Interface for radial explosion event data
  68034. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68035. */
  68036. export interface PhysicsRadialExplosionEventData {
  68037. /**
  68038. * A sphere used for the radial explosion event
  68039. */
  68040. sphere: Mesh;
  68041. }
  68042. /**
  68043. * Interface for gravitational field event data
  68044. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68045. */
  68046. export interface PhysicsGravitationalFieldEventData {
  68047. /**
  68048. * A sphere mesh used for the gravitational field event
  68049. */
  68050. sphere: Mesh;
  68051. }
  68052. /**
  68053. * Interface for updraft event data
  68054. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68055. */
  68056. export interface PhysicsUpdraftEventData {
  68057. /**
  68058. * A cylinder used for the updraft event
  68059. */
  68060. cylinder: Mesh;
  68061. }
  68062. /**
  68063. * Interface for vortex event data
  68064. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68065. */
  68066. export interface PhysicsVortexEventData {
  68067. /**
  68068. * A cylinder used for the vortex event
  68069. */
  68070. cylinder: Mesh;
  68071. }
  68072. /**
  68073. * Interface for an affected physics impostor
  68074. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68075. */
  68076. export interface PhysicsAffectedImpostorWithData {
  68077. /**
  68078. * The impostor affected by the effect
  68079. */
  68080. impostor: PhysicsImpostor;
  68081. /**
  68082. * The data about the hit/horce from the explosion
  68083. */
  68084. hitData: PhysicsHitData;
  68085. }
  68086. }
  68087. declare module "babylonjs/Physics/Plugins/index" {
  68088. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  68089. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  68090. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  68091. }
  68092. declare module "babylonjs/Physics/index" {
  68093. export * from "babylonjs/Physics/IPhysicsEngine";
  68094. export * from "babylonjs/Physics/physicsEngine";
  68095. export * from "babylonjs/Physics/physicsEngineComponent";
  68096. export * from "babylonjs/Physics/physicsHelper";
  68097. export * from "babylonjs/Physics/physicsImpostor";
  68098. export * from "babylonjs/Physics/physicsJoint";
  68099. export * from "babylonjs/Physics/Plugins/index";
  68100. }
  68101. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  68102. /** @hidden */
  68103. export var blackAndWhitePixelShader: {
  68104. name: string;
  68105. shader: string;
  68106. };
  68107. }
  68108. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  68109. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68110. import { Camera } from "babylonjs/Cameras/camera";
  68111. import { Engine } from "babylonjs/Engines/engine";
  68112. import "babylonjs/Shaders/blackAndWhite.fragment";
  68113. /**
  68114. * Post process used to render in black and white
  68115. */
  68116. export class BlackAndWhitePostProcess extends PostProcess {
  68117. /**
  68118. * Linear about to convert he result to black and white (default: 1)
  68119. */
  68120. degree: number;
  68121. /**
  68122. * Creates a black and white post process
  68123. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  68124. * @param name The name of the effect.
  68125. * @param options The required width/height ratio to downsize to before computing the render pass.
  68126. * @param camera The camera to apply the render pass to.
  68127. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68128. * @param engine The engine which the post process will be applied. (default: current engine)
  68129. * @param reusable If the post process can be reused on the same frame. (default: false)
  68130. */
  68131. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68132. }
  68133. }
  68134. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  68135. import { Nullable } from "babylonjs/types";
  68136. import { Camera } from "babylonjs/Cameras/camera";
  68137. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  68138. import { Engine } from "babylonjs/Engines/engine";
  68139. /**
  68140. * This represents a set of one or more post processes in Babylon.
  68141. * A post process can be used to apply a shader to a texture after it is rendered.
  68142. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68143. */
  68144. export class PostProcessRenderEffect {
  68145. private _postProcesses;
  68146. private _getPostProcesses;
  68147. private _singleInstance;
  68148. private _cameras;
  68149. private _indicesForCamera;
  68150. /**
  68151. * Name of the effect
  68152. * @hidden
  68153. */
  68154. _name: string;
  68155. /**
  68156. * Instantiates a post process render effect.
  68157. * A post process can be used to apply a shader to a texture after it is rendered.
  68158. * @param engine The engine the effect is tied to
  68159. * @param name The name of the effect
  68160. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  68161. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  68162. */
  68163. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  68164. /**
  68165. * Checks if all the post processes in the effect are supported.
  68166. */
  68167. get isSupported(): boolean;
  68168. /**
  68169. * Updates the current state of the effect
  68170. * @hidden
  68171. */
  68172. _update(): void;
  68173. /**
  68174. * Attaches the effect on cameras
  68175. * @param cameras The camera to attach to.
  68176. * @hidden
  68177. */
  68178. _attachCameras(cameras: Camera): void;
  68179. /**
  68180. * Attaches the effect on cameras
  68181. * @param cameras The camera to attach to.
  68182. * @hidden
  68183. */
  68184. _attachCameras(cameras: Camera[]): void;
  68185. /**
  68186. * Detaches the effect on cameras
  68187. * @param cameras The camera to detatch from.
  68188. * @hidden
  68189. */
  68190. _detachCameras(cameras: Camera): void;
  68191. /**
  68192. * Detatches the effect on cameras
  68193. * @param cameras The camera to detatch from.
  68194. * @hidden
  68195. */
  68196. _detachCameras(cameras: Camera[]): void;
  68197. /**
  68198. * Enables the effect on given cameras
  68199. * @param cameras The camera to enable.
  68200. * @hidden
  68201. */
  68202. _enable(cameras: Camera): void;
  68203. /**
  68204. * Enables the effect on given cameras
  68205. * @param cameras The camera to enable.
  68206. * @hidden
  68207. */
  68208. _enable(cameras: Nullable<Camera[]>): void;
  68209. /**
  68210. * Disables the effect on the given cameras
  68211. * @param cameras The camera to disable.
  68212. * @hidden
  68213. */
  68214. _disable(cameras: Camera): void;
  68215. /**
  68216. * Disables the effect on the given cameras
  68217. * @param cameras The camera to disable.
  68218. * @hidden
  68219. */
  68220. _disable(cameras: Nullable<Camera[]>): void;
  68221. /**
  68222. * Gets a list of the post processes contained in the effect.
  68223. * @param camera The camera to get the post processes on.
  68224. * @returns The list of the post processes in the effect.
  68225. */
  68226. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  68227. }
  68228. }
  68229. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  68230. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  68231. /** @hidden */
  68232. export var extractHighlightsPixelShader: {
  68233. name: string;
  68234. shader: string;
  68235. };
  68236. }
  68237. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  68238. import { Nullable } from "babylonjs/types";
  68239. import { Camera } from "babylonjs/Cameras/camera";
  68240. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68241. import { Engine } from "babylonjs/Engines/engine";
  68242. import "babylonjs/Shaders/extractHighlights.fragment";
  68243. /**
  68244. * 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.
  68245. */
  68246. export class ExtractHighlightsPostProcess extends PostProcess {
  68247. /**
  68248. * The luminance threshold, pixels below this value will be set to black.
  68249. */
  68250. threshold: number;
  68251. /** @hidden */
  68252. _exposure: number;
  68253. /**
  68254. * Post process which has the input texture to be used when performing highlight extraction
  68255. * @hidden
  68256. */
  68257. _inputPostProcess: Nullable<PostProcess>;
  68258. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68259. }
  68260. }
  68261. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  68262. /** @hidden */
  68263. export var bloomMergePixelShader: {
  68264. name: string;
  68265. shader: string;
  68266. };
  68267. }
  68268. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  68269. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68270. import { Nullable } from "babylonjs/types";
  68271. import { Engine } from "babylonjs/Engines/engine";
  68272. import { Camera } from "babylonjs/Cameras/camera";
  68273. import "babylonjs/Shaders/bloomMerge.fragment";
  68274. /**
  68275. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68276. */
  68277. export class BloomMergePostProcess extends PostProcess {
  68278. /** Weight of the bloom to be added to the original input. */
  68279. weight: number;
  68280. /**
  68281. * Creates a new instance of @see BloomMergePostProcess
  68282. * @param name The name of the effect.
  68283. * @param originalFromInput Post process which's input will be used for the merge.
  68284. * @param blurred Blurred highlights post process which's output will be used.
  68285. * @param weight Weight of the bloom to be added to the original input.
  68286. * @param options The required width/height ratio to downsize to before computing the render pass.
  68287. * @param camera The camera to apply the render pass to.
  68288. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68289. * @param engine The engine which the post process will be applied. (default: current engine)
  68290. * @param reusable If the post process can be reused on the same frame. (default: false)
  68291. * @param textureType Type of textures used when performing the post process. (default: 0)
  68292. * @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)
  68293. */
  68294. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  68295. /** Weight of the bloom to be added to the original input. */
  68296. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68297. }
  68298. }
  68299. declare module "babylonjs/PostProcesses/bloomEffect" {
  68300. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68301. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  68302. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  68303. import { Camera } from "babylonjs/Cameras/camera";
  68304. import { Scene } from "babylonjs/scene";
  68305. /**
  68306. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  68307. */
  68308. export class BloomEffect extends PostProcessRenderEffect {
  68309. private bloomScale;
  68310. /**
  68311. * @hidden Internal
  68312. */
  68313. _effects: Array<PostProcess>;
  68314. /**
  68315. * @hidden Internal
  68316. */
  68317. _downscale: ExtractHighlightsPostProcess;
  68318. private _blurX;
  68319. private _blurY;
  68320. private _merge;
  68321. /**
  68322. * The luminance threshold to find bright areas of the image to bloom.
  68323. */
  68324. get threshold(): number;
  68325. set threshold(value: number);
  68326. /**
  68327. * The strength of the bloom.
  68328. */
  68329. get weight(): number;
  68330. set weight(value: number);
  68331. /**
  68332. * Specifies the size of the bloom blur kernel, relative to the final output size
  68333. */
  68334. get kernel(): number;
  68335. set kernel(value: number);
  68336. /**
  68337. * Creates a new instance of @see BloomEffect
  68338. * @param scene The scene the effect belongs to.
  68339. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  68340. * @param bloomKernel The size of the kernel to be used when applying the blur.
  68341. * @param bloomWeight The the strength of bloom.
  68342. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68343. * @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)
  68344. */
  68345. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  68346. /**
  68347. * Disposes each of the internal effects for a given camera.
  68348. * @param camera The camera to dispose the effect on.
  68349. */
  68350. disposeEffects(camera: Camera): void;
  68351. /**
  68352. * @hidden Internal
  68353. */
  68354. _updateEffects(): void;
  68355. /**
  68356. * Internal
  68357. * @returns if all the contained post processes are ready.
  68358. * @hidden
  68359. */
  68360. _isReady(): boolean;
  68361. }
  68362. }
  68363. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  68364. /** @hidden */
  68365. export var chromaticAberrationPixelShader: {
  68366. name: string;
  68367. shader: string;
  68368. };
  68369. }
  68370. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  68371. import { Vector2 } from "babylonjs/Maths/math.vector";
  68372. import { Nullable } from "babylonjs/types";
  68373. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68374. import { Camera } from "babylonjs/Cameras/camera";
  68375. import { Engine } from "babylonjs/Engines/engine";
  68376. import "babylonjs/Shaders/chromaticAberration.fragment";
  68377. /**
  68378. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  68379. */
  68380. export class ChromaticAberrationPostProcess extends PostProcess {
  68381. /**
  68382. * The amount of seperation of rgb channels (default: 30)
  68383. */
  68384. aberrationAmount: number;
  68385. /**
  68386. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  68387. */
  68388. radialIntensity: number;
  68389. /**
  68390. * 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))
  68391. */
  68392. direction: Vector2;
  68393. /**
  68394. * 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))
  68395. */
  68396. centerPosition: Vector2;
  68397. /**
  68398. * Creates a new instance ChromaticAberrationPostProcess
  68399. * @param name The name of the effect.
  68400. * @param screenWidth The width of the screen to apply the effect on.
  68401. * @param screenHeight The height of the screen to apply the effect on.
  68402. * @param options The required width/height ratio to downsize to before computing the render pass.
  68403. * @param camera The camera to apply the render pass to.
  68404. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68405. * @param engine The engine which the post process will be applied. (default: current engine)
  68406. * @param reusable If the post process can be reused on the same frame. (default: false)
  68407. * @param textureType Type of textures used when performing the post process. (default: 0)
  68408. * @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)
  68409. */
  68410. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68411. }
  68412. }
  68413. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  68414. /** @hidden */
  68415. export var circleOfConfusionPixelShader: {
  68416. name: string;
  68417. shader: string;
  68418. };
  68419. }
  68420. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  68421. import { Nullable } from "babylonjs/types";
  68422. import { Engine } from "babylonjs/Engines/engine";
  68423. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68424. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68425. import { Camera } from "babylonjs/Cameras/camera";
  68426. import "babylonjs/Shaders/circleOfConfusion.fragment";
  68427. /**
  68428. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  68429. */
  68430. export class CircleOfConfusionPostProcess extends PostProcess {
  68431. /**
  68432. * 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.
  68433. */
  68434. lensSize: number;
  68435. /**
  68436. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68437. */
  68438. fStop: number;
  68439. /**
  68440. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68441. */
  68442. focusDistance: number;
  68443. /**
  68444. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  68445. */
  68446. focalLength: number;
  68447. private _depthTexture;
  68448. /**
  68449. * Creates a new instance CircleOfConfusionPostProcess
  68450. * @param name The name of the effect.
  68451. * @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.
  68452. * @param options The required width/height ratio to downsize to before computing the render pass.
  68453. * @param camera The camera to apply the render pass to.
  68454. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68455. * @param engine The engine which the post process will be applied. (default: current engine)
  68456. * @param reusable If the post process can be reused on the same frame. (default: false)
  68457. * @param textureType Type of textures used when performing the post process. (default: 0)
  68458. * @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)
  68459. */
  68460. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68461. /**
  68462. * 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.
  68463. */
  68464. set depthTexture(value: RenderTargetTexture);
  68465. }
  68466. }
  68467. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  68468. /** @hidden */
  68469. export var colorCorrectionPixelShader: {
  68470. name: string;
  68471. shader: string;
  68472. };
  68473. }
  68474. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  68475. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68476. import { Engine } from "babylonjs/Engines/engine";
  68477. import { Camera } from "babylonjs/Cameras/camera";
  68478. import "babylonjs/Shaders/colorCorrection.fragment";
  68479. /**
  68480. *
  68481. * This post-process allows the modification of rendered colors by using
  68482. * a 'look-up table' (LUT). This effect is also called Color Grading.
  68483. *
  68484. * The object needs to be provided an url to a texture containing the color
  68485. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  68486. * Use an image editing software to tweak the LUT to match your needs.
  68487. *
  68488. * For an example of a color LUT, see here:
  68489. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  68490. * For explanations on color grading, see here:
  68491. * @see http://udn.epicgames.com/Three/ColorGrading.html
  68492. *
  68493. */
  68494. export class ColorCorrectionPostProcess extends PostProcess {
  68495. private _colorTableTexture;
  68496. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68497. }
  68498. }
  68499. declare module "babylonjs/Shaders/convolution.fragment" {
  68500. /** @hidden */
  68501. export var convolutionPixelShader: {
  68502. name: string;
  68503. shader: string;
  68504. };
  68505. }
  68506. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  68507. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68508. import { Nullable } from "babylonjs/types";
  68509. import { Camera } from "babylonjs/Cameras/camera";
  68510. import { Engine } from "babylonjs/Engines/engine";
  68511. import "babylonjs/Shaders/convolution.fragment";
  68512. /**
  68513. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  68514. * input texture to perform effects such as edge detection or sharpening
  68515. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68516. */
  68517. export class ConvolutionPostProcess extends PostProcess {
  68518. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68519. kernel: number[];
  68520. /**
  68521. * Creates a new instance ConvolutionPostProcess
  68522. * @param name The name of the effect.
  68523. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  68524. * @param options The required width/height ratio to downsize to before computing the render pass.
  68525. * @param camera The camera to apply the render pass to.
  68526. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68527. * @param engine The engine which the post process will be applied. (default: current engine)
  68528. * @param reusable If the post process can be reused on the same frame. (default: false)
  68529. * @param textureType Type of textures used when performing the post process. (default: 0)
  68530. */
  68531. constructor(name: string,
  68532. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68533. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68534. /**
  68535. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68536. */
  68537. static EdgeDetect0Kernel: number[];
  68538. /**
  68539. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68540. */
  68541. static EdgeDetect1Kernel: number[];
  68542. /**
  68543. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68544. */
  68545. static EdgeDetect2Kernel: number[];
  68546. /**
  68547. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68548. */
  68549. static SharpenKernel: number[];
  68550. /**
  68551. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68552. */
  68553. static EmbossKernel: number[];
  68554. /**
  68555. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68556. */
  68557. static GaussianKernel: number[];
  68558. }
  68559. }
  68560. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  68561. import { Nullable } from "babylonjs/types";
  68562. import { Vector2 } from "babylonjs/Maths/math.vector";
  68563. import { Camera } from "babylonjs/Cameras/camera";
  68564. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68565. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  68566. import { Engine } from "babylonjs/Engines/engine";
  68567. import { Scene } from "babylonjs/scene";
  68568. /**
  68569. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  68570. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  68571. * based on samples that have a large difference in distance than the center pixel.
  68572. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  68573. */
  68574. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  68575. direction: Vector2;
  68576. /**
  68577. * Creates a new instance CircleOfConfusionPostProcess
  68578. * @param name The name of the effect.
  68579. * @param scene The scene the effect belongs to.
  68580. * @param direction The direction the blur should be applied.
  68581. * @param kernel The size of the kernel used to blur.
  68582. * @param options The required width/height ratio to downsize to before computing the render pass.
  68583. * @param camera The camera to apply the render pass to.
  68584. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  68585. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  68586. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68587. * @param engine The engine which the post process will be applied. (default: current engine)
  68588. * @param reusable If the post process can be reused on the same frame. (default: false)
  68589. * @param textureType Type of textures used when performing the post process. (default: 0)
  68590. * @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)
  68591. */
  68592. 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);
  68593. }
  68594. }
  68595. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  68596. /** @hidden */
  68597. export var depthOfFieldMergePixelShader: {
  68598. name: string;
  68599. shader: string;
  68600. };
  68601. }
  68602. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  68603. import { Nullable } from "babylonjs/types";
  68604. import { Camera } from "babylonjs/Cameras/camera";
  68605. import { Effect } from "babylonjs/Materials/effect";
  68606. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68607. import { Engine } from "babylonjs/Engines/engine";
  68608. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  68609. /**
  68610. * Options to be set when merging outputs from the default pipeline.
  68611. */
  68612. export class DepthOfFieldMergePostProcessOptions {
  68613. /**
  68614. * The original image to merge on top of
  68615. */
  68616. originalFromInput: PostProcess;
  68617. /**
  68618. * Parameters to perform the merge of the depth of field effect
  68619. */
  68620. depthOfField?: {
  68621. circleOfConfusion: PostProcess;
  68622. blurSteps: Array<PostProcess>;
  68623. };
  68624. /**
  68625. * Parameters to perform the merge of bloom effect
  68626. */
  68627. bloom?: {
  68628. blurred: PostProcess;
  68629. weight: number;
  68630. };
  68631. }
  68632. /**
  68633. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68634. */
  68635. export class DepthOfFieldMergePostProcess extends PostProcess {
  68636. private blurSteps;
  68637. /**
  68638. * Creates a new instance of DepthOfFieldMergePostProcess
  68639. * @param name The name of the effect.
  68640. * @param originalFromInput Post process which's input will be used for the merge.
  68641. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  68642. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  68643. * @param options The required width/height ratio to downsize to before computing the render pass.
  68644. * @param camera The camera to apply the render pass to.
  68645. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68646. * @param engine The engine which the post process will be applied. (default: current engine)
  68647. * @param reusable If the post process can be reused on the same frame. (default: false)
  68648. * @param textureType Type of textures used when performing the post process. (default: 0)
  68649. * @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)
  68650. */
  68651. 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);
  68652. /**
  68653. * Updates the effect with the current post process compile time values and recompiles the shader.
  68654. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68655. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68656. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68657. * @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
  68658. * @param onCompiled Called when the shader has been compiled.
  68659. * @param onError Called if there is an error when compiling a shader.
  68660. */
  68661. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68662. }
  68663. }
  68664. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  68665. import { Nullable } from "babylonjs/types";
  68666. import { Camera } from "babylonjs/Cameras/camera";
  68667. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68668. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  68669. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68670. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  68671. import { Scene } from "babylonjs/scene";
  68672. /**
  68673. * Specifies the level of max blur that should be applied when using the depth of field effect
  68674. */
  68675. export enum DepthOfFieldEffectBlurLevel {
  68676. /**
  68677. * Subtle blur
  68678. */
  68679. Low = 0,
  68680. /**
  68681. * Medium blur
  68682. */
  68683. Medium = 1,
  68684. /**
  68685. * Large blur
  68686. */
  68687. High = 2
  68688. }
  68689. /**
  68690. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  68691. */
  68692. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  68693. private _circleOfConfusion;
  68694. /**
  68695. * @hidden Internal, blurs from high to low
  68696. */
  68697. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  68698. private _depthOfFieldBlurY;
  68699. private _dofMerge;
  68700. /**
  68701. * @hidden Internal post processes in depth of field effect
  68702. */
  68703. _effects: Array<PostProcess>;
  68704. /**
  68705. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  68706. */
  68707. set focalLength(value: number);
  68708. get focalLength(): number;
  68709. /**
  68710. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68711. */
  68712. set fStop(value: number);
  68713. get fStop(): number;
  68714. /**
  68715. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68716. */
  68717. set focusDistance(value: number);
  68718. get focusDistance(): number;
  68719. /**
  68720. * 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.
  68721. */
  68722. set lensSize(value: number);
  68723. get lensSize(): number;
  68724. /**
  68725. * Creates a new instance DepthOfFieldEffect
  68726. * @param scene The scene the effect belongs to.
  68727. * @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.
  68728. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68729. * @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)
  68730. */
  68731. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  68732. /**
  68733. * Get the current class name of the current effet
  68734. * @returns "DepthOfFieldEffect"
  68735. */
  68736. getClassName(): string;
  68737. /**
  68738. * 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.
  68739. */
  68740. set depthTexture(value: RenderTargetTexture);
  68741. /**
  68742. * Disposes each of the internal effects for a given camera.
  68743. * @param camera The camera to dispose the effect on.
  68744. */
  68745. disposeEffects(camera: Camera): void;
  68746. /**
  68747. * @hidden Internal
  68748. */
  68749. _updateEffects(): void;
  68750. /**
  68751. * Internal
  68752. * @returns if all the contained post processes are ready.
  68753. * @hidden
  68754. */
  68755. _isReady(): boolean;
  68756. }
  68757. }
  68758. declare module "babylonjs/Shaders/displayPass.fragment" {
  68759. /** @hidden */
  68760. export var displayPassPixelShader: {
  68761. name: string;
  68762. shader: string;
  68763. };
  68764. }
  68765. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  68766. import { Nullable } from "babylonjs/types";
  68767. import { Camera } from "babylonjs/Cameras/camera";
  68768. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68769. import { Engine } from "babylonjs/Engines/engine";
  68770. import "babylonjs/Shaders/displayPass.fragment";
  68771. /**
  68772. * DisplayPassPostProcess which produces an output the same as it's input
  68773. */
  68774. export class DisplayPassPostProcess extends PostProcess {
  68775. /**
  68776. * Creates the DisplayPassPostProcess
  68777. * @param name The name of the effect.
  68778. * @param options The required width/height ratio to downsize to before computing the render pass.
  68779. * @param camera The camera to apply the render pass to.
  68780. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68781. * @param engine The engine which the post process will be applied. (default: current engine)
  68782. * @param reusable If the post process can be reused on the same frame. (default: false)
  68783. */
  68784. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68785. }
  68786. }
  68787. declare module "babylonjs/Shaders/filter.fragment" {
  68788. /** @hidden */
  68789. export var filterPixelShader: {
  68790. name: string;
  68791. shader: string;
  68792. };
  68793. }
  68794. declare module "babylonjs/PostProcesses/filterPostProcess" {
  68795. import { Nullable } from "babylonjs/types";
  68796. import { Matrix } from "babylonjs/Maths/math.vector";
  68797. import { Camera } from "babylonjs/Cameras/camera";
  68798. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68799. import { Engine } from "babylonjs/Engines/engine";
  68800. import "babylonjs/Shaders/filter.fragment";
  68801. /**
  68802. * Applies a kernel filter to the image
  68803. */
  68804. export class FilterPostProcess extends PostProcess {
  68805. /** The matrix to be applied to the image */
  68806. kernelMatrix: Matrix;
  68807. /**
  68808. *
  68809. * @param name The name of the effect.
  68810. * @param kernelMatrix The matrix to be applied to the image
  68811. * @param options The required width/height ratio to downsize to before computing the render pass.
  68812. * @param camera The camera to apply the render pass to.
  68813. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68814. * @param engine The engine which the post process will be applied. (default: current engine)
  68815. * @param reusable If the post process can be reused on the same frame. (default: false)
  68816. */
  68817. constructor(name: string,
  68818. /** The matrix to be applied to the image */
  68819. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68820. }
  68821. }
  68822. declare module "babylonjs/Shaders/fxaa.fragment" {
  68823. /** @hidden */
  68824. export var fxaaPixelShader: {
  68825. name: string;
  68826. shader: string;
  68827. };
  68828. }
  68829. declare module "babylonjs/Shaders/fxaa.vertex" {
  68830. /** @hidden */
  68831. export var fxaaVertexShader: {
  68832. name: string;
  68833. shader: string;
  68834. };
  68835. }
  68836. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  68837. import { Nullable } from "babylonjs/types";
  68838. import { Camera } from "babylonjs/Cameras/camera";
  68839. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68840. import { Engine } from "babylonjs/Engines/engine";
  68841. import "babylonjs/Shaders/fxaa.fragment";
  68842. import "babylonjs/Shaders/fxaa.vertex";
  68843. /**
  68844. * Fxaa post process
  68845. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  68846. */
  68847. export class FxaaPostProcess extends PostProcess {
  68848. /** @hidden */
  68849. texelWidth: number;
  68850. /** @hidden */
  68851. texelHeight: number;
  68852. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68853. private _getDefines;
  68854. }
  68855. }
  68856. declare module "babylonjs/Shaders/grain.fragment" {
  68857. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  68858. /** @hidden */
  68859. export var grainPixelShader: {
  68860. name: string;
  68861. shader: string;
  68862. };
  68863. }
  68864. declare module "babylonjs/PostProcesses/grainPostProcess" {
  68865. import { Nullable } from "babylonjs/types";
  68866. import { Camera } from "babylonjs/Cameras/camera";
  68867. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68868. import { Engine } from "babylonjs/Engines/engine";
  68869. import "babylonjs/Shaders/grain.fragment";
  68870. /**
  68871. * The GrainPostProcess adds noise to the image at mid luminance levels
  68872. */
  68873. export class GrainPostProcess extends PostProcess {
  68874. /**
  68875. * The intensity of the grain added (default: 30)
  68876. */
  68877. intensity: number;
  68878. /**
  68879. * If the grain should be randomized on every frame
  68880. */
  68881. animated: boolean;
  68882. /**
  68883. * Creates a new instance of @see GrainPostProcess
  68884. * @param name The name of the effect.
  68885. * @param options The required width/height ratio to downsize to before computing the render pass.
  68886. * @param camera The camera to apply the render pass to.
  68887. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68888. * @param engine The engine which the post process will be applied. (default: current engine)
  68889. * @param reusable If the post process can be reused on the same frame. (default: false)
  68890. * @param textureType Type of textures used when performing the post process. (default: 0)
  68891. * @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)
  68892. */
  68893. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68894. }
  68895. }
  68896. declare module "babylonjs/Shaders/highlights.fragment" {
  68897. /** @hidden */
  68898. export var highlightsPixelShader: {
  68899. name: string;
  68900. shader: string;
  68901. };
  68902. }
  68903. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  68904. import { Nullable } from "babylonjs/types";
  68905. import { Camera } from "babylonjs/Cameras/camera";
  68906. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68907. import { Engine } from "babylonjs/Engines/engine";
  68908. import "babylonjs/Shaders/highlights.fragment";
  68909. /**
  68910. * Extracts highlights from the image
  68911. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68912. */
  68913. export class HighlightsPostProcess extends PostProcess {
  68914. /**
  68915. * Extracts highlights from the image
  68916. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68917. * @param name The name of the effect.
  68918. * @param options The required width/height ratio to downsize to before computing the render pass.
  68919. * @param camera The camera to apply the render pass to.
  68920. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68921. * @param engine The engine which the post process will be applied. (default: current engine)
  68922. * @param reusable If the post process can be reused on the same frame. (default: false)
  68923. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  68924. */
  68925. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68926. }
  68927. }
  68928. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  68929. /** @hidden */
  68930. export var mrtFragmentDeclaration: {
  68931. name: string;
  68932. shader: string;
  68933. };
  68934. }
  68935. declare module "babylonjs/Shaders/geometry.fragment" {
  68936. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  68937. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  68938. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  68939. /** @hidden */
  68940. export var geometryPixelShader: {
  68941. name: string;
  68942. shader: string;
  68943. };
  68944. }
  68945. declare module "babylonjs/Shaders/geometry.vertex" {
  68946. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  68947. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  68948. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  68949. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  68950. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  68951. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  68952. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  68953. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  68954. /** @hidden */
  68955. export var geometryVertexShader: {
  68956. name: string;
  68957. shader: string;
  68958. };
  68959. }
  68960. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  68961. import { Matrix } from "babylonjs/Maths/math.vector";
  68962. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68963. import { Mesh } from "babylonjs/Meshes/mesh";
  68964. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  68965. import { Effect } from "babylonjs/Materials/effect";
  68966. import { Scene } from "babylonjs/scene";
  68967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68968. import "babylonjs/Shaders/geometry.fragment";
  68969. import "babylonjs/Shaders/geometry.vertex";
  68970. /** @hidden */
  68971. interface ISavedTransformationMatrix {
  68972. world: Matrix;
  68973. viewProjection: Matrix;
  68974. }
  68975. /**
  68976. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68977. */
  68978. export class GeometryBufferRenderer {
  68979. /**
  68980. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68981. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68982. */
  68983. static readonly POSITION_TEXTURE_TYPE: number;
  68984. /**
  68985. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68986. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68987. */
  68988. static readonly VELOCITY_TEXTURE_TYPE: number;
  68989. /**
  68990. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68991. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68992. */
  68993. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68994. /**
  68995. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68996. * in order to compute objects velocities when enableVelocity is set to "true"
  68997. * @hidden
  68998. */
  68999. _previousTransformationMatrices: {
  69000. [index: number]: ISavedTransformationMatrix;
  69001. };
  69002. /**
  69003. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  69004. * in order to compute objects velocities when enableVelocity is set to "true"
  69005. * @hidden
  69006. */
  69007. _previousBonesTransformationMatrices: {
  69008. [index: number]: Float32Array;
  69009. };
  69010. /**
  69011. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  69012. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  69013. */
  69014. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  69015. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  69016. renderTransparentMeshes: boolean;
  69017. private _scene;
  69018. private _multiRenderTarget;
  69019. private _ratio;
  69020. private _enablePosition;
  69021. private _enableVelocity;
  69022. private _enableReflectivity;
  69023. private _positionIndex;
  69024. private _velocityIndex;
  69025. private _reflectivityIndex;
  69026. protected _effect: Effect;
  69027. protected _cachedDefines: string;
  69028. /**
  69029. * Set the render list (meshes to be rendered) used in the G buffer.
  69030. */
  69031. set renderList(meshes: Mesh[]);
  69032. /**
  69033. * Gets wether or not G buffer are supported by the running hardware.
  69034. * This requires draw buffer supports
  69035. */
  69036. get isSupported(): boolean;
  69037. /**
  69038. * Returns the index of the given texture type in the G-Buffer textures array
  69039. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  69040. * @returns the index of the given texture type in the G-Buffer textures array
  69041. */
  69042. getTextureIndex(textureType: number): number;
  69043. /**
  69044. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  69045. */
  69046. get enablePosition(): boolean;
  69047. /**
  69048. * Sets whether or not objects positions are enabled for the G buffer.
  69049. */
  69050. set enablePosition(enable: boolean);
  69051. /**
  69052. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  69053. */
  69054. get enableVelocity(): boolean;
  69055. /**
  69056. * Sets wether or not objects velocities are enabled for the G buffer.
  69057. */
  69058. set enableVelocity(enable: boolean);
  69059. /**
  69060. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  69061. */
  69062. get enableReflectivity(): boolean;
  69063. /**
  69064. * Sets wether or not objects roughness are enabled for the G buffer.
  69065. */
  69066. set enableReflectivity(enable: boolean);
  69067. /**
  69068. * Gets the scene associated with the buffer.
  69069. */
  69070. get scene(): Scene;
  69071. /**
  69072. * Gets the ratio used by the buffer during its creation.
  69073. * How big is the buffer related to the main canvas.
  69074. */
  69075. get ratio(): number;
  69076. /** @hidden */
  69077. static _SceneComponentInitialization: (scene: Scene) => void;
  69078. /**
  69079. * Creates a new G Buffer for the scene
  69080. * @param scene The scene the buffer belongs to
  69081. * @param ratio How big is the buffer related to the main canvas.
  69082. */
  69083. constructor(scene: Scene, ratio?: number);
  69084. /**
  69085. * Checks wether everything is ready to render a submesh to the G buffer.
  69086. * @param subMesh the submesh to check readiness for
  69087. * @param useInstances is the mesh drawn using instance or not
  69088. * @returns true if ready otherwise false
  69089. */
  69090. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69091. /**
  69092. * Gets the current underlying G Buffer.
  69093. * @returns the buffer
  69094. */
  69095. getGBuffer(): MultiRenderTarget;
  69096. /**
  69097. * Gets the number of samples used to render the buffer (anti aliasing).
  69098. */
  69099. get samples(): number;
  69100. /**
  69101. * Sets the number of samples used to render the buffer (anti aliasing).
  69102. */
  69103. set samples(value: number);
  69104. /**
  69105. * Disposes the renderer and frees up associated resources.
  69106. */
  69107. dispose(): void;
  69108. protected _createRenderTargets(): void;
  69109. private _copyBonesTransformationMatrices;
  69110. }
  69111. }
  69112. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  69113. import { Nullable } from "babylonjs/types";
  69114. import { Scene } from "babylonjs/scene";
  69115. import { ISceneComponent } from "babylonjs/sceneComponent";
  69116. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  69117. module "babylonjs/scene" {
  69118. interface Scene {
  69119. /** @hidden (Backing field) */
  69120. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69121. /**
  69122. * Gets or Sets the current geometry buffer associated to the scene.
  69123. */
  69124. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69125. /**
  69126. * Enables a GeometryBufferRender and associates it with the scene
  69127. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  69128. * @returns the GeometryBufferRenderer
  69129. */
  69130. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  69131. /**
  69132. * Disables the GeometryBufferRender associated with the scene
  69133. */
  69134. disableGeometryBufferRenderer(): void;
  69135. }
  69136. }
  69137. /**
  69138. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  69139. * in several rendering techniques.
  69140. */
  69141. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  69142. /**
  69143. * The component name helpful to identify the component in the list of scene components.
  69144. */
  69145. readonly name: string;
  69146. /**
  69147. * The scene the component belongs to.
  69148. */
  69149. scene: Scene;
  69150. /**
  69151. * Creates a new instance of the component for the given scene
  69152. * @param scene Defines the scene to register the component in
  69153. */
  69154. constructor(scene: Scene);
  69155. /**
  69156. * Registers the component in a given scene
  69157. */
  69158. register(): void;
  69159. /**
  69160. * Rebuilds the elements related to this component in case of
  69161. * context lost for instance.
  69162. */
  69163. rebuild(): void;
  69164. /**
  69165. * Disposes the component and the associated ressources
  69166. */
  69167. dispose(): void;
  69168. private _gatherRenderTargets;
  69169. }
  69170. }
  69171. declare module "babylonjs/Shaders/motionBlur.fragment" {
  69172. /** @hidden */
  69173. export var motionBlurPixelShader: {
  69174. name: string;
  69175. shader: string;
  69176. };
  69177. }
  69178. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  69179. import { Nullable } from "babylonjs/types";
  69180. import { Camera } from "babylonjs/Cameras/camera";
  69181. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69182. import { Scene } from "babylonjs/scene";
  69183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69184. import "babylonjs/Animations/animatable";
  69185. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  69186. import "babylonjs/Shaders/motionBlur.fragment";
  69187. import { Engine } from "babylonjs/Engines/engine";
  69188. /**
  69189. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  69190. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  69191. * As an example, all you have to do is to create the post-process:
  69192. * var mb = new BABYLON.MotionBlurPostProcess(
  69193. * 'mb', // The name of the effect.
  69194. * scene, // The scene containing the objects to blur according to their velocity.
  69195. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  69196. * camera // The camera to apply the render pass to.
  69197. * );
  69198. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  69199. */
  69200. export class MotionBlurPostProcess extends PostProcess {
  69201. /**
  69202. * Defines how much the image is blurred by the movement. Default value is equal to 1
  69203. */
  69204. motionStrength: number;
  69205. /**
  69206. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  69207. */
  69208. get motionBlurSamples(): number;
  69209. /**
  69210. * Sets the number of iterations to be used for motion blur quality
  69211. */
  69212. set motionBlurSamples(samples: number);
  69213. private _motionBlurSamples;
  69214. private _geometryBufferRenderer;
  69215. /**
  69216. * Creates a new instance MotionBlurPostProcess
  69217. * @param name The name of the effect.
  69218. * @param scene The scene containing the objects to blur according to their velocity.
  69219. * @param options The required width/height ratio to downsize to before computing the render pass.
  69220. * @param camera The camera to apply the render pass to.
  69221. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69222. * @param engine The engine which the post process will be applied. (default: current engine)
  69223. * @param reusable If the post process can be reused on the same frame. (default: false)
  69224. * @param textureType Type of textures used when performing the post process. (default: 0)
  69225. * @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)
  69226. */
  69227. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69228. /**
  69229. * Excludes the given skinned mesh from computing bones velocities.
  69230. * 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.
  69231. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  69232. */
  69233. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69234. /**
  69235. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  69236. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  69237. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  69238. */
  69239. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69240. /**
  69241. * Disposes the post process.
  69242. * @param camera The camera to dispose the post process on.
  69243. */
  69244. dispose(camera?: Camera): void;
  69245. }
  69246. }
  69247. declare module "babylonjs/Shaders/refraction.fragment" {
  69248. /** @hidden */
  69249. export var refractionPixelShader: {
  69250. name: string;
  69251. shader: string;
  69252. };
  69253. }
  69254. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  69255. import { Color3 } from "babylonjs/Maths/math.color";
  69256. import { Camera } from "babylonjs/Cameras/camera";
  69257. import { Texture } from "babylonjs/Materials/Textures/texture";
  69258. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69259. import { Engine } from "babylonjs/Engines/engine";
  69260. import "babylonjs/Shaders/refraction.fragment";
  69261. /**
  69262. * Post process which applies a refractin texture
  69263. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69264. */
  69265. export class RefractionPostProcess extends PostProcess {
  69266. /** the base color of the refraction (used to taint the rendering) */
  69267. color: Color3;
  69268. /** simulated refraction depth */
  69269. depth: number;
  69270. /** the coefficient of the base color (0 to remove base color tainting) */
  69271. colorLevel: number;
  69272. private _refTexture;
  69273. private _ownRefractionTexture;
  69274. /**
  69275. * Gets or sets the refraction texture
  69276. * Please note that you are responsible for disposing the texture if you set it manually
  69277. */
  69278. get refractionTexture(): Texture;
  69279. set refractionTexture(value: Texture);
  69280. /**
  69281. * Initializes the RefractionPostProcess
  69282. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69283. * @param name The name of the effect.
  69284. * @param refractionTextureUrl Url of the refraction texture to use
  69285. * @param color the base color of the refraction (used to taint the rendering)
  69286. * @param depth simulated refraction depth
  69287. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  69288. * @param camera The camera to apply the render pass to.
  69289. * @param options The required width/height ratio to downsize to before computing the render pass.
  69290. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69291. * @param engine The engine which the post process will be applied. (default: current engine)
  69292. * @param reusable If the post process can be reused on the same frame. (default: false)
  69293. */
  69294. constructor(name: string, refractionTextureUrl: string,
  69295. /** the base color of the refraction (used to taint the rendering) */
  69296. color: Color3,
  69297. /** simulated refraction depth */
  69298. depth: number,
  69299. /** the coefficient of the base color (0 to remove base color tainting) */
  69300. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69301. /**
  69302. * Disposes of the post process
  69303. * @param camera Camera to dispose post process on
  69304. */
  69305. dispose(camera: Camera): void;
  69306. }
  69307. }
  69308. declare module "babylonjs/Shaders/sharpen.fragment" {
  69309. /** @hidden */
  69310. export var sharpenPixelShader: {
  69311. name: string;
  69312. shader: string;
  69313. };
  69314. }
  69315. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  69316. import { Nullable } from "babylonjs/types";
  69317. import { Camera } from "babylonjs/Cameras/camera";
  69318. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69319. import "babylonjs/Shaders/sharpen.fragment";
  69320. import { Engine } from "babylonjs/Engines/engine";
  69321. /**
  69322. * The SharpenPostProcess applies a sharpen kernel to every pixel
  69323. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69324. */
  69325. export class SharpenPostProcess extends PostProcess {
  69326. /**
  69327. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  69328. */
  69329. colorAmount: number;
  69330. /**
  69331. * How much sharpness should be applied (default: 0.3)
  69332. */
  69333. edgeAmount: number;
  69334. /**
  69335. * Creates a new instance ConvolutionPostProcess
  69336. * @param name The name of the effect.
  69337. * @param options The required width/height ratio to downsize to before computing the render pass.
  69338. * @param camera The camera to apply the render pass to.
  69339. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69340. * @param engine The engine which the post process will be applied. (default: current engine)
  69341. * @param reusable If the post process can be reused on the same frame. (default: false)
  69342. * @param textureType Type of textures used when performing the post process. (default: 0)
  69343. * @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)
  69344. */
  69345. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69346. }
  69347. }
  69348. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  69349. import { Nullable } from "babylonjs/types";
  69350. import { Camera } from "babylonjs/Cameras/camera";
  69351. import { Engine } from "babylonjs/Engines/engine";
  69352. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69353. import { IInspectable } from "babylonjs/Misc/iInspectable";
  69354. /**
  69355. * PostProcessRenderPipeline
  69356. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69357. */
  69358. export class PostProcessRenderPipeline {
  69359. private engine;
  69360. private _renderEffects;
  69361. private _renderEffectsForIsolatedPass;
  69362. /**
  69363. * List of inspectable custom properties (used by the Inspector)
  69364. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  69365. */
  69366. inspectableCustomProperties: IInspectable[];
  69367. /**
  69368. * @hidden
  69369. */
  69370. protected _cameras: Camera[];
  69371. /** @hidden */
  69372. _name: string;
  69373. /**
  69374. * Gets pipeline name
  69375. */
  69376. get name(): string;
  69377. /** Gets the list of attached cameras */
  69378. get cameras(): Camera[];
  69379. /**
  69380. * Initializes a PostProcessRenderPipeline
  69381. * @param engine engine to add the pipeline to
  69382. * @param name name of the pipeline
  69383. */
  69384. constructor(engine: Engine, name: string);
  69385. /**
  69386. * Gets the class name
  69387. * @returns "PostProcessRenderPipeline"
  69388. */
  69389. getClassName(): string;
  69390. /**
  69391. * If all the render effects in the pipeline are supported
  69392. */
  69393. get isSupported(): boolean;
  69394. /**
  69395. * Adds an effect to the pipeline
  69396. * @param renderEffect the effect to add
  69397. */
  69398. addEffect(renderEffect: PostProcessRenderEffect): void;
  69399. /** @hidden */
  69400. _rebuild(): void;
  69401. /** @hidden */
  69402. _enableEffect(renderEffectName: string, cameras: Camera): void;
  69403. /** @hidden */
  69404. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  69405. /** @hidden */
  69406. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69407. /** @hidden */
  69408. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69409. /** @hidden */
  69410. _attachCameras(cameras: Camera, unique: boolean): void;
  69411. /** @hidden */
  69412. _attachCameras(cameras: Camera[], unique: boolean): void;
  69413. /** @hidden */
  69414. _detachCameras(cameras: Camera): void;
  69415. /** @hidden */
  69416. _detachCameras(cameras: Nullable<Camera[]>): void;
  69417. /** @hidden */
  69418. _update(): void;
  69419. /** @hidden */
  69420. _reset(): void;
  69421. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  69422. /**
  69423. * Disposes of the pipeline
  69424. */
  69425. dispose(): void;
  69426. }
  69427. }
  69428. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  69429. import { Camera } from "babylonjs/Cameras/camera";
  69430. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69431. /**
  69432. * PostProcessRenderPipelineManager class
  69433. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69434. */
  69435. export class PostProcessRenderPipelineManager {
  69436. private _renderPipelines;
  69437. /**
  69438. * Initializes a PostProcessRenderPipelineManager
  69439. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69440. */
  69441. constructor();
  69442. /**
  69443. * Gets the list of supported render pipelines
  69444. */
  69445. get supportedPipelines(): PostProcessRenderPipeline[];
  69446. /**
  69447. * Adds a pipeline to the manager
  69448. * @param renderPipeline The pipeline to add
  69449. */
  69450. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  69451. /**
  69452. * Attaches a camera to the pipeline
  69453. * @param renderPipelineName The name of the pipeline to attach to
  69454. * @param cameras the camera to attach
  69455. * @param unique if the camera can be attached multiple times to the pipeline
  69456. */
  69457. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  69458. /**
  69459. * Detaches a camera from the pipeline
  69460. * @param renderPipelineName The name of the pipeline to detach from
  69461. * @param cameras the camera to detach
  69462. */
  69463. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  69464. /**
  69465. * Enables an effect by name on a pipeline
  69466. * @param renderPipelineName the name of the pipeline to enable the effect in
  69467. * @param renderEffectName the name of the effect to enable
  69468. * @param cameras the cameras that the effect should be enabled on
  69469. */
  69470. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69471. /**
  69472. * Disables an effect by name on a pipeline
  69473. * @param renderPipelineName the name of the pipeline to disable the effect in
  69474. * @param renderEffectName the name of the effect to disable
  69475. * @param cameras the cameras that the effect should be disabled on
  69476. */
  69477. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69478. /**
  69479. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  69480. */
  69481. update(): void;
  69482. /** @hidden */
  69483. _rebuild(): void;
  69484. /**
  69485. * Disposes of the manager and pipelines
  69486. */
  69487. dispose(): void;
  69488. }
  69489. }
  69490. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  69491. import { ISceneComponent } from "babylonjs/sceneComponent";
  69492. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  69493. import { Scene } from "babylonjs/scene";
  69494. module "babylonjs/scene" {
  69495. interface Scene {
  69496. /** @hidden (Backing field) */
  69497. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69498. /**
  69499. * Gets the postprocess render pipeline manager
  69500. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69501. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69502. */
  69503. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69504. }
  69505. }
  69506. /**
  69507. * Defines the Render Pipeline scene component responsible to rendering pipelines
  69508. */
  69509. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  69510. /**
  69511. * The component name helpfull to identify the component in the list of scene components.
  69512. */
  69513. readonly name: string;
  69514. /**
  69515. * The scene the component belongs to.
  69516. */
  69517. scene: Scene;
  69518. /**
  69519. * Creates a new instance of the component for the given scene
  69520. * @param scene Defines the scene to register the component in
  69521. */
  69522. constructor(scene: Scene);
  69523. /**
  69524. * Registers the component in a given scene
  69525. */
  69526. register(): void;
  69527. /**
  69528. * Rebuilds the elements related to this component in case of
  69529. * context lost for instance.
  69530. */
  69531. rebuild(): void;
  69532. /**
  69533. * Disposes the component and the associated ressources
  69534. */
  69535. dispose(): void;
  69536. private _gatherRenderTargets;
  69537. }
  69538. }
  69539. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  69540. import { Nullable } from "babylonjs/types";
  69541. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69542. import { Camera } from "babylonjs/Cameras/camera";
  69543. import { IDisposable } from "babylonjs/scene";
  69544. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  69545. import { Scene } from "babylonjs/scene";
  69546. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  69547. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  69548. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  69549. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  69550. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  69551. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69552. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  69553. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69554. import { Animation } from "babylonjs/Animations/animation";
  69555. /**
  69556. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  69557. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69558. */
  69559. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69560. private _scene;
  69561. private _camerasToBeAttached;
  69562. /**
  69563. * ID of the sharpen post process,
  69564. */
  69565. private readonly SharpenPostProcessId;
  69566. /**
  69567. * @ignore
  69568. * ID of the image processing post process;
  69569. */
  69570. readonly ImageProcessingPostProcessId: string;
  69571. /**
  69572. * @ignore
  69573. * ID of the Fast Approximate Anti-Aliasing post process;
  69574. */
  69575. readonly FxaaPostProcessId: string;
  69576. /**
  69577. * ID of the chromatic aberration post process,
  69578. */
  69579. private readonly ChromaticAberrationPostProcessId;
  69580. /**
  69581. * ID of the grain post process
  69582. */
  69583. private readonly GrainPostProcessId;
  69584. /**
  69585. * Sharpen post process which will apply a sharpen convolution to enhance edges
  69586. */
  69587. sharpen: SharpenPostProcess;
  69588. private _sharpenEffect;
  69589. private bloom;
  69590. /**
  69591. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  69592. */
  69593. depthOfField: DepthOfFieldEffect;
  69594. /**
  69595. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69596. */
  69597. fxaa: FxaaPostProcess;
  69598. /**
  69599. * Image post processing pass used to perform operations such as tone mapping or color grading.
  69600. */
  69601. imageProcessing: ImageProcessingPostProcess;
  69602. /**
  69603. * Chromatic aberration post process which will shift rgb colors in the image
  69604. */
  69605. chromaticAberration: ChromaticAberrationPostProcess;
  69606. private _chromaticAberrationEffect;
  69607. /**
  69608. * Grain post process which add noise to the image
  69609. */
  69610. grain: GrainPostProcess;
  69611. private _grainEffect;
  69612. /**
  69613. * Glow post process which adds a glow to emissive areas of the image
  69614. */
  69615. private _glowLayer;
  69616. /**
  69617. * Animations which can be used to tweak settings over a period of time
  69618. */
  69619. animations: Animation[];
  69620. private _imageProcessingConfigurationObserver;
  69621. private _sharpenEnabled;
  69622. private _bloomEnabled;
  69623. private _depthOfFieldEnabled;
  69624. private _depthOfFieldBlurLevel;
  69625. private _fxaaEnabled;
  69626. private _imageProcessingEnabled;
  69627. private _defaultPipelineTextureType;
  69628. private _bloomScale;
  69629. private _chromaticAberrationEnabled;
  69630. private _grainEnabled;
  69631. private _buildAllowed;
  69632. /**
  69633. * Gets active scene
  69634. */
  69635. get scene(): Scene;
  69636. /**
  69637. * Enable or disable the sharpen process from the pipeline
  69638. */
  69639. set sharpenEnabled(enabled: boolean);
  69640. get sharpenEnabled(): boolean;
  69641. private _resizeObserver;
  69642. private _hardwareScaleLevel;
  69643. private _bloomKernel;
  69644. /**
  69645. * Specifies the size of the bloom blur kernel, relative to the final output size
  69646. */
  69647. get bloomKernel(): number;
  69648. set bloomKernel(value: number);
  69649. /**
  69650. * Specifies the weight of the bloom in the final rendering
  69651. */
  69652. private _bloomWeight;
  69653. /**
  69654. * Specifies the luma threshold for the area that will be blurred by the bloom
  69655. */
  69656. private _bloomThreshold;
  69657. private _hdr;
  69658. /**
  69659. * The strength of the bloom.
  69660. */
  69661. set bloomWeight(value: number);
  69662. get bloomWeight(): number;
  69663. /**
  69664. * The strength of the bloom.
  69665. */
  69666. set bloomThreshold(value: number);
  69667. get bloomThreshold(): number;
  69668. /**
  69669. * The scale of the bloom, lower value will provide better performance.
  69670. */
  69671. set bloomScale(value: number);
  69672. get bloomScale(): number;
  69673. /**
  69674. * Enable or disable the bloom from the pipeline
  69675. */
  69676. set bloomEnabled(enabled: boolean);
  69677. get bloomEnabled(): boolean;
  69678. private _rebuildBloom;
  69679. /**
  69680. * If the depth of field is enabled.
  69681. */
  69682. get depthOfFieldEnabled(): boolean;
  69683. set depthOfFieldEnabled(enabled: boolean);
  69684. /**
  69685. * Blur level of the depth of field effect. (Higher blur will effect performance)
  69686. */
  69687. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  69688. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  69689. /**
  69690. * If the anti aliasing is enabled.
  69691. */
  69692. set fxaaEnabled(enabled: boolean);
  69693. get fxaaEnabled(): boolean;
  69694. private _samples;
  69695. /**
  69696. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69697. */
  69698. set samples(sampleCount: number);
  69699. get samples(): number;
  69700. /**
  69701. * If image processing is enabled.
  69702. */
  69703. set imageProcessingEnabled(enabled: boolean);
  69704. get imageProcessingEnabled(): boolean;
  69705. /**
  69706. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  69707. */
  69708. set glowLayerEnabled(enabled: boolean);
  69709. get glowLayerEnabled(): boolean;
  69710. /**
  69711. * Gets the glow layer (or null if not defined)
  69712. */
  69713. get glowLayer(): Nullable<GlowLayer>;
  69714. /**
  69715. * Enable or disable the chromaticAberration process from the pipeline
  69716. */
  69717. set chromaticAberrationEnabled(enabled: boolean);
  69718. get chromaticAberrationEnabled(): boolean;
  69719. /**
  69720. * Enable or disable the grain process from the pipeline
  69721. */
  69722. set grainEnabled(enabled: boolean);
  69723. get grainEnabled(): boolean;
  69724. /**
  69725. * @constructor
  69726. * @param name - The rendering pipeline name (default: "")
  69727. * @param hdr - If high dynamic range textures should be used (default: true)
  69728. * @param scene - The scene linked to this pipeline (default: the last created scene)
  69729. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  69730. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  69731. */
  69732. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  69733. /**
  69734. * Get the class name
  69735. * @returns "DefaultRenderingPipeline"
  69736. */
  69737. getClassName(): string;
  69738. /**
  69739. * Force the compilation of the entire pipeline.
  69740. */
  69741. prepare(): void;
  69742. private _hasCleared;
  69743. private _prevPostProcess;
  69744. private _prevPrevPostProcess;
  69745. private _setAutoClearAndTextureSharing;
  69746. private _depthOfFieldSceneObserver;
  69747. private _buildPipeline;
  69748. private _disposePostProcesses;
  69749. /**
  69750. * Adds a camera to the pipeline
  69751. * @param camera the camera to be added
  69752. */
  69753. addCamera(camera: Camera): void;
  69754. /**
  69755. * Removes a camera from the pipeline
  69756. * @param camera the camera to remove
  69757. */
  69758. removeCamera(camera: Camera): void;
  69759. /**
  69760. * Dispose of the pipeline and stop all post processes
  69761. */
  69762. dispose(): void;
  69763. /**
  69764. * Serialize the rendering pipeline (Used when exporting)
  69765. * @returns the serialized object
  69766. */
  69767. serialize(): any;
  69768. /**
  69769. * Parse the serialized pipeline
  69770. * @param source Source pipeline.
  69771. * @param scene The scene to load the pipeline to.
  69772. * @param rootUrl The URL of the serialized pipeline.
  69773. * @returns An instantiated pipeline from the serialized object.
  69774. */
  69775. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  69776. }
  69777. }
  69778. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  69779. /** @hidden */
  69780. export var lensHighlightsPixelShader: {
  69781. name: string;
  69782. shader: string;
  69783. };
  69784. }
  69785. declare module "babylonjs/Shaders/depthOfField.fragment" {
  69786. /** @hidden */
  69787. export var depthOfFieldPixelShader: {
  69788. name: string;
  69789. shader: string;
  69790. };
  69791. }
  69792. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  69793. import { Camera } from "babylonjs/Cameras/camera";
  69794. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69795. import { Scene } from "babylonjs/scene";
  69796. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69797. import "babylonjs/Shaders/chromaticAberration.fragment";
  69798. import "babylonjs/Shaders/lensHighlights.fragment";
  69799. import "babylonjs/Shaders/depthOfField.fragment";
  69800. /**
  69801. * BABYLON.JS Chromatic Aberration GLSL Shader
  69802. * Author: Olivier Guyot
  69803. * Separates very slightly R, G and B colors on the edges of the screen
  69804. * Inspired by Francois Tarlier & Martins Upitis
  69805. */
  69806. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  69807. /**
  69808. * @ignore
  69809. * The chromatic aberration PostProcess id in the pipeline
  69810. */
  69811. LensChromaticAberrationEffect: string;
  69812. /**
  69813. * @ignore
  69814. * The highlights enhancing PostProcess id in the pipeline
  69815. */
  69816. HighlightsEnhancingEffect: string;
  69817. /**
  69818. * @ignore
  69819. * The depth-of-field PostProcess id in the pipeline
  69820. */
  69821. LensDepthOfFieldEffect: string;
  69822. private _scene;
  69823. private _depthTexture;
  69824. private _grainTexture;
  69825. private _chromaticAberrationPostProcess;
  69826. private _highlightsPostProcess;
  69827. private _depthOfFieldPostProcess;
  69828. private _edgeBlur;
  69829. private _grainAmount;
  69830. private _chromaticAberration;
  69831. private _distortion;
  69832. private _highlightsGain;
  69833. private _highlightsThreshold;
  69834. private _dofDistance;
  69835. private _dofAperture;
  69836. private _dofDarken;
  69837. private _dofPentagon;
  69838. private _blurNoise;
  69839. /**
  69840. * @constructor
  69841. *
  69842. * Effect parameters are as follow:
  69843. * {
  69844. * chromatic_aberration: number; // from 0 to x (1 for realism)
  69845. * edge_blur: number; // from 0 to x (1 for realism)
  69846. * distortion: number; // from 0 to x (1 for realism)
  69847. * grain_amount: number; // from 0 to 1
  69848. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  69849. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  69850. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  69851. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  69852. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  69853. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  69854. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  69855. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  69856. * }
  69857. * Note: if an effect parameter is unset, effect is disabled
  69858. *
  69859. * @param name The rendering pipeline name
  69860. * @param parameters - An object containing all parameters (see above)
  69861. * @param scene The scene linked to this pipeline
  69862. * @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)
  69863. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69864. */
  69865. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  69866. /**
  69867. * Get the class name
  69868. * @returns "LensRenderingPipeline"
  69869. */
  69870. getClassName(): string;
  69871. /**
  69872. * Gets associated scene
  69873. */
  69874. get scene(): Scene;
  69875. /**
  69876. * Gets or sets the edge blur
  69877. */
  69878. get edgeBlur(): number;
  69879. set edgeBlur(value: number);
  69880. /**
  69881. * Gets or sets the grain amount
  69882. */
  69883. get grainAmount(): number;
  69884. set grainAmount(value: number);
  69885. /**
  69886. * Gets or sets the chromatic aberration amount
  69887. */
  69888. get chromaticAberration(): number;
  69889. set chromaticAberration(value: number);
  69890. /**
  69891. * Gets or sets the depth of field aperture
  69892. */
  69893. get dofAperture(): number;
  69894. set dofAperture(value: number);
  69895. /**
  69896. * Gets or sets the edge distortion
  69897. */
  69898. get edgeDistortion(): number;
  69899. set edgeDistortion(value: number);
  69900. /**
  69901. * Gets or sets the depth of field distortion
  69902. */
  69903. get dofDistortion(): number;
  69904. set dofDistortion(value: number);
  69905. /**
  69906. * Gets or sets the darken out of focus amount
  69907. */
  69908. get darkenOutOfFocus(): number;
  69909. set darkenOutOfFocus(value: number);
  69910. /**
  69911. * Gets or sets a boolean indicating if blur noise is enabled
  69912. */
  69913. get blurNoise(): boolean;
  69914. set blurNoise(value: boolean);
  69915. /**
  69916. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  69917. */
  69918. get pentagonBokeh(): boolean;
  69919. set pentagonBokeh(value: boolean);
  69920. /**
  69921. * Gets or sets the highlight grain amount
  69922. */
  69923. get highlightsGain(): number;
  69924. set highlightsGain(value: number);
  69925. /**
  69926. * Gets or sets the highlight threshold
  69927. */
  69928. get highlightsThreshold(): number;
  69929. set highlightsThreshold(value: number);
  69930. /**
  69931. * Sets the amount of blur at the edges
  69932. * @param amount blur amount
  69933. */
  69934. setEdgeBlur(amount: number): void;
  69935. /**
  69936. * Sets edge blur to 0
  69937. */
  69938. disableEdgeBlur(): void;
  69939. /**
  69940. * Sets the amout of grain
  69941. * @param amount Amount of grain
  69942. */
  69943. setGrainAmount(amount: number): void;
  69944. /**
  69945. * Set grain amount to 0
  69946. */
  69947. disableGrain(): void;
  69948. /**
  69949. * Sets the chromatic aberration amount
  69950. * @param amount amount of chromatic aberration
  69951. */
  69952. setChromaticAberration(amount: number): void;
  69953. /**
  69954. * Sets chromatic aberration amount to 0
  69955. */
  69956. disableChromaticAberration(): void;
  69957. /**
  69958. * Sets the EdgeDistortion amount
  69959. * @param amount amount of EdgeDistortion
  69960. */
  69961. setEdgeDistortion(amount: number): void;
  69962. /**
  69963. * Sets edge distortion to 0
  69964. */
  69965. disableEdgeDistortion(): void;
  69966. /**
  69967. * Sets the FocusDistance amount
  69968. * @param amount amount of FocusDistance
  69969. */
  69970. setFocusDistance(amount: number): void;
  69971. /**
  69972. * Disables depth of field
  69973. */
  69974. disableDepthOfField(): void;
  69975. /**
  69976. * Sets the Aperture amount
  69977. * @param amount amount of Aperture
  69978. */
  69979. setAperture(amount: number): void;
  69980. /**
  69981. * Sets the DarkenOutOfFocus amount
  69982. * @param amount amount of DarkenOutOfFocus
  69983. */
  69984. setDarkenOutOfFocus(amount: number): void;
  69985. private _pentagonBokehIsEnabled;
  69986. /**
  69987. * Creates a pentagon bokeh effect
  69988. */
  69989. enablePentagonBokeh(): void;
  69990. /**
  69991. * Disables the pentagon bokeh effect
  69992. */
  69993. disablePentagonBokeh(): void;
  69994. /**
  69995. * Enables noise blur
  69996. */
  69997. enableNoiseBlur(): void;
  69998. /**
  69999. * Disables noise blur
  70000. */
  70001. disableNoiseBlur(): void;
  70002. /**
  70003. * Sets the HighlightsGain amount
  70004. * @param amount amount of HighlightsGain
  70005. */
  70006. setHighlightsGain(amount: number): void;
  70007. /**
  70008. * Sets the HighlightsThreshold amount
  70009. * @param amount amount of HighlightsThreshold
  70010. */
  70011. setHighlightsThreshold(amount: number): void;
  70012. /**
  70013. * Disables highlights
  70014. */
  70015. disableHighlights(): void;
  70016. /**
  70017. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  70018. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  70019. */
  70020. dispose(disableDepthRender?: boolean): void;
  70021. private _createChromaticAberrationPostProcess;
  70022. private _createHighlightsPostProcess;
  70023. private _createDepthOfFieldPostProcess;
  70024. private _createGrainTexture;
  70025. }
  70026. }
  70027. declare module "babylonjs/Shaders/ssao2.fragment" {
  70028. /** @hidden */
  70029. export var ssao2PixelShader: {
  70030. name: string;
  70031. shader: string;
  70032. };
  70033. }
  70034. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  70035. /** @hidden */
  70036. export var ssaoCombinePixelShader: {
  70037. name: string;
  70038. shader: string;
  70039. };
  70040. }
  70041. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  70042. import { Camera } from "babylonjs/Cameras/camera";
  70043. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  70044. import { Scene } from "babylonjs/scene";
  70045. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  70046. import "babylonjs/Shaders/ssao2.fragment";
  70047. import "babylonjs/Shaders/ssaoCombine.fragment";
  70048. /**
  70049. * Render pipeline to produce ssao effect
  70050. */
  70051. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  70052. /**
  70053. * @ignore
  70054. * The PassPostProcess id in the pipeline that contains the original scene color
  70055. */
  70056. SSAOOriginalSceneColorEffect: string;
  70057. /**
  70058. * @ignore
  70059. * The SSAO PostProcess id in the pipeline
  70060. */
  70061. SSAORenderEffect: string;
  70062. /**
  70063. * @ignore
  70064. * The horizontal blur PostProcess id in the pipeline
  70065. */
  70066. SSAOBlurHRenderEffect: string;
  70067. /**
  70068. * @ignore
  70069. * The vertical blur PostProcess id in the pipeline
  70070. */
  70071. SSAOBlurVRenderEffect: string;
  70072. /**
  70073. * @ignore
  70074. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70075. */
  70076. SSAOCombineRenderEffect: string;
  70077. /**
  70078. * The output strength of the SSAO post-process. Default value is 1.0.
  70079. */
  70080. totalStrength: number;
  70081. /**
  70082. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  70083. */
  70084. maxZ: number;
  70085. /**
  70086. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  70087. */
  70088. minZAspect: number;
  70089. private _samples;
  70090. /**
  70091. * Number of samples used for the SSAO calculations. Default value is 8
  70092. */
  70093. set samples(n: number);
  70094. get samples(): number;
  70095. private _textureSamples;
  70096. /**
  70097. * Number of samples to use for antialiasing
  70098. */
  70099. set textureSamples(n: number);
  70100. get textureSamples(): number;
  70101. /**
  70102. * Ratio object used for SSAO ratio and blur ratio
  70103. */
  70104. private _ratio;
  70105. /**
  70106. * Dynamically generated sphere sampler.
  70107. */
  70108. private _sampleSphere;
  70109. /**
  70110. * Blur filter offsets
  70111. */
  70112. private _samplerOffsets;
  70113. private _expensiveBlur;
  70114. /**
  70115. * If bilateral blur should be used
  70116. */
  70117. set expensiveBlur(b: boolean);
  70118. get expensiveBlur(): boolean;
  70119. /**
  70120. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  70121. */
  70122. radius: number;
  70123. /**
  70124. * The base color of the SSAO post-process
  70125. * The final result is "base + ssao" between [0, 1]
  70126. */
  70127. base: number;
  70128. /**
  70129. * Support test.
  70130. */
  70131. static get IsSupported(): boolean;
  70132. private _scene;
  70133. private _depthTexture;
  70134. private _normalTexture;
  70135. private _randomTexture;
  70136. private _originalColorPostProcess;
  70137. private _ssaoPostProcess;
  70138. private _blurHPostProcess;
  70139. private _blurVPostProcess;
  70140. private _ssaoCombinePostProcess;
  70141. /**
  70142. * Gets active scene
  70143. */
  70144. get scene(): Scene;
  70145. /**
  70146. * @constructor
  70147. * @param name The rendering pipeline name
  70148. * @param scene The scene linked to this pipeline
  70149. * @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 }
  70150. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70151. */
  70152. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  70153. /**
  70154. * Get the class name
  70155. * @returns "SSAO2RenderingPipeline"
  70156. */
  70157. getClassName(): string;
  70158. /**
  70159. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70160. */
  70161. dispose(disableGeometryBufferRenderer?: boolean): void;
  70162. private _createBlurPostProcess;
  70163. /** @hidden */
  70164. _rebuild(): void;
  70165. private _bits;
  70166. private _radicalInverse_VdC;
  70167. private _hammersley;
  70168. private _hemisphereSample_uniform;
  70169. private _generateHemisphere;
  70170. private _createSSAOPostProcess;
  70171. private _createSSAOCombinePostProcess;
  70172. private _createRandomTexture;
  70173. /**
  70174. * Serialize the rendering pipeline (Used when exporting)
  70175. * @returns the serialized object
  70176. */
  70177. serialize(): any;
  70178. /**
  70179. * Parse the serialized pipeline
  70180. * @param source Source pipeline.
  70181. * @param scene The scene to load the pipeline to.
  70182. * @param rootUrl The URL of the serialized pipeline.
  70183. * @returns An instantiated pipeline from the serialized object.
  70184. */
  70185. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  70186. }
  70187. }
  70188. declare module "babylonjs/Shaders/ssao.fragment" {
  70189. /** @hidden */
  70190. export var ssaoPixelShader: {
  70191. name: string;
  70192. shader: string;
  70193. };
  70194. }
  70195. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  70196. import { Camera } from "babylonjs/Cameras/camera";
  70197. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  70198. import { Scene } from "babylonjs/scene";
  70199. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  70200. import "babylonjs/Shaders/ssao.fragment";
  70201. import "babylonjs/Shaders/ssaoCombine.fragment";
  70202. /**
  70203. * Render pipeline to produce ssao effect
  70204. */
  70205. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  70206. /**
  70207. * @ignore
  70208. * The PassPostProcess id in the pipeline that contains the original scene color
  70209. */
  70210. SSAOOriginalSceneColorEffect: string;
  70211. /**
  70212. * @ignore
  70213. * The SSAO PostProcess id in the pipeline
  70214. */
  70215. SSAORenderEffect: string;
  70216. /**
  70217. * @ignore
  70218. * The horizontal blur PostProcess id in the pipeline
  70219. */
  70220. SSAOBlurHRenderEffect: string;
  70221. /**
  70222. * @ignore
  70223. * The vertical blur PostProcess id in the pipeline
  70224. */
  70225. SSAOBlurVRenderEffect: string;
  70226. /**
  70227. * @ignore
  70228. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70229. */
  70230. SSAOCombineRenderEffect: string;
  70231. /**
  70232. * The output strength of the SSAO post-process. Default value is 1.0.
  70233. */
  70234. totalStrength: number;
  70235. /**
  70236. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  70237. */
  70238. radius: number;
  70239. /**
  70240. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  70241. * Must not be equal to fallOff and superior to fallOff.
  70242. * Default value is 0.0075
  70243. */
  70244. area: number;
  70245. /**
  70246. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  70247. * Must not be equal to area and inferior to area.
  70248. * Default value is 0.000001
  70249. */
  70250. fallOff: number;
  70251. /**
  70252. * The base color of the SSAO post-process
  70253. * The final result is "base + ssao" between [0, 1]
  70254. */
  70255. base: number;
  70256. private _scene;
  70257. private _depthTexture;
  70258. private _randomTexture;
  70259. private _originalColorPostProcess;
  70260. private _ssaoPostProcess;
  70261. private _blurHPostProcess;
  70262. private _blurVPostProcess;
  70263. private _ssaoCombinePostProcess;
  70264. private _firstUpdate;
  70265. /**
  70266. * Gets active scene
  70267. */
  70268. get scene(): Scene;
  70269. /**
  70270. * @constructor
  70271. * @param name - The rendering pipeline name
  70272. * @param scene - The scene linked to this pipeline
  70273. * @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 }
  70274. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  70275. */
  70276. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  70277. /**
  70278. * Get the class name
  70279. * @returns "SSAORenderingPipeline"
  70280. */
  70281. getClassName(): string;
  70282. /**
  70283. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70284. */
  70285. dispose(disableDepthRender?: boolean): void;
  70286. private _createBlurPostProcess;
  70287. /** @hidden */
  70288. _rebuild(): void;
  70289. private _createSSAOPostProcess;
  70290. private _createSSAOCombinePostProcess;
  70291. private _createRandomTexture;
  70292. }
  70293. }
  70294. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  70295. /** @hidden */
  70296. export var screenSpaceReflectionPixelShader: {
  70297. name: string;
  70298. shader: string;
  70299. };
  70300. }
  70301. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  70302. import { Nullable } from "babylonjs/types";
  70303. import { Camera } from "babylonjs/Cameras/camera";
  70304. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70305. import { Scene } from "babylonjs/scene";
  70306. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  70307. import { Engine } from "babylonjs/Engines/engine";
  70308. /**
  70309. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  70310. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  70311. */
  70312. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  70313. /**
  70314. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  70315. */
  70316. threshold: number;
  70317. /**
  70318. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  70319. */
  70320. strength: number;
  70321. /**
  70322. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  70323. */
  70324. reflectionSpecularFalloffExponent: number;
  70325. /**
  70326. * Gets or sets the step size used to iterate until the effect finds the color of the reflection's pixel. Typically in interval [0.1, 1.0]
  70327. */
  70328. step: number;
  70329. /**
  70330. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  70331. */
  70332. roughnessFactor: number;
  70333. private _geometryBufferRenderer;
  70334. private _enableSmoothReflections;
  70335. private _reflectionSamples;
  70336. private _smoothSteps;
  70337. /**
  70338. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  70339. * @param name The name of the effect.
  70340. * @param scene The scene containing the objects to calculate reflections.
  70341. * @param options The required width/height ratio to downsize to before computing the render pass.
  70342. * @param camera The camera to apply the render pass to.
  70343. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70344. * @param engine The engine which the post process will be applied. (default: current engine)
  70345. * @param reusable If the post process can be reused on the same frame. (default: false)
  70346. * @param textureType Type of textures used when performing the post process. (default: 0)
  70347. * @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)
  70348. */
  70349. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70350. /**
  70351. * Gets wether or not smoothing reflections is enabled.
  70352. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70353. */
  70354. get enableSmoothReflections(): boolean;
  70355. /**
  70356. * Sets wether or not smoothing reflections is enabled.
  70357. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70358. */
  70359. set enableSmoothReflections(enabled: boolean);
  70360. /**
  70361. * Gets the number of samples taken while computing reflections. More samples count is high,
  70362. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70363. */
  70364. get reflectionSamples(): number;
  70365. /**
  70366. * Sets the number of samples taken while computing reflections. More samples count is high,
  70367. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70368. */
  70369. set reflectionSamples(samples: number);
  70370. /**
  70371. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  70372. * more the post-process will require GPU power and can generate a drop in FPS.
  70373. * Default value (5.0) work pretty well in all cases but can be adjusted.
  70374. */
  70375. get smoothSteps(): number;
  70376. set smoothSteps(steps: number);
  70377. private _updateEffectDefines;
  70378. }
  70379. }
  70380. declare module "babylonjs/Shaders/standard.fragment" {
  70381. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  70382. /** @hidden */
  70383. export var standardPixelShader: {
  70384. name: string;
  70385. shader: string;
  70386. };
  70387. }
  70388. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  70389. import { Nullable } from "babylonjs/types";
  70390. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  70391. import { Camera } from "babylonjs/Cameras/camera";
  70392. import { Texture } from "babylonjs/Materials/Textures/texture";
  70393. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70394. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  70395. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  70396. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  70397. import { IDisposable } from "babylonjs/scene";
  70398. import { SpotLight } from "babylonjs/Lights/spotLight";
  70399. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  70400. import { Scene } from "babylonjs/scene";
  70401. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  70402. import { Animation } from "babylonjs/Animations/animation";
  70403. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  70404. import "babylonjs/Shaders/standard.fragment";
  70405. /**
  70406. * Standard rendering pipeline
  70407. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70408. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  70409. */
  70410. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70411. /**
  70412. * Public members
  70413. */
  70414. /**
  70415. * Post-process which contains the original scene color before the pipeline applies all the effects
  70416. */
  70417. originalPostProcess: Nullable<PostProcess>;
  70418. /**
  70419. * Post-process used to down scale an image x4
  70420. */
  70421. downSampleX4PostProcess: Nullable<PostProcess>;
  70422. /**
  70423. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  70424. */
  70425. brightPassPostProcess: Nullable<PostProcess>;
  70426. /**
  70427. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  70428. */
  70429. blurHPostProcesses: PostProcess[];
  70430. /**
  70431. * Post-process array storing all the vertical blur post-processes used by the pipeline
  70432. */
  70433. blurVPostProcesses: PostProcess[];
  70434. /**
  70435. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  70436. */
  70437. textureAdderPostProcess: Nullable<PostProcess>;
  70438. /**
  70439. * Post-process used to create volumetric lighting effect
  70440. */
  70441. volumetricLightPostProcess: Nullable<PostProcess>;
  70442. /**
  70443. * Post-process used to smooth the previous volumetric light post-process on the X axis
  70444. */
  70445. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  70446. /**
  70447. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  70448. */
  70449. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  70450. /**
  70451. * Post-process used to merge the volumetric light effect and the real scene color
  70452. */
  70453. volumetricLightMergePostProces: Nullable<PostProcess>;
  70454. /**
  70455. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  70456. */
  70457. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  70458. /**
  70459. * Base post-process used to calculate the average luminance of the final image for HDR
  70460. */
  70461. luminancePostProcess: Nullable<PostProcess>;
  70462. /**
  70463. * Post-processes used to create down sample post-processes in order to get
  70464. * the average luminance of the final image for HDR
  70465. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  70466. */
  70467. luminanceDownSamplePostProcesses: PostProcess[];
  70468. /**
  70469. * Post-process used to create a HDR effect (light adaptation)
  70470. */
  70471. hdrPostProcess: Nullable<PostProcess>;
  70472. /**
  70473. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  70474. */
  70475. textureAdderFinalPostProcess: Nullable<PostProcess>;
  70476. /**
  70477. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  70478. */
  70479. lensFlareFinalPostProcess: Nullable<PostProcess>;
  70480. /**
  70481. * Post-process used to merge the final HDR post-process and the real scene color
  70482. */
  70483. hdrFinalPostProcess: Nullable<PostProcess>;
  70484. /**
  70485. * Post-process used to create a lens flare effect
  70486. */
  70487. lensFlarePostProcess: Nullable<PostProcess>;
  70488. /**
  70489. * Post-process that merges the result of the lens flare post-process and the real scene color
  70490. */
  70491. lensFlareComposePostProcess: Nullable<PostProcess>;
  70492. /**
  70493. * Post-process used to create a motion blur effect
  70494. */
  70495. motionBlurPostProcess: Nullable<PostProcess>;
  70496. /**
  70497. * Post-process used to create a depth of field effect
  70498. */
  70499. depthOfFieldPostProcess: Nullable<PostProcess>;
  70500. /**
  70501. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70502. */
  70503. fxaaPostProcess: Nullable<FxaaPostProcess>;
  70504. /**
  70505. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  70506. */
  70507. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  70508. /**
  70509. * Represents the brightness threshold in order to configure the illuminated surfaces
  70510. */
  70511. brightThreshold: number;
  70512. /**
  70513. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  70514. */
  70515. blurWidth: number;
  70516. /**
  70517. * Sets if the blur for highlighted surfaces must be only horizontal
  70518. */
  70519. horizontalBlur: boolean;
  70520. /**
  70521. * Gets the overall exposure used by the pipeline
  70522. */
  70523. get exposure(): number;
  70524. /**
  70525. * Sets the overall exposure used by the pipeline
  70526. */
  70527. set exposure(value: number);
  70528. /**
  70529. * Texture used typically to simulate "dirty" on camera lens
  70530. */
  70531. lensTexture: Nullable<Texture>;
  70532. /**
  70533. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  70534. */
  70535. volumetricLightCoefficient: number;
  70536. /**
  70537. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  70538. */
  70539. volumetricLightPower: number;
  70540. /**
  70541. * Used the set the blur intensity to smooth the volumetric lights
  70542. */
  70543. volumetricLightBlurScale: number;
  70544. /**
  70545. * Light (spot or directional) used to generate the volumetric lights rays
  70546. * The source light must have a shadow generate so the pipeline can get its
  70547. * depth map
  70548. */
  70549. sourceLight: Nullable<SpotLight | DirectionalLight>;
  70550. /**
  70551. * For eye adaptation, represents the minimum luminance the eye can see
  70552. */
  70553. hdrMinimumLuminance: number;
  70554. /**
  70555. * For eye adaptation, represents the decrease luminance speed
  70556. */
  70557. hdrDecreaseRate: number;
  70558. /**
  70559. * For eye adaptation, represents the increase luminance speed
  70560. */
  70561. hdrIncreaseRate: number;
  70562. /**
  70563. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70564. */
  70565. get hdrAutoExposure(): boolean;
  70566. /**
  70567. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70568. */
  70569. set hdrAutoExposure(value: boolean);
  70570. /**
  70571. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  70572. */
  70573. lensColorTexture: Nullable<Texture>;
  70574. /**
  70575. * The overall strengh for the lens flare effect
  70576. */
  70577. lensFlareStrength: number;
  70578. /**
  70579. * Dispersion coefficient for lens flare ghosts
  70580. */
  70581. lensFlareGhostDispersal: number;
  70582. /**
  70583. * Main lens flare halo width
  70584. */
  70585. lensFlareHaloWidth: number;
  70586. /**
  70587. * Based on the lens distortion effect, defines how much the lens flare result
  70588. * is distorted
  70589. */
  70590. lensFlareDistortionStrength: number;
  70591. /**
  70592. * Configures the blur intensity used for for lens flare (halo)
  70593. */
  70594. lensFlareBlurWidth: number;
  70595. /**
  70596. * Lens star texture must be used to simulate rays on the flares and is available
  70597. * in the documentation
  70598. */
  70599. lensStarTexture: Nullable<Texture>;
  70600. /**
  70601. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  70602. * flare effect by taking account of the dirt texture
  70603. */
  70604. lensFlareDirtTexture: Nullable<Texture>;
  70605. /**
  70606. * Represents the focal length for the depth of field effect
  70607. */
  70608. depthOfFieldDistance: number;
  70609. /**
  70610. * Represents the blur intensity for the blurred part of the depth of field effect
  70611. */
  70612. depthOfFieldBlurWidth: number;
  70613. /**
  70614. * Gets how much the image is blurred by the movement while using the motion blur post-process
  70615. */
  70616. get motionStrength(): number;
  70617. /**
  70618. * Sets how much the image is blurred by the movement while using the motion blur post-process
  70619. */
  70620. set motionStrength(strength: number);
  70621. /**
  70622. * Gets wether or not the motion blur post-process is object based or screen based.
  70623. */
  70624. get objectBasedMotionBlur(): boolean;
  70625. /**
  70626. * Sets wether or not the motion blur post-process should be object based or screen based
  70627. */
  70628. set objectBasedMotionBlur(value: boolean);
  70629. /**
  70630. * List of animations for the pipeline (IAnimatable implementation)
  70631. */
  70632. animations: Animation[];
  70633. /**
  70634. * Private members
  70635. */
  70636. private _scene;
  70637. private _currentDepthOfFieldSource;
  70638. private _basePostProcess;
  70639. private _fixedExposure;
  70640. private _currentExposure;
  70641. private _hdrAutoExposure;
  70642. private _hdrCurrentLuminance;
  70643. private _motionStrength;
  70644. private _isObjectBasedMotionBlur;
  70645. private _floatTextureType;
  70646. private _camerasToBeAttached;
  70647. private _ratio;
  70648. private _bloomEnabled;
  70649. private _depthOfFieldEnabled;
  70650. private _vlsEnabled;
  70651. private _lensFlareEnabled;
  70652. private _hdrEnabled;
  70653. private _motionBlurEnabled;
  70654. private _fxaaEnabled;
  70655. private _screenSpaceReflectionsEnabled;
  70656. private _motionBlurSamples;
  70657. private _volumetricLightStepsCount;
  70658. private _samples;
  70659. /**
  70660. * @ignore
  70661. * Specifies if the bloom pipeline is enabled
  70662. */
  70663. get BloomEnabled(): boolean;
  70664. set BloomEnabled(enabled: boolean);
  70665. /**
  70666. * @ignore
  70667. * Specifies if the depth of field pipeline is enabed
  70668. */
  70669. get DepthOfFieldEnabled(): boolean;
  70670. set DepthOfFieldEnabled(enabled: boolean);
  70671. /**
  70672. * @ignore
  70673. * Specifies if the lens flare pipeline is enabed
  70674. */
  70675. get LensFlareEnabled(): boolean;
  70676. set LensFlareEnabled(enabled: boolean);
  70677. /**
  70678. * @ignore
  70679. * Specifies if the HDR pipeline is enabled
  70680. */
  70681. get HDREnabled(): boolean;
  70682. set HDREnabled(enabled: boolean);
  70683. /**
  70684. * @ignore
  70685. * Specifies if the volumetric lights scattering effect is enabled
  70686. */
  70687. get VLSEnabled(): boolean;
  70688. set VLSEnabled(enabled: boolean);
  70689. /**
  70690. * @ignore
  70691. * Specifies if the motion blur effect is enabled
  70692. */
  70693. get MotionBlurEnabled(): boolean;
  70694. set MotionBlurEnabled(enabled: boolean);
  70695. /**
  70696. * Specifies if anti-aliasing is enabled
  70697. */
  70698. get fxaaEnabled(): boolean;
  70699. set fxaaEnabled(enabled: boolean);
  70700. /**
  70701. * Specifies if screen space reflections are enabled.
  70702. */
  70703. get screenSpaceReflectionsEnabled(): boolean;
  70704. set screenSpaceReflectionsEnabled(enabled: boolean);
  70705. /**
  70706. * Specifies the number of steps used to calculate the volumetric lights
  70707. * Typically in interval [50, 200]
  70708. */
  70709. get volumetricLightStepsCount(): number;
  70710. set volumetricLightStepsCount(count: number);
  70711. /**
  70712. * Specifies the number of samples used for the motion blur effect
  70713. * Typically in interval [16, 64]
  70714. */
  70715. get motionBlurSamples(): number;
  70716. set motionBlurSamples(samples: number);
  70717. /**
  70718. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70719. */
  70720. get samples(): number;
  70721. set samples(sampleCount: number);
  70722. /**
  70723. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70724. * @constructor
  70725. * @param name The rendering pipeline name
  70726. * @param scene The scene linked to this pipeline
  70727. * @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)
  70728. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  70729. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70730. */
  70731. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  70732. private _buildPipeline;
  70733. private _createDownSampleX4PostProcess;
  70734. private _createBrightPassPostProcess;
  70735. private _createBlurPostProcesses;
  70736. private _createTextureAdderPostProcess;
  70737. private _createVolumetricLightPostProcess;
  70738. private _createLuminancePostProcesses;
  70739. private _createHdrPostProcess;
  70740. private _createLensFlarePostProcess;
  70741. private _createDepthOfFieldPostProcess;
  70742. private _createMotionBlurPostProcess;
  70743. private _getDepthTexture;
  70744. private _disposePostProcesses;
  70745. /**
  70746. * Dispose of the pipeline and stop all post processes
  70747. */
  70748. dispose(): void;
  70749. /**
  70750. * Serialize the rendering pipeline (Used when exporting)
  70751. * @returns the serialized object
  70752. */
  70753. serialize(): any;
  70754. /**
  70755. * Parse the serialized pipeline
  70756. * @param source Source pipeline.
  70757. * @param scene The scene to load the pipeline to.
  70758. * @param rootUrl The URL of the serialized pipeline.
  70759. * @returns An instantiated pipeline from the serialized object.
  70760. */
  70761. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  70762. /**
  70763. * Luminance steps
  70764. */
  70765. static LuminanceSteps: number;
  70766. }
  70767. }
  70768. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  70769. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  70770. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  70771. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  70772. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  70773. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  70774. }
  70775. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  70776. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  70777. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  70778. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  70779. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  70780. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  70781. }
  70782. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  70783. /** @hidden */
  70784. export var stereoscopicInterlacePixelShader: {
  70785. name: string;
  70786. shader: string;
  70787. };
  70788. }
  70789. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  70790. import { Camera } from "babylonjs/Cameras/camera";
  70791. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70792. import { Engine } from "babylonjs/Engines/engine";
  70793. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  70794. /**
  70795. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  70796. */
  70797. export class StereoscopicInterlacePostProcessI extends PostProcess {
  70798. private _stepSize;
  70799. private _passedProcess;
  70800. /**
  70801. * Initializes a StereoscopicInterlacePostProcessI
  70802. * @param name The name of the effect.
  70803. * @param rigCameras The rig cameras to be appled to the post process
  70804. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  70805. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  70806. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70807. * @param engine The engine which the post process will be applied. (default: current engine)
  70808. * @param reusable If the post process can be reused on the same frame. (default: false)
  70809. */
  70810. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70811. }
  70812. /**
  70813. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  70814. */
  70815. export class StereoscopicInterlacePostProcess extends PostProcess {
  70816. private _stepSize;
  70817. private _passedProcess;
  70818. /**
  70819. * Initializes a StereoscopicInterlacePostProcess
  70820. * @param name The name of the effect.
  70821. * @param rigCameras The rig cameras to be appled to the post process
  70822. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  70823. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70824. * @param engine The engine which the post process will be applied. (default: current engine)
  70825. * @param reusable If the post process can be reused on the same frame. (default: false)
  70826. */
  70827. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70828. }
  70829. }
  70830. declare module "babylonjs/Shaders/tonemap.fragment" {
  70831. /** @hidden */
  70832. export var tonemapPixelShader: {
  70833. name: string;
  70834. shader: string;
  70835. };
  70836. }
  70837. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  70838. import { Camera } from "babylonjs/Cameras/camera";
  70839. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70840. import "babylonjs/Shaders/tonemap.fragment";
  70841. import { Engine } from "babylonjs/Engines/engine";
  70842. /** Defines operator used for tonemapping */
  70843. export enum TonemappingOperator {
  70844. /** Hable */
  70845. Hable = 0,
  70846. /** Reinhard */
  70847. Reinhard = 1,
  70848. /** HejiDawson */
  70849. HejiDawson = 2,
  70850. /** Photographic */
  70851. Photographic = 3
  70852. }
  70853. /**
  70854. * Defines a post process to apply tone mapping
  70855. */
  70856. export class TonemapPostProcess extends PostProcess {
  70857. private _operator;
  70858. /** Defines the required exposure adjustement */
  70859. exposureAdjustment: number;
  70860. /**
  70861. * Creates a new TonemapPostProcess
  70862. * @param name defines the name of the postprocess
  70863. * @param _operator defines the operator to use
  70864. * @param exposureAdjustment defines the required exposure adjustement
  70865. * @param camera defines the camera to use (can be null)
  70866. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  70867. * @param engine defines the hosting engine (can be ignore if camera is set)
  70868. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  70869. */
  70870. constructor(name: string, _operator: TonemappingOperator,
  70871. /** Defines the required exposure adjustement */
  70872. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  70873. }
  70874. }
  70875. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  70876. /** @hidden */
  70877. export var volumetricLightScatteringPixelShader: {
  70878. name: string;
  70879. shader: string;
  70880. };
  70881. }
  70882. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  70883. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70884. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70885. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70886. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70887. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70888. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70889. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70890. /** @hidden */
  70891. export var volumetricLightScatteringPassVertexShader: {
  70892. name: string;
  70893. shader: string;
  70894. };
  70895. }
  70896. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  70897. /** @hidden */
  70898. export var volumetricLightScatteringPassPixelShader: {
  70899. name: string;
  70900. shader: string;
  70901. };
  70902. }
  70903. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  70904. import { Vector3 } from "babylonjs/Maths/math.vector";
  70905. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70906. import { Mesh } from "babylonjs/Meshes/mesh";
  70907. import { Camera } from "babylonjs/Cameras/camera";
  70908. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  70909. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70910. import { Scene } from "babylonjs/scene";
  70911. import "babylonjs/Meshes/Builders/planeBuilder";
  70912. import "babylonjs/Shaders/depth.vertex";
  70913. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  70914. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  70915. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  70916. import { Engine } from "babylonjs/Engines/engine";
  70917. /**
  70918. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  70919. */
  70920. export class VolumetricLightScatteringPostProcess extends PostProcess {
  70921. private _volumetricLightScatteringPass;
  70922. private _volumetricLightScatteringRTT;
  70923. private _viewPort;
  70924. private _screenCoordinates;
  70925. private _cachedDefines;
  70926. /**
  70927. * If not undefined, the mesh position is computed from the attached node position
  70928. */
  70929. attachedNode: {
  70930. position: Vector3;
  70931. };
  70932. /**
  70933. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  70934. */
  70935. customMeshPosition: Vector3;
  70936. /**
  70937. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  70938. */
  70939. useCustomMeshPosition: boolean;
  70940. /**
  70941. * If the post-process should inverse the light scattering direction
  70942. */
  70943. invert: boolean;
  70944. /**
  70945. * The internal mesh used by the post-process
  70946. */
  70947. mesh: Mesh;
  70948. /**
  70949. * @hidden
  70950. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  70951. */
  70952. get useDiffuseColor(): boolean;
  70953. set useDiffuseColor(useDiffuseColor: boolean);
  70954. /**
  70955. * Array containing the excluded meshes not rendered in the internal pass
  70956. */
  70957. excludedMeshes: AbstractMesh[];
  70958. /**
  70959. * Controls the overall intensity of the post-process
  70960. */
  70961. exposure: number;
  70962. /**
  70963. * Dissipates each sample's contribution in range [0, 1]
  70964. */
  70965. decay: number;
  70966. /**
  70967. * Controls the overall intensity of each sample
  70968. */
  70969. weight: number;
  70970. /**
  70971. * Controls the density of each sample
  70972. */
  70973. density: number;
  70974. /**
  70975. * @constructor
  70976. * @param name The post-process name
  70977. * @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)
  70978. * @param camera The camera that the post-process will be attached to
  70979. * @param mesh The mesh used to create the light scattering
  70980. * @param samples The post-process quality, default 100
  70981. * @param samplingModeThe post-process filtering mode
  70982. * @param engine The babylon engine
  70983. * @param reusable If the post-process is reusable
  70984. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  70985. */
  70986. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  70987. /**
  70988. * Returns the string "VolumetricLightScatteringPostProcess"
  70989. * @returns "VolumetricLightScatteringPostProcess"
  70990. */
  70991. getClassName(): string;
  70992. private _isReady;
  70993. /**
  70994. * Sets the new light position for light scattering effect
  70995. * @param position The new custom light position
  70996. */
  70997. setCustomMeshPosition(position: Vector3): void;
  70998. /**
  70999. * Returns the light position for light scattering effect
  71000. * @return Vector3 The custom light position
  71001. */
  71002. getCustomMeshPosition(): Vector3;
  71003. /**
  71004. * Disposes the internal assets and detaches the post-process from the camera
  71005. */
  71006. dispose(camera: Camera): void;
  71007. /**
  71008. * Returns the render target texture used by the post-process
  71009. * @return the render target texture used by the post-process
  71010. */
  71011. getPass(): RenderTargetTexture;
  71012. private _meshExcluded;
  71013. private _createPass;
  71014. private _updateMeshScreenCoordinates;
  71015. /**
  71016. * Creates a default mesh for the Volumeric Light Scattering post-process
  71017. * @param name The mesh name
  71018. * @param scene The scene where to create the mesh
  71019. * @return the default mesh
  71020. */
  71021. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  71022. }
  71023. }
  71024. declare module "babylonjs/PostProcesses/index" {
  71025. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  71026. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  71027. export * from "babylonjs/PostProcesses/bloomEffect";
  71028. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  71029. export * from "babylonjs/PostProcesses/blurPostProcess";
  71030. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  71031. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  71032. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  71033. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  71034. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  71035. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  71036. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  71037. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  71038. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  71039. export * from "babylonjs/PostProcesses/filterPostProcess";
  71040. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  71041. export * from "babylonjs/PostProcesses/grainPostProcess";
  71042. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  71043. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  71044. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  71045. export * from "babylonjs/PostProcesses/passPostProcess";
  71046. export * from "babylonjs/PostProcesses/postProcess";
  71047. export * from "babylonjs/PostProcesses/postProcessManager";
  71048. export * from "babylonjs/PostProcesses/refractionPostProcess";
  71049. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  71050. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  71051. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  71052. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  71053. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  71054. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  71055. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  71056. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  71057. }
  71058. declare module "babylonjs/Probes/index" {
  71059. export * from "babylonjs/Probes/reflectionProbe";
  71060. }
  71061. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  71062. import { Scene } from "babylonjs/scene";
  71063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71064. import { SmartArray } from "babylonjs/Misc/smartArray";
  71065. import { ISceneComponent } from "babylonjs/sceneComponent";
  71066. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  71067. import "babylonjs/Meshes/Builders/boxBuilder";
  71068. import "babylonjs/Shaders/color.fragment";
  71069. import "babylonjs/Shaders/color.vertex";
  71070. import { Color3 } from "babylonjs/Maths/math.color";
  71071. module "babylonjs/scene" {
  71072. interface Scene {
  71073. /** @hidden (Backing field) */
  71074. _boundingBoxRenderer: BoundingBoxRenderer;
  71075. /** @hidden (Backing field) */
  71076. _forceShowBoundingBoxes: boolean;
  71077. /**
  71078. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  71079. */
  71080. forceShowBoundingBoxes: boolean;
  71081. /**
  71082. * Gets the bounding box renderer associated with the scene
  71083. * @returns a BoundingBoxRenderer
  71084. */
  71085. getBoundingBoxRenderer(): BoundingBoxRenderer;
  71086. }
  71087. }
  71088. module "babylonjs/Meshes/abstractMesh" {
  71089. interface AbstractMesh {
  71090. /** @hidden (Backing field) */
  71091. _showBoundingBox: boolean;
  71092. /**
  71093. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  71094. */
  71095. showBoundingBox: boolean;
  71096. }
  71097. }
  71098. /**
  71099. * Component responsible of rendering the bounding box of the meshes in a scene.
  71100. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  71101. */
  71102. export class BoundingBoxRenderer implements ISceneComponent {
  71103. /**
  71104. * The component name helpfull to identify the component in the list of scene components.
  71105. */
  71106. readonly name: string;
  71107. /**
  71108. * The scene the component belongs to.
  71109. */
  71110. scene: Scene;
  71111. /**
  71112. * Color of the bounding box lines placed in front of an object
  71113. */
  71114. frontColor: Color3;
  71115. /**
  71116. * Color of the bounding box lines placed behind an object
  71117. */
  71118. backColor: Color3;
  71119. /**
  71120. * Defines if the renderer should show the back lines or not
  71121. */
  71122. showBackLines: boolean;
  71123. /**
  71124. * @hidden
  71125. */
  71126. renderList: SmartArray<BoundingBox>;
  71127. private _colorShader;
  71128. private _vertexBuffers;
  71129. private _indexBuffer;
  71130. private _fillIndexBuffer;
  71131. private _fillIndexData;
  71132. /**
  71133. * Instantiates a new bounding box renderer in a scene.
  71134. * @param scene the scene the renderer renders in
  71135. */
  71136. constructor(scene: Scene);
  71137. /**
  71138. * Registers the component in a given scene
  71139. */
  71140. register(): void;
  71141. private _evaluateSubMesh;
  71142. private _activeMesh;
  71143. private _prepareRessources;
  71144. private _createIndexBuffer;
  71145. /**
  71146. * Rebuilds the elements related to this component in case of
  71147. * context lost for instance.
  71148. */
  71149. rebuild(): void;
  71150. /**
  71151. * @hidden
  71152. */
  71153. reset(): void;
  71154. /**
  71155. * Render the bounding boxes of a specific rendering group
  71156. * @param renderingGroupId defines the rendering group to render
  71157. */
  71158. render(renderingGroupId: number): void;
  71159. /**
  71160. * In case of occlusion queries, we can render the occlusion bounding box through this method
  71161. * @param mesh Define the mesh to render the occlusion bounding box for
  71162. */
  71163. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  71164. /**
  71165. * Dispose and release the resources attached to this renderer.
  71166. */
  71167. dispose(): void;
  71168. }
  71169. }
  71170. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  71171. import { Nullable } from "babylonjs/types";
  71172. import { Scene } from "babylonjs/scene";
  71173. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  71174. import { Camera } from "babylonjs/Cameras/camera";
  71175. import { ISceneComponent } from "babylonjs/sceneComponent";
  71176. module "babylonjs/scene" {
  71177. interface Scene {
  71178. /** @hidden (Backing field) */
  71179. _depthRenderer: {
  71180. [id: string]: DepthRenderer;
  71181. };
  71182. /**
  71183. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  71184. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  71185. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  71186. * @returns the created depth renderer
  71187. */
  71188. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  71189. /**
  71190. * Disables a depth renderer for a given camera
  71191. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  71192. */
  71193. disableDepthRenderer(camera?: Nullable<Camera>): void;
  71194. }
  71195. }
  71196. /**
  71197. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  71198. * in several rendering techniques.
  71199. */
  71200. export class DepthRendererSceneComponent implements ISceneComponent {
  71201. /**
  71202. * The component name helpfull to identify the component in the list of scene components.
  71203. */
  71204. readonly name: string;
  71205. /**
  71206. * The scene the component belongs to.
  71207. */
  71208. scene: Scene;
  71209. /**
  71210. * Creates a new instance of the component for the given scene
  71211. * @param scene Defines the scene to register the component in
  71212. */
  71213. constructor(scene: Scene);
  71214. /**
  71215. * Registers the component in a given scene
  71216. */
  71217. register(): void;
  71218. /**
  71219. * Rebuilds the elements related to this component in case of
  71220. * context lost for instance.
  71221. */
  71222. rebuild(): void;
  71223. /**
  71224. * Disposes the component and the associated ressources
  71225. */
  71226. dispose(): void;
  71227. private _gatherRenderTargets;
  71228. private _gatherActiveCameraRenderTargets;
  71229. }
  71230. }
  71231. declare module "babylonjs/Shaders/outline.fragment" {
  71232. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  71233. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  71234. /** @hidden */
  71235. export var outlinePixelShader: {
  71236. name: string;
  71237. shader: string;
  71238. };
  71239. }
  71240. declare module "babylonjs/Shaders/outline.vertex" {
  71241. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  71242. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  71243. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  71244. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  71245. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  71246. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  71247. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  71248. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  71249. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  71250. /** @hidden */
  71251. export var outlineVertexShader: {
  71252. name: string;
  71253. shader: string;
  71254. };
  71255. }
  71256. declare module "babylonjs/Rendering/outlineRenderer" {
  71257. import { SubMesh } from "babylonjs/Meshes/subMesh";
  71258. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  71259. import { Scene } from "babylonjs/scene";
  71260. import { ISceneComponent } from "babylonjs/sceneComponent";
  71261. import "babylonjs/Shaders/outline.fragment";
  71262. import "babylonjs/Shaders/outline.vertex";
  71263. module "babylonjs/scene" {
  71264. interface Scene {
  71265. /** @hidden */
  71266. _outlineRenderer: OutlineRenderer;
  71267. /**
  71268. * Gets the outline renderer associated with the scene
  71269. * @returns a OutlineRenderer
  71270. */
  71271. getOutlineRenderer(): OutlineRenderer;
  71272. }
  71273. }
  71274. module "babylonjs/Meshes/abstractMesh" {
  71275. interface AbstractMesh {
  71276. /** @hidden (Backing field) */
  71277. _renderOutline: boolean;
  71278. /**
  71279. * Gets or sets a boolean indicating if the outline must be rendered as well
  71280. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  71281. */
  71282. renderOutline: boolean;
  71283. /** @hidden (Backing field) */
  71284. _renderOverlay: boolean;
  71285. /**
  71286. * Gets or sets a boolean indicating if the overlay must be rendered as well
  71287. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  71288. */
  71289. renderOverlay: boolean;
  71290. }
  71291. }
  71292. /**
  71293. * This class is responsible to draw bothe outline/overlay of meshes.
  71294. * It should not be used directly but through the available method on mesh.
  71295. */
  71296. export class OutlineRenderer implements ISceneComponent {
  71297. /**
  71298. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  71299. */
  71300. private static _StencilReference;
  71301. /**
  71302. * The name of the component. Each component must have a unique name.
  71303. */
  71304. name: string;
  71305. /**
  71306. * The scene the component belongs to.
  71307. */
  71308. scene: Scene;
  71309. /**
  71310. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  71311. */
  71312. zOffset: number;
  71313. private _engine;
  71314. private _effect;
  71315. private _cachedDefines;
  71316. private _savedDepthWrite;
  71317. /**
  71318. * Instantiates a new outline renderer. (There could be only one per scene).
  71319. * @param scene Defines the scene it belongs to
  71320. */
  71321. constructor(scene: Scene);
  71322. /**
  71323. * Register the component to one instance of a scene.
  71324. */
  71325. register(): void;
  71326. /**
  71327. * Rebuilds the elements related to this component in case of
  71328. * context lost for instance.
  71329. */
  71330. rebuild(): void;
  71331. /**
  71332. * Disposes the component and the associated ressources.
  71333. */
  71334. dispose(): void;
  71335. /**
  71336. * Renders the outline in the canvas.
  71337. * @param subMesh Defines the sumesh to render
  71338. * @param batch Defines the batch of meshes in case of instances
  71339. * @param useOverlay Defines if the rendering is for the overlay or the outline
  71340. */
  71341. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  71342. /**
  71343. * Returns whether or not the outline renderer is ready for a given submesh.
  71344. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  71345. * @param subMesh Defines the submesh to check readyness for
  71346. * @param useInstances Defines wheter wee are trying to render instances or not
  71347. * @returns true if ready otherwise false
  71348. */
  71349. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  71350. private _beforeRenderingMesh;
  71351. private _afterRenderingMesh;
  71352. }
  71353. }
  71354. declare module "babylonjs/Rendering/index" {
  71355. export * from "babylonjs/Rendering/boundingBoxRenderer";
  71356. export * from "babylonjs/Rendering/depthRenderer";
  71357. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  71358. export * from "babylonjs/Rendering/edgesRenderer";
  71359. export * from "babylonjs/Rendering/geometryBufferRenderer";
  71360. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  71361. export * from "babylonjs/Rendering/outlineRenderer";
  71362. export * from "babylonjs/Rendering/renderingGroup";
  71363. export * from "babylonjs/Rendering/renderingManager";
  71364. export * from "babylonjs/Rendering/utilityLayerRenderer";
  71365. }
  71366. declare module "babylonjs/Sprites/ISprites" {
  71367. /**
  71368. * Defines the basic options interface of a Sprite Frame Source Size.
  71369. */
  71370. export interface ISpriteJSONSpriteSourceSize {
  71371. /**
  71372. * number of the original width of the Frame
  71373. */
  71374. w: number;
  71375. /**
  71376. * number of the original height of the Frame
  71377. */
  71378. h: number;
  71379. }
  71380. /**
  71381. * Defines the basic options interface of a Sprite Frame Data.
  71382. */
  71383. export interface ISpriteJSONSpriteFrameData {
  71384. /**
  71385. * number of the x offset of the Frame
  71386. */
  71387. x: number;
  71388. /**
  71389. * number of the y offset of the Frame
  71390. */
  71391. y: number;
  71392. /**
  71393. * number of the width of the Frame
  71394. */
  71395. w: number;
  71396. /**
  71397. * number of the height of the Frame
  71398. */
  71399. h: number;
  71400. }
  71401. /**
  71402. * Defines the basic options interface of a JSON Sprite.
  71403. */
  71404. export interface ISpriteJSONSprite {
  71405. /**
  71406. * string name of the Frame
  71407. */
  71408. filename: string;
  71409. /**
  71410. * ISpriteJSONSpriteFrame basic object of the frame data
  71411. */
  71412. frame: ISpriteJSONSpriteFrameData;
  71413. /**
  71414. * boolean to flag is the frame was rotated.
  71415. */
  71416. rotated: boolean;
  71417. /**
  71418. * boolean to flag is the frame was trimmed.
  71419. */
  71420. trimmed: boolean;
  71421. /**
  71422. * ISpriteJSONSpriteFrame basic object of the source data
  71423. */
  71424. spriteSourceSize: ISpriteJSONSpriteFrameData;
  71425. /**
  71426. * ISpriteJSONSpriteFrame basic object of the source data
  71427. */
  71428. sourceSize: ISpriteJSONSpriteSourceSize;
  71429. }
  71430. /**
  71431. * Defines the basic options interface of a JSON atlas.
  71432. */
  71433. export interface ISpriteJSONAtlas {
  71434. /**
  71435. * Array of objects that contain the frame data.
  71436. */
  71437. frames: Array<ISpriteJSONSprite>;
  71438. /**
  71439. * object basic object containing the sprite meta data.
  71440. */
  71441. meta?: object;
  71442. }
  71443. }
  71444. declare module "babylonjs/Shaders/spriteMap.fragment" {
  71445. /** @hidden */
  71446. export var spriteMapPixelShader: {
  71447. name: string;
  71448. shader: string;
  71449. };
  71450. }
  71451. declare module "babylonjs/Shaders/spriteMap.vertex" {
  71452. /** @hidden */
  71453. export var spriteMapVertexShader: {
  71454. name: string;
  71455. shader: string;
  71456. };
  71457. }
  71458. declare module "babylonjs/Sprites/spriteMap" {
  71459. import { IDisposable, Scene } from "babylonjs/scene";
  71460. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  71461. import { Texture } from "babylonjs/Materials/Textures/texture";
  71462. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  71463. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  71464. import "babylonjs/Meshes/Builders/planeBuilder";
  71465. import "babylonjs/Shaders/spriteMap.fragment";
  71466. import "babylonjs/Shaders/spriteMap.vertex";
  71467. /**
  71468. * Defines the basic options interface of a SpriteMap
  71469. */
  71470. export interface ISpriteMapOptions {
  71471. /**
  71472. * Vector2 of the number of cells in the grid.
  71473. */
  71474. stageSize?: Vector2;
  71475. /**
  71476. * Vector2 of the size of the output plane in World Units.
  71477. */
  71478. outputSize?: Vector2;
  71479. /**
  71480. * Vector3 of the position of the output plane in World Units.
  71481. */
  71482. outputPosition?: Vector3;
  71483. /**
  71484. * Vector3 of the rotation of the output plane.
  71485. */
  71486. outputRotation?: Vector3;
  71487. /**
  71488. * number of layers that the system will reserve in resources.
  71489. */
  71490. layerCount?: number;
  71491. /**
  71492. * number of max animation frames a single cell will reserve in resources.
  71493. */
  71494. maxAnimationFrames?: number;
  71495. /**
  71496. * number cell index of the base tile when the system compiles.
  71497. */
  71498. baseTile?: number;
  71499. /**
  71500. * boolean flip the sprite after its been repositioned by the framing data.
  71501. */
  71502. flipU?: boolean;
  71503. /**
  71504. * Vector3 scalar of the global RGB values of the SpriteMap.
  71505. */
  71506. colorMultiply?: Vector3;
  71507. }
  71508. /**
  71509. * Defines the IDisposable interface in order to be cleanable from resources.
  71510. */
  71511. export interface ISpriteMap extends IDisposable {
  71512. /**
  71513. * String name of the SpriteMap.
  71514. */
  71515. name: string;
  71516. /**
  71517. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  71518. */
  71519. atlasJSON: ISpriteJSONAtlas;
  71520. /**
  71521. * Texture of the SpriteMap.
  71522. */
  71523. spriteSheet: Texture;
  71524. /**
  71525. * The parameters to initialize the SpriteMap with.
  71526. */
  71527. options: ISpriteMapOptions;
  71528. }
  71529. /**
  71530. * Class used to manage a grid restricted sprite deployment on an Output plane.
  71531. */
  71532. export class SpriteMap implements ISpriteMap {
  71533. /** The Name of the spriteMap */
  71534. name: string;
  71535. /** The JSON file with the frame and meta data */
  71536. atlasJSON: ISpriteJSONAtlas;
  71537. /** The systems Sprite Sheet Texture */
  71538. spriteSheet: Texture;
  71539. /** Arguments passed with the Constructor */
  71540. options: ISpriteMapOptions;
  71541. /** Public Sprite Storage array, parsed from atlasJSON */
  71542. sprites: Array<ISpriteJSONSprite>;
  71543. /** Returns the Number of Sprites in the System */
  71544. get spriteCount(): number;
  71545. /** Returns the Position of Output Plane*/
  71546. get position(): Vector3;
  71547. /** Returns the Position of Output Plane*/
  71548. set position(v: Vector3);
  71549. /** Returns the Rotation of Output Plane*/
  71550. get rotation(): Vector3;
  71551. /** Returns the Rotation of Output Plane*/
  71552. set rotation(v: Vector3);
  71553. /** Sets the AnimationMap*/
  71554. get animationMap(): RawTexture;
  71555. /** Sets the AnimationMap*/
  71556. set animationMap(v: RawTexture);
  71557. /** Scene that the SpriteMap was created in */
  71558. private _scene;
  71559. /** Texture Buffer of Float32 that holds tile frame data*/
  71560. private _frameMap;
  71561. /** Texture Buffers of Float32 that holds tileMap data*/
  71562. private _tileMaps;
  71563. /** Texture Buffer of Float32 that holds Animation Data*/
  71564. private _animationMap;
  71565. /** Custom ShaderMaterial Central to the System*/
  71566. private _material;
  71567. /** Custom ShaderMaterial Central to the System*/
  71568. private _output;
  71569. /** Systems Time Ticker*/
  71570. private _time;
  71571. /**
  71572. * Creates a new SpriteMap
  71573. * @param name defines the SpriteMaps Name
  71574. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  71575. * @param spriteSheet is the Texture that the Sprites are on.
  71576. * @param options a basic deployment configuration
  71577. * @param scene The Scene that the map is deployed on
  71578. */
  71579. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  71580. /**
  71581. * Returns tileID location
  71582. * @returns Vector2 the cell position ID
  71583. */
  71584. getTileID(): Vector2;
  71585. /**
  71586. * Gets the UV location of the mouse over the SpriteMap.
  71587. * @returns Vector2 the UV position of the mouse interaction
  71588. */
  71589. getMousePosition(): Vector2;
  71590. /**
  71591. * Creates the "frame" texture Buffer
  71592. * -------------------------------------
  71593. * Structure of frames
  71594. * "filename": "Falling-Water-2.png",
  71595. * "frame": {"x":69,"y":103,"w":24,"h":32},
  71596. * "rotated": true,
  71597. * "trimmed": true,
  71598. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  71599. * "sourceSize": {"w":32,"h":32}
  71600. * @returns RawTexture of the frameMap
  71601. */
  71602. private _createFrameBuffer;
  71603. /**
  71604. * Creates the tileMap texture Buffer
  71605. * @param buffer normally and array of numbers, or a false to generate from scratch
  71606. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  71607. * @returns RawTexture of the tileMap
  71608. */
  71609. private _createTileBuffer;
  71610. /**
  71611. * Modifies the data of the tileMaps
  71612. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  71613. * @param pos is the iVector2 Coordinates of the Tile
  71614. * @param tile The SpriteIndex of the new Tile
  71615. */
  71616. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  71617. /**
  71618. * Creates the animationMap texture Buffer
  71619. * @param buffer normally and array of numbers, or a false to generate from scratch
  71620. * @returns RawTexture of the animationMap
  71621. */
  71622. private _createTileAnimationBuffer;
  71623. /**
  71624. * Modifies the data of the animationMap
  71625. * @param cellID is the Index of the Sprite
  71626. * @param _frame is the target Animation frame
  71627. * @param toCell is the Target Index of the next frame of the animation
  71628. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  71629. * @param speed is a global scalar of the time variable on the map.
  71630. */
  71631. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  71632. /**
  71633. * Exports the .tilemaps file
  71634. */
  71635. saveTileMaps(): void;
  71636. /**
  71637. * Imports the .tilemaps file
  71638. * @param url of the .tilemaps file
  71639. */
  71640. loadTileMaps(url: string): void;
  71641. /**
  71642. * Release associated resources
  71643. */
  71644. dispose(): void;
  71645. }
  71646. }
  71647. declare module "babylonjs/Sprites/spritePackedManager" {
  71648. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  71649. import { Scene } from "babylonjs/scene";
  71650. /**
  71651. * Class used to manage multiple sprites of different sizes on the same spritesheet
  71652. * @see http://doc.babylonjs.com/babylon101/sprites
  71653. */
  71654. export class SpritePackedManager extends SpriteManager {
  71655. /** defines the packed manager's name */
  71656. name: string;
  71657. /**
  71658. * Creates a new sprite manager from a packed sprite sheet
  71659. * @param name defines the manager's name
  71660. * @param imgUrl defines the sprite sheet url
  71661. * @param capacity defines the maximum allowed number of sprites
  71662. * @param scene defines the hosting scene
  71663. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  71664. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71665. * @param samplingMode defines the smapling mode to use with spritesheet
  71666. * @param fromPacked set to true; do not alter
  71667. */
  71668. constructor(
  71669. /** defines the packed manager's name */
  71670. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  71671. }
  71672. }
  71673. declare module "babylonjs/Sprites/index" {
  71674. export * from "babylonjs/Sprites/sprite";
  71675. export * from "babylonjs/Sprites/ISprites";
  71676. export * from "babylonjs/Sprites/spriteManager";
  71677. export * from "babylonjs/Sprites/spriteMap";
  71678. export * from "babylonjs/Sprites/spritePackedManager";
  71679. export * from "babylonjs/Sprites/spriteSceneComponent";
  71680. }
  71681. declare module "babylonjs/States/index" {
  71682. export * from "babylonjs/States/alphaCullingState";
  71683. export * from "babylonjs/States/depthCullingState";
  71684. export * from "babylonjs/States/stencilState";
  71685. }
  71686. declare module "babylonjs/Misc/assetsManager" {
  71687. import { Scene } from "babylonjs/scene";
  71688. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71689. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71690. import { Skeleton } from "babylonjs/Bones/skeleton";
  71691. import { Observable } from "babylonjs/Misc/observable";
  71692. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  71693. import { Texture } from "babylonjs/Materials/Textures/texture";
  71694. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  71695. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  71696. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  71697. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  71698. /**
  71699. * Defines the list of states available for a task inside a AssetsManager
  71700. */
  71701. export enum AssetTaskState {
  71702. /**
  71703. * Initialization
  71704. */
  71705. INIT = 0,
  71706. /**
  71707. * Running
  71708. */
  71709. RUNNING = 1,
  71710. /**
  71711. * Done
  71712. */
  71713. DONE = 2,
  71714. /**
  71715. * Error
  71716. */
  71717. ERROR = 3
  71718. }
  71719. /**
  71720. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  71721. */
  71722. export abstract class AbstractAssetTask {
  71723. /**
  71724. * Task name
  71725. */ name: string;
  71726. /**
  71727. * Callback called when the task is successful
  71728. */
  71729. onSuccess: (task: any) => void;
  71730. /**
  71731. * Callback called when the task is not successful
  71732. */
  71733. onError: (task: any, message?: string, exception?: any) => void;
  71734. /**
  71735. * Creates a new AssetsManager
  71736. * @param name defines the name of the task
  71737. */
  71738. constructor(
  71739. /**
  71740. * Task name
  71741. */ name: string);
  71742. private _isCompleted;
  71743. private _taskState;
  71744. private _errorObject;
  71745. /**
  71746. * Get if the task is completed
  71747. */
  71748. get isCompleted(): boolean;
  71749. /**
  71750. * Gets the current state of the task
  71751. */
  71752. get taskState(): AssetTaskState;
  71753. /**
  71754. * Gets the current error object (if task is in error)
  71755. */
  71756. get errorObject(): {
  71757. message?: string;
  71758. exception?: any;
  71759. };
  71760. /**
  71761. * Internal only
  71762. * @hidden
  71763. */
  71764. _setErrorObject(message?: string, exception?: any): void;
  71765. /**
  71766. * Execute the current task
  71767. * @param scene defines the scene where you want your assets to be loaded
  71768. * @param onSuccess is a callback called when the task is successfully executed
  71769. * @param onError is a callback called if an error occurs
  71770. */
  71771. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71772. /**
  71773. * Execute the current task
  71774. * @param scene defines the scene where you want your assets to be loaded
  71775. * @param onSuccess is a callback called when the task is successfully executed
  71776. * @param onError is a callback called if an error occurs
  71777. */
  71778. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71779. /**
  71780. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  71781. * This can be used with failed tasks that have the reason for failure fixed.
  71782. */
  71783. reset(): void;
  71784. private onErrorCallback;
  71785. private onDoneCallback;
  71786. }
  71787. /**
  71788. * Define the interface used by progress events raised during assets loading
  71789. */
  71790. export interface IAssetsProgressEvent {
  71791. /**
  71792. * Defines the number of remaining tasks to process
  71793. */
  71794. remainingCount: number;
  71795. /**
  71796. * Defines the total number of tasks
  71797. */
  71798. totalCount: number;
  71799. /**
  71800. * Defines the task that was just processed
  71801. */
  71802. task: AbstractAssetTask;
  71803. }
  71804. /**
  71805. * Class used to share progress information about assets loading
  71806. */
  71807. export class AssetsProgressEvent implements IAssetsProgressEvent {
  71808. /**
  71809. * Defines the number of remaining tasks to process
  71810. */
  71811. remainingCount: number;
  71812. /**
  71813. * Defines the total number of tasks
  71814. */
  71815. totalCount: number;
  71816. /**
  71817. * Defines the task that was just processed
  71818. */
  71819. task: AbstractAssetTask;
  71820. /**
  71821. * Creates a AssetsProgressEvent
  71822. * @param remainingCount defines the number of remaining tasks to process
  71823. * @param totalCount defines the total number of tasks
  71824. * @param task defines the task that was just processed
  71825. */
  71826. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  71827. }
  71828. /**
  71829. * Define a task used by AssetsManager to load meshes
  71830. */
  71831. export class MeshAssetTask extends AbstractAssetTask {
  71832. /**
  71833. * Defines the name of the task
  71834. */
  71835. name: string;
  71836. /**
  71837. * Defines the list of mesh's names you want to load
  71838. */
  71839. meshesNames: any;
  71840. /**
  71841. * Defines the root url to use as a base to load your meshes and associated resources
  71842. */
  71843. rootUrl: string;
  71844. /**
  71845. * Defines the filename of the scene to load from
  71846. */
  71847. sceneFilename: string;
  71848. /**
  71849. * Gets the list of loaded meshes
  71850. */
  71851. loadedMeshes: Array<AbstractMesh>;
  71852. /**
  71853. * Gets the list of loaded particle systems
  71854. */
  71855. loadedParticleSystems: Array<IParticleSystem>;
  71856. /**
  71857. * Gets the list of loaded skeletons
  71858. */
  71859. loadedSkeletons: Array<Skeleton>;
  71860. /**
  71861. * Gets the list of loaded animation groups
  71862. */
  71863. loadedAnimationGroups: Array<AnimationGroup>;
  71864. /**
  71865. * Callback called when the task is successful
  71866. */
  71867. onSuccess: (task: MeshAssetTask) => void;
  71868. /**
  71869. * Callback called when the task is successful
  71870. */
  71871. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  71872. /**
  71873. * Creates a new MeshAssetTask
  71874. * @param name defines the name of the task
  71875. * @param meshesNames defines the list of mesh's names you want to load
  71876. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  71877. * @param sceneFilename defines the filename of the scene to load from
  71878. */
  71879. constructor(
  71880. /**
  71881. * Defines the name of the task
  71882. */
  71883. name: string,
  71884. /**
  71885. * Defines the list of mesh's names you want to load
  71886. */
  71887. meshesNames: any,
  71888. /**
  71889. * Defines the root url to use as a base to load your meshes and associated resources
  71890. */
  71891. rootUrl: string,
  71892. /**
  71893. * Defines the filename of the scene to load from
  71894. */
  71895. sceneFilename: string);
  71896. /**
  71897. * Execute the current task
  71898. * @param scene defines the scene where you want your assets to be loaded
  71899. * @param onSuccess is a callback called when the task is successfully executed
  71900. * @param onError is a callback called if an error occurs
  71901. */
  71902. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71903. }
  71904. /**
  71905. * Define a task used by AssetsManager to load text content
  71906. */
  71907. export class TextFileAssetTask extends AbstractAssetTask {
  71908. /**
  71909. * Defines the name of the task
  71910. */
  71911. name: string;
  71912. /**
  71913. * Defines the location of the file to load
  71914. */
  71915. url: string;
  71916. /**
  71917. * Gets the loaded text string
  71918. */
  71919. text: string;
  71920. /**
  71921. * Callback called when the task is successful
  71922. */
  71923. onSuccess: (task: TextFileAssetTask) => void;
  71924. /**
  71925. * Callback called when the task is successful
  71926. */
  71927. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  71928. /**
  71929. * Creates a new TextFileAssetTask object
  71930. * @param name defines the name of the task
  71931. * @param url defines the location of the file to load
  71932. */
  71933. constructor(
  71934. /**
  71935. * Defines the name of the task
  71936. */
  71937. name: string,
  71938. /**
  71939. * Defines the location of the file to load
  71940. */
  71941. url: string);
  71942. /**
  71943. * Execute the current task
  71944. * @param scene defines the scene where you want your assets to be loaded
  71945. * @param onSuccess is a callback called when the task is successfully executed
  71946. * @param onError is a callback called if an error occurs
  71947. */
  71948. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71949. }
  71950. /**
  71951. * Define a task used by AssetsManager to load binary data
  71952. */
  71953. export class BinaryFileAssetTask extends AbstractAssetTask {
  71954. /**
  71955. * Defines the name of the task
  71956. */
  71957. name: string;
  71958. /**
  71959. * Defines the location of the file to load
  71960. */
  71961. url: string;
  71962. /**
  71963. * Gets the lodaded data (as an array buffer)
  71964. */
  71965. data: ArrayBuffer;
  71966. /**
  71967. * Callback called when the task is successful
  71968. */
  71969. onSuccess: (task: BinaryFileAssetTask) => void;
  71970. /**
  71971. * Callback called when the task is successful
  71972. */
  71973. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  71974. /**
  71975. * Creates a new BinaryFileAssetTask object
  71976. * @param name defines the name of the new task
  71977. * @param url defines the location of the file to load
  71978. */
  71979. constructor(
  71980. /**
  71981. * Defines the name of the task
  71982. */
  71983. name: string,
  71984. /**
  71985. * Defines the location of the file to load
  71986. */
  71987. url: string);
  71988. /**
  71989. * Execute the current task
  71990. * @param scene defines the scene where you want your assets to be loaded
  71991. * @param onSuccess is a callback called when the task is successfully executed
  71992. * @param onError is a callback called if an error occurs
  71993. */
  71994. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71995. }
  71996. /**
  71997. * Define a task used by AssetsManager to load images
  71998. */
  71999. export class ImageAssetTask extends AbstractAssetTask {
  72000. /**
  72001. * Defines the name of the task
  72002. */
  72003. name: string;
  72004. /**
  72005. * Defines the location of the image to load
  72006. */
  72007. url: string;
  72008. /**
  72009. * Gets the loaded images
  72010. */
  72011. image: HTMLImageElement;
  72012. /**
  72013. * Callback called when the task is successful
  72014. */
  72015. onSuccess: (task: ImageAssetTask) => void;
  72016. /**
  72017. * Callback called when the task is successful
  72018. */
  72019. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  72020. /**
  72021. * Creates a new ImageAssetTask
  72022. * @param name defines the name of the task
  72023. * @param url defines the location of the image to load
  72024. */
  72025. constructor(
  72026. /**
  72027. * Defines the name of the task
  72028. */
  72029. name: string,
  72030. /**
  72031. * Defines the location of the image to load
  72032. */
  72033. url: string);
  72034. /**
  72035. * Execute the current task
  72036. * @param scene defines the scene where you want your assets to be loaded
  72037. * @param onSuccess is a callback called when the task is successfully executed
  72038. * @param onError is a callback called if an error occurs
  72039. */
  72040. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72041. }
  72042. /**
  72043. * Defines the interface used by texture loading tasks
  72044. */
  72045. export interface ITextureAssetTask<TEX extends BaseTexture> {
  72046. /**
  72047. * Gets the loaded texture
  72048. */
  72049. texture: TEX;
  72050. }
  72051. /**
  72052. * Define a task used by AssetsManager to load 2D textures
  72053. */
  72054. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  72055. /**
  72056. * Defines the name of the task
  72057. */
  72058. name: string;
  72059. /**
  72060. * Defines the location of the file to load
  72061. */
  72062. url: string;
  72063. /**
  72064. * Defines if mipmap should not be generated (default is false)
  72065. */
  72066. noMipmap?: boolean | undefined;
  72067. /**
  72068. * Defines if texture must be inverted on Y axis (default is true)
  72069. */
  72070. invertY: boolean;
  72071. /**
  72072. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72073. */
  72074. samplingMode: number;
  72075. /**
  72076. * Gets the loaded texture
  72077. */
  72078. texture: Texture;
  72079. /**
  72080. * Callback called when the task is successful
  72081. */
  72082. onSuccess: (task: TextureAssetTask) => void;
  72083. /**
  72084. * Callback called when the task is successful
  72085. */
  72086. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  72087. /**
  72088. * Creates a new TextureAssetTask object
  72089. * @param name defines the name of the task
  72090. * @param url defines the location of the file to load
  72091. * @param noMipmap defines if mipmap should not be generated (default is false)
  72092. * @param invertY defines if texture must be inverted on Y axis (default is true)
  72093. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72094. */
  72095. constructor(
  72096. /**
  72097. * Defines the name of the task
  72098. */
  72099. name: string,
  72100. /**
  72101. * Defines the location of the file to load
  72102. */
  72103. url: string,
  72104. /**
  72105. * Defines if mipmap should not be generated (default is false)
  72106. */
  72107. noMipmap?: boolean | undefined,
  72108. /**
  72109. * Defines if texture must be inverted on Y axis (default is true)
  72110. */
  72111. invertY?: boolean,
  72112. /**
  72113. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72114. */
  72115. samplingMode?: number);
  72116. /**
  72117. * Execute the current task
  72118. * @param scene defines the scene where you want your assets to be loaded
  72119. * @param onSuccess is a callback called when the task is successfully executed
  72120. * @param onError is a callback called if an error occurs
  72121. */
  72122. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72123. }
  72124. /**
  72125. * Define a task used by AssetsManager to load cube textures
  72126. */
  72127. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  72128. /**
  72129. * Defines the name of the task
  72130. */
  72131. name: string;
  72132. /**
  72133. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72134. */
  72135. url: string;
  72136. /**
  72137. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72138. */
  72139. extensions?: string[] | undefined;
  72140. /**
  72141. * Defines if mipmaps should not be generated (default is false)
  72142. */
  72143. noMipmap?: boolean | undefined;
  72144. /**
  72145. * Defines the explicit list of files (undefined by default)
  72146. */
  72147. files?: string[] | undefined;
  72148. /**
  72149. * Gets the loaded texture
  72150. */
  72151. texture: CubeTexture;
  72152. /**
  72153. * Callback called when the task is successful
  72154. */
  72155. onSuccess: (task: CubeTextureAssetTask) => void;
  72156. /**
  72157. * Callback called when the task is successful
  72158. */
  72159. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  72160. /**
  72161. * Creates a new CubeTextureAssetTask
  72162. * @param name defines the name of the task
  72163. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72164. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72165. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72166. * @param files defines the explicit list of files (undefined by default)
  72167. */
  72168. constructor(
  72169. /**
  72170. * Defines the name of the task
  72171. */
  72172. name: string,
  72173. /**
  72174. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72175. */
  72176. url: string,
  72177. /**
  72178. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72179. */
  72180. extensions?: string[] | undefined,
  72181. /**
  72182. * Defines if mipmaps should not be generated (default is false)
  72183. */
  72184. noMipmap?: boolean | undefined,
  72185. /**
  72186. * Defines the explicit list of files (undefined by default)
  72187. */
  72188. files?: string[] | undefined);
  72189. /**
  72190. * Execute the current task
  72191. * @param scene defines the scene where you want your assets to be loaded
  72192. * @param onSuccess is a callback called when the task is successfully executed
  72193. * @param onError is a callback called if an error occurs
  72194. */
  72195. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72196. }
  72197. /**
  72198. * Define a task used by AssetsManager to load HDR cube textures
  72199. */
  72200. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  72201. /**
  72202. * Defines the name of the task
  72203. */
  72204. name: string;
  72205. /**
  72206. * Defines the location of the file to load
  72207. */
  72208. url: string;
  72209. /**
  72210. * Defines the desired size (the more it increases the longer the generation will be)
  72211. */
  72212. size: number;
  72213. /**
  72214. * Defines if mipmaps should not be generated (default is false)
  72215. */
  72216. noMipmap: boolean;
  72217. /**
  72218. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72219. */
  72220. generateHarmonics: boolean;
  72221. /**
  72222. * 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)
  72223. */
  72224. gammaSpace: boolean;
  72225. /**
  72226. * Internal Use Only
  72227. */
  72228. reserved: boolean;
  72229. /**
  72230. * Gets the loaded texture
  72231. */
  72232. texture: HDRCubeTexture;
  72233. /**
  72234. * Callback called when the task is successful
  72235. */
  72236. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  72237. /**
  72238. * Callback called when the task is successful
  72239. */
  72240. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  72241. /**
  72242. * Creates a new HDRCubeTextureAssetTask object
  72243. * @param name defines the name of the task
  72244. * @param url defines the location of the file to load
  72245. * @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.
  72246. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72247. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72248. * @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)
  72249. * @param reserved Internal use only
  72250. */
  72251. constructor(
  72252. /**
  72253. * Defines the name of the task
  72254. */
  72255. name: string,
  72256. /**
  72257. * Defines the location of the file to load
  72258. */
  72259. url: string,
  72260. /**
  72261. * Defines the desired size (the more it increases the longer the generation will be)
  72262. */
  72263. size: number,
  72264. /**
  72265. * Defines if mipmaps should not be generated (default is false)
  72266. */
  72267. noMipmap?: boolean,
  72268. /**
  72269. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72270. */
  72271. generateHarmonics?: boolean,
  72272. /**
  72273. * 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)
  72274. */
  72275. gammaSpace?: boolean,
  72276. /**
  72277. * Internal Use Only
  72278. */
  72279. reserved?: boolean);
  72280. /**
  72281. * Execute the current task
  72282. * @param scene defines the scene where you want your assets to be loaded
  72283. * @param onSuccess is a callback called when the task is successfully executed
  72284. * @param onError is a callback called if an error occurs
  72285. */
  72286. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72287. }
  72288. /**
  72289. * Define a task used by AssetsManager to load Equirectangular cube textures
  72290. */
  72291. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  72292. /**
  72293. * Defines the name of the task
  72294. */
  72295. name: string;
  72296. /**
  72297. * Defines the location of the file to load
  72298. */
  72299. url: string;
  72300. /**
  72301. * Defines the desired size (the more it increases the longer the generation will be)
  72302. */
  72303. size: number;
  72304. /**
  72305. * Defines if mipmaps should not be generated (default is false)
  72306. */
  72307. noMipmap: boolean;
  72308. /**
  72309. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72310. * but the standard material would require them in Gamma space) (default is true)
  72311. */
  72312. gammaSpace: boolean;
  72313. /**
  72314. * Gets the loaded texture
  72315. */
  72316. texture: EquiRectangularCubeTexture;
  72317. /**
  72318. * Callback called when the task is successful
  72319. */
  72320. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  72321. /**
  72322. * Callback called when the task is successful
  72323. */
  72324. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  72325. /**
  72326. * Creates a new EquiRectangularCubeTextureAssetTask object
  72327. * @param name defines the name of the task
  72328. * @param url defines the location of the file to load
  72329. * @param size defines the desired size (the more it increases the longer the generation will be)
  72330. * If the size is omitted this implies you are using a preprocessed cubemap.
  72331. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72332. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  72333. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  72334. * (default is true)
  72335. */
  72336. constructor(
  72337. /**
  72338. * Defines the name of the task
  72339. */
  72340. name: string,
  72341. /**
  72342. * Defines the location of the file to load
  72343. */
  72344. url: string,
  72345. /**
  72346. * Defines the desired size (the more it increases the longer the generation will be)
  72347. */
  72348. size: number,
  72349. /**
  72350. * Defines if mipmaps should not be generated (default is false)
  72351. */
  72352. noMipmap?: boolean,
  72353. /**
  72354. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72355. * but the standard material would require them in Gamma space) (default is true)
  72356. */
  72357. gammaSpace?: boolean);
  72358. /**
  72359. * Execute the current task
  72360. * @param scene defines the scene where you want your assets to be loaded
  72361. * @param onSuccess is a callback called when the task is successfully executed
  72362. * @param onError is a callback called if an error occurs
  72363. */
  72364. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72365. }
  72366. /**
  72367. * This class can be used to easily import assets into a scene
  72368. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  72369. */
  72370. export class AssetsManager {
  72371. private _scene;
  72372. private _isLoading;
  72373. protected _tasks: AbstractAssetTask[];
  72374. protected _waitingTasksCount: number;
  72375. protected _totalTasksCount: number;
  72376. /**
  72377. * Callback called when all tasks are processed
  72378. */
  72379. onFinish: (tasks: AbstractAssetTask[]) => void;
  72380. /**
  72381. * Callback called when a task is successful
  72382. */
  72383. onTaskSuccess: (task: AbstractAssetTask) => void;
  72384. /**
  72385. * Callback called when a task had an error
  72386. */
  72387. onTaskError: (task: AbstractAssetTask) => void;
  72388. /**
  72389. * Callback called when a task is done (whatever the result is)
  72390. */
  72391. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  72392. /**
  72393. * Observable called when all tasks are processed
  72394. */
  72395. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  72396. /**
  72397. * Observable called when a task had an error
  72398. */
  72399. onTaskErrorObservable: Observable<AbstractAssetTask>;
  72400. /**
  72401. * Observable called when all tasks were executed
  72402. */
  72403. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  72404. /**
  72405. * Observable called when a task is done (whatever the result is)
  72406. */
  72407. onProgressObservable: Observable<IAssetsProgressEvent>;
  72408. /**
  72409. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  72410. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  72411. */
  72412. useDefaultLoadingScreen: boolean;
  72413. /**
  72414. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  72415. * when all assets have been downloaded.
  72416. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  72417. */
  72418. autoHideLoadingUI: boolean;
  72419. /**
  72420. * Creates a new AssetsManager
  72421. * @param scene defines the scene to work on
  72422. */
  72423. constructor(scene: Scene);
  72424. /**
  72425. * Add a MeshAssetTask to the list of active tasks
  72426. * @param taskName defines the name of the new task
  72427. * @param meshesNames defines the name of meshes to load
  72428. * @param rootUrl defines the root url to use to locate files
  72429. * @param sceneFilename defines the filename of the scene file
  72430. * @returns a new MeshAssetTask object
  72431. */
  72432. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  72433. /**
  72434. * Add a TextFileAssetTask to the list of active tasks
  72435. * @param taskName defines the name of the new task
  72436. * @param url defines the url of the file to load
  72437. * @returns a new TextFileAssetTask object
  72438. */
  72439. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  72440. /**
  72441. * Add a BinaryFileAssetTask to the list of active tasks
  72442. * @param taskName defines the name of the new task
  72443. * @param url defines the url of the file to load
  72444. * @returns a new BinaryFileAssetTask object
  72445. */
  72446. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  72447. /**
  72448. * Add a ImageAssetTask to the list of active tasks
  72449. * @param taskName defines the name of the new task
  72450. * @param url defines the url of the file to load
  72451. * @returns a new ImageAssetTask object
  72452. */
  72453. addImageTask(taskName: string, url: string): ImageAssetTask;
  72454. /**
  72455. * Add a TextureAssetTask to the list of active tasks
  72456. * @param taskName defines the name of the new task
  72457. * @param url defines the url of the file to load
  72458. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72459. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  72460. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  72461. * @returns a new TextureAssetTask object
  72462. */
  72463. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  72464. /**
  72465. * Add a CubeTextureAssetTask to the list of active tasks
  72466. * @param taskName defines the name of the new task
  72467. * @param url defines the url of the file to load
  72468. * @param extensions defines the extension to use to load the cube map (can be null)
  72469. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72470. * @param files defines the list of files to load (can be null)
  72471. * @returns a new CubeTextureAssetTask object
  72472. */
  72473. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  72474. /**
  72475. *
  72476. * Add a HDRCubeTextureAssetTask to the list of active tasks
  72477. * @param taskName defines the name of the new task
  72478. * @param url defines the url of the file to load
  72479. * @param size defines the size you want for the cubemap (can be null)
  72480. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72481. * @param generateHarmonics defines if you want to automatically generate (true by default)
  72482. * @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)
  72483. * @param reserved Internal use only
  72484. * @returns a new HDRCubeTextureAssetTask object
  72485. */
  72486. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  72487. /**
  72488. *
  72489. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  72490. * @param taskName defines the name of the new task
  72491. * @param url defines the url of the file to load
  72492. * @param size defines the size you want for the cubemap (can be null)
  72493. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72494. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  72495. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  72496. * @returns a new EquiRectangularCubeTextureAssetTask object
  72497. */
  72498. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  72499. /**
  72500. * Remove a task from the assets manager.
  72501. * @param task the task to remove
  72502. */
  72503. removeTask(task: AbstractAssetTask): void;
  72504. private _decreaseWaitingTasksCount;
  72505. private _runTask;
  72506. /**
  72507. * Reset the AssetsManager and remove all tasks
  72508. * @return the current instance of the AssetsManager
  72509. */
  72510. reset(): AssetsManager;
  72511. /**
  72512. * Start the loading process
  72513. * @return the current instance of the AssetsManager
  72514. */
  72515. load(): AssetsManager;
  72516. /**
  72517. * Start the loading process as an async operation
  72518. * @return a promise returning the list of failed tasks
  72519. */
  72520. loadAsync(): Promise<void>;
  72521. }
  72522. }
  72523. declare module "babylonjs/Misc/deferred" {
  72524. /**
  72525. * Wrapper class for promise with external resolve and reject.
  72526. */
  72527. export class Deferred<T> {
  72528. /**
  72529. * The promise associated with this deferred object.
  72530. */
  72531. readonly promise: Promise<T>;
  72532. private _resolve;
  72533. private _reject;
  72534. /**
  72535. * The resolve method of the promise associated with this deferred object.
  72536. */
  72537. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  72538. /**
  72539. * The reject method of the promise associated with this deferred object.
  72540. */
  72541. get reject(): (reason?: any) => void;
  72542. /**
  72543. * Constructor for this deferred object.
  72544. */
  72545. constructor();
  72546. }
  72547. }
  72548. declare module "babylonjs/Misc/meshExploder" {
  72549. import { Mesh } from "babylonjs/Meshes/mesh";
  72550. /**
  72551. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  72552. */
  72553. export class MeshExploder {
  72554. private _centerMesh;
  72555. private _meshes;
  72556. private _meshesOrigins;
  72557. private _toCenterVectors;
  72558. private _scaledDirection;
  72559. private _newPosition;
  72560. private _centerPosition;
  72561. /**
  72562. * Explodes meshes from a center mesh.
  72563. * @param meshes The meshes to explode.
  72564. * @param centerMesh The mesh to be center of explosion.
  72565. */
  72566. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  72567. private _setCenterMesh;
  72568. /**
  72569. * Get class name
  72570. * @returns "MeshExploder"
  72571. */
  72572. getClassName(): string;
  72573. /**
  72574. * "Exploded meshes"
  72575. * @returns Array of meshes with the centerMesh at index 0.
  72576. */
  72577. getMeshes(): Array<Mesh>;
  72578. /**
  72579. * Explodes meshes giving a specific direction
  72580. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  72581. */
  72582. explode(direction?: number): void;
  72583. }
  72584. }
  72585. declare module "babylonjs/Misc/filesInput" {
  72586. import { Engine } from "babylonjs/Engines/engine";
  72587. import { Scene } from "babylonjs/scene";
  72588. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  72589. /**
  72590. * Class used to help managing file picking and drag'n'drop
  72591. */
  72592. export class FilesInput {
  72593. /**
  72594. * List of files ready to be loaded
  72595. */
  72596. static get FilesToLoad(): {
  72597. [key: string]: File;
  72598. };
  72599. /**
  72600. * Callback called when a file is processed
  72601. */
  72602. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  72603. private _engine;
  72604. private _currentScene;
  72605. private _sceneLoadedCallback;
  72606. private _progressCallback;
  72607. private _additionalRenderLoopLogicCallback;
  72608. private _textureLoadingCallback;
  72609. private _startingProcessingFilesCallback;
  72610. private _onReloadCallback;
  72611. private _errorCallback;
  72612. private _elementToMonitor;
  72613. private _sceneFileToLoad;
  72614. private _filesToLoad;
  72615. /**
  72616. * Creates a new FilesInput
  72617. * @param engine defines the rendering engine
  72618. * @param scene defines the hosting scene
  72619. * @param sceneLoadedCallback callback called when scene is loaded
  72620. * @param progressCallback callback called to track progress
  72621. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  72622. * @param textureLoadingCallback callback called when a texture is loading
  72623. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  72624. * @param onReloadCallback callback called when a reload is requested
  72625. * @param errorCallback callback call if an error occurs
  72626. */
  72627. 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);
  72628. private _dragEnterHandler;
  72629. private _dragOverHandler;
  72630. private _dropHandler;
  72631. /**
  72632. * Calls this function to listen to drag'n'drop events on a specific DOM element
  72633. * @param elementToMonitor defines the DOM element to track
  72634. */
  72635. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  72636. /**
  72637. * Release all associated resources
  72638. */
  72639. dispose(): void;
  72640. private renderFunction;
  72641. private drag;
  72642. private drop;
  72643. private _traverseFolder;
  72644. private _processFiles;
  72645. /**
  72646. * Load files from a drop event
  72647. * @param event defines the drop event to use as source
  72648. */
  72649. loadFiles(event: any): void;
  72650. private _processReload;
  72651. /**
  72652. * Reload the current scene from the loaded files
  72653. */
  72654. reload(): void;
  72655. }
  72656. }
  72657. declare module "babylonjs/Misc/HighDynamicRange/index" {
  72658. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  72659. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  72660. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  72661. }
  72662. declare module "babylonjs/Misc/sceneOptimizer" {
  72663. import { Scene, IDisposable } from "babylonjs/scene";
  72664. import { Observable } from "babylonjs/Misc/observable";
  72665. /**
  72666. * Defines the root class used to create scene optimization to use with SceneOptimizer
  72667. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72668. */
  72669. export class SceneOptimization {
  72670. /**
  72671. * Defines the priority of this optimization (0 by default which means first in the list)
  72672. */
  72673. priority: number;
  72674. /**
  72675. * Gets a string describing the action executed by the current optimization
  72676. * @returns description string
  72677. */
  72678. getDescription(): string;
  72679. /**
  72680. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72681. * @param scene defines the current scene where to apply this optimization
  72682. * @param optimizer defines the current optimizer
  72683. * @returns true if everything that can be done was applied
  72684. */
  72685. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72686. /**
  72687. * Creates the SceneOptimization object
  72688. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72689. * @param desc defines the description associated with the optimization
  72690. */
  72691. constructor(
  72692. /**
  72693. * Defines the priority of this optimization (0 by default which means first in the list)
  72694. */
  72695. priority?: number);
  72696. }
  72697. /**
  72698. * Defines an optimization used to reduce the size of render target textures
  72699. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72700. */
  72701. export class TextureOptimization extends SceneOptimization {
  72702. /**
  72703. * Defines the priority of this optimization (0 by default which means first in the list)
  72704. */
  72705. priority: number;
  72706. /**
  72707. * 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
  72708. */
  72709. maximumSize: number;
  72710. /**
  72711. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72712. */
  72713. step: number;
  72714. /**
  72715. * Gets a string describing the action executed by the current optimization
  72716. * @returns description string
  72717. */
  72718. getDescription(): string;
  72719. /**
  72720. * Creates the TextureOptimization object
  72721. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72722. * @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
  72723. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72724. */
  72725. constructor(
  72726. /**
  72727. * Defines the priority of this optimization (0 by default which means first in the list)
  72728. */
  72729. priority?: number,
  72730. /**
  72731. * 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
  72732. */
  72733. maximumSize?: number,
  72734. /**
  72735. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72736. */
  72737. step?: number);
  72738. /**
  72739. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72740. * @param scene defines the current scene where to apply this optimization
  72741. * @param optimizer defines the current optimizer
  72742. * @returns true if everything that can be done was applied
  72743. */
  72744. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72745. }
  72746. /**
  72747. * Defines an optimization used to increase or decrease the rendering resolution
  72748. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72749. */
  72750. export class HardwareScalingOptimization extends SceneOptimization {
  72751. /**
  72752. * Defines the priority of this optimization (0 by default which means first in the list)
  72753. */
  72754. priority: number;
  72755. /**
  72756. * Defines the maximum scale to use (2 by default)
  72757. */
  72758. maximumScale: number;
  72759. /**
  72760. * Defines the step to use between two passes (0.5 by default)
  72761. */
  72762. step: number;
  72763. private _currentScale;
  72764. private _directionOffset;
  72765. /**
  72766. * Gets a string describing the action executed by the current optimization
  72767. * @return description string
  72768. */
  72769. getDescription(): string;
  72770. /**
  72771. * Creates the HardwareScalingOptimization object
  72772. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72773. * @param maximumScale defines the maximum scale to use (2 by default)
  72774. * @param step defines the step to use between two passes (0.5 by default)
  72775. */
  72776. constructor(
  72777. /**
  72778. * Defines the priority of this optimization (0 by default which means first in the list)
  72779. */
  72780. priority?: number,
  72781. /**
  72782. * Defines the maximum scale to use (2 by default)
  72783. */
  72784. maximumScale?: number,
  72785. /**
  72786. * Defines the step to use between two passes (0.5 by default)
  72787. */
  72788. step?: number);
  72789. /**
  72790. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72791. * @param scene defines the current scene where to apply this optimization
  72792. * @param optimizer defines the current optimizer
  72793. * @returns true if everything that can be done was applied
  72794. */
  72795. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72796. }
  72797. /**
  72798. * Defines an optimization used to remove shadows
  72799. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72800. */
  72801. export class ShadowsOptimization extends SceneOptimization {
  72802. /**
  72803. * Gets a string describing the action executed by the current optimization
  72804. * @return description string
  72805. */
  72806. getDescription(): string;
  72807. /**
  72808. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72809. * @param scene defines the current scene where to apply this optimization
  72810. * @param optimizer defines the current optimizer
  72811. * @returns true if everything that can be done was applied
  72812. */
  72813. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72814. }
  72815. /**
  72816. * Defines an optimization used to turn post-processes off
  72817. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72818. */
  72819. export class PostProcessesOptimization extends SceneOptimization {
  72820. /**
  72821. * Gets a string describing the action executed by the current optimization
  72822. * @return description string
  72823. */
  72824. getDescription(): string;
  72825. /**
  72826. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72827. * @param scene defines the current scene where to apply this optimization
  72828. * @param optimizer defines the current optimizer
  72829. * @returns true if everything that can be done was applied
  72830. */
  72831. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72832. }
  72833. /**
  72834. * Defines an optimization used to turn lens flares off
  72835. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72836. */
  72837. export class LensFlaresOptimization extends SceneOptimization {
  72838. /**
  72839. * Gets a string describing the action executed by the current optimization
  72840. * @return description string
  72841. */
  72842. getDescription(): string;
  72843. /**
  72844. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72845. * @param scene defines the current scene where to apply this optimization
  72846. * @param optimizer defines the current optimizer
  72847. * @returns true if everything that can be done was applied
  72848. */
  72849. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72850. }
  72851. /**
  72852. * Defines an optimization based on user defined callback.
  72853. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72854. */
  72855. export class CustomOptimization extends SceneOptimization {
  72856. /**
  72857. * Callback called to apply the custom optimization.
  72858. */
  72859. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  72860. /**
  72861. * Callback called to get custom description
  72862. */
  72863. onGetDescription: () => string;
  72864. /**
  72865. * Gets a string describing the action executed by the current optimization
  72866. * @returns description string
  72867. */
  72868. getDescription(): string;
  72869. /**
  72870. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72871. * @param scene defines the current scene where to apply this optimization
  72872. * @param optimizer defines the current optimizer
  72873. * @returns true if everything that can be done was applied
  72874. */
  72875. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72876. }
  72877. /**
  72878. * Defines an optimization used to turn particles off
  72879. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72880. */
  72881. export class ParticlesOptimization extends SceneOptimization {
  72882. /**
  72883. * Gets a string describing the action executed by the current optimization
  72884. * @return description string
  72885. */
  72886. getDescription(): string;
  72887. /**
  72888. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72889. * @param scene defines the current scene where to apply this optimization
  72890. * @param optimizer defines the current optimizer
  72891. * @returns true if everything that can be done was applied
  72892. */
  72893. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72894. }
  72895. /**
  72896. * Defines an optimization used to turn render targets off
  72897. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72898. */
  72899. export class RenderTargetsOptimization extends SceneOptimization {
  72900. /**
  72901. * Gets a string describing the action executed by the current optimization
  72902. * @return description string
  72903. */
  72904. getDescription(): string;
  72905. /**
  72906. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72907. * @param scene defines the current scene where to apply this optimization
  72908. * @param optimizer defines the current optimizer
  72909. * @returns true if everything that can be done was applied
  72910. */
  72911. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72912. }
  72913. /**
  72914. * Defines an optimization used to merge meshes with compatible materials
  72915. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72916. */
  72917. export class MergeMeshesOptimization extends SceneOptimization {
  72918. private static _UpdateSelectionTree;
  72919. /**
  72920. * Gets or sets a boolean which defines if optimization octree has to be updated
  72921. */
  72922. static get UpdateSelectionTree(): boolean;
  72923. /**
  72924. * Gets or sets a boolean which defines if optimization octree has to be updated
  72925. */
  72926. static set UpdateSelectionTree(value: boolean);
  72927. /**
  72928. * Gets a string describing the action executed by the current optimization
  72929. * @return description string
  72930. */
  72931. getDescription(): string;
  72932. private _canBeMerged;
  72933. /**
  72934. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72935. * @param scene defines the current scene where to apply this optimization
  72936. * @param optimizer defines the current optimizer
  72937. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  72938. * @returns true if everything that can be done was applied
  72939. */
  72940. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  72941. }
  72942. /**
  72943. * Defines a list of options used by SceneOptimizer
  72944. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72945. */
  72946. export class SceneOptimizerOptions {
  72947. /**
  72948. * Defines the target frame rate to reach (60 by default)
  72949. */
  72950. targetFrameRate: number;
  72951. /**
  72952. * Defines the interval between two checkes (2000ms by default)
  72953. */
  72954. trackerDuration: number;
  72955. /**
  72956. * Gets the list of optimizations to apply
  72957. */
  72958. optimizations: SceneOptimization[];
  72959. /**
  72960. * Creates a new list of options used by SceneOptimizer
  72961. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  72962. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  72963. */
  72964. constructor(
  72965. /**
  72966. * Defines the target frame rate to reach (60 by default)
  72967. */
  72968. targetFrameRate?: number,
  72969. /**
  72970. * Defines the interval between two checkes (2000ms by default)
  72971. */
  72972. trackerDuration?: number);
  72973. /**
  72974. * Add a new optimization
  72975. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  72976. * @returns the current SceneOptimizerOptions
  72977. */
  72978. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  72979. /**
  72980. * Add a new custom optimization
  72981. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  72982. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  72983. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72984. * @returns the current SceneOptimizerOptions
  72985. */
  72986. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  72987. /**
  72988. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  72989. * @param targetFrameRate defines the target frame rate (60 by default)
  72990. * @returns a SceneOptimizerOptions object
  72991. */
  72992. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72993. /**
  72994. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  72995. * @param targetFrameRate defines the target frame rate (60 by default)
  72996. * @returns a SceneOptimizerOptions object
  72997. */
  72998. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72999. /**
  73000. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  73001. * @param targetFrameRate defines the target frame rate (60 by default)
  73002. * @returns a SceneOptimizerOptions object
  73003. */
  73004. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73005. }
  73006. /**
  73007. * Class used to run optimizations in order to reach a target frame rate
  73008. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73009. */
  73010. export class SceneOptimizer implements IDisposable {
  73011. private _isRunning;
  73012. private _options;
  73013. private _scene;
  73014. private _currentPriorityLevel;
  73015. private _targetFrameRate;
  73016. private _trackerDuration;
  73017. private _currentFrameRate;
  73018. private _sceneDisposeObserver;
  73019. private _improvementMode;
  73020. /**
  73021. * Defines an observable called when the optimizer reaches the target frame rate
  73022. */
  73023. onSuccessObservable: Observable<SceneOptimizer>;
  73024. /**
  73025. * Defines an observable called when the optimizer enables an optimization
  73026. */
  73027. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  73028. /**
  73029. * Defines an observable called when the optimizer is not able to reach the target frame rate
  73030. */
  73031. onFailureObservable: Observable<SceneOptimizer>;
  73032. /**
  73033. * Gets a boolean indicating if the optimizer is in improvement mode
  73034. */
  73035. get isInImprovementMode(): boolean;
  73036. /**
  73037. * Gets the current priority level (0 at start)
  73038. */
  73039. get currentPriorityLevel(): number;
  73040. /**
  73041. * Gets the current frame rate checked by the SceneOptimizer
  73042. */
  73043. get currentFrameRate(): number;
  73044. /**
  73045. * Gets or sets the current target frame rate (60 by default)
  73046. */
  73047. get targetFrameRate(): number;
  73048. /**
  73049. * Gets or sets the current target frame rate (60 by default)
  73050. */
  73051. set targetFrameRate(value: number);
  73052. /**
  73053. * Gets or sets the current interval between two checks (every 2000ms by default)
  73054. */
  73055. get trackerDuration(): number;
  73056. /**
  73057. * Gets or sets the current interval between two checks (every 2000ms by default)
  73058. */
  73059. set trackerDuration(value: number);
  73060. /**
  73061. * Gets the list of active optimizations
  73062. */
  73063. get optimizations(): SceneOptimization[];
  73064. /**
  73065. * Creates a new SceneOptimizer
  73066. * @param scene defines the scene to work on
  73067. * @param options defines the options to use with the SceneOptimizer
  73068. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  73069. * @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)
  73070. */
  73071. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  73072. /**
  73073. * Stops the current optimizer
  73074. */
  73075. stop(): void;
  73076. /**
  73077. * Reset the optimizer to initial step (current priority level = 0)
  73078. */
  73079. reset(): void;
  73080. /**
  73081. * Start the optimizer. By default it will try to reach a specific framerate
  73082. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  73083. */
  73084. start(): void;
  73085. private _checkCurrentState;
  73086. /**
  73087. * Release all resources
  73088. */
  73089. dispose(): void;
  73090. /**
  73091. * Helper function to create a SceneOptimizer with one single line of code
  73092. * @param scene defines the scene to work on
  73093. * @param options defines the options to use with the SceneOptimizer
  73094. * @param onSuccess defines a callback to call on success
  73095. * @param onFailure defines a callback to call on failure
  73096. * @returns the new SceneOptimizer object
  73097. */
  73098. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  73099. }
  73100. }
  73101. declare module "babylonjs/Misc/sceneSerializer" {
  73102. import { Scene } from "babylonjs/scene";
  73103. /**
  73104. * Class used to serialize a scene into a string
  73105. */
  73106. export class SceneSerializer {
  73107. /**
  73108. * Clear cache used by a previous serialization
  73109. */
  73110. static ClearCache(): void;
  73111. /**
  73112. * Serialize a scene into a JSON compatible object
  73113. * @param scene defines the scene to serialize
  73114. * @returns a JSON compatible object
  73115. */
  73116. static Serialize(scene: Scene): any;
  73117. /**
  73118. * Serialize a mesh into a JSON compatible object
  73119. * @param toSerialize defines the mesh to serialize
  73120. * @param withParents defines if parents must be serialized as well
  73121. * @param withChildren defines if children must be serialized as well
  73122. * @returns a JSON compatible object
  73123. */
  73124. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  73125. }
  73126. }
  73127. declare module "babylonjs/Misc/textureTools" {
  73128. import { Texture } from "babylonjs/Materials/Textures/texture";
  73129. /**
  73130. * Class used to host texture specific utilities
  73131. */
  73132. export class TextureTools {
  73133. /**
  73134. * Uses the GPU to create a copy texture rescaled at a given size
  73135. * @param texture Texture to copy from
  73136. * @param width defines the desired width
  73137. * @param height defines the desired height
  73138. * @param useBilinearMode defines if bilinear mode has to be used
  73139. * @return the generated texture
  73140. */
  73141. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  73142. }
  73143. }
  73144. declare module "babylonjs/Misc/videoRecorder" {
  73145. import { Nullable } from "babylonjs/types";
  73146. import { Engine } from "babylonjs/Engines/engine";
  73147. /**
  73148. * This represents the different options available for the video capture.
  73149. */
  73150. export interface VideoRecorderOptions {
  73151. /** Defines the mime type of the video. */
  73152. mimeType: string;
  73153. /** Defines the FPS the video should be recorded at. */
  73154. fps: number;
  73155. /** Defines the chunk size for the recording data. */
  73156. recordChunckSize: number;
  73157. /** The audio tracks to attach to the recording. */
  73158. audioTracks?: MediaStreamTrack[];
  73159. }
  73160. /**
  73161. * This can help with recording videos from BabylonJS.
  73162. * This is based on the available WebRTC functionalities of the browser.
  73163. *
  73164. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  73165. */
  73166. export class VideoRecorder {
  73167. private static readonly _defaultOptions;
  73168. /**
  73169. * Returns whether or not the VideoRecorder is available in your browser.
  73170. * @param engine Defines the Babylon Engine.
  73171. * @returns true if supported otherwise false.
  73172. */
  73173. static IsSupported(engine: Engine): boolean;
  73174. private readonly _options;
  73175. private _canvas;
  73176. private _mediaRecorder;
  73177. private _recordedChunks;
  73178. private _fileName;
  73179. private _resolve;
  73180. private _reject;
  73181. /**
  73182. * True when a recording is already in progress.
  73183. */
  73184. get isRecording(): boolean;
  73185. /**
  73186. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  73187. * @param engine Defines the BabylonJS Engine you wish to record.
  73188. * @param options Defines options that can be used to customize the capture.
  73189. */
  73190. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  73191. /**
  73192. * Stops the current recording before the default capture timeout passed in the startRecording function.
  73193. */
  73194. stopRecording(): void;
  73195. /**
  73196. * Starts recording the canvas for a max duration specified in parameters.
  73197. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  73198. * If null no automatic download will start and you can rely on the promise to get the data back.
  73199. * @param maxDuration Defines the maximum recording time in seconds.
  73200. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  73201. * @return A promise callback at the end of the recording with the video data in Blob.
  73202. */
  73203. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  73204. /**
  73205. * Releases internal resources used during the recording.
  73206. */
  73207. dispose(): void;
  73208. private _handleDataAvailable;
  73209. private _handleError;
  73210. private _handleStop;
  73211. }
  73212. }
  73213. declare module "babylonjs/Misc/screenshotTools" {
  73214. import { Camera } from "babylonjs/Cameras/camera";
  73215. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  73216. import { Engine } from "babylonjs/Engines/engine";
  73217. /**
  73218. * Class containing a set of static utilities functions for screenshots
  73219. */
  73220. export class ScreenshotTools {
  73221. /**
  73222. * Captures a screenshot of the current rendering
  73223. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  73224. * @param engine defines the rendering engine
  73225. * @param camera defines the source camera
  73226. * @param size This parameter can be set to a single number or to an object with the
  73227. * following (optional) properties: precision, width, height. If a single number is passed,
  73228. * it will be used for both width and height. If an object is passed, the screenshot size
  73229. * will be derived from the parameters. The precision property is a multiplier allowing
  73230. * rendering at a higher or lower resolution
  73231. * @param successCallback defines the callback receives a single parameter which contains the
  73232. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73233. * src parameter of an <img> to display it
  73234. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73235. * Check your browser for supported MIME types
  73236. */
  73237. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  73238. /**
  73239. * Captures a screenshot of the current rendering
  73240. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  73241. * @param engine defines the rendering engine
  73242. * @param camera defines the source camera
  73243. * @param size This parameter can be set to a single number or to an object with the
  73244. * following (optional) properties: precision, width, height. If a single number is passed,
  73245. * it will be used for both width and height. If an object is passed, the screenshot size
  73246. * will be derived from the parameters. The precision property is a multiplier allowing
  73247. * rendering at a higher or lower resolution
  73248. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73249. * Check your browser for supported MIME types
  73250. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73251. * to the src parameter of an <img> to display it
  73252. */
  73253. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  73254. /**
  73255. * Generates an image screenshot from the specified camera.
  73256. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  73257. * @param engine The engine to use for rendering
  73258. * @param camera The camera to use for rendering
  73259. * @param size This parameter can be set to a single number or to an object with the
  73260. * following (optional) properties: precision, width, height. If a single number is passed,
  73261. * it will be used for both width and height. If an object is passed, the screenshot size
  73262. * will be derived from the parameters. The precision property is a multiplier allowing
  73263. * rendering at a higher or lower resolution
  73264. * @param successCallback The callback receives a single parameter which contains the
  73265. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73266. * src parameter of an <img> to display it
  73267. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73268. * Check your browser for supported MIME types
  73269. * @param samples Texture samples (default: 1)
  73270. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73271. * @param fileName A name for for the downloaded file.
  73272. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73273. */
  73274. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  73275. /**
  73276. * Generates an image screenshot from the specified camera.
  73277. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  73278. * @param engine The engine to use for rendering
  73279. * @param camera The camera to use for rendering
  73280. * @param size This parameter can be set to a single number or to an object with the
  73281. * following (optional) properties: precision, width, height. If a single number is passed,
  73282. * it will be used for both width and height. If an object is passed, the screenshot size
  73283. * will be derived from the parameters. The precision property is a multiplier allowing
  73284. * rendering at a higher or lower resolution
  73285. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73286. * Check your browser for supported MIME types
  73287. * @param samples Texture samples (default: 1)
  73288. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73289. * @param fileName A name for for the downloaded file.
  73290. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73291. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73292. * to the src parameter of an <img> to display it
  73293. */
  73294. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  73295. /**
  73296. * Gets height and width for screenshot size
  73297. * @private
  73298. */
  73299. private static _getScreenshotSize;
  73300. }
  73301. }
  73302. declare module "babylonjs/Misc/dataReader" {
  73303. /**
  73304. * Interface for a data buffer
  73305. */
  73306. export interface IDataBuffer {
  73307. /**
  73308. * Reads bytes from the data buffer.
  73309. * @param byteOffset The byte offset to read
  73310. * @param byteLength The byte length to read
  73311. * @returns A promise that resolves when the bytes are read
  73312. */
  73313. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  73314. /**
  73315. * The byte length of the buffer.
  73316. */
  73317. readonly byteLength: number;
  73318. }
  73319. /**
  73320. * Utility class for reading from a data buffer
  73321. */
  73322. export class DataReader {
  73323. /**
  73324. * The data buffer associated with this data reader.
  73325. */
  73326. readonly buffer: IDataBuffer;
  73327. /**
  73328. * The current byte offset from the beginning of the data buffer.
  73329. */
  73330. byteOffset: number;
  73331. private _dataView;
  73332. private _dataByteOffset;
  73333. /**
  73334. * Constructor
  73335. * @param buffer The buffer to read
  73336. */
  73337. constructor(buffer: IDataBuffer);
  73338. /**
  73339. * Loads the given byte length.
  73340. * @param byteLength The byte length to load
  73341. * @returns A promise that resolves when the load is complete
  73342. */
  73343. loadAsync(byteLength: number): Promise<void>;
  73344. /**
  73345. * Read a unsigned 32-bit integer from the currently loaded data range.
  73346. * @returns The 32-bit integer read
  73347. */
  73348. readUint32(): number;
  73349. /**
  73350. * Read a byte array from the currently loaded data range.
  73351. * @param byteLength The byte length to read
  73352. * @returns The byte array read
  73353. */
  73354. readUint8Array(byteLength: number): Uint8Array;
  73355. /**
  73356. * Read a string from the currently loaded data range.
  73357. * @param byteLength The byte length to read
  73358. * @returns The string read
  73359. */
  73360. readString(byteLength: number): string;
  73361. /**
  73362. * Skips the given byte length the currently loaded data range.
  73363. * @param byteLength The byte length to skip
  73364. */
  73365. skipBytes(byteLength: number): void;
  73366. }
  73367. }
  73368. declare module "babylonjs/Misc/dataStorage" {
  73369. /**
  73370. * Class for storing data to local storage if available or in-memory storage otherwise
  73371. */
  73372. export class DataStorage {
  73373. private static _Storage;
  73374. private static _GetStorage;
  73375. /**
  73376. * Reads a string from the data storage
  73377. * @param key The key to read
  73378. * @param defaultValue The value if the key doesn't exist
  73379. * @returns The string value
  73380. */
  73381. static ReadString(key: string, defaultValue: string): string;
  73382. /**
  73383. * Writes a string to the data storage
  73384. * @param key The key to write
  73385. * @param value The value to write
  73386. */
  73387. static WriteString(key: string, value: string): void;
  73388. /**
  73389. * Reads a boolean from the data storage
  73390. * @param key The key to read
  73391. * @param defaultValue The value if the key doesn't exist
  73392. * @returns The boolean value
  73393. */
  73394. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  73395. /**
  73396. * Writes a boolean to the data storage
  73397. * @param key The key to write
  73398. * @param value The value to write
  73399. */
  73400. static WriteBoolean(key: string, value: boolean): void;
  73401. /**
  73402. * Reads a number from the data storage
  73403. * @param key The key to read
  73404. * @param defaultValue The value if the key doesn't exist
  73405. * @returns The number value
  73406. */
  73407. static ReadNumber(key: string, defaultValue: number): number;
  73408. /**
  73409. * Writes a number to the data storage
  73410. * @param key The key to write
  73411. * @param value The value to write
  73412. */
  73413. static WriteNumber(key: string, value: number): void;
  73414. }
  73415. }
  73416. declare module "babylonjs/Misc/index" {
  73417. export * from "babylonjs/Misc/andOrNotEvaluator";
  73418. export * from "babylonjs/Misc/assetsManager";
  73419. export * from "babylonjs/Misc/basis";
  73420. export * from "babylonjs/Misc/dds";
  73421. export * from "babylonjs/Misc/decorators";
  73422. export * from "babylonjs/Misc/deferred";
  73423. export * from "babylonjs/Misc/environmentTextureTools";
  73424. export * from "babylonjs/Misc/meshExploder";
  73425. export * from "babylonjs/Misc/filesInput";
  73426. export * from "babylonjs/Misc/HighDynamicRange/index";
  73427. export * from "babylonjs/Misc/khronosTextureContainer";
  73428. export * from "babylonjs/Misc/observable";
  73429. export * from "babylonjs/Misc/performanceMonitor";
  73430. export * from "babylonjs/Misc/promise";
  73431. export * from "babylonjs/Misc/sceneOptimizer";
  73432. export * from "babylonjs/Misc/sceneSerializer";
  73433. export * from "babylonjs/Misc/smartArray";
  73434. export * from "babylonjs/Misc/stringDictionary";
  73435. export * from "babylonjs/Misc/tags";
  73436. export * from "babylonjs/Misc/textureTools";
  73437. export * from "babylonjs/Misc/tga";
  73438. export * from "babylonjs/Misc/tools";
  73439. export * from "babylonjs/Misc/videoRecorder";
  73440. export * from "babylonjs/Misc/virtualJoystick";
  73441. export * from "babylonjs/Misc/workerPool";
  73442. export * from "babylonjs/Misc/logger";
  73443. export * from "babylonjs/Misc/typeStore";
  73444. export * from "babylonjs/Misc/filesInputStore";
  73445. export * from "babylonjs/Misc/deepCopier";
  73446. export * from "babylonjs/Misc/pivotTools";
  73447. export * from "babylonjs/Misc/precisionDate";
  73448. export * from "babylonjs/Misc/screenshotTools";
  73449. export * from "babylonjs/Misc/typeStore";
  73450. export * from "babylonjs/Misc/webRequest";
  73451. export * from "babylonjs/Misc/iInspectable";
  73452. export * from "babylonjs/Misc/brdfTextureTools";
  73453. export * from "babylonjs/Misc/rgbdTextureTools";
  73454. export * from "babylonjs/Misc/gradients";
  73455. export * from "babylonjs/Misc/perfCounter";
  73456. export * from "babylonjs/Misc/fileRequest";
  73457. export * from "babylonjs/Misc/customAnimationFrameRequester";
  73458. export * from "babylonjs/Misc/retryStrategy";
  73459. export * from "babylonjs/Misc/interfaces/screenshotSize";
  73460. export * from "babylonjs/Misc/canvasGenerator";
  73461. export * from "babylonjs/Misc/fileTools";
  73462. export * from "babylonjs/Misc/stringTools";
  73463. export * from "babylonjs/Misc/dataReader";
  73464. export * from "babylonjs/Misc/minMaxReducer";
  73465. export * from "babylonjs/Misc/depthReducer";
  73466. export * from "babylonjs/Misc/dataStorage";
  73467. }
  73468. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  73469. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73470. import { Observable } from "babylonjs/Misc/observable";
  73471. import { Matrix } from "babylonjs/Maths/math.vector";
  73472. import { TransformNode } from "babylonjs/Meshes/transformNode";
  73473. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73474. /**
  73475. * Options used for hit testing
  73476. */
  73477. export interface IWebXRLegacyHitTestOptions {
  73478. /**
  73479. * Only test when user interacted with the scene. Default - hit test every frame
  73480. */
  73481. testOnPointerDownOnly?: boolean;
  73482. /**
  73483. * The node to use to transform the local results to world coordinates
  73484. */
  73485. worldParentNode?: TransformNode;
  73486. }
  73487. /**
  73488. * Interface defining the babylon result of raycasting/hit-test
  73489. */
  73490. export interface IWebXRLegacyHitResult {
  73491. /**
  73492. * Transformation matrix that can be applied to a node that will put it in the hit point location
  73493. */
  73494. transformationMatrix: Matrix;
  73495. /**
  73496. * The native hit test result
  73497. */
  73498. xrHitResult: XRHitResult | XRHitTestResult;
  73499. }
  73500. /**
  73501. * The currently-working hit-test module.
  73502. * Hit test (or Ray-casting) is used to interact with the real world.
  73503. * For further information read here - https://github.com/immersive-web/hit-test
  73504. */
  73505. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  73506. /**
  73507. * options to use when constructing this feature
  73508. */
  73509. readonly options: IWebXRLegacyHitTestOptions;
  73510. private _direction;
  73511. private _mat;
  73512. private _onSelectEnabled;
  73513. private _origin;
  73514. /**
  73515. * The module's name
  73516. */
  73517. static readonly Name: string;
  73518. /**
  73519. * The (Babylon) version of this module.
  73520. * This is an integer representing the implementation version.
  73521. * This number does not correspond to the WebXR specs version
  73522. */
  73523. static readonly Version: number;
  73524. /**
  73525. * Populated with the last native XR Hit Results
  73526. */
  73527. lastNativeXRHitResults: XRHitResult[];
  73528. /**
  73529. * Triggered when new babylon (transformed) hit test results are available
  73530. */
  73531. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  73532. /**
  73533. * Creates a new instance of the (legacy version) hit test feature
  73534. * @param _xrSessionManager an instance of WebXRSessionManager
  73535. * @param options options to use when constructing this feature
  73536. */
  73537. constructor(_xrSessionManager: WebXRSessionManager,
  73538. /**
  73539. * options to use when constructing this feature
  73540. */
  73541. options?: IWebXRLegacyHitTestOptions);
  73542. /**
  73543. * execute a hit test with an XR Ray
  73544. *
  73545. * @param xrSession a native xrSession that will execute this hit test
  73546. * @param xrRay the ray (position and direction) to use for ray-casting
  73547. * @param referenceSpace native XR reference space to use for the hit-test
  73548. * @param filter filter function that will filter the results
  73549. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73550. */
  73551. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  73552. /**
  73553. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  73554. * @param event the (select) event to use to select with
  73555. * @param referenceSpace the reference space to use for this hit test
  73556. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73557. */
  73558. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  73559. /**
  73560. * attach this feature
  73561. * Will usually be called by the features manager
  73562. *
  73563. * @returns true if successful.
  73564. */
  73565. attach(): boolean;
  73566. /**
  73567. * detach this feature.
  73568. * Will usually be called by the features manager
  73569. *
  73570. * @returns true if successful.
  73571. */
  73572. detach(): boolean;
  73573. /**
  73574. * Dispose this feature and all of the resources attached
  73575. */
  73576. dispose(): void;
  73577. protected _onXRFrame(frame: XRFrame): void;
  73578. private _onHitTestResults;
  73579. private _onSelect;
  73580. }
  73581. }
  73582. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  73583. import { TransformNode } from "babylonjs/Meshes/transformNode";
  73584. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73585. import { Observable } from "babylonjs/Misc/observable";
  73586. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  73587. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73588. /**
  73589. * Options used in the plane detector module
  73590. */
  73591. export interface IWebXRPlaneDetectorOptions {
  73592. /**
  73593. * The node to use to transform the local results to world coordinates
  73594. */
  73595. worldParentNode?: TransformNode;
  73596. }
  73597. /**
  73598. * A babylon interface for a WebXR plane.
  73599. * A Plane is actually a polygon, built from N points in space
  73600. *
  73601. * Supported in chrome 79, not supported in canary 81 ATM
  73602. */
  73603. export interface IWebXRPlane {
  73604. /**
  73605. * a babylon-assigned ID for this polygon
  73606. */
  73607. id: number;
  73608. /**
  73609. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  73610. */
  73611. polygonDefinition: Array<Vector3>;
  73612. /**
  73613. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  73614. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  73615. */
  73616. transformationMatrix: Matrix;
  73617. /**
  73618. * the native xr-plane object
  73619. */
  73620. xrPlane: XRPlane;
  73621. }
  73622. /**
  73623. * The plane detector is used to detect planes in the real world when in AR
  73624. * For more information see https://github.com/immersive-web/real-world-geometry/
  73625. */
  73626. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  73627. private _options;
  73628. private _detectedPlanes;
  73629. private _enabled;
  73630. private _lastFrameDetected;
  73631. /**
  73632. * The module's name
  73633. */
  73634. static readonly Name: string;
  73635. /**
  73636. * The (Babylon) version of this module.
  73637. * This is an integer representing the implementation version.
  73638. * This number does not correspond to the WebXR specs version
  73639. */
  73640. static readonly Version: number;
  73641. /**
  73642. * Observers registered here will be executed when a new plane was added to the session
  73643. */
  73644. onPlaneAddedObservable: Observable<IWebXRPlane>;
  73645. /**
  73646. * Observers registered here will be executed when a plane is no longer detected in the session
  73647. */
  73648. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  73649. /**
  73650. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  73651. * This can execute N times every frame
  73652. */
  73653. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  73654. /**
  73655. * construct a new Plane Detector
  73656. * @param _xrSessionManager an instance of xr Session manager
  73657. * @param _options configuration to use when constructing this feature
  73658. */
  73659. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  73660. /**
  73661. * Dispose this feature and all of the resources attached
  73662. */
  73663. dispose(): void;
  73664. protected _onXRFrame(frame: XRFrame): void;
  73665. private _init;
  73666. private _updatePlaneWithXRPlane;
  73667. /**
  73668. * avoiding using Array.find for global support.
  73669. * @param xrPlane the plane to find in the array
  73670. */
  73671. private findIndexInPlaneArray;
  73672. }
  73673. }
  73674. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  73675. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73676. import { Observable } from "babylonjs/Misc/observable";
  73677. import { Matrix } from "babylonjs/Maths/math.vector";
  73678. import { TransformNode } from "babylonjs/Meshes/transformNode";
  73679. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  73680. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  73681. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73682. /**
  73683. * Configuration options of the anchor system
  73684. */
  73685. export interface IWebXRAnchorSystemOptions {
  73686. /**
  73687. * Should a new anchor be added every time a select event is triggered
  73688. */
  73689. addAnchorOnSelect?: boolean;
  73690. /**
  73691. * should the anchor system use plane detection.
  73692. * If set to true, the plane-detection feature should be set using setPlaneDetector
  73693. */
  73694. usePlaneDetection?: boolean;
  73695. /**
  73696. * a node that will be used to convert local to world coordinates
  73697. */
  73698. worldParentNode?: TransformNode;
  73699. }
  73700. /**
  73701. * A babylon container for an XR Anchor
  73702. */
  73703. export interface IWebXRAnchor {
  73704. /**
  73705. * A babylon-assigned ID for this anchor
  73706. */
  73707. id: number;
  73708. /**
  73709. * Transformation matrix to apply to an object attached to this anchor
  73710. */
  73711. transformationMatrix: Matrix;
  73712. /**
  73713. * The native anchor object
  73714. */
  73715. xrAnchor: XRAnchor;
  73716. }
  73717. /**
  73718. * An implementation of the anchor system of WebXR.
  73719. * Note that the current documented implementation is not available in any browser. Future implementations
  73720. * will use the frame to create an anchor and not the session or a detected plane
  73721. * For further information see https://github.com/immersive-web/anchors/
  73722. */
  73723. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  73724. private _options;
  73725. private _enabled;
  73726. private _hitTestModule;
  73727. private _lastFrameDetected;
  73728. private _onSelect;
  73729. private _planeDetector;
  73730. private _trackedAnchors;
  73731. /**
  73732. * The module's name
  73733. */
  73734. static readonly Name: string;
  73735. /**
  73736. * The (Babylon) version of this module.
  73737. * This is an integer representing the implementation version.
  73738. * This number does not correspond to the WebXR specs version
  73739. */
  73740. static readonly Version: number;
  73741. /**
  73742. * Observers registered here will be executed when a new anchor was added to the session
  73743. */
  73744. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  73745. /**
  73746. * Observers registered here will be executed when an anchor was removed from the session
  73747. */
  73748. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  73749. /**
  73750. * Observers registered here will be executed when an existing anchor updates
  73751. * This can execute N times every frame
  73752. */
  73753. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  73754. /**
  73755. * constructs a new anchor system
  73756. * @param _xrSessionManager an instance of WebXRSessionManager
  73757. * @param _options configuration object for this feature
  73758. */
  73759. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  73760. /**
  73761. * Add anchor at a specific XR point.
  73762. *
  73763. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  73764. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  73765. * @returns a promise the fulfills when the anchor was created
  73766. */
  73767. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  73768. /**
  73769. * attach this feature
  73770. * Will usually be called by the features manager
  73771. *
  73772. * @returns true if successful.
  73773. */
  73774. attach(): boolean;
  73775. /**
  73776. * detach this feature.
  73777. * Will usually be called by the features manager
  73778. *
  73779. * @returns true if successful.
  73780. */
  73781. detach(): boolean;
  73782. /**
  73783. * Dispose this feature and all of the resources attached
  73784. */
  73785. dispose(): void;
  73786. /**
  73787. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  73788. * @param hitTestModule the hit-test module to use.
  73789. */
  73790. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  73791. /**
  73792. * set the plane detector to use in order to create anchors from frames
  73793. * @param planeDetector the plane-detector module to use
  73794. * @param enable enable plane-anchors. default is true
  73795. */
  73796. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  73797. protected _onXRFrame(frame: XRFrame): void;
  73798. /**
  73799. * avoiding using Array.find for global support.
  73800. * @param xrAnchor the plane to find in the array
  73801. */
  73802. private _findIndexInAnchorArray;
  73803. private _updateAnchorWithXRFrame;
  73804. }
  73805. }
  73806. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  73807. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73808. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73809. import { Observable } from "babylonjs/Misc/observable";
  73810. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73811. /**
  73812. * Options interface for the background remover plugin
  73813. */
  73814. export interface IWebXRBackgroundRemoverOptions {
  73815. /**
  73816. * Further background meshes to disable when entering AR
  73817. */
  73818. backgroundMeshes?: AbstractMesh[];
  73819. /**
  73820. * flags to configure the removal of the environment helper.
  73821. * If not set, the entire background will be removed. If set, flags should be set as well.
  73822. */
  73823. environmentHelperRemovalFlags?: {
  73824. /**
  73825. * Should the skybox be removed (default false)
  73826. */
  73827. skyBox?: boolean;
  73828. /**
  73829. * Should the ground be removed (default false)
  73830. */
  73831. ground?: boolean;
  73832. };
  73833. /**
  73834. * don't disable the environment helper
  73835. */
  73836. ignoreEnvironmentHelper?: boolean;
  73837. }
  73838. /**
  73839. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  73840. */
  73841. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  73842. /**
  73843. * read-only options to be used in this module
  73844. */
  73845. readonly options: IWebXRBackgroundRemoverOptions;
  73846. /**
  73847. * The module's name
  73848. */
  73849. static readonly Name: string;
  73850. /**
  73851. * The (Babylon) version of this module.
  73852. * This is an integer representing the implementation version.
  73853. * This number does not correspond to the WebXR specs version
  73854. */
  73855. static readonly Version: number;
  73856. /**
  73857. * registered observers will be triggered when the background state changes
  73858. */
  73859. onBackgroundStateChangedObservable: Observable<boolean>;
  73860. /**
  73861. * constructs a new background remover module
  73862. * @param _xrSessionManager the session manager for this module
  73863. * @param options read-only options to be used in this module
  73864. */
  73865. constructor(_xrSessionManager: WebXRSessionManager,
  73866. /**
  73867. * read-only options to be used in this module
  73868. */
  73869. options?: IWebXRBackgroundRemoverOptions);
  73870. /**
  73871. * attach this feature
  73872. * Will usually be called by the features manager
  73873. *
  73874. * @returns true if successful.
  73875. */
  73876. attach(): boolean;
  73877. /**
  73878. * detach this feature.
  73879. * Will usually be called by the features manager
  73880. *
  73881. * @returns true if successful.
  73882. */
  73883. detach(): boolean;
  73884. /**
  73885. * Dispose this feature and all of the resources attached
  73886. */
  73887. dispose(): void;
  73888. protected _onXRFrame(_xrFrame: XRFrame): void;
  73889. private _setBackgroundState;
  73890. }
  73891. }
  73892. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  73893. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73894. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  73895. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  73896. import { WebXRInput } from "babylonjs/XR/webXRInput";
  73897. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73898. import { Nullable } from "babylonjs/types";
  73899. /**
  73900. * Options for the controller physics feature
  73901. */
  73902. export class IWebXRControllerPhysicsOptions {
  73903. /**
  73904. * Should the headset get its own impostor
  73905. */
  73906. enableHeadsetImpostor?: boolean;
  73907. /**
  73908. * Optional parameters for the headset impostor
  73909. */
  73910. headsetImpostorParams?: {
  73911. /**
  73912. * The type of impostor to create. Default is sphere
  73913. */
  73914. impostorType: number;
  73915. /**
  73916. * the size of the impostor. Defaults to 10cm
  73917. */
  73918. impostorSize?: number | {
  73919. width: number;
  73920. height: number;
  73921. depth: number;
  73922. };
  73923. /**
  73924. * Friction definitions
  73925. */
  73926. friction?: number;
  73927. /**
  73928. * Restitution
  73929. */
  73930. restitution?: number;
  73931. };
  73932. /**
  73933. * The physics properties of the future impostors
  73934. */
  73935. physicsProperties?: {
  73936. /**
  73937. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  73938. * Note that this requires a physics engine that supports mesh impostors!
  73939. */
  73940. useControllerMesh?: boolean;
  73941. /**
  73942. * The type of impostor to create. Default is sphere
  73943. */
  73944. impostorType?: number;
  73945. /**
  73946. * the size of the impostor. Defaults to 10cm
  73947. */
  73948. impostorSize?: number | {
  73949. width: number;
  73950. height: number;
  73951. depth: number;
  73952. };
  73953. /**
  73954. * Friction definitions
  73955. */
  73956. friction?: number;
  73957. /**
  73958. * Restitution
  73959. */
  73960. restitution?: number;
  73961. };
  73962. /**
  73963. * the xr input to use with this pointer selection
  73964. */
  73965. xrInput: WebXRInput;
  73966. }
  73967. /**
  73968. * Add physics impostor to your webxr controllers,
  73969. * including naive calculation of their linear and angular velocity
  73970. */
  73971. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  73972. private readonly _options;
  73973. private _attachController;
  73974. private _controllers;
  73975. private _debugMode;
  73976. private _delta;
  73977. private _headsetImpostor?;
  73978. private _headsetMesh?;
  73979. private _lastTimestamp;
  73980. private _tmpQuaternion;
  73981. private _tmpVector;
  73982. /**
  73983. * The module's name
  73984. */
  73985. static readonly Name: string;
  73986. /**
  73987. * The (Babylon) version of this module.
  73988. * This is an integer representing the implementation version.
  73989. * This number does not correspond to the webxr specs version
  73990. */
  73991. static readonly Version: number;
  73992. /**
  73993. * Construct a new Controller Physics Feature
  73994. * @param _xrSessionManager the corresponding xr session manager
  73995. * @param _options options to create this feature with
  73996. */
  73997. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  73998. /**
  73999. * @hidden
  74000. * enable debugging - will show console outputs and the impostor mesh
  74001. */
  74002. _enablePhysicsDebug(): void;
  74003. /**
  74004. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  74005. * @param xrController the controller to add
  74006. */
  74007. addController(xrController: WebXRInputSource): void;
  74008. /**
  74009. * attach this feature
  74010. * Will usually be called by the features manager
  74011. *
  74012. * @returns true if successful.
  74013. */
  74014. attach(): boolean;
  74015. /**
  74016. * detach this feature.
  74017. * Will usually be called by the features manager
  74018. *
  74019. * @returns true if successful.
  74020. */
  74021. detach(): boolean;
  74022. /**
  74023. * Get the headset impostor, if enabled
  74024. * @returns the impostor
  74025. */
  74026. getHeadsetImpostor(): PhysicsImpostor | undefined;
  74027. /**
  74028. * Get the physics impostor of a specific controller.
  74029. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  74030. * @param controller the controller or the controller id of which to get the impostor
  74031. * @returns the impostor or null
  74032. */
  74033. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  74034. /**
  74035. * Update the physics properties provided in the constructor
  74036. * @param newProperties the new properties object
  74037. */
  74038. setPhysicsProperties(newProperties: {
  74039. impostorType?: number;
  74040. impostorSize?: number | {
  74041. width: number;
  74042. height: number;
  74043. depth: number;
  74044. };
  74045. friction?: number;
  74046. restitution?: number;
  74047. }): void;
  74048. protected _onXRFrame(_xrFrame: any): void;
  74049. private _detachController;
  74050. }
  74051. }
  74052. declare module "babylonjs/XR/features/WebXRHitTest" {
  74053. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  74054. import { Observable } from "babylonjs/Misc/observable";
  74055. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  74056. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  74057. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult } from "babylonjs/XR/features/WebXRHitTestLegacy";
  74058. /**
  74059. * Options used for hit testing (version 2)
  74060. */
  74061. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  74062. /**
  74063. * Do not create a permanent hit test. Will usually be used when only
  74064. * transient inputs are needed.
  74065. */
  74066. disablePermanentHitTest?: boolean;
  74067. /**
  74068. * Enable transient (for example touch-based) hit test inspections
  74069. */
  74070. enableTransientHitTest?: boolean;
  74071. /**
  74072. * Offset ray for the permanent hit test
  74073. */
  74074. offsetRay?: Vector3;
  74075. /**
  74076. * Offset ray for the transient hit test
  74077. */
  74078. transientOffsetRay?: Vector3;
  74079. /**
  74080. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  74081. */
  74082. useReferenceSpace?: boolean;
  74083. }
  74084. /**
  74085. * Interface defining the babylon result of hit-test
  74086. */
  74087. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  74088. /**
  74089. * The input source that generated this hit test (if transient)
  74090. */
  74091. inputSource?: XRInputSource;
  74092. /**
  74093. * Is this a transient hit test
  74094. */
  74095. isTransient?: boolean;
  74096. /**
  74097. * Position of the hit test result
  74098. */
  74099. position: Vector3;
  74100. /**
  74101. * Rotation of the hit test result
  74102. */
  74103. rotationQuaternion: Quaternion;
  74104. }
  74105. /**
  74106. * The currently-working hit-test module.
  74107. * Hit test (or Ray-casting) is used to interact with the real world.
  74108. * For further information read here - https://github.com/immersive-web/hit-test
  74109. *
  74110. * Tested on chrome (mobile) 80.
  74111. */
  74112. export class WebXRHitTest extends WebXRAbstractFeature {
  74113. /**
  74114. * options to use when constructing this feature
  74115. */
  74116. readonly options: IWebXRHitTestOptions;
  74117. private _tmpMat;
  74118. private _tmpPos;
  74119. private _tmpQuat;
  74120. private _transientXrHitTestSource;
  74121. private _xrHitTestSource;
  74122. private initHitTestSource;
  74123. /**
  74124. * The module's name
  74125. */
  74126. static readonly Name: string;
  74127. /**
  74128. * The (Babylon) version of this module.
  74129. * This is an integer representing the implementation version.
  74130. * This number does not correspond to the WebXR specs version
  74131. */
  74132. static readonly Version: number;
  74133. /**
  74134. * When set to true, each hit test will have its own position/rotation objects
  74135. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  74136. * the developers will clone them or copy them as they see fit.
  74137. */
  74138. autoCloneTransformation: boolean;
  74139. /**
  74140. * Populated with the last native XR Hit Results
  74141. */
  74142. lastNativeXRHitResults: XRHitResult[];
  74143. /**
  74144. * Triggered when new babylon (transformed) hit test results are available
  74145. */
  74146. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  74147. /**
  74148. * Use this to temporarily pause hit test checks.
  74149. */
  74150. paused: boolean;
  74151. /**
  74152. * Creates a new instance of the hit test feature
  74153. * @param _xrSessionManager an instance of WebXRSessionManager
  74154. * @param options options to use when constructing this feature
  74155. */
  74156. constructor(_xrSessionManager: WebXRSessionManager,
  74157. /**
  74158. * options to use when constructing this feature
  74159. */
  74160. options?: IWebXRHitTestOptions);
  74161. /**
  74162. * attach this feature
  74163. * Will usually be called by the features manager
  74164. *
  74165. * @returns true if successful.
  74166. */
  74167. attach(): boolean;
  74168. /**
  74169. * detach this feature.
  74170. * Will usually be called by the features manager
  74171. *
  74172. * @returns true if successful.
  74173. */
  74174. detach(): boolean;
  74175. /**
  74176. * Dispose this feature and all of the resources attached
  74177. */
  74178. dispose(): void;
  74179. protected _onXRFrame(frame: XRFrame): void;
  74180. private _processWebXRHitTestResult;
  74181. }
  74182. }
  74183. declare module "babylonjs/XR/features/index" {
  74184. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  74185. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  74186. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  74187. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  74188. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  74189. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  74190. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  74191. export * from "babylonjs/XR/features/WebXRHitTest";
  74192. }
  74193. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  74194. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  74195. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74196. import { Scene } from "babylonjs/scene";
  74197. /**
  74198. * The motion controller class for all microsoft mixed reality controllers
  74199. */
  74200. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  74201. protected readonly _mapping: {
  74202. defaultButton: {
  74203. valueNodeName: string;
  74204. unpressedNodeName: string;
  74205. pressedNodeName: string;
  74206. };
  74207. defaultAxis: {
  74208. valueNodeName: string;
  74209. minNodeName: string;
  74210. maxNodeName: string;
  74211. };
  74212. buttons: {
  74213. "xr-standard-trigger": {
  74214. rootNodeName: string;
  74215. componentProperty: string;
  74216. states: string[];
  74217. };
  74218. "xr-standard-squeeze": {
  74219. rootNodeName: string;
  74220. componentProperty: string;
  74221. states: string[];
  74222. };
  74223. "xr-standard-touchpad": {
  74224. rootNodeName: string;
  74225. labelAnchorNodeName: string;
  74226. touchPointNodeName: string;
  74227. };
  74228. "xr-standard-thumbstick": {
  74229. rootNodeName: string;
  74230. componentProperty: string;
  74231. states: string[];
  74232. };
  74233. };
  74234. axes: {
  74235. "xr-standard-touchpad": {
  74236. "x-axis": {
  74237. rootNodeName: string;
  74238. };
  74239. "y-axis": {
  74240. rootNodeName: string;
  74241. };
  74242. };
  74243. "xr-standard-thumbstick": {
  74244. "x-axis": {
  74245. rootNodeName: string;
  74246. };
  74247. "y-axis": {
  74248. rootNodeName: string;
  74249. };
  74250. };
  74251. };
  74252. };
  74253. /**
  74254. * The base url used to load the left and right controller models
  74255. */
  74256. static MODEL_BASE_URL: string;
  74257. /**
  74258. * The name of the left controller model file
  74259. */
  74260. static MODEL_LEFT_FILENAME: string;
  74261. /**
  74262. * The name of the right controller model file
  74263. */
  74264. static MODEL_RIGHT_FILENAME: string;
  74265. profileId: string;
  74266. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  74267. protected _getFilenameAndPath(): {
  74268. filename: string;
  74269. path: string;
  74270. };
  74271. protected _getModelLoadingConstraints(): boolean;
  74272. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74273. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74274. protected _updateModel(): void;
  74275. }
  74276. }
  74277. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  74278. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  74279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74280. import { Scene } from "babylonjs/scene";
  74281. /**
  74282. * The motion controller class for oculus touch (quest, rift).
  74283. * This class supports legacy mapping as well the standard xr mapping
  74284. */
  74285. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  74286. private _forceLegacyControllers;
  74287. private _modelRootNode;
  74288. /**
  74289. * The base url used to load the left and right controller models
  74290. */
  74291. static MODEL_BASE_URL: string;
  74292. /**
  74293. * The name of the left controller model file
  74294. */
  74295. static MODEL_LEFT_FILENAME: string;
  74296. /**
  74297. * The name of the right controller model file
  74298. */
  74299. static MODEL_RIGHT_FILENAME: string;
  74300. /**
  74301. * Base Url for the Quest controller model.
  74302. */
  74303. static QUEST_MODEL_BASE_URL: string;
  74304. profileId: string;
  74305. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  74306. protected _getFilenameAndPath(): {
  74307. filename: string;
  74308. path: string;
  74309. };
  74310. protected _getModelLoadingConstraints(): boolean;
  74311. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74312. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74313. protected _updateModel(): void;
  74314. /**
  74315. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  74316. * between the touch and touch 2.
  74317. */
  74318. private _isQuest;
  74319. }
  74320. }
  74321. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  74322. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  74323. import { Scene } from "babylonjs/scene";
  74324. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74325. /**
  74326. * The motion controller class for the standard HTC-Vive controllers
  74327. */
  74328. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  74329. private _modelRootNode;
  74330. /**
  74331. * The base url used to load the left and right controller models
  74332. */
  74333. static MODEL_BASE_URL: string;
  74334. /**
  74335. * File name for the controller model.
  74336. */
  74337. static MODEL_FILENAME: string;
  74338. profileId: string;
  74339. /**
  74340. * Create a new Vive motion controller object
  74341. * @param scene the scene to use to create this controller
  74342. * @param gamepadObject the corresponding gamepad object
  74343. * @param handness the handness of the controller
  74344. */
  74345. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  74346. protected _getFilenameAndPath(): {
  74347. filename: string;
  74348. path: string;
  74349. };
  74350. protected _getModelLoadingConstraints(): boolean;
  74351. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74352. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74353. protected _updateModel(): void;
  74354. }
  74355. }
  74356. declare module "babylonjs/XR/motionController/index" {
  74357. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  74358. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  74359. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  74360. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  74361. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  74362. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  74363. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  74364. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  74365. }
  74366. declare module "babylonjs/XR/index" {
  74367. export * from "babylonjs/XR/webXRCamera";
  74368. export * from "babylonjs/XR/webXREnterExitUI";
  74369. export * from "babylonjs/XR/webXRExperienceHelper";
  74370. export * from "babylonjs/XR/webXRInput";
  74371. export * from "babylonjs/XR/webXRInputSource";
  74372. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  74373. export * from "babylonjs/XR/webXRTypes";
  74374. export * from "babylonjs/XR/webXRSessionManager";
  74375. export * from "babylonjs/XR/webXRDefaultExperience";
  74376. export * from "babylonjs/XR/webXRFeaturesManager";
  74377. export * from "babylonjs/XR/features/index";
  74378. export * from "babylonjs/XR/motionController/index";
  74379. }
  74380. declare module "babylonjs/index" {
  74381. export * from "babylonjs/abstractScene";
  74382. export * from "babylonjs/Actions/index";
  74383. export * from "babylonjs/Animations/index";
  74384. export * from "babylonjs/assetContainer";
  74385. export * from "babylonjs/Audio/index";
  74386. export * from "babylonjs/Behaviors/index";
  74387. export * from "babylonjs/Bones/index";
  74388. export * from "babylonjs/Cameras/index";
  74389. export * from "babylonjs/Collisions/index";
  74390. export * from "babylonjs/Culling/index";
  74391. export * from "babylonjs/Debug/index";
  74392. export * from "babylonjs/DeviceInput/index";
  74393. export * from "babylonjs/Engines/index";
  74394. export * from "babylonjs/Events/index";
  74395. export * from "babylonjs/Gamepads/index";
  74396. export * from "babylonjs/Gizmos/index";
  74397. export * from "babylonjs/Helpers/index";
  74398. export * from "babylonjs/Instrumentation/index";
  74399. export * from "babylonjs/Layers/index";
  74400. export * from "babylonjs/LensFlares/index";
  74401. export * from "babylonjs/Lights/index";
  74402. export * from "babylonjs/Loading/index";
  74403. export * from "babylonjs/Materials/index";
  74404. export * from "babylonjs/Maths/index";
  74405. export * from "babylonjs/Meshes/index";
  74406. export * from "babylonjs/Morph/index";
  74407. export * from "babylonjs/Navigation/index";
  74408. export * from "babylonjs/node";
  74409. export * from "babylonjs/Offline/index";
  74410. export * from "babylonjs/Particles/index";
  74411. export * from "babylonjs/Physics/index";
  74412. export * from "babylonjs/PostProcesses/index";
  74413. export * from "babylonjs/Probes/index";
  74414. export * from "babylonjs/Rendering/index";
  74415. export * from "babylonjs/scene";
  74416. export * from "babylonjs/sceneComponent";
  74417. export * from "babylonjs/Sprites/index";
  74418. export * from "babylonjs/States/index";
  74419. export * from "babylonjs/Misc/index";
  74420. export * from "babylonjs/XR/index";
  74421. export * from "babylonjs/types";
  74422. }
  74423. declare module "babylonjs/Animations/pathCursor" {
  74424. import { Vector3 } from "babylonjs/Maths/math.vector";
  74425. import { Path2 } from "babylonjs/Maths/math.path";
  74426. /**
  74427. * A cursor which tracks a point on a path
  74428. */
  74429. export class PathCursor {
  74430. private path;
  74431. /**
  74432. * Stores path cursor callbacks for when an onchange event is triggered
  74433. */
  74434. private _onchange;
  74435. /**
  74436. * The value of the path cursor
  74437. */
  74438. value: number;
  74439. /**
  74440. * The animation array of the path cursor
  74441. */
  74442. animations: Animation[];
  74443. /**
  74444. * Initializes the path cursor
  74445. * @param path The path to track
  74446. */
  74447. constructor(path: Path2);
  74448. /**
  74449. * Gets the cursor point on the path
  74450. * @returns A point on the path cursor at the cursor location
  74451. */
  74452. getPoint(): Vector3;
  74453. /**
  74454. * Moves the cursor ahead by the step amount
  74455. * @param step The amount to move the cursor forward
  74456. * @returns This path cursor
  74457. */
  74458. moveAhead(step?: number): PathCursor;
  74459. /**
  74460. * Moves the cursor behind by the step amount
  74461. * @param step The amount to move the cursor back
  74462. * @returns This path cursor
  74463. */
  74464. moveBack(step?: number): PathCursor;
  74465. /**
  74466. * Moves the cursor by the step amount
  74467. * If the step amount is greater than one, an exception is thrown
  74468. * @param step The amount to move the cursor
  74469. * @returns This path cursor
  74470. */
  74471. move(step: number): PathCursor;
  74472. /**
  74473. * Ensures that the value is limited between zero and one
  74474. * @returns This path cursor
  74475. */
  74476. private ensureLimits;
  74477. /**
  74478. * Runs onchange callbacks on change (used by the animation engine)
  74479. * @returns This path cursor
  74480. */
  74481. private raiseOnChange;
  74482. /**
  74483. * Executes a function on change
  74484. * @param f A path cursor onchange callback
  74485. * @returns This path cursor
  74486. */
  74487. onchange(f: (cursor: PathCursor) => void): PathCursor;
  74488. }
  74489. }
  74490. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  74491. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  74492. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  74493. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  74494. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  74495. }
  74496. declare module "babylonjs/Engines/Processors/Expressions/index" {
  74497. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  74498. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  74499. }
  74500. declare module "babylonjs/Engines/Processors/index" {
  74501. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  74502. export * from "babylonjs/Engines/Processors/Expressions/index";
  74503. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  74504. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  74505. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  74506. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  74507. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  74508. export * from "babylonjs/Engines/Processors/shaderProcessor";
  74509. }
  74510. declare module "babylonjs/Legacy/legacy" {
  74511. import * as Babylon from "babylonjs/index";
  74512. export * from "babylonjs/index";
  74513. }
  74514. declare module "babylonjs/Shaders/blur.fragment" {
  74515. /** @hidden */
  74516. export var blurPixelShader: {
  74517. name: string;
  74518. shader: string;
  74519. };
  74520. }
  74521. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  74522. /** @hidden */
  74523. export var pointCloudVertexDeclaration: {
  74524. name: string;
  74525. shader: string;
  74526. };
  74527. }
  74528. declare module "babylonjs" {
  74529. export * from "babylonjs/Legacy/legacy";
  74530. }
  74531. declare module BABYLON {
  74532. /** Alias type for value that can be null */
  74533. export type Nullable<T> = T | null;
  74534. /**
  74535. * Alias type for number that are floats
  74536. * @ignorenaming
  74537. */
  74538. export type float = number;
  74539. /**
  74540. * Alias type for number that are doubles.
  74541. * @ignorenaming
  74542. */
  74543. export type double = number;
  74544. /**
  74545. * Alias type for number that are integer
  74546. * @ignorenaming
  74547. */
  74548. export type int = number;
  74549. /** Alias type for number array or Float32Array */
  74550. export type FloatArray = number[] | Float32Array;
  74551. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  74552. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  74553. /**
  74554. * Alias for types that can be used by a Buffer or VertexBuffer.
  74555. */
  74556. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  74557. /**
  74558. * Alias type for primitive types
  74559. * @ignorenaming
  74560. */
  74561. type Primitive = undefined | null | boolean | string | number | Function;
  74562. /**
  74563. * Type modifier to make all the properties of an object Readonly
  74564. */
  74565. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  74566. /**
  74567. * Type modifier to make all the properties of an object Readonly recursively
  74568. */
  74569. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  74570. /**
  74571. * Type modifier to make object properties readonly.
  74572. */
  74573. export type DeepImmutableObject<T> = {
  74574. readonly [K in keyof T]: DeepImmutable<T[K]>;
  74575. };
  74576. /** @hidden */
  74577. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  74578. }
  74579. }
  74580. declare module BABYLON {
  74581. /**
  74582. * A class serves as a medium between the observable and its observers
  74583. */
  74584. export class EventState {
  74585. /**
  74586. * Create a new EventState
  74587. * @param mask defines the mask associated with this state
  74588. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  74589. * @param target defines the original target of the state
  74590. * @param currentTarget defines the current target of the state
  74591. */
  74592. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  74593. /**
  74594. * Initialize the current event state
  74595. * @param mask defines the mask associated with this state
  74596. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  74597. * @param target defines the original target of the state
  74598. * @param currentTarget defines the current target of the state
  74599. * @returns the current event state
  74600. */
  74601. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  74602. /**
  74603. * An Observer can set this property to true to prevent subsequent observers of being notified
  74604. */
  74605. skipNextObservers: boolean;
  74606. /**
  74607. * Get the mask value that were used to trigger the event corresponding to this EventState object
  74608. */
  74609. mask: number;
  74610. /**
  74611. * The object that originally notified the event
  74612. */
  74613. target?: any;
  74614. /**
  74615. * The current object in the bubbling phase
  74616. */
  74617. currentTarget?: any;
  74618. /**
  74619. * This will be populated with the return value of the last function that was executed.
  74620. * If it is the first function in the callback chain it will be the event data.
  74621. */
  74622. lastReturnValue?: any;
  74623. }
  74624. /**
  74625. * Represent an Observer registered to a given Observable object.
  74626. */
  74627. export class Observer<T> {
  74628. /**
  74629. * Defines the callback to call when the observer is notified
  74630. */
  74631. callback: (eventData: T, eventState: EventState) => void;
  74632. /**
  74633. * Defines the mask of the observer (used to filter notifications)
  74634. */
  74635. mask: number;
  74636. /**
  74637. * Defines the current scope used to restore the JS context
  74638. */
  74639. scope: any;
  74640. /** @hidden */
  74641. _willBeUnregistered: boolean;
  74642. /**
  74643. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  74644. */
  74645. unregisterOnNextCall: boolean;
  74646. /**
  74647. * Creates a new observer
  74648. * @param callback defines the callback to call when the observer is notified
  74649. * @param mask defines the mask of the observer (used to filter notifications)
  74650. * @param scope defines the current scope used to restore the JS context
  74651. */
  74652. constructor(
  74653. /**
  74654. * Defines the callback to call when the observer is notified
  74655. */
  74656. callback: (eventData: T, eventState: EventState) => void,
  74657. /**
  74658. * Defines the mask of the observer (used to filter notifications)
  74659. */
  74660. mask: number,
  74661. /**
  74662. * Defines the current scope used to restore the JS context
  74663. */
  74664. scope?: any);
  74665. }
  74666. /**
  74667. * Represent a list of observers registered to multiple Observables object.
  74668. */
  74669. export class MultiObserver<T> {
  74670. private _observers;
  74671. private _observables;
  74672. /**
  74673. * Release associated resources
  74674. */
  74675. dispose(): void;
  74676. /**
  74677. * Raise a callback when one of the observable will notify
  74678. * @param observables defines a list of observables to watch
  74679. * @param callback defines the callback to call on notification
  74680. * @param mask defines the mask used to filter notifications
  74681. * @param scope defines the current scope used to restore the JS context
  74682. * @returns the new MultiObserver
  74683. */
  74684. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  74685. }
  74686. /**
  74687. * The Observable class is a simple implementation of the Observable pattern.
  74688. *
  74689. * 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.
  74690. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  74691. * 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).
  74692. * 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.
  74693. */
  74694. export class Observable<T> {
  74695. private _observers;
  74696. private _eventState;
  74697. private _onObserverAdded;
  74698. /**
  74699. * Gets the list of observers
  74700. */
  74701. get observers(): Array<Observer<T>>;
  74702. /**
  74703. * Creates a new observable
  74704. * @param onObserverAdded defines a callback to call when a new observer is added
  74705. */
  74706. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  74707. /**
  74708. * Create a new Observer with the specified callback
  74709. * @param callback the callback that will be executed for that Observer
  74710. * @param mask the mask used to filter observers
  74711. * @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.
  74712. * @param scope optional scope for the callback to be called from
  74713. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  74714. * @returns the new observer created for the callback
  74715. */
  74716. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  74717. /**
  74718. * Create a new Observer with the specified callback and unregisters after the next notification
  74719. * @param callback the callback that will be executed for that Observer
  74720. * @returns the new observer created for the callback
  74721. */
  74722. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  74723. /**
  74724. * Remove an Observer from the Observable object
  74725. * @param observer the instance of the Observer to remove
  74726. * @returns false if it doesn't belong to this Observable
  74727. */
  74728. remove(observer: Nullable<Observer<T>>): boolean;
  74729. /**
  74730. * Remove a callback from the Observable object
  74731. * @param callback the callback to remove
  74732. * @param scope optional scope. If used only the callbacks with this scope will be removed
  74733. * @returns false if it doesn't belong to this Observable
  74734. */
  74735. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  74736. private _deferUnregister;
  74737. private _remove;
  74738. /**
  74739. * Moves the observable to the top of the observer list making it get called first when notified
  74740. * @param observer the observer to move
  74741. */
  74742. makeObserverTopPriority(observer: Observer<T>): void;
  74743. /**
  74744. * Moves the observable to the bottom of the observer list making it get called last when notified
  74745. * @param observer the observer to move
  74746. */
  74747. makeObserverBottomPriority(observer: Observer<T>): void;
  74748. /**
  74749. * Notify all Observers by calling their respective callback with the given data
  74750. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  74751. * @param eventData defines the data to send to all observers
  74752. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  74753. * @param target defines the original target of the state
  74754. * @param currentTarget defines the current target of the state
  74755. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  74756. */
  74757. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  74758. /**
  74759. * Calling this will execute each callback, expecting it to be a promise or return a value.
  74760. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  74761. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  74762. * and it is crucial that all callbacks will be executed.
  74763. * The order of the callbacks is kept, callbacks are not executed parallel.
  74764. *
  74765. * @param eventData The data to be sent to each callback
  74766. * @param mask is used to filter observers defaults to -1
  74767. * @param target defines the callback target (see EventState)
  74768. * @param currentTarget defines he current object in the bubbling phase
  74769. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  74770. */
  74771. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  74772. /**
  74773. * Notify a specific observer
  74774. * @param observer defines the observer to notify
  74775. * @param eventData defines the data to be sent to each callback
  74776. * @param mask is used to filter observers defaults to -1
  74777. */
  74778. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  74779. /**
  74780. * Gets a boolean indicating if the observable has at least one observer
  74781. * @returns true is the Observable has at least one Observer registered
  74782. */
  74783. hasObservers(): boolean;
  74784. /**
  74785. * Clear the list of observers
  74786. */
  74787. clear(): void;
  74788. /**
  74789. * Clone the current observable
  74790. * @returns a new observable
  74791. */
  74792. clone(): Observable<T>;
  74793. /**
  74794. * Does this observable handles observer registered with a given mask
  74795. * @param mask defines the mask to be tested
  74796. * @return whether or not one observer registered with the given mask is handeled
  74797. **/
  74798. hasSpecificMask(mask?: number): boolean;
  74799. }
  74800. }
  74801. declare module BABYLON {
  74802. /**
  74803. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  74804. * Babylon.js
  74805. */
  74806. export class DomManagement {
  74807. /**
  74808. * Checks if the window object exists
  74809. * @returns true if the window object exists
  74810. */
  74811. static IsWindowObjectExist(): boolean;
  74812. /**
  74813. * Checks if the navigator object exists
  74814. * @returns true if the navigator object exists
  74815. */
  74816. static IsNavigatorAvailable(): boolean;
  74817. /**
  74818. * Check if the document object exists
  74819. * @returns true if the document object exists
  74820. */
  74821. static IsDocumentAvailable(): boolean;
  74822. /**
  74823. * Extracts text content from a DOM element hierarchy
  74824. * @param element defines the root element
  74825. * @returns a string
  74826. */
  74827. static GetDOMTextContent(element: HTMLElement): string;
  74828. }
  74829. }
  74830. declare module BABYLON {
  74831. /**
  74832. * Logger used througouht the application to allow configuration of
  74833. * the log level required for the messages.
  74834. */
  74835. export class Logger {
  74836. /**
  74837. * No log
  74838. */
  74839. static readonly NoneLogLevel: number;
  74840. /**
  74841. * Only message logs
  74842. */
  74843. static readonly MessageLogLevel: number;
  74844. /**
  74845. * Only warning logs
  74846. */
  74847. static readonly WarningLogLevel: number;
  74848. /**
  74849. * Only error logs
  74850. */
  74851. static readonly ErrorLogLevel: number;
  74852. /**
  74853. * All logs
  74854. */
  74855. static readonly AllLogLevel: number;
  74856. private static _LogCache;
  74857. /**
  74858. * Gets a value indicating the number of loading errors
  74859. * @ignorenaming
  74860. */
  74861. static errorsCount: number;
  74862. /**
  74863. * Callback called when a new log is added
  74864. */
  74865. static OnNewCacheEntry: (entry: string) => void;
  74866. private static _AddLogEntry;
  74867. private static _FormatMessage;
  74868. private static _LogDisabled;
  74869. private static _LogEnabled;
  74870. private static _WarnDisabled;
  74871. private static _WarnEnabled;
  74872. private static _ErrorDisabled;
  74873. private static _ErrorEnabled;
  74874. /**
  74875. * Log a message to the console
  74876. */
  74877. static Log: (message: string) => void;
  74878. /**
  74879. * Write a warning message to the console
  74880. */
  74881. static Warn: (message: string) => void;
  74882. /**
  74883. * Write an error message to the console
  74884. */
  74885. static Error: (message: string) => void;
  74886. /**
  74887. * Gets current log cache (list of logs)
  74888. */
  74889. static get LogCache(): string;
  74890. /**
  74891. * Clears the log cache
  74892. */
  74893. static ClearLogCache(): void;
  74894. /**
  74895. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  74896. */
  74897. static set LogLevels(level: number);
  74898. }
  74899. }
  74900. declare module BABYLON {
  74901. /** @hidden */
  74902. export class _TypeStore {
  74903. /** @hidden */
  74904. static RegisteredTypes: {
  74905. [key: string]: Object;
  74906. };
  74907. /** @hidden */
  74908. static GetClass(fqdn: string): any;
  74909. }
  74910. }
  74911. declare module BABYLON {
  74912. /**
  74913. * Helper to manipulate strings
  74914. */
  74915. export class StringTools {
  74916. /**
  74917. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  74918. * @param str Source string
  74919. * @param suffix Suffix to search for in the source string
  74920. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  74921. */
  74922. static EndsWith(str: string, suffix: string): boolean;
  74923. /**
  74924. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  74925. * @param str Source string
  74926. * @param suffix Suffix to search for in the source string
  74927. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  74928. */
  74929. static StartsWith(str: string, suffix: string): boolean;
  74930. /**
  74931. * Decodes a buffer into a string
  74932. * @param buffer The buffer to decode
  74933. * @returns The decoded string
  74934. */
  74935. static Decode(buffer: Uint8Array | Uint16Array): string;
  74936. /**
  74937. * Encode a buffer to a base64 string
  74938. * @param buffer defines the buffer to encode
  74939. * @returns the encoded string
  74940. */
  74941. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  74942. /**
  74943. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  74944. * @param num the number to convert and pad
  74945. * @param length the expected length of the string
  74946. * @returns the padded string
  74947. */
  74948. static PadNumber(num: number, length: number): string;
  74949. }
  74950. }
  74951. declare module BABYLON {
  74952. /**
  74953. * Class containing a set of static utilities functions for deep copy.
  74954. */
  74955. export class DeepCopier {
  74956. /**
  74957. * Tries to copy an object by duplicating every property
  74958. * @param source defines the source object
  74959. * @param destination defines the target object
  74960. * @param doNotCopyList defines a list of properties to avoid
  74961. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  74962. */
  74963. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  74964. }
  74965. }
  74966. declare module BABYLON {
  74967. /**
  74968. * Class containing a set of static utilities functions for precision date
  74969. */
  74970. export class PrecisionDate {
  74971. /**
  74972. * Gets either window.performance.now() if supported or Date.now() else
  74973. */
  74974. static get Now(): number;
  74975. }
  74976. }
  74977. declare module BABYLON {
  74978. /** @hidden */
  74979. export class _DevTools {
  74980. static WarnImport(name: string): string;
  74981. }
  74982. }
  74983. declare module BABYLON {
  74984. /**
  74985. * Interface used to define the mechanism to get data from the network
  74986. */
  74987. export interface IWebRequest {
  74988. /**
  74989. * Returns client's response url
  74990. */
  74991. responseURL: string;
  74992. /**
  74993. * Returns client's status
  74994. */
  74995. status: number;
  74996. /**
  74997. * Returns client's status as a text
  74998. */
  74999. statusText: string;
  75000. }
  75001. }
  75002. declare module BABYLON {
  75003. /**
  75004. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  75005. */
  75006. export class WebRequest implements IWebRequest {
  75007. private _xhr;
  75008. /**
  75009. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  75010. * i.e. when loading files, where the server/service expects an Authorization header
  75011. */
  75012. static CustomRequestHeaders: {
  75013. [key: string]: string;
  75014. };
  75015. /**
  75016. * Add callback functions in this array to update all the requests before they get sent to the network
  75017. */
  75018. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  75019. private _injectCustomRequestHeaders;
  75020. /**
  75021. * Gets or sets a function to be called when loading progress changes
  75022. */
  75023. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  75024. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  75025. /**
  75026. * Returns client's state
  75027. */
  75028. get readyState(): number;
  75029. /**
  75030. * Returns client's status
  75031. */
  75032. get status(): number;
  75033. /**
  75034. * Returns client's status as a text
  75035. */
  75036. get statusText(): string;
  75037. /**
  75038. * Returns client's response
  75039. */
  75040. get response(): any;
  75041. /**
  75042. * Returns client's response url
  75043. */
  75044. get responseURL(): string;
  75045. /**
  75046. * Returns client's response as text
  75047. */
  75048. get responseText(): string;
  75049. /**
  75050. * Gets or sets the expected response type
  75051. */
  75052. get responseType(): XMLHttpRequestResponseType;
  75053. set responseType(value: XMLHttpRequestResponseType);
  75054. /** @hidden */
  75055. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  75056. /** @hidden */
  75057. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  75058. /**
  75059. * Cancels any network activity
  75060. */
  75061. abort(): void;
  75062. /**
  75063. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  75064. * @param body defines an optional request body
  75065. */
  75066. send(body?: Document | BodyInit | null): void;
  75067. /**
  75068. * Sets the request method, request URL
  75069. * @param method defines the method to use (GET, POST, etc..)
  75070. * @param url defines the url to connect with
  75071. */
  75072. open(method: string, url: string): void;
  75073. /**
  75074. * Sets the value of a request header.
  75075. * @param name The name of the header whose value is to be set
  75076. * @param value The value to set as the body of the header
  75077. */
  75078. setRequestHeader(name: string, value: string): void;
  75079. /**
  75080. * Get the string containing the text of a particular header's value.
  75081. * @param name The name of the header
  75082. * @returns The string containing the text of the given header name
  75083. */
  75084. getResponseHeader(name: string): Nullable<string>;
  75085. }
  75086. }
  75087. declare module BABYLON {
  75088. /**
  75089. * File request interface
  75090. */
  75091. export interface IFileRequest {
  75092. /**
  75093. * Raised when the request is complete (success or error).
  75094. */
  75095. onCompleteObservable: Observable<IFileRequest>;
  75096. /**
  75097. * Aborts the request for a file.
  75098. */
  75099. abort: () => void;
  75100. }
  75101. }
  75102. declare module BABYLON {
  75103. /**
  75104. * Define options used to create a render target texture
  75105. */
  75106. export class RenderTargetCreationOptions {
  75107. /**
  75108. * Specifies is mipmaps must be generated
  75109. */
  75110. generateMipMaps?: boolean;
  75111. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  75112. generateDepthBuffer?: boolean;
  75113. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  75114. generateStencilBuffer?: boolean;
  75115. /** Defines texture type (int by default) */
  75116. type?: number;
  75117. /** Defines sampling mode (trilinear by default) */
  75118. samplingMode?: number;
  75119. /** Defines format (RGBA by default) */
  75120. format?: number;
  75121. }
  75122. }
  75123. declare module BABYLON {
  75124. /** Defines the cross module used constants to avoid circular dependncies */
  75125. export class Constants {
  75126. /** Defines that alpha blending is disabled */
  75127. static readonly ALPHA_DISABLE: number;
  75128. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  75129. static readonly ALPHA_ADD: number;
  75130. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  75131. static readonly ALPHA_COMBINE: number;
  75132. /** Defines that alpha blending is DEST - SRC * DEST */
  75133. static readonly ALPHA_SUBTRACT: number;
  75134. /** Defines that alpha blending is SRC * DEST */
  75135. static readonly ALPHA_MULTIPLY: number;
  75136. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  75137. static readonly ALPHA_MAXIMIZED: number;
  75138. /** Defines that alpha blending is SRC + DEST */
  75139. static readonly ALPHA_ONEONE: number;
  75140. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  75141. static readonly ALPHA_PREMULTIPLIED: number;
  75142. /**
  75143. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  75144. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  75145. */
  75146. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  75147. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  75148. static readonly ALPHA_INTERPOLATE: number;
  75149. /**
  75150. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  75151. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  75152. */
  75153. static readonly ALPHA_SCREENMODE: number;
  75154. /**
  75155. * Defines that alpha blending is SRC + DST
  75156. * Alpha will be set to SRC ALPHA + DST ALPHA
  75157. */
  75158. static readonly ALPHA_ONEONE_ONEONE: number;
  75159. /**
  75160. * Defines that alpha blending is SRC * DST ALPHA + DST
  75161. * Alpha will be set to 0
  75162. */
  75163. static readonly ALPHA_ALPHATOCOLOR: number;
  75164. /**
  75165. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  75166. */
  75167. static readonly ALPHA_REVERSEONEMINUS: number;
  75168. /**
  75169. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  75170. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  75171. */
  75172. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  75173. /**
  75174. * Defines that alpha blending is SRC + DST
  75175. * Alpha will be set to SRC ALPHA
  75176. */
  75177. static readonly ALPHA_ONEONE_ONEZERO: number;
  75178. /**
  75179. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  75180. * Alpha will be set to DST ALPHA
  75181. */
  75182. static readonly ALPHA_EXCLUSION: number;
  75183. /** Defines that alpha blending equation a SUM */
  75184. static readonly ALPHA_EQUATION_ADD: number;
  75185. /** Defines that alpha blending equation a SUBSTRACTION */
  75186. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  75187. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  75188. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  75189. /** Defines that alpha blending equation a MAX operation */
  75190. static readonly ALPHA_EQUATION_MAX: number;
  75191. /** Defines that alpha blending equation a MIN operation */
  75192. static readonly ALPHA_EQUATION_MIN: number;
  75193. /**
  75194. * Defines that alpha blending equation a DARKEN operation:
  75195. * It takes the min of the src and sums the alpha channels.
  75196. */
  75197. static readonly ALPHA_EQUATION_DARKEN: number;
  75198. /** Defines that the ressource is not delayed*/
  75199. static readonly DELAYLOADSTATE_NONE: number;
  75200. /** Defines that the ressource was successfully delay loaded */
  75201. static readonly DELAYLOADSTATE_LOADED: number;
  75202. /** Defines that the ressource is currently delay loading */
  75203. static readonly DELAYLOADSTATE_LOADING: number;
  75204. /** Defines that the ressource is delayed and has not started loading */
  75205. static readonly DELAYLOADSTATE_NOTLOADED: number;
  75206. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  75207. static readonly NEVER: number;
  75208. /** 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 */
  75209. static readonly ALWAYS: number;
  75210. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  75211. static readonly LESS: number;
  75212. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  75213. static readonly EQUAL: number;
  75214. /** 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 */
  75215. static readonly LEQUAL: number;
  75216. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  75217. static readonly GREATER: number;
  75218. /** 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 */
  75219. static readonly GEQUAL: number;
  75220. /** 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 */
  75221. static readonly NOTEQUAL: number;
  75222. /** Passed to stencilOperation to specify that stencil value must be kept */
  75223. static readonly KEEP: number;
  75224. /** Passed to stencilOperation to specify that stencil value must be replaced */
  75225. static readonly REPLACE: number;
  75226. /** Passed to stencilOperation to specify that stencil value must be incremented */
  75227. static readonly INCR: number;
  75228. /** Passed to stencilOperation to specify that stencil value must be decremented */
  75229. static readonly DECR: number;
  75230. /** Passed to stencilOperation to specify that stencil value must be inverted */
  75231. static readonly INVERT: number;
  75232. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  75233. static readonly INCR_WRAP: number;
  75234. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  75235. static readonly DECR_WRAP: number;
  75236. /** Texture is not repeating outside of 0..1 UVs */
  75237. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  75238. /** Texture is repeating outside of 0..1 UVs */
  75239. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  75240. /** Texture is repeating and mirrored */
  75241. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  75242. /** ALPHA */
  75243. static readonly TEXTUREFORMAT_ALPHA: number;
  75244. /** LUMINANCE */
  75245. static readonly TEXTUREFORMAT_LUMINANCE: number;
  75246. /** LUMINANCE_ALPHA */
  75247. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  75248. /** RGB */
  75249. static readonly TEXTUREFORMAT_RGB: number;
  75250. /** RGBA */
  75251. static readonly TEXTUREFORMAT_RGBA: number;
  75252. /** RED */
  75253. static readonly TEXTUREFORMAT_RED: number;
  75254. /** RED (2nd reference) */
  75255. static readonly TEXTUREFORMAT_R: number;
  75256. /** RG */
  75257. static readonly TEXTUREFORMAT_RG: number;
  75258. /** RED_INTEGER */
  75259. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  75260. /** RED_INTEGER (2nd reference) */
  75261. static readonly TEXTUREFORMAT_R_INTEGER: number;
  75262. /** RG_INTEGER */
  75263. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  75264. /** RGB_INTEGER */
  75265. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  75266. /** RGBA_INTEGER */
  75267. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  75268. /** UNSIGNED_BYTE */
  75269. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  75270. /** UNSIGNED_BYTE (2nd reference) */
  75271. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  75272. /** FLOAT */
  75273. static readonly TEXTURETYPE_FLOAT: number;
  75274. /** HALF_FLOAT */
  75275. static readonly TEXTURETYPE_HALF_FLOAT: number;
  75276. /** BYTE */
  75277. static readonly TEXTURETYPE_BYTE: number;
  75278. /** SHORT */
  75279. static readonly TEXTURETYPE_SHORT: number;
  75280. /** UNSIGNED_SHORT */
  75281. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  75282. /** INT */
  75283. static readonly TEXTURETYPE_INT: number;
  75284. /** UNSIGNED_INT */
  75285. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  75286. /** UNSIGNED_SHORT_4_4_4_4 */
  75287. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  75288. /** UNSIGNED_SHORT_5_5_5_1 */
  75289. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  75290. /** UNSIGNED_SHORT_5_6_5 */
  75291. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  75292. /** UNSIGNED_INT_2_10_10_10_REV */
  75293. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  75294. /** UNSIGNED_INT_24_8 */
  75295. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  75296. /** UNSIGNED_INT_10F_11F_11F_REV */
  75297. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  75298. /** UNSIGNED_INT_5_9_9_9_REV */
  75299. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  75300. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  75301. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  75302. /** nearest is mag = nearest and min = nearest and no mip */
  75303. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  75304. /** mag = nearest and min = nearest and mip = none */
  75305. static readonly TEXTURE_NEAREST_NEAREST: number;
  75306. /** Bilinear is mag = linear and min = linear and no mip */
  75307. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  75308. /** mag = linear and min = linear and mip = none */
  75309. static readonly TEXTURE_LINEAR_LINEAR: number;
  75310. /** Trilinear is mag = linear and min = linear and mip = linear */
  75311. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  75312. /** Trilinear is mag = linear and min = linear and mip = linear */
  75313. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  75314. /** mag = nearest and min = nearest and mip = nearest */
  75315. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  75316. /** mag = nearest and min = linear and mip = nearest */
  75317. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  75318. /** mag = nearest and min = linear and mip = linear */
  75319. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  75320. /** mag = nearest and min = linear and mip = none */
  75321. static readonly TEXTURE_NEAREST_LINEAR: number;
  75322. /** nearest is mag = nearest and min = nearest and mip = linear */
  75323. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  75324. /** mag = linear and min = nearest and mip = nearest */
  75325. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  75326. /** mag = linear and min = nearest and mip = linear */
  75327. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  75328. /** Bilinear is mag = linear and min = linear and mip = nearest */
  75329. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  75330. /** mag = linear and min = nearest and mip = none */
  75331. static readonly TEXTURE_LINEAR_NEAREST: number;
  75332. /** Explicit coordinates mode */
  75333. static readonly TEXTURE_EXPLICIT_MODE: number;
  75334. /** Spherical coordinates mode */
  75335. static readonly TEXTURE_SPHERICAL_MODE: number;
  75336. /** Planar coordinates mode */
  75337. static readonly TEXTURE_PLANAR_MODE: number;
  75338. /** Cubic coordinates mode */
  75339. static readonly TEXTURE_CUBIC_MODE: number;
  75340. /** Projection coordinates mode */
  75341. static readonly TEXTURE_PROJECTION_MODE: number;
  75342. /** Skybox coordinates mode */
  75343. static readonly TEXTURE_SKYBOX_MODE: number;
  75344. /** Inverse Cubic coordinates mode */
  75345. static readonly TEXTURE_INVCUBIC_MODE: number;
  75346. /** Equirectangular coordinates mode */
  75347. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  75348. /** Equirectangular Fixed coordinates mode */
  75349. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  75350. /** Equirectangular Fixed Mirrored coordinates mode */
  75351. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  75352. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  75353. static readonly SCALEMODE_FLOOR: number;
  75354. /** Defines that texture rescaling will look for the nearest power of 2 size */
  75355. static readonly SCALEMODE_NEAREST: number;
  75356. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  75357. static readonly SCALEMODE_CEILING: number;
  75358. /**
  75359. * The dirty texture flag value
  75360. */
  75361. static readonly MATERIAL_TextureDirtyFlag: number;
  75362. /**
  75363. * The dirty light flag value
  75364. */
  75365. static readonly MATERIAL_LightDirtyFlag: number;
  75366. /**
  75367. * The dirty fresnel flag value
  75368. */
  75369. static readonly MATERIAL_FresnelDirtyFlag: number;
  75370. /**
  75371. * The dirty attribute flag value
  75372. */
  75373. static readonly MATERIAL_AttributesDirtyFlag: number;
  75374. /**
  75375. * The dirty misc flag value
  75376. */
  75377. static readonly MATERIAL_MiscDirtyFlag: number;
  75378. /**
  75379. * The all dirty flag value
  75380. */
  75381. static readonly MATERIAL_AllDirtyFlag: number;
  75382. /**
  75383. * Returns the triangle fill mode
  75384. */
  75385. static readonly MATERIAL_TriangleFillMode: number;
  75386. /**
  75387. * Returns the wireframe mode
  75388. */
  75389. static readonly MATERIAL_WireFrameFillMode: number;
  75390. /**
  75391. * Returns the point fill mode
  75392. */
  75393. static readonly MATERIAL_PointFillMode: number;
  75394. /**
  75395. * Returns the point list draw mode
  75396. */
  75397. static readonly MATERIAL_PointListDrawMode: number;
  75398. /**
  75399. * Returns the line list draw mode
  75400. */
  75401. static readonly MATERIAL_LineListDrawMode: number;
  75402. /**
  75403. * Returns the line loop draw mode
  75404. */
  75405. static readonly MATERIAL_LineLoopDrawMode: number;
  75406. /**
  75407. * Returns the line strip draw mode
  75408. */
  75409. static readonly MATERIAL_LineStripDrawMode: number;
  75410. /**
  75411. * Returns the triangle strip draw mode
  75412. */
  75413. static readonly MATERIAL_TriangleStripDrawMode: number;
  75414. /**
  75415. * Returns the triangle fan draw mode
  75416. */
  75417. static readonly MATERIAL_TriangleFanDrawMode: number;
  75418. /**
  75419. * Stores the clock-wise side orientation
  75420. */
  75421. static readonly MATERIAL_ClockWiseSideOrientation: number;
  75422. /**
  75423. * Stores the counter clock-wise side orientation
  75424. */
  75425. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  75426. /**
  75427. * Nothing
  75428. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75429. */
  75430. static readonly ACTION_NothingTrigger: number;
  75431. /**
  75432. * On pick
  75433. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75434. */
  75435. static readonly ACTION_OnPickTrigger: number;
  75436. /**
  75437. * On left pick
  75438. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75439. */
  75440. static readonly ACTION_OnLeftPickTrigger: number;
  75441. /**
  75442. * On right pick
  75443. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75444. */
  75445. static readonly ACTION_OnRightPickTrigger: number;
  75446. /**
  75447. * On center pick
  75448. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75449. */
  75450. static readonly ACTION_OnCenterPickTrigger: number;
  75451. /**
  75452. * On pick down
  75453. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75454. */
  75455. static readonly ACTION_OnPickDownTrigger: number;
  75456. /**
  75457. * On double pick
  75458. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75459. */
  75460. static readonly ACTION_OnDoublePickTrigger: number;
  75461. /**
  75462. * On pick up
  75463. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75464. */
  75465. static readonly ACTION_OnPickUpTrigger: number;
  75466. /**
  75467. * On pick out.
  75468. * This trigger will only be raised if you also declared a OnPickDown
  75469. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75470. */
  75471. static readonly ACTION_OnPickOutTrigger: number;
  75472. /**
  75473. * On long press
  75474. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75475. */
  75476. static readonly ACTION_OnLongPressTrigger: number;
  75477. /**
  75478. * On pointer over
  75479. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75480. */
  75481. static readonly ACTION_OnPointerOverTrigger: number;
  75482. /**
  75483. * On pointer out
  75484. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75485. */
  75486. static readonly ACTION_OnPointerOutTrigger: number;
  75487. /**
  75488. * On every frame
  75489. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75490. */
  75491. static readonly ACTION_OnEveryFrameTrigger: number;
  75492. /**
  75493. * On intersection enter
  75494. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75495. */
  75496. static readonly ACTION_OnIntersectionEnterTrigger: number;
  75497. /**
  75498. * On intersection exit
  75499. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75500. */
  75501. static readonly ACTION_OnIntersectionExitTrigger: number;
  75502. /**
  75503. * On key down
  75504. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75505. */
  75506. static readonly ACTION_OnKeyDownTrigger: number;
  75507. /**
  75508. * On key up
  75509. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75510. */
  75511. static readonly ACTION_OnKeyUpTrigger: number;
  75512. /**
  75513. * Billboard mode will only apply to Y axis
  75514. */
  75515. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  75516. /**
  75517. * Billboard mode will apply to all axes
  75518. */
  75519. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  75520. /**
  75521. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  75522. */
  75523. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  75524. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  75525. * Test order :
  75526. * Is the bounding sphere outside the frustum ?
  75527. * If not, are the bounding box vertices outside the frustum ?
  75528. * It not, then the cullable object is in the frustum.
  75529. */
  75530. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  75531. /** Culling strategy : Bounding Sphere Only.
  75532. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  75533. * It's also less accurate than the standard because some not visible objects can still be selected.
  75534. * Test : is the bounding sphere outside the frustum ?
  75535. * If not, then the cullable object is in the frustum.
  75536. */
  75537. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  75538. /** Culling strategy : Optimistic Inclusion.
  75539. * This in an inclusion test first, then the standard exclusion test.
  75540. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  75541. * 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.
  75542. * Anyway, it's as accurate as the standard strategy.
  75543. * Test :
  75544. * Is the cullable object bounding sphere center in the frustum ?
  75545. * If not, apply the default culling strategy.
  75546. */
  75547. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  75548. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  75549. * This in an inclusion test first, then the bounding sphere only exclusion test.
  75550. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  75551. * 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.
  75552. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  75553. * Test :
  75554. * Is the cullable object bounding sphere center in the frustum ?
  75555. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  75556. */
  75557. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  75558. /**
  75559. * No logging while loading
  75560. */
  75561. static readonly SCENELOADER_NO_LOGGING: number;
  75562. /**
  75563. * Minimal logging while loading
  75564. */
  75565. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  75566. /**
  75567. * Summary logging while loading
  75568. */
  75569. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  75570. /**
  75571. * Detailled logging while loading
  75572. */
  75573. static readonly SCENELOADER_DETAILED_LOGGING: number;
  75574. }
  75575. }
  75576. declare module BABYLON {
  75577. /**
  75578. * This represents the required contract to create a new type of texture loader.
  75579. */
  75580. export interface IInternalTextureLoader {
  75581. /**
  75582. * Defines wether the loader supports cascade loading the different faces.
  75583. */
  75584. supportCascades: boolean;
  75585. /**
  75586. * This returns if the loader support the current file information.
  75587. * @param extension defines the file extension of the file being loaded
  75588. * @returns true if the loader can load the specified file
  75589. */
  75590. canLoad(extension: string): boolean;
  75591. /**
  75592. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  75593. * @param data contains the texture data
  75594. * @param texture defines the BabylonJS internal texture
  75595. * @param createPolynomials will be true if polynomials have been requested
  75596. * @param onLoad defines the callback to trigger once the texture is ready
  75597. * @param onError defines the callback to trigger in case of error
  75598. */
  75599. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  75600. /**
  75601. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  75602. * @param data contains the texture data
  75603. * @param texture defines the BabylonJS internal texture
  75604. * @param callback defines the method to call once ready to upload
  75605. */
  75606. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  75607. }
  75608. }
  75609. declare module BABYLON {
  75610. /**
  75611. * Class used to store and describe the pipeline context associated with an effect
  75612. */
  75613. export interface IPipelineContext {
  75614. /**
  75615. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  75616. */
  75617. isAsync: boolean;
  75618. /**
  75619. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  75620. */
  75621. isReady: boolean;
  75622. /** @hidden */
  75623. _getVertexShaderCode(): string | null;
  75624. /** @hidden */
  75625. _getFragmentShaderCode(): string | null;
  75626. /** @hidden */
  75627. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  75628. }
  75629. }
  75630. declare module BABYLON {
  75631. /**
  75632. * Class used to store gfx data (like WebGLBuffer)
  75633. */
  75634. export class DataBuffer {
  75635. /**
  75636. * Gets or sets the number of objects referencing this buffer
  75637. */
  75638. references: number;
  75639. /** Gets or sets the size of the underlying buffer */
  75640. capacity: number;
  75641. /**
  75642. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  75643. */
  75644. is32Bits: boolean;
  75645. /**
  75646. * Gets the underlying buffer
  75647. */
  75648. get underlyingResource(): any;
  75649. }
  75650. }
  75651. declare module BABYLON {
  75652. /** @hidden */
  75653. export interface IShaderProcessor {
  75654. attributeProcessor?: (attribute: string) => string;
  75655. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  75656. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  75657. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  75658. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  75659. lineProcessor?: (line: string, isFragment: boolean) => string;
  75660. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  75661. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  75662. }
  75663. }
  75664. declare module BABYLON {
  75665. /** @hidden */
  75666. export interface ProcessingOptions {
  75667. defines: string[];
  75668. indexParameters: any;
  75669. isFragment: boolean;
  75670. shouldUseHighPrecisionShader: boolean;
  75671. supportsUniformBuffers: boolean;
  75672. shadersRepository: string;
  75673. includesShadersStore: {
  75674. [key: string]: string;
  75675. };
  75676. processor?: IShaderProcessor;
  75677. version: string;
  75678. platformName: string;
  75679. lookForClosingBracketForUniformBuffer?: boolean;
  75680. }
  75681. }
  75682. declare module BABYLON {
  75683. /** @hidden */
  75684. export class ShaderCodeNode {
  75685. line: string;
  75686. children: ShaderCodeNode[];
  75687. additionalDefineKey?: string;
  75688. additionalDefineValue?: string;
  75689. isValid(preprocessors: {
  75690. [key: string]: string;
  75691. }): boolean;
  75692. process(preprocessors: {
  75693. [key: string]: string;
  75694. }, options: ProcessingOptions): string;
  75695. }
  75696. }
  75697. declare module BABYLON {
  75698. /** @hidden */
  75699. export class ShaderCodeCursor {
  75700. private _lines;
  75701. lineIndex: number;
  75702. get currentLine(): string;
  75703. get canRead(): boolean;
  75704. set lines(value: string[]);
  75705. }
  75706. }
  75707. declare module BABYLON {
  75708. /** @hidden */
  75709. export class ShaderCodeConditionNode extends ShaderCodeNode {
  75710. process(preprocessors: {
  75711. [key: string]: string;
  75712. }, options: ProcessingOptions): string;
  75713. }
  75714. }
  75715. declare module BABYLON {
  75716. /** @hidden */
  75717. export class ShaderDefineExpression {
  75718. isTrue(preprocessors: {
  75719. [key: string]: string;
  75720. }): boolean;
  75721. private static _OperatorPriority;
  75722. private static _Stack;
  75723. static postfixToInfix(postfix: string[]): string;
  75724. static infixToPostfix(infix: string): string[];
  75725. }
  75726. }
  75727. declare module BABYLON {
  75728. /** @hidden */
  75729. export class ShaderCodeTestNode extends ShaderCodeNode {
  75730. testExpression: ShaderDefineExpression;
  75731. isValid(preprocessors: {
  75732. [key: string]: string;
  75733. }): boolean;
  75734. }
  75735. }
  75736. declare module BABYLON {
  75737. /** @hidden */
  75738. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  75739. define: string;
  75740. not: boolean;
  75741. constructor(define: string, not?: boolean);
  75742. isTrue(preprocessors: {
  75743. [key: string]: string;
  75744. }): boolean;
  75745. }
  75746. }
  75747. declare module BABYLON {
  75748. /** @hidden */
  75749. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  75750. leftOperand: ShaderDefineExpression;
  75751. rightOperand: ShaderDefineExpression;
  75752. isTrue(preprocessors: {
  75753. [key: string]: string;
  75754. }): boolean;
  75755. }
  75756. }
  75757. declare module BABYLON {
  75758. /** @hidden */
  75759. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  75760. leftOperand: ShaderDefineExpression;
  75761. rightOperand: ShaderDefineExpression;
  75762. isTrue(preprocessors: {
  75763. [key: string]: string;
  75764. }): boolean;
  75765. }
  75766. }
  75767. declare module BABYLON {
  75768. /** @hidden */
  75769. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  75770. define: string;
  75771. operand: string;
  75772. testValue: string;
  75773. constructor(define: string, operand: string, testValue: string);
  75774. isTrue(preprocessors: {
  75775. [key: string]: string;
  75776. }): boolean;
  75777. }
  75778. }
  75779. declare module BABYLON {
  75780. /**
  75781. * Class used to enable access to offline support
  75782. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  75783. */
  75784. export interface IOfflineProvider {
  75785. /**
  75786. * Gets a boolean indicating if scene must be saved in the database
  75787. */
  75788. enableSceneOffline: boolean;
  75789. /**
  75790. * Gets a boolean indicating if textures must be saved in the database
  75791. */
  75792. enableTexturesOffline: boolean;
  75793. /**
  75794. * Open the offline support and make it available
  75795. * @param successCallback defines the callback to call on success
  75796. * @param errorCallback defines the callback to call on error
  75797. */
  75798. open(successCallback: () => void, errorCallback: () => void): void;
  75799. /**
  75800. * Loads an image from the offline support
  75801. * @param url defines the url to load from
  75802. * @param image defines the target DOM image
  75803. */
  75804. loadImage(url: string, image: HTMLImageElement): void;
  75805. /**
  75806. * Loads a file from offline support
  75807. * @param url defines the URL to load from
  75808. * @param sceneLoaded defines a callback to call on success
  75809. * @param progressCallBack defines a callback to call when progress changed
  75810. * @param errorCallback defines a callback to call on error
  75811. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  75812. */
  75813. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  75814. }
  75815. }
  75816. declare module BABYLON {
  75817. /**
  75818. * Class used to help managing file picking and drag'n'drop
  75819. * File Storage
  75820. */
  75821. export class FilesInputStore {
  75822. /**
  75823. * List of files ready to be loaded
  75824. */
  75825. static FilesToLoad: {
  75826. [key: string]: File;
  75827. };
  75828. }
  75829. }
  75830. declare module BABYLON {
  75831. /**
  75832. * Class used to define a retry strategy when error happens while loading assets
  75833. */
  75834. export class RetryStrategy {
  75835. /**
  75836. * Function used to defines an exponential back off strategy
  75837. * @param maxRetries defines the maximum number of retries (3 by default)
  75838. * @param baseInterval defines the interval between retries
  75839. * @returns the strategy function to use
  75840. */
  75841. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  75842. }
  75843. }
  75844. declare module BABYLON {
  75845. /**
  75846. * @ignore
  75847. * Application error to support additional information when loading a file
  75848. */
  75849. export abstract class BaseError extends Error {
  75850. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  75851. }
  75852. }
  75853. declare module BABYLON {
  75854. /** @ignore */
  75855. export class LoadFileError extends BaseError {
  75856. request?: WebRequest;
  75857. file?: File;
  75858. /**
  75859. * Creates a new LoadFileError
  75860. * @param message defines the message of the error
  75861. * @param request defines the optional web request
  75862. * @param file defines the optional file
  75863. */
  75864. constructor(message: string, object?: WebRequest | File);
  75865. }
  75866. /** @ignore */
  75867. export class RequestFileError extends BaseError {
  75868. request: WebRequest;
  75869. /**
  75870. * Creates a new LoadFileError
  75871. * @param message defines the message of the error
  75872. * @param request defines the optional web request
  75873. */
  75874. constructor(message: string, request: WebRequest);
  75875. }
  75876. /** @ignore */
  75877. export class ReadFileError extends BaseError {
  75878. file: File;
  75879. /**
  75880. * Creates a new ReadFileError
  75881. * @param message defines the message of the error
  75882. * @param file defines the optional file
  75883. */
  75884. constructor(message: string, file: File);
  75885. }
  75886. /**
  75887. * @hidden
  75888. */
  75889. export class FileTools {
  75890. /**
  75891. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  75892. */
  75893. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  75894. /**
  75895. * Gets or sets the base URL to use to load assets
  75896. */
  75897. static BaseUrl: string;
  75898. /**
  75899. * Default behaviour for cors in the application.
  75900. * It can be a string if the expected behavior is identical in the entire app.
  75901. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  75902. */
  75903. static CorsBehavior: string | ((url: string | string[]) => string);
  75904. /**
  75905. * Gets or sets a function used to pre-process url before using them to load assets
  75906. */
  75907. static PreprocessUrl: (url: string) => string;
  75908. /**
  75909. * Removes unwanted characters from an url
  75910. * @param url defines the url to clean
  75911. * @returns the cleaned url
  75912. */
  75913. private static _CleanUrl;
  75914. /**
  75915. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  75916. * @param url define the url we are trying
  75917. * @param element define the dom element where to configure the cors policy
  75918. */
  75919. static SetCorsBehavior(url: string | string[], element: {
  75920. crossOrigin: string | null;
  75921. }): void;
  75922. /**
  75923. * Loads an image as an HTMLImageElement.
  75924. * @param input url string, ArrayBuffer, or Blob to load
  75925. * @param onLoad callback called when the image successfully loads
  75926. * @param onError callback called when the image fails to load
  75927. * @param offlineProvider offline provider for caching
  75928. * @param mimeType optional mime type
  75929. * @returns the HTMLImageElement of the loaded image
  75930. */
  75931. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  75932. /**
  75933. * Reads a file from a File object
  75934. * @param file defines the file to load
  75935. * @param onSuccess defines the callback to call when data is loaded
  75936. * @param onProgress defines the callback to call during loading process
  75937. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  75938. * @param onError defines the callback to call when an error occurs
  75939. * @returns a file request object
  75940. */
  75941. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  75942. /**
  75943. * Loads a file from a url
  75944. * @param url url to load
  75945. * @param onSuccess callback called when the file successfully loads
  75946. * @param onProgress callback called while file is loading (if the server supports this mode)
  75947. * @param offlineProvider defines the offline provider for caching
  75948. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  75949. * @param onError callback called when the file fails to load
  75950. * @returns a file request object
  75951. */
  75952. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  75953. /**
  75954. * Loads a file
  75955. * @param url url to load
  75956. * @param onSuccess callback called when the file successfully loads
  75957. * @param onProgress callback called while file is loading (if the server supports this mode)
  75958. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  75959. * @param onError callback called when the file fails to load
  75960. * @param onOpened callback called when the web request is opened
  75961. * @returns a file request object
  75962. */
  75963. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  75964. /**
  75965. * Checks if the loaded document was accessed via `file:`-Protocol.
  75966. * @returns boolean
  75967. */
  75968. static IsFileURL(): boolean;
  75969. }
  75970. }
  75971. declare module BABYLON {
  75972. /** @hidden */
  75973. export class ShaderProcessor {
  75974. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  75975. private static _ProcessPrecision;
  75976. private static _ExtractOperation;
  75977. private static _BuildSubExpression;
  75978. private static _BuildExpression;
  75979. private static _MoveCursorWithinIf;
  75980. private static _MoveCursor;
  75981. private static _EvaluatePreProcessors;
  75982. private static _PreparePreProcessors;
  75983. private static _ProcessShaderConversion;
  75984. private static _ProcessIncludes;
  75985. /**
  75986. * Loads a file from a url
  75987. * @param url url to load
  75988. * @param onSuccess callback called when the file successfully loads
  75989. * @param onProgress callback called while file is loading (if the server supports this mode)
  75990. * @param offlineProvider defines the offline provider for caching
  75991. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  75992. * @param onError callback called when the file fails to load
  75993. * @returns a file request object
  75994. * @hidden
  75995. */
  75996. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  75997. }
  75998. }
  75999. declare module BABYLON {
  76000. /**
  76001. * @hidden
  76002. */
  76003. export interface IColor4Like {
  76004. r: float;
  76005. g: float;
  76006. b: float;
  76007. a: float;
  76008. }
  76009. /**
  76010. * @hidden
  76011. */
  76012. export interface IColor3Like {
  76013. r: float;
  76014. g: float;
  76015. b: float;
  76016. }
  76017. /**
  76018. * @hidden
  76019. */
  76020. export interface IVector4Like {
  76021. x: float;
  76022. y: float;
  76023. z: float;
  76024. w: float;
  76025. }
  76026. /**
  76027. * @hidden
  76028. */
  76029. export interface IVector3Like {
  76030. x: float;
  76031. y: float;
  76032. z: float;
  76033. }
  76034. /**
  76035. * @hidden
  76036. */
  76037. export interface IVector2Like {
  76038. x: float;
  76039. y: float;
  76040. }
  76041. /**
  76042. * @hidden
  76043. */
  76044. export interface IMatrixLike {
  76045. toArray(): DeepImmutable<Float32Array>;
  76046. updateFlag: int;
  76047. }
  76048. /**
  76049. * @hidden
  76050. */
  76051. export interface IViewportLike {
  76052. x: float;
  76053. y: float;
  76054. width: float;
  76055. height: float;
  76056. }
  76057. /**
  76058. * @hidden
  76059. */
  76060. export interface IPlaneLike {
  76061. normal: IVector3Like;
  76062. d: float;
  76063. normalize(): void;
  76064. }
  76065. }
  76066. declare module BABYLON {
  76067. /**
  76068. * Interface used to define common properties for effect fallbacks
  76069. */
  76070. export interface IEffectFallbacks {
  76071. /**
  76072. * Removes the defines that should be removed when falling back.
  76073. * @param currentDefines defines the current define statements for the shader.
  76074. * @param effect defines the current effect we try to compile
  76075. * @returns The resulting defines with defines of the current rank removed.
  76076. */
  76077. reduce(currentDefines: string, effect: Effect): string;
  76078. /**
  76079. * Removes the fallback from the bound mesh.
  76080. */
  76081. unBindMesh(): void;
  76082. /**
  76083. * Checks to see if more fallbacks are still availible.
  76084. */
  76085. hasMoreFallbacks: boolean;
  76086. }
  76087. }
  76088. declare module BABYLON {
  76089. /**
  76090. * Class used to evalaute queries containing `and` and `or` operators
  76091. */
  76092. export class AndOrNotEvaluator {
  76093. /**
  76094. * Evaluate a query
  76095. * @param query defines the query to evaluate
  76096. * @param evaluateCallback defines the callback used to filter result
  76097. * @returns true if the query matches
  76098. */
  76099. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  76100. private static _HandleParenthesisContent;
  76101. private static _SimplifyNegation;
  76102. }
  76103. }
  76104. declare module BABYLON {
  76105. /**
  76106. * Class used to store custom tags
  76107. */
  76108. export class Tags {
  76109. /**
  76110. * Adds support for tags on the given object
  76111. * @param obj defines the object to use
  76112. */
  76113. static EnableFor(obj: any): void;
  76114. /**
  76115. * Removes tags support
  76116. * @param obj defines the object to use
  76117. */
  76118. static DisableFor(obj: any): void;
  76119. /**
  76120. * Gets a boolean indicating if the given object has tags
  76121. * @param obj defines the object to use
  76122. * @returns a boolean
  76123. */
  76124. static HasTags(obj: any): boolean;
  76125. /**
  76126. * Gets the tags available on a given object
  76127. * @param obj defines the object to use
  76128. * @param asString defines if the tags must be returned as a string instead of an array of strings
  76129. * @returns the tags
  76130. */
  76131. static GetTags(obj: any, asString?: boolean): any;
  76132. /**
  76133. * Adds tags to an object
  76134. * @param obj defines the object to use
  76135. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  76136. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  76137. */
  76138. static AddTagsTo(obj: any, tagsString: string): void;
  76139. /**
  76140. * @hidden
  76141. */
  76142. static _AddTagTo(obj: any, tag: string): void;
  76143. /**
  76144. * Removes specific tags from a specific object
  76145. * @param obj defines the object to use
  76146. * @param tagsString defines the tags to remove
  76147. */
  76148. static RemoveTagsFrom(obj: any, tagsString: string): void;
  76149. /**
  76150. * @hidden
  76151. */
  76152. static _RemoveTagFrom(obj: any, tag: string): void;
  76153. /**
  76154. * Defines if tags hosted on an object match a given query
  76155. * @param obj defines the object to use
  76156. * @param tagsQuery defines the tag query
  76157. * @returns a boolean
  76158. */
  76159. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  76160. }
  76161. }
  76162. declare module BABYLON {
  76163. /**
  76164. * Scalar computation library
  76165. */
  76166. export class Scalar {
  76167. /**
  76168. * Two pi constants convenient for computation.
  76169. */
  76170. static TwoPi: number;
  76171. /**
  76172. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  76173. * @param a number
  76174. * @param b number
  76175. * @param epsilon (default = 1.401298E-45)
  76176. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  76177. */
  76178. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  76179. /**
  76180. * Returns a string : the upper case translation of the number i to hexadecimal.
  76181. * @param i number
  76182. * @returns the upper case translation of the number i to hexadecimal.
  76183. */
  76184. static ToHex(i: number): string;
  76185. /**
  76186. * Returns -1 if value is negative and +1 is value is positive.
  76187. * @param value the value
  76188. * @returns the value itself if it's equal to zero.
  76189. */
  76190. static Sign(value: number): number;
  76191. /**
  76192. * Returns the value itself if it's between min and max.
  76193. * Returns min if the value is lower than min.
  76194. * Returns max if the value is greater than max.
  76195. * @param value the value to clmap
  76196. * @param min the min value to clamp to (default: 0)
  76197. * @param max the max value to clamp to (default: 1)
  76198. * @returns the clamped value
  76199. */
  76200. static Clamp(value: number, min?: number, max?: number): number;
  76201. /**
  76202. * the log2 of value.
  76203. * @param value the value to compute log2 of
  76204. * @returns the log2 of value.
  76205. */
  76206. static Log2(value: number): number;
  76207. /**
  76208. * Loops the value, so that it is never larger than length and never smaller than 0.
  76209. *
  76210. * This is similar to the modulo operator but it works with floating point numbers.
  76211. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  76212. * With t = 5 and length = 2.5, the result would be 0.0.
  76213. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  76214. * @param value the value
  76215. * @param length the length
  76216. * @returns the looped value
  76217. */
  76218. static Repeat(value: number, length: number): number;
  76219. /**
  76220. * Normalize the value between 0.0 and 1.0 using min and max values
  76221. * @param value value to normalize
  76222. * @param min max to normalize between
  76223. * @param max min to normalize between
  76224. * @returns the normalized value
  76225. */
  76226. static Normalize(value: number, min: number, max: number): number;
  76227. /**
  76228. * Denormalize the value from 0.0 and 1.0 using min and max values
  76229. * @param normalized value to denormalize
  76230. * @param min max to denormalize between
  76231. * @param max min to denormalize between
  76232. * @returns the denormalized value
  76233. */
  76234. static Denormalize(normalized: number, min: number, max: number): number;
  76235. /**
  76236. * Calculates the shortest difference between two given angles given in degrees.
  76237. * @param current current angle in degrees
  76238. * @param target target angle in degrees
  76239. * @returns the delta
  76240. */
  76241. static DeltaAngle(current: number, target: number): number;
  76242. /**
  76243. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  76244. * @param tx value
  76245. * @param length length
  76246. * @returns The returned value will move back and forth between 0 and length
  76247. */
  76248. static PingPong(tx: number, length: number): number;
  76249. /**
  76250. * Interpolates between min and max with smoothing at the limits.
  76251. *
  76252. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  76253. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  76254. * @param from from
  76255. * @param to to
  76256. * @param tx value
  76257. * @returns the smooth stepped value
  76258. */
  76259. static SmoothStep(from: number, to: number, tx: number): number;
  76260. /**
  76261. * Moves a value current towards target.
  76262. *
  76263. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  76264. * Negative values of maxDelta pushes the value away from target.
  76265. * @param current current value
  76266. * @param target target value
  76267. * @param maxDelta max distance to move
  76268. * @returns resulting value
  76269. */
  76270. static MoveTowards(current: number, target: number, maxDelta: number): number;
  76271. /**
  76272. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  76273. *
  76274. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  76275. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  76276. * @param current current value
  76277. * @param target target value
  76278. * @param maxDelta max distance to move
  76279. * @returns resulting angle
  76280. */
  76281. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  76282. /**
  76283. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  76284. * @param start start value
  76285. * @param end target value
  76286. * @param amount amount to lerp between
  76287. * @returns the lerped value
  76288. */
  76289. static Lerp(start: number, end: number, amount: number): number;
  76290. /**
  76291. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  76292. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  76293. * @param start start value
  76294. * @param end target value
  76295. * @param amount amount to lerp between
  76296. * @returns the lerped value
  76297. */
  76298. static LerpAngle(start: number, end: number, amount: number): number;
  76299. /**
  76300. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  76301. * @param a start value
  76302. * @param b target value
  76303. * @param value value between a and b
  76304. * @returns the inverseLerp value
  76305. */
  76306. static InverseLerp(a: number, b: number, value: number): number;
  76307. /**
  76308. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  76309. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  76310. * @param value1 spline value
  76311. * @param tangent1 spline value
  76312. * @param value2 spline value
  76313. * @param tangent2 spline value
  76314. * @param amount input value
  76315. * @returns hermite result
  76316. */
  76317. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  76318. /**
  76319. * Returns a random float number between and min and max values
  76320. * @param min min value of random
  76321. * @param max max value of random
  76322. * @returns random value
  76323. */
  76324. static RandomRange(min: number, max: number): number;
  76325. /**
  76326. * This function returns percentage of a number in a given range.
  76327. *
  76328. * RangeToPercent(40,20,60) will return 0.5 (50%)
  76329. * RangeToPercent(34,0,100) will return 0.34 (34%)
  76330. * @param number to convert to percentage
  76331. * @param min min range
  76332. * @param max max range
  76333. * @returns the percentage
  76334. */
  76335. static RangeToPercent(number: number, min: number, max: number): number;
  76336. /**
  76337. * This function returns number that corresponds to the percentage in a given range.
  76338. *
  76339. * PercentToRange(0.34,0,100) will return 34.
  76340. * @param percent to convert to number
  76341. * @param min min range
  76342. * @param max max range
  76343. * @returns the number
  76344. */
  76345. static PercentToRange(percent: number, min: number, max: number): number;
  76346. /**
  76347. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  76348. * @param angle The angle to normalize in radian.
  76349. * @return The converted angle.
  76350. */
  76351. static NormalizeRadians(angle: number): number;
  76352. }
  76353. }
  76354. declare module BABYLON {
  76355. /**
  76356. * Constant used to convert a value to gamma space
  76357. * @ignorenaming
  76358. */
  76359. export const ToGammaSpace: number;
  76360. /**
  76361. * Constant used to convert a value to linear space
  76362. * @ignorenaming
  76363. */
  76364. export const ToLinearSpace = 2.2;
  76365. /**
  76366. * Constant used to define the minimal number value in Babylon.js
  76367. * @ignorenaming
  76368. */
  76369. let Epsilon: number;
  76370. }
  76371. declare module BABYLON {
  76372. /**
  76373. * Class used to represent a viewport on screen
  76374. */
  76375. export class Viewport {
  76376. /** viewport left coordinate */
  76377. x: number;
  76378. /** viewport top coordinate */
  76379. y: number;
  76380. /**viewport width */
  76381. width: number;
  76382. /** viewport height */
  76383. height: number;
  76384. /**
  76385. * Creates a Viewport object located at (x, y) and sized (width, height)
  76386. * @param x defines viewport left coordinate
  76387. * @param y defines viewport top coordinate
  76388. * @param width defines the viewport width
  76389. * @param height defines the viewport height
  76390. */
  76391. constructor(
  76392. /** viewport left coordinate */
  76393. x: number,
  76394. /** viewport top coordinate */
  76395. y: number,
  76396. /**viewport width */
  76397. width: number,
  76398. /** viewport height */
  76399. height: number);
  76400. /**
  76401. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  76402. * @param renderWidth defines the rendering width
  76403. * @param renderHeight defines the rendering height
  76404. * @returns a new Viewport
  76405. */
  76406. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  76407. /**
  76408. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  76409. * @param renderWidth defines the rendering width
  76410. * @param renderHeight defines the rendering height
  76411. * @param ref defines the target viewport
  76412. * @returns the current viewport
  76413. */
  76414. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  76415. /**
  76416. * Returns a new Viewport copied from the current one
  76417. * @returns a new Viewport
  76418. */
  76419. clone(): Viewport;
  76420. }
  76421. }
  76422. declare module BABYLON {
  76423. /**
  76424. * Class containing a set of static utilities functions for arrays.
  76425. */
  76426. export class ArrayTools {
  76427. /**
  76428. * Returns an array of the given size filled with element built from the given constructor and the paramters
  76429. * @param size the number of element to construct and put in the array
  76430. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  76431. * @returns a new array filled with new objects
  76432. */
  76433. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  76434. }
  76435. }
  76436. declare module BABYLON {
  76437. /**
  76438. * Class representing a vector containing 2 coordinates
  76439. */
  76440. export class Vector2 {
  76441. /** defines the first coordinate */
  76442. x: number;
  76443. /** defines the second coordinate */
  76444. y: number;
  76445. /**
  76446. * Creates a new Vector2 from the given x and y coordinates
  76447. * @param x defines the first coordinate
  76448. * @param y defines the second coordinate
  76449. */
  76450. constructor(
  76451. /** defines the first coordinate */
  76452. x?: number,
  76453. /** defines the second coordinate */
  76454. y?: number);
  76455. /**
  76456. * Gets a string with the Vector2 coordinates
  76457. * @returns a string with the Vector2 coordinates
  76458. */
  76459. toString(): string;
  76460. /**
  76461. * Gets class name
  76462. * @returns the string "Vector2"
  76463. */
  76464. getClassName(): string;
  76465. /**
  76466. * Gets current vector hash code
  76467. * @returns the Vector2 hash code as a number
  76468. */
  76469. getHashCode(): number;
  76470. /**
  76471. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  76472. * @param array defines the source array
  76473. * @param index defines the offset in source array
  76474. * @returns the current Vector2
  76475. */
  76476. toArray(array: FloatArray, index?: number): Vector2;
  76477. /**
  76478. * Copy the current vector to an array
  76479. * @returns a new array with 2 elements: the Vector2 coordinates.
  76480. */
  76481. asArray(): number[];
  76482. /**
  76483. * Sets the Vector2 coordinates with the given Vector2 coordinates
  76484. * @param source defines the source Vector2
  76485. * @returns the current updated Vector2
  76486. */
  76487. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  76488. /**
  76489. * Sets the Vector2 coordinates with the given floats
  76490. * @param x defines the first coordinate
  76491. * @param y defines the second coordinate
  76492. * @returns the current updated Vector2
  76493. */
  76494. copyFromFloats(x: number, y: number): Vector2;
  76495. /**
  76496. * Sets the Vector2 coordinates with the given floats
  76497. * @param x defines the first coordinate
  76498. * @param y defines the second coordinate
  76499. * @returns the current updated Vector2
  76500. */
  76501. set(x: number, y: number): Vector2;
  76502. /**
  76503. * Add another vector with the current one
  76504. * @param otherVector defines the other vector
  76505. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  76506. */
  76507. add(otherVector: DeepImmutable<Vector2>): Vector2;
  76508. /**
  76509. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  76510. * @param otherVector defines the other vector
  76511. * @param result defines the target vector
  76512. * @returns the unmodified current Vector2
  76513. */
  76514. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  76515. /**
  76516. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  76517. * @param otherVector defines the other vector
  76518. * @returns the current updated Vector2
  76519. */
  76520. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  76521. /**
  76522. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  76523. * @param otherVector defines the other vector
  76524. * @returns a new Vector2
  76525. */
  76526. addVector3(otherVector: Vector3): Vector2;
  76527. /**
  76528. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  76529. * @param otherVector defines the other vector
  76530. * @returns a new Vector2
  76531. */
  76532. subtract(otherVector: Vector2): Vector2;
  76533. /**
  76534. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  76535. * @param otherVector defines the other vector
  76536. * @param result defines the target vector
  76537. * @returns the unmodified current Vector2
  76538. */
  76539. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  76540. /**
  76541. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  76542. * @param otherVector defines the other vector
  76543. * @returns the current updated Vector2
  76544. */
  76545. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  76546. /**
  76547. * Multiplies in place the current Vector2 coordinates by the given ones
  76548. * @param otherVector defines the other vector
  76549. * @returns the current updated Vector2
  76550. */
  76551. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  76552. /**
  76553. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  76554. * @param otherVector defines the other vector
  76555. * @returns a new Vector2
  76556. */
  76557. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  76558. /**
  76559. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  76560. * @param otherVector defines the other vector
  76561. * @param result defines the target vector
  76562. * @returns the unmodified current Vector2
  76563. */
  76564. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  76565. /**
  76566. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  76567. * @param x defines the first coordinate
  76568. * @param y defines the second coordinate
  76569. * @returns a new Vector2
  76570. */
  76571. multiplyByFloats(x: number, y: number): Vector2;
  76572. /**
  76573. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  76574. * @param otherVector defines the other vector
  76575. * @returns a new Vector2
  76576. */
  76577. divide(otherVector: Vector2): Vector2;
  76578. /**
  76579. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  76580. * @param otherVector defines the other vector
  76581. * @param result defines the target vector
  76582. * @returns the unmodified current Vector2
  76583. */
  76584. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  76585. /**
  76586. * Divides the current Vector2 coordinates by the given ones
  76587. * @param otherVector defines the other vector
  76588. * @returns the current updated Vector2
  76589. */
  76590. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  76591. /**
  76592. * Gets a new Vector2 with current Vector2 negated coordinates
  76593. * @returns a new Vector2
  76594. */
  76595. negate(): Vector2;
  76596. /**
  76597. * Negate this vector in place
  76598. * @returns this
  76599. */
  76600. negateInPlace(): Vector2;
  76601. /**
  76602. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  76603. * @param result defines the Vector3 object where to store the result
  76604. * @returns the current Vector2
  76605. */
  76606. negateToRef(result: Vector2): Vector2;
  76607. /**
  76608. * Multiply the Vector2 coordinates by scale
  76609. * @param scale defines the scaling factor
  76610. * @returns the current updated Vector2
  76611. */
  76612. scaleInPlace(scale: number): Vector2;
  76613. /**
  76614. * Returns a new Vector2 scaled by "scale" from the current Vector2
  76615. * @param scale defines the scaling factor
  76616. * @returns a new Vector2
  76617. */
  76618. scale(scale: number): Vector2;
  76619. /**
  76620. * Scale the current Vector2 values by a factor to a given Vector2
  76621. * @param scale defines the scale factor
  76622. * @param result defines the Vector2 object where to store the result
  76623. * @returns the unmodified current Vector2
  76624. */
  76625. scaleToRef(scale: number, result: Vector2): Vector2;
  76626. /**
  76627. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  76628. * @param scale defines the scale factor
  76629. * @param result defines the Vector2 object where to store the result
  76630. * @returns the unmodified current Vector2
  76631. */
  76632. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  76633. /**
  76634. * Gets a boolean if two vectors are equals
  76635. * @param otherVector defines the other vector
  76636. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  76637. */
  76638. equals(otherVector: DeepImmutable<Vector2>): boolean;
  76639. /**
  76640. * Gets a boolean if two vectors are equals (using an epsilon value)
  76641. * @param otherVector defines the other vector
  76642. * @param epsilon defines the minimal distance to consider equality
  76643. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  76644. */
  76645. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  76646. /**
  76647. * Gets a new Vector2 from current Vector2 floored values
  76648. * @returns a new Vector2
  76649. */
  76650. floor(): Vector2;
  76651. /**
  76652. * Gets a new Vector2 from current Vector2 floored values
  76653. * @returns a new Vector2
  76654. */
  76655. fract(): Vector2;
  76656. /**
  76657. * Gets the length of the vector
  76658. * @returns the vector length (float)
  76659. */
  76660. length(): number;
  76661. /**
  76662. * Gets the vector squared length
  76663. * @returns the vector squared length (float)
  76664. */
  76665. lengthSquared(): number;
  76666. /**
  76667. * Normalize the vector
  76668. * @returns the current updated Vector2
  76669. */
  76670. normalize(): Vector2;
  76671. /**
  76672. * Gets a new Vector2 copied from the Vector2
  76673. * @returns a new Vector2
  76674. */
  76675. clone(): Vector2;
  76676. /**
  76677. * Gets a new Vector2(0, 0)
  76678. * @returns a new Vector2
  76679. */
  76680. static Zero(): Vector2;
  76681. /**
  76682. * Gets a new Vector2(1, 1)
  76683. * @returns a new Vector2
  76684. */
  76685. static One(): Vector2;
  76686. /**
  76687. * Gets a new Vector2 set from the given index element of the given array
  76688. * @param array defines the data source
  76689. * @param offset defines the offset in the data source
  76690. * @returns a new Vector2
  76691. */
  76692. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  76693. /**
  76694. * Sets "result" from the given index element of the given array
  76695. * @param array defines the data source
  76696. * @param offset defines the offset in the data source
  76697. * @param result defines the target vector
  76698. */
  76699. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  76700. /**
  76701. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  76702. * @param value1 defines 1st point of control
  76703. * @param value2 defines 2nd point of control
  76704. * @param value3 defines 3rd point of control
  76705. * @param value4 defines 4th point of control
  76706. * @param amount defines the interpolation factor
  76707. * @returns a new Vector2
  76708. */
  76709. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  76710. /**
  76711. * 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".
  76712. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  76713. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  76714. * @param value defines the value to clamp
  76715. * @param min defines the lower limit
  76716. * @param max defines the upper limit
  76717. * @returns a new Vector2
  76718. */
  76719. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  76720. /**
  76721. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  76722. * @param value1 defines the 1st control point
  76723. * @param tangent1 defines the outgoing tangent
  76724. * @param value2 defines the 2nd control point
  76725. * @param tangent2 defines the incoming tangent
  76726. * @param amount defines the interpolation factor
  76727. * @returns a new Vector2
  76728. */
  76729. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  76730. /**
  76731. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  76732. * @param start defines the start vector
  76733. * @param end defines the end vector
  76734. * @param amount defines the interpolation factor
  76735. * @returns a new Vector2
  76736. */
  76737. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  76738. /**
  76739. * Gets the dot product of the vector "left" and the vector "right"
  76740. * @param left defines first vector
  76741. * @param right defines second vector
  76742. * @returns the dot product (float)
  76743. */
  76744. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  76745. /**
  76746. * Returns a new Vector2 equal to the normalized given vector
  76747. * @param vector defines the vector to normalize
  76748. * @returns a new Vector2
  76749. */
  76750. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  76751. /**
  76752. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  76753. * @param left defines 1st vector
  76754. * @param right defines 2nd vector
  76755. * @returns a new Vector2
  76756. */
  76757. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  76758. /**
  76759. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  76760. * @param left defines 1st vector
  76761. * @param right defines 2nd vector
  76762. * @returns a new Vector2
  76763. */
  76764. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  76765. /**
  76766. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  76767. * @param vector defines the vector to transform
  76768. * @param transformation defines the matrix to apply
  76769. * @returns a new Vector2
  76770. */
  76771. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  76772. /**
  76773. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  76774. * @param vector defines the vector to transform
  76775. * @param transformation defines the matrix to apply
  76776. * @param result defines the target vector
  76777. */
  76778. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  76779. /**
  76780. * Determines if a given vector is included in a triangle
  76781. * @param p defines the vector to test
  76782. * @param p0 defines 1st triangle point
  76783. * @param p1 defines 2nd triangle point
  76784. * @param p2 defines 3rd triangle point
  76785. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  76786. */
  76787. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  76788. /**
  76789. * Gets the distance between the vectors "value1" and "value2"
  76790. * @param value1 defines first vector
  76791. * @param value2 defines second vector
  76792. * @returns the distance between vectors
  76793. */
  76794. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  76795. /**
  76796. * Returns the squared distance between the vectors "value1" and "value2"
  76797. * @param value1 defines first vector
  76798. * @param value2 defines second vector
  76799. * @returns the squared distance between vectors
  76800. */
  76801. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  76802. /**
  76803. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  76804. * @param value1 defines first vector
  76805. * @param value2 defines second vector
  76806. * @returns a new Vector2
  76807. */
  76808. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  76809. /**
  76810. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  76811. * @param p defines the middle point
  76812. * @param segA defines one point of the segment
  76813. * @param segB defines the other point of the segment
  76814. * @returns the shortest distance
  76815. */
  76816. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  76817. }
  76818. /**
  76819. * Class used to store (x,y,z) vector representation
  76820. * A Vector3 is the main object used in 3D geometry
  76821. * It can represent etiher the coordinates of a point the space, either a direction
  76822. * Reminder: js uses a left handed forward facing system
  76823. */
  76824. export class Vector3 {
  76825. /**
  76826. * Defines the first coordinates (on X axis)
  76827. */
  76828. x: number;
  76829. /**
  76830. * Defines the second coordinates (on Y axis)
  76831. */
  76832. y: number;
  76833. /**
  76834. * Defines the third coordinates (on Z axis)
  76835. */
  76836. z: number;
  76837. private static _UpReadOnly;
  76838. private static _ZeroReadOnly;
  76839. /**
  76840. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  76841. * @param x defines the first coordinates (on X axis)
  76842. * @param y defines the second coordinates (on Y axis)
  76843. * @param z defines the third coordinates (on Z axis)
  76844. */
  76845. constructor(
  76846. /**
  76847. * Defines the first coordinates (on X axis)
  76848. */
  76849. x?: number,
  76850. /**
  76851. * Defines the second coordinates (on Y axis)
  76852. */
  76853. y?: number,
  76854. /**
  76855. * Defines the third coordinates (on Z axis)
  76856. */
  76857. z?: number);
  76858. /**
  76859. * Creates a string representation of the Vector3
  76860. * @returns a string with the Vector3 coordinates.
  76861. */
  76862. toString(): string;
  76863. /**
  76864. * Gets the class name
  76865. * @returns the string "Vector3"
  76866. */
  76867. getClassName(): string;
  76868. /**
  76869. * Creates the Vector3 hash code
  76870. * @returns a number which tends to be unique between Vector3 instances
  76871. */
  76872. getHashCode(): number;
  76873. /**
  76874. * Creates an array containing three elements : the coordinates of the Vector3
  76875. * @returns a new array of numbers
  76876. */
  76877. asArray(): number[];
  76878. /**
  76879. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  76880. * @param array defines the destination array
  76881. * @param index defines the offset in the destination array
  76882. * @returns the current Vector3
  76883. */
  76884. toArray(array: FloatArray, index?: number): Vector3;
  76885. /**
  76886. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  76887. * @returns a new Quaternion object, computed from the Vector3 coordinates
  76888. */
  76889. toQuaternion(): Quaternion;
  76890. /**
  76891. * Adds the given vector to the current Vector3
  76892. * @param otherVector defines the second operand
  76893. * @returns the current updated Vector3
  76894. */
  76895. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  76896. /**
  76897. * Adds the given coordinates to the current Vector3
  76898. * @param x defines the x coordinate of the operand
  76899. * @param y defines the y coordinate of the operand
  76900. * @param z defines the z coordinate of the operand
  76901. * @returns the current updated Vector3
  76902. */
  76903. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  76904. /**
  76905. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  76906. * @param otherVector defines the second operand
  76907. * @returns the resulting Vector3
  76908. */
  76909. add(otherVector: DeepImmutable<Vector3>): Vector3;
  76910. /**
  76911. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  76912. * @param otherVector defines the second operand
  76913. * @param result defines the Vector3 object where to store the result
  76914. * @returns the current Vector3
  76915. */
  76916. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76917. /**
  76918. * Subtract the given vector from the current Vector3
  76919. * @param otherVector defines the second operand
  76920. * @returns the current updated Vector3
  76921. */
  76922. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  76923. /**
  76924. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  76925. * @param otherVector defines the second operand
  76926. * @returns the resulting Vector3
  76927. */
  76928. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  76929. /**
  76930. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  76931. * @param otherVector defines the second operand
  76932. * @param result defines the Vector3 object where to store the result
  76933. * @returns the current Vector3
  76934. */
  76935. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76936. /**
  76937. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  76938. * @param x defines the x coordinate of the operand
  76939. * @param y defines the y coordinate of the operand
  76940. * @param z defines the z coordinate of the operand
  76941. * @returns the resulting Vector3
  76942. */
  76943. subtractFromFloats(x: number, y: number, z: number): Vector3;
  76944. /**
  76945. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  76946. * @param x defines the x coordinate of the operand
  76947. * @param y defines the y coordinate of the operand
  76948. * @param z defines the z coordinate of the operand
  76949. * @param result defines the Vector3 object where to store the result
  76950. * @returns the current Vector3
  76951. */
  76952. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  76953. /**
  76954. * Gets a new Vector3 set with the current Vector3 negated coordinates
  76955. * @returns a new Vector3
  76956. */
  76957. negate(): Vector3;
  76958. /**
  76959. * Negate this vector in place
  76960. * @returns this
  76961. */
  76962. negateInPlace(): Vector3;
  76963. /**
  76964. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  76965. * @param result defines the Vector3 object where to store the result
  76966. * @returns the current Vector3
  76967. */
  76968. negateToRef(result: Vector3): Vector3;
  76969. /**
  76970. * Multiplies the Vector3 coordinates by the float "scale"
  76971. * @param scale defines the multiplier factor
  76972. * @returns the current updated Vector3
  76973. */
  76974. scaleInPlace(scale: number): Vector3;
  76975. /**
  76976. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  76977. * @param scale defines the multiplier factor
  76978. * @returns a new Vector3
  76979. */
  76980. scale(scale: number): Vector3;
  76981. /**
  76982. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  76983. * @param scale defines the multiplier factor
  76984. * @param result defines the Vector3 object where to store the result
  76985. * @returns the current Vector3
  76986. */
  76987. scaleToRef(scale: number, result: Vector3): Vector3;
  76988. /**
  76989. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  76990. * @param scale defines the scale factor
  76991. * @param result defines the Vector3 object where to store the result
  76992. * @returns the unmodified current Vector3
  76993. */
  76994. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  76995. /**
  76996. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  76997. * @param otherVector defines the second operand
  76998. * @returns true if both vectors are equals
  76999. */
  77000. equals(otherVector: DeepImmutable<Vector3>): boolean;
  77001. /**
  77002. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  77003. * @param otherVector defines the second operand
  77004. * @param epsilon defines the minimal distance to define values as equals
  77005. * @returns true if both vectors are distant less than epsilon
  77006. */
  77007. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  77008. /**
  77009. * Returns true if the current Vector3 coordinates equals the given floats
  77010. * @param x defines the x coordinate of the operand
  77011. * @param y defines the y coordinate of the operand
  77012. * @param z defines the z coordinate of the operand
  77013. * @returns true if both vectors are equals
  77014. */
  77015. equalsToFloats(x: number, y: number, z: number): boolean;
  77016. /**
  77017. * Multiplies the current Vector3 coordinates by the given ones
  77018. * @param otherVector defines the second operand
  77019. * @returns the current updated Vector3
  77020. */
  77021. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  77022. /**
  77023. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  77024. * @param otherVector defines the second operand
  77025. * @returns the new Vector3
  77026. */
  77027. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  77028. /**
  77029. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  77030. * @param otherVector defines the second operand
  77031. * @param result defines the Vector3 object where to store the result
  77032. * @returns the current Vector3
  77033. */
  77034. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  77035. /**
  77036. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  77037. * @param x defines the x coordinate of the operand
  77038. * @param y defines the y coordinate of the operand
  77039. * @param z defines the z coordinate of the operand
  77040. * @returns the new Vector3
  77041. */
  77042. multiplyByFloats(x: number, y: number, z: number): Vector3;
  77043. /**
  77044. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  77045. * @param otherVector defines the second operand
  77046. * @returns the new Vector3
  77047. */
  77048. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  77049. /**
  77050. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  77051. * @param otherVector defines the second operand
  77052. * @param result defines the Vector3 object where to store the result
  77053. * @returns the current Vector3
  77054. */
  77055. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  77056. /**
  77057. * Divides the current Vector3 coordinates by the given ones.
  77058. * @param otherVector defines the second operand
  77059. * @returns the current updated Vector3
  77060. */
  77061. divideInPlace(otherVector: Vector3): Vector3;
  77062. /**
  77063. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  77064. * @param other defines the second operand
  77065. * @returns the current updated Vector3
  77066. */
  77067. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  77068. /**
  77069. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  77070. * @param other defines the second operand
  77071. * @returns the current updated Vector3
  77072. */
  77073. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  77074. /**
  77075. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  77076. * @param x defines the x coordinate of the operand
  77077. * @param y defines the y coordinate of the operand
  77078. * @param z defines the z coordinate of the operand
  77079. * @returns the current updated Vector3
  77080. */
  77081. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  77082. /**
  77083. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  77084. * @param x defines the x coordinate of the operand
  77085. * @param y defines the y coordinate of the operand
  77086. * @param z defines the z coordinate of the operand
  77087. * @returns the current updated Vector3
  77088. */
  77089. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  77090. /**
  77091. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  77092. * Check if is non uniform within a certain amount of decimal places to account for this
  77093. * @param epsilon the amount the values can differ
  77094. * @returns if the the vector is non uniform to a certain number of decimal places
  77095. */
  77096. isNonUniformWithinEpsilon(epsilon: number): boolean;
  77097. /**
  77098. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  77099. */
  77100. get isNonUniform(): boolean;
  77101. /**
  77102. * Gets a new Vector3 from current Vector3 floored values
  77103. * @returns a new Vector3
  77104. */
  77105. floor(): Vector3;
  77106. /**
  77107. * Gets a new Vector3 from current Vector3 floored values
  77108. * @returns a new Vector3
  77109. */
  77110. fract(): Vector3;
  77111. /**
  77112. * Gets the length of the Vector3
  77113. * @returns the length of the Vector3
  77114. */
  77115. length(): number;
  77116. /**
  77117. * Gets the squared length of the Vector3
  77118. * @returns squared length of the Vector3
  77119. */
  77120. lengthSquared(): number;
  77121. /**
  77122. * Normalize the current Vector3.
  77123. * Please note that this is an in place operation.
  77124. * @returns the current updated Vector3
  77125. */
  77126. normalize(): Vector3;
  77127. /**
  77128. * Reorders the x y z properties of the vector in place
  77129. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  77130. * @returns the current updated vector
  77131. */
  77132. reorderInPlace(order: string): this;
  77133. /**
  77134. * Rotates the vector around 0,0,0 by a quaternion
  77135. * @param quaternion the rotation quaternion
  77136. * @param result vector to store the result
  77137. * @returns the resulting vector
  77138. */
  77139. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  77140. /**
  77141. * Rotates a vector around a given point
  77142. * @param quaternion the rotation quaternion
  77143. * @param point the point to rotate around
  77144. * @param result vector to store the result
  77145. * @returns the resulting vector
  77146. */
  77147. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  77148. /**
  77149. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  77150. * The cross product is then orthogonal to both current and "other"
  77151. * @param other defines the right operand
  77152. * @returns the cross product
  77153. */
  77154. cross(other: Vector3): Vector3;
  77155. /**
  77156. * Normalize the current Vector3 with the given input length.
  77157. * Please note that this is an in place operation.
  77158. * @param len the length of the vector
  77159. * @returns the current updated Vector3
  77160. */
  77161. normalizeFromLength(len: number): Vector3;
  77162. /**
  77163. * Normalize the current Vector3 to a new vector
  77164. * @returns the new Vector3
  77165. */
  77166. normalizeToNew(): Vector3;
  77167. /**
  77168. * Normalize the current Vector3 to the reference
  77169. * @param reference define the Vector3 to update
  77170. * @returns the updated Vector3
  77171. */
  77172. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  77173. /**
  77174. * Creates a new Vector3 copied from the current Vector3
  77175. * @returns the new Vector3
  77176. */
  77177. clone(): Vector3;
  77178. /**
  77179. * Copies the given vector coordinates to the current Vector3 ones
  77180. * @param source defines the source Vector3
  77181. * @returns the current updated Vector3
  77182. */
  77183. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  77184. /**
  77185. * Copies the given floats to the current Vector3 coordinates
  77186. * @param x defines the x coordinate of the operand
  77187. * @param y defines the y coordinate of the operand
  77188. * @param z defines the z coordinate of the operand
  77189. * @returns the current updated Vector3
  77190. */
  77191. copyFromFloats(x: number, y: number, z: number): Vector3;
  77192. /**
  77193. * Copies the given floats to the current Vector3 coordinates
  77194. * @param x defines the x coordinate of the operand
  77195. * @param y defines the y coordinate of the operand
  77196. * @param z defines the z coordinate of the operand
  77197. * @returns the current updated Vector3
  77198. */
  77199. set(x: number, y: number, z: number): Vector3;
  77200. /**
  77201. * Copies the given float to the current Vector3 coordinates
  77202. * @param v defines the x, y and z coordinates of the operand
  77203. * @returns the current updated Vector3
  77204. */
  77205. setAll(v: number): Vector3;
  77206. /**
  77207. * Get the clip factor between two vectors
  77208. * @param vector0 defines the first operand
  77209. * @param vector1 defines the second operand
  77210. * @param axis defines the axis to use
  77211. * @param size defines the size along the axis
  77212. * @returns the clip factor
  77213. */
  77214. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  77215. /**
  77216. * Get angle between two vectors
  77217. * @param vector0 angle between vector0 and vector1
  77218. * @param vector1 angle between vector0 and vector1
  77219. * @param normal direction of the normal
  77220. * @return the angle between vector0 and vector1
  77221. */
  77222. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  77223. /**
  77224. * Returns a new Vector3 set from the index "offset" of the given array
  77225. * @param array defines the source array
  77226. * @param offset defines the offset in the source array
  77227. * @returns the new Vector3
  77228. */
  77229. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  77230. /**
  77231. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  77232. * @param array defines the source array
  77233. * @param offset defines the offset in the source array
  77234. * @returns the new Vector3
  77235. * @deprecated Please use FromArray instead.
  77236. */
  77237. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  77238. /**
  77239. * Sets the given vector "result" with the element values from the index "offset" of the given array
  77240. * @param array defines the source array
  77241. * @param offset defines the offset in the source array
  77242. * @param result defines the Vector3 where to store the result
  77243. */
  77244. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  77245. /**
  77246. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  77247. * @param array defines the source array
  77248. * @param offset defines the offset in the source array
  77249. * @param result defines the Vector3 where to store the result
  77250. * @deprecated Please use FromArrayToRef instead.
  77251. */
  77252. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  77253. /**
  77254. * Sets the given vector "result" with the given floats.
  77255. * @param x defines the x coordinate of the source
  77256. * @param y defines the y coordinate of the source
  77257. * @param z defines the z coordinate of the source
  77258. * @param result defines the Vector3 where to store the result
  77259. */
  77260. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  77261. /**
  77262. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  77263. * @returns a new empty Vector3
  77264. */
  77265. static Zero(): Vector3;
  77266. /**
  77267. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  77268. * @returns a new unit Vector3
  77269. */
  77270. static One(): Vector3;
  77271. /**
  77272. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  77273. * @returns a new up Vector3
  77274. */
  77275. static Up(): Vector3;
  77276. /**
  77277. * Gets a up Vector3 that must not be updated
  77278. */
  77279. static get UpReadOnly(): DeepImmutable<Vector3>;
  77280. /**
  77281. * Gets a zero Vector3 that must not be updated
  77282. */
  77283. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  77284. /**
  77285. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  77286. * @returns a new down Vector3
  77287. */
  77288. static Down(): Vector3;
  77289. /**
  77290. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  77291. * @param rightHandedSystem is the scene right-handed (negative z)
  77292. * @returns a new forward Vector3
  77293. */
  77294. static Forward(rightHandedSystem?: boolean): Vector3;
  77295. /**
  77296. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  77297. * @param rightHandedSystem is the scene right-handed (negative-z)
  77298. * @returns a new forward Vector3
  77299. */
  77300. static Backward(rightHandedSystem?: boolean): Vector3;
  77301. /**
  77302. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  77303. * @returns a new right Vector3
  77304. */
  77305. static Right(): Vector3;
  77306. /**
  77307. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  77308. * @returns a new left Vector3
  77309. */
  77310. static Left(): Vector3;
  77311. /**
  77312. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  77313. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  77314. * @param vector defines the Vector3 to transform
  77315. * @param transformation defines the transformation matrix
  77316. * @returns the transformed Vector3
  77317. */
  77318. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  77319. /**
  77320. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  77321. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  77322. * @param vector defines the Vector3 to transform
  77323. * @param transformation defines the transformation matrix
  77324. * @param result defines the Vector3 where to store the result
  77325. */
  77326. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  77327. /**
  77328. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  77329. * This method computes tranformed coordinates only, not transformed direction vectors
  77330. * @param x define the x coordinate of the source vector
  77331. * @param y define the y coordinate of the source vector
  77332. * @param z define the z coordinate of the source vector
  77333. * @param transformation defines the transformation matrix
  77334. * @param result defines the Vector3 where to store the result
  77335. */
  77336. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  77337. /**
  77338. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  77339. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  77340. * @param vector defines the Vector3 to transform
  77341. * @param transformation defines the transformation matrix
  77342. * @returns the new Vector3
  77343. */
  77344. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  77345. /**
  77346. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  77347. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  77348. * @param vector defines the Vector3 to transform
  77349. * @param transformation defines the transformation matrix
  77350. * @param result defines the Vector3 where to store the result
  77351. */
  77352. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  77353. /**
  77354. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  77355. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  77356. * @param x define the x coordinate of the source vector
  77357. * @param y define the y coordinate of the source vector
  77358. * @param z define the z coordinate of the source vector
  77359. * @param transformation defines the transformation matrix
  77360. * @param result defines the Vector3 where to store the result
  77361. */
  77362. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  77363. /**
  77364. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  77365. * @param value1 defines the first control point
  77366. * @param value2 defines the second control point
  77367. * @param value3 defines the third control point
  77368. * @param value4 defines the fourth control point
  77369. * @param amount defines the amount on the spline to use
  77370. * @returns the new Vector3
  77371. */
  77372. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  77373. /**
  77374. * 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"
  77375. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  77376. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  77377. * @param value defines the current value
  77378. * @param min defines the lower range value
  77379. * @param max defines the upper range value
  77380. * @returns the new Vector3
  77381. */
  77382. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  77383. /**
  77384. * 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"
  77385. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  77386. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  77387. * @param value defines the current value
  77388. * @param min defines the lower range value
  77389. * @param max defines the upper range value
  77390. * @param result defines the Vector3 where to store the result
  77391. */
  77392. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  77393. /**
  77394. * Checks if a given vector is inside a specific range
  77395. * @param v defines the vector to test
  77396. * @param min defines the minimum range
  77397. * @param max defines the maximum range
  77398. */
  77399. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  77400. /**
  77401. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  77402. * @param value1 defines the first control point
  77403. * @param tangent1 defines the first tangent vector
  77404. * @param value2 defines the second control point
  77405. * @param tangent2 defines the second tangent vector
  77406. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  77407. * @returns the new Vector3
  77408. */
  77409. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  77410. /**
  77411. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  77412. * @param start defines the start value
  77413. * @param end defines the end value
  77414. * @param amount max defines amount between both (between 0 and 1)
  77415. * @returns the new Vector3
  77416. */
  77417. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  77418. /**
  77419. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  77420. * @param start defines the start value
  77421. * @param end defines the end value
  77422. * @param amount max defines amount between both (between 0 and 1)
  77423. * @param result defines the Vector3 where to store the result
  77424. */
  77425. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  77426. /**
  77427. * Returns the dot product (float) between the vectors "left" and "right"
  77428. * @param left defines the left operand
  77429. * @param right defines the right operand
  77430. * @returns the dot product
  77431. */
  77432. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  77433. /**
  77434. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  77435. * The cross product is then orthogonal to both "left" and "right"
  77436. * @param left defines the left operand
  77437. * @param right defines the right operand
  77438. * @returns the cross product
  77439. */
  77440. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  77441. /**
  77442. * Sets the given vector "result" with the cross product of "left" and "right"
  77443. * The cross product is then orthogonal to both "left" and "right"
  77444. * @param left defines the left operand
  77445. * @param right defines the right operand
  77446. * @param result defines the Vector3 where to store the result
  77447. */
  77448. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  77449. /**
  77450. * Returns a new Vector3 as the normalization of the given vector
  77451. * @param vector defines the Vector3 to normalize
  77452. * @returns the new Vector3
  77453. */
  77454. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  77455. /**
  77456. * Sets the given vector "result" with the normalization of the given first vector
  77457. * @param vector defines the Vector3 to normalize
  77458. * @param result defines the Vector3 where to store the result
  77459. */
  77460. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  77461. /**
  77462. * Project a Vector3 onto screen space
  77463. * @param vector defines the Vector3 to project
  77464. * @param world defines the world matrix to use
  77465. * @param transform defines the transform (view x projection) matrix to use
  77466. * @param viewport defines the screen viewport to use
  77467. * @returns the new Vector3
  77468. */
  77469. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  77470. /** @hidden */
  77471. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  77472. /**
  77473. * Unproject from screen space to object space
  77474. * @param source defines the screen space Vector3 to use
  77475. * @param viewportWidth defines the current width of the viewport
  77476. * @param viewportHeight defines the current height of the viewport
  77477. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77478. * @param transform defines the transform (view x projection) matrix to use
  77479. * @returns the new Vector3
  77480. */
  77481. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  77482. /**
  77483. * Unproject from screen space to object space
  77484. * @param source defines the screen space Vector3 to use
  77485. * @param viewportWidth defines the current width of the viewport
  77486. * @param viewportHeight defines the current height of the viewport
  77487. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77488. * @param view defines the view matrix to use
  77489. * @param projection defines the projection matrix to use
  77490. * @returns the new Vector3
  77491. */
  77492. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  77493. /**
  77494. * Unproject from screen space to object space
  77495. * @param source defines the screen space Vector3 to use
  77496. * @param viewportWidth defines the current width of the viewport
  77497. * @param viewportHeight defines the current height of the viewport
  77498. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77499. * @param view defines the view matrix to use
  77500. * @param projection defines the projection matrix to use
  77501. * @param result defines the Vector3 where to store the result
  77502. */
  77503. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  77504. /**
  77505. * Unproject from screen space to object space
  77506. * @param sourceX defines the screen space x coordinate to use
  77507. * @param sourceY defines the screen space y coordinate to use
  77508. * @param sourceZ defines the screen space z coordinate to use
  77509. * @param viewportWidth defines the current width of the viewport
  77510. * @param viewportHeight defines the current height of the viewport
  77511. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77512. * @param view defines the view matrix to use
  77513. * @param projection defines the projection matrix to use
  77514. * @param result defines the Vector3 where to store the result
  77515. */
  77516. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  77517. /**
  77518. * Gets the minimal coordinate values between two Vector3
  77519. * @param left defines the first operand
  77520. * @param right defines the second operand
  77521. * @returns the new Vector3
  77522. */
  77523. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  77524. /**
  77525. * Gets the maximal coordinate values between two Vector3
  77526. * @param left defines the first operand
  77527. * @param right defines the second operand
  77528. * @returns the new Vector3
  77529. */
  77530. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  77531. /**
  77532. * Returns the distance between the vectors "value1" and "value2"
  77533. * @param value1 defines the first operand
  77534. * @param value2 defines the second operand
  77535. * @returns the distance
  77536. */
  77537. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  77538. /**
  77539. * Returns the squared distance between the vectors "value1" and "value2"
  77540. * @param value1 defines the first operand
  77541. * @param value2 defines the second operand
  77542. * @returns the squared distance
  77543. */
  77544. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  77545. /**
  77546. * Returns a new Vector3 located at the center between "value1" and "value2"
  77547. * @param value1 defines the first operand
  77548. * @param value2 defines the second operand
  77549. * @returns the new Vector3
  77550. */
  77551. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  77552. /**
  77553. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  77554. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  77555. * to something in order to rotate it from its local system to the given target system
  77556. * Note: axis1, axis2 and axis3 are normalized during this operation
  77557. * @param axis1 defines the first axis
  77558. * @param axis2 defines the second axis
  77559. * @param axis3 defines the third axis
  77560. * @returns a new Vector3
  77561. */
  77562. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  77563. /**
  77564. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  77565. * @param axis1 defines the first axis
  77566. * @param axis2 defines the second axis
  77567. * @param axis3 defines the third axis
  77568. * @param ref defines the Vector3 where to store the result
  77569. */
  77570. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  77571. }
  77572. /**
  77573. * Vector4 class created for EulerAngle class conversion to Quaternion
  77574. */
  77575. export class Vector4 {
  77576. /** x value of the vector */
  77577. x: number;
  77578. /** y value of the vector */
  77579. y: number;
  77580. /** z value of the vector */
  77581. z: number;
  77582. /** w value of the vector */
  77583. w: number;
  77584. /**
  77585. * Creates a Vector4 object from the given floats.
  77586. * @param x x value of the vector
  77587. * @param y y value of the vector
  77588. * @param z z value of the vector
  77589. * @param w w value of the vector
  77590. */
  77591. constructor(
  77592. /** x value of the vector */
  77593. x: number,
  77594. /** y value of the vector */
  77595. y: number,
  77596. /** z value of the vector */
  77597. z: number,
  77598. /** w value of the vector */
  77599. w: number);
  77600. /**
  77601. * Returns the string with the Vector4 coordinates.
  77602. * @returns a string containing all the vector values
  77603. */
  77604. toString(): string;
  77605. /**
  77606. * Returns the string "Vector4".
  77607. * @returns "Vector4"
  77608. */
  77609. getClassName(): string;
  77610. /**
  77611. * Returns the Vector4 hash code.
  77612. * @returns a unique hash code
  77613. */
  77614. getHashCode(): number;
  77615. /**
  77616. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  77617. * @returns the resulting array
  77618. */
  77619. asArray(): number[];
  77620. /**
  77621. * Populates the given array from the given index with the Vector4 coordinates.
  77622. * @param array array to populate
  77623. * @param index index of the array to start at (default: 0)
  77624. * @returns the Vector4.
  77625. */
  77626. toArray(array: FloatArray, index?: number): Vector4;
  77627. /**
  77628. * Adds the given vector to the current Vector4.
  77629. * @param otherVector the vector to add
  77630. * @returns the updated Vector4.
  77631. */
  77632. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  77633. /**
  77634. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  77635. * @param otherVector the vector to add
  77636. * @returns the resulting vector
  77637. */
  77638. add(otherVector: DeepImmutable<Vector4>): Vector4;
  77639. /**
  77640. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  77641. * @param otherVector the vector to add
  77642. * @param result the vector to store the result
  77643. * @returns the current Vector4.
  77644. */
  77645. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  77646. /**
  77647. * Subtract in place the given vector from the current Vector4.
  77648. * @param otherVector the vector to subtract
  77649. * @returns the updated Vector4.
  77650. */
  77651. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  77652. /**
  77653. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  77654. * @param otherVector the vector to add
  77655. * @returns the new vector with the result
  77656. */
  77657. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  77658. /**
  77659. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  77660. * @param otherVector the vector to subtract
  77661. * @param result the vector to store the result
  77662. * @returns the current Vector4.
  77663. */
  77664. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  77665. /**
  77666. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  77667. */
  77668. /**
  77669. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  77670. * @param x value to subtract
  77671. * @param y value to subtract
  77672. * @param z value to subtract
  77673. * @param w value to subtract
  77674. * @returns new vector containing the result
  77675. */
  77676. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  77677. /**
  77678. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  77679. * @param x value to subtract
  77680. * @param y value to subtract
  77681. * @param z value to subtract
  77682. * @param w value to subtract
  77683. * @param result the vector to store the result in
  77684. * @returns the current Vector4.
  77685. */
  77686. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  77687. /**
  77688. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  77689. * @returns a new vector with the negated values
  77690. */
  77691. negate(): Vector4;
  77692. /**
  77693. * Negate this vector in place
  77694. * @returns this
  77695. */
  77696. negateInPlace(): Vector4;
  77697. /**
  77698. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  77699. * @param result defines the Vector3 object where to store the result
  77700. * @returns the current Vector4
  77701. */
  77702. negateToRef(result: Vector4): Vector4;
  77703. /**
  77704. * Multiplies the current Vector4 coordinates by scale (float).
  77705. * @param scale the number to scale with
  77706. * @returns the updated Vector4.
  77707. */
  77708. scaleInPlace(scale: number): Vector4;
  77709. /**
  77710. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  77711. * @param scale the number to scale with
  77712. * @returns a new vector with the result
  77713. */
  77714. scale(scale: number): Vector4;
  77715. /**
  77716. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  77717. * @param scale the number to scale with
  77718. * @param result a vector to store the result in
  77719. * @returns the current Vector4.
  77720. */
  77721. scaleToRef(scale: number, result: Vector4): Vector4;
  77722. /**
  77723. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  77724. * @param scale defines the scale factor
  77725. * @param result defines the Vector4 object where to store the result
  77726. * @returns the unmodified current Vector4
  77727. */
  77728. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  77729. /**
  77730. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  77731. * @param otherVector the vector to compare against
  77732. * @returns true if they are equal
  77733. */
  77734. equals(otherVector: DeepImmutable<Vector4>): boolean;
  77735. /**
  77736. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  77737. * @param otherVector vector to compare against
  77738. * @param epsilon (Default: very small number)
  77739. * @returns true if they are equal
  77740. */
  77741. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  77742. /**
  77743. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  77744. * @param x x value to compare against
  77745. * @param y y value to compare against
  77746. * @param z z value to compare against
  77747. * @param w w value to compare against
  77748. * @returns true if equal
  77749. */
  77750. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  77751. /**
  77752. * Multiplies in place the current Vector4 by the given one.
  77753. * @param otherVector vector to multiple with
  77754. * @returns the updated Vector4.
  77755. */
  77756. multiplyInPlace(otherVector: Vector4): Vector4;
  77757. /**
  77758. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  77759. * @param otherVector vector to multiple with
  77760. * @returns resulting new vector
  77761. */
  77762. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  77763. /**
  77764. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  77765. * @param otherVector vector to multiple with
  77766. * @param result vector to store the result
  77767. * @returns the current Vector4.
  77768. */
  77769. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  77770. /**
  77771. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  77772. * @param x x value multiply with
  77773. * @param y y value multiply with
  77774. * @param z z value multiply with
  77775. * @param w w value multiply with
  77776. * @returns resulting new vector
  77777. */
  77778. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  77779. /**
  77780. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  77781. * @param otherVector vector to devide with
  77782. * @returns resulting new vector
  77783. */
  77784. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  77785. /**
  77786. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  77787. * @param otherVector vector to devide with
  77788. * @param result vector to store the result
  77789. * @returns the current Vector4.
  77790. */
  77791. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  77792. /**
  77793. * Divides the current Vector3 coordinates by the given ones.
  77794. * @param otherVector vector to devide with
  77795. * @returns the updated Vector3.
  77796. */
  77797. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  77798. /**
  77799. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  77800. * @param other defines the second operand
  77801. * @returns the current updated Vector4
  77802. */
  77803. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  77804. /**
  77805. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  77806. * @param other defines the second operand
  77807. * @returns the current updated Vector4
  77808. */
  77809. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  77810. /**
  77811. * Gets a new Vector4 from current Vector4 floored values
  77812. * @returns a new Vector4
  77813. */
  77814. floor(): Vector4;
  77815. /**
  77816. * Gets a new Vector4 from current Vector3 floored values
  77817. * @returns a new Vector4
  77818. */
  77819. fract(): Vector4;
  77820. /**
  77821. * Returns the Vector4 length (float).
  77822. * @returns the length
  77823. */
  77824. length(): number;
  77825. /**
  77826. * Returns the Vector4 squared length (float).
  77827. * @returns the length squared
  77828. */
  77829. lengthSquared(): number;
  77830. /**
  77831. * Normalizes in place the Vector4.
  77832. * @returns the updated Vector4.
  77833. */
  77834. normalize(): Vector4;
  77835. /**
  77836. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  77837. * @returns this converted to a new vector3
  77838. */
  77839. toVector3(): Vector3;
  77840. /**
  77841. * Returns a new Vector4 copied from the current one.
  77842. * @returns the new cloned vector
  77843. */
  77844. clone(): Vector4;
  77845. /**
  77846. * Updates the current Vector4 with the given one coordinates.
  77847. * @param source the source vector to copy from
  77848. * @returns the updated Vector4.
  77849. */
  77850. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  77851. /**
  77852. * Updates the current Vector4 coordinates with the given floats.
  77853. * @param x float to copy from
  77854. * @param y float to copy from
  77855. * @param z float to copy from
  77856. * @param w float to copy from
  77857. * @returns the updated Vector4.
  77858. */
  77859. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  77860. /**
  77861. * Updates the current Vector4 coordinates with the given floats.
  77862. * @param x float to set from
  77863. * @param y float to set from
  77864. * @param z float to set from
  77865. * @param w float to set from
  77866. * @returns the updated Vector4.
  77867. */
  77868. set(x: number, y: number, z: number, w: number): Vector4;
  77869. /**
  77870. * Copies the given float to the current Vector3 coordinates
  77871. * @param v defines the x, y, z and w coordinates of the operand
  77872. * @returns the current updated Vector3
  77873. */
  77874. setAll(v: number): Vector4;
  77875. /**
  77876. * Returns a new Vector4 set from the starting index of the given array.
  77877. * @param array the array to pull values from
  77878. * @param offset the offset into the array to start at
  77879. * @returns the new vector
  77880. */
  77881. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  77882. /**
  77883. * Updates the given vector "result" from the starting index of the given array.
  77884. * @param array the array to pull values from
  77885. * @param offset the offset into the array to start at
  77886. * @param result the vector to store the result in
  77887. */
  77888. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  77889. /**
  77890. * Updates the given vector "result" from the starting index of the given Float32Array.
  77891. * @param array the array to pull values from
  77892. * @param offset the offset into the array to start at
  77893. * @param result the vector to store the result in
  77894. */
  77895. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  77896. /**
  77897. * Updates the given vector "result" coordinates from the given floats.
  77898. * @param x float to set from
  77899. * @param y float to set from
  77900. * @param z float to set from
  77901. * @param w float to set from
  77902. * @param result the vector to the floats in
  77903. */
  77904. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  77905. /**
  77906. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  77907. * @returns the new vector
  77908. */
  77909. static Zero(): Vector4;
  77910. /**
  77911. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  77912. * @returns the new vector
  77913. */
  77914. static One(): Vector4;
  77915. /**
  77916. * Returns a new normalized Vector4 from the given one.
  77917. * @param vector the vector to normalize
  77918. * @returns the vector
  77919. */
  77920. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  77921. /**
  77922. * Updates the given vector "result" from the normalization of the given one.
  77923. * @param vector the vector to normalize
  77924. * @param result the vector to store the result in
  77925. */
  77926. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  77927. /**
  77928. * Returns a vector with the minimum values from the left and right vectors
  77929. * @param left left vector to minimize
  77930. * @param right right vector to minimize
  77931. * @returns a new vector with the minimum of the left and right vector values
  77932. */
  77933. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  77934. /**
  77935. * Returns a vector with the maximum values from the left and right vectors
  77936. * @param left left vector to maximize
  77937. * @param right right vector to maximize
  77938. * @returns a new vector with the maximum of the left and right vector values
  77939. */
  77940. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  77941. /**
  77942. * Returns the distance (float) between the vectors "value1" and "value2".
  77943. * @param value1 value to calulate the distance between
  77944. * @param value2 value to calulate the distance between
  77945. * @return the distance between the two vectors
  77946. */
  77947. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  77948. /**
  77949. * Returns the squared distance (float) between the vectors "value1" and "value2".
  77950. * @param value1 value to calulate the distance between
  77951. * @param value2 value to calulate the distance between
  77952. * @return the distance between the two vectors squared
  77953. */
  77954. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  77955. /**
  77956. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  77957. * @param value1 value to calulate the center between
  77958. * @param value2 value to calulate the center between
  77959. * @return the center between the two vectors
  77960. */
  77961. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  77962. /**
  77963. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  77964. * This methods computes transformed normalized direction vectors only.
  77965. * @param vector the vector to transform
  77966. * @param transformation the transformation matrix to apply
  77967. * @returns the new vector
  77968. */
  77969. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  77970. /**
  77971. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  77972. * This methods computes transformed normalized direction vectors only.
  77973. * @param vector the vector to transform
  77974. * @param transformation the transformation matrix to apply
  77975. * @param result the vector to store the result in
  77976. */
  77977. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  77978. /**
  77979. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  77980. * This methods computes transformed normalized direction vectors only.
  77981. * @param x value to transform
  77982. * @param y value to transform
  77983. * @param z value to transform
  77984. * @param w value to transform
  77985. * @param transformation the transformation matrix to apply
  77986. * @param result the vector to store the results in
  77987. */
  77988. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  77989. /**
  77990. * Creates a new Vector4 from a Vector3
  77991. * @param source defines the source data
  77992. * @param w defines the 4th component (default is 0)
  77993. * @returns a new Vector4
  77994. */
  77995. static FromVector3(source: Vector3, w?: number): Vector4;
  77996. }
  77997. /**
  77998. * Class used to store quaternion data
  77999. * @see https://en.wikipedia.org/wiki/Quaternion
  78000. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  78001. */
  78002. export class Quaternion {
  78003. /** defines the first component (0 by default) */
  78004. x: number;
  78005. /** defines the second component (0 by default) */
  78006. y: number;
  78007. /** defines the third component (0 by default) */
  78008. z: number;
  78009. /** defines the fourth component (1.0 by default) */
  78010. w: number;
  78011. /**
  78012. * Creates a new Quaternion from the given floats
  78013. * @param x defines the first component (0 by default)
  78014. * @param y defines the second component (0 by default)
  78015. * @param z defines the third component (0 by default)
  78016. * @param w defines the fourth component (1.0 by default)
  78017. */
  78018. constructor(
  78019. /** defines the first component (0 by default) */
  78020. x?: number,
  78021. /** defines the second component (0 by default) */
  78022. y?: number,
  78023. /** defines the third component (0 by default) */
  78024. z?: number,
  78025. /** defines the fourth component (1.0 by default) */
  78026. w?: number);
  78027. /**
  78028. * Gets a string representation for the current quaternion
  78029. * @returns a string with the Quaternion coordinates
  78030. */
  78031. toString(): string;
  78032. /**
  78033. * Gets the class name of the quaternion
  78034. * @returns the string "Quaternion"
  78035. */
  78036. getClassName(): string;
  78037. /**
  78038. * Gets a hash code for this quaternion
  78039. * @returns the quaternion hash code
  78040. */
  78041. getHashCode(): number;
  78042. /**
  78043. * Copy the quaternion to an array
  78044. * @returns a new array populated with 4 elements from the quaternion coordinates
  78045. */
  78046. asArray(): number[];
  78047. /**
  78048. * Check if two quaternions are equals
  78049. * @param otherQuaternion defines the second operand
  78050. * @return true if the current quaternion and the given one coordinates are strictly equals
  78051. */
  78052. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  78053. /**
  78054. * Gets a boolean if two quaternions are equals (using an epsilon value)
  78055. * @param otherQuaternion defines the other quaternion
  78056. * @param epsilon defines the minimal distance to consider equality
  78057. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  78058. */
  78059. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  78060. /**
  78061. * Clone the current quaternion
  78062. * @returns a new quaternion copied from the current one
  78063. */
  78064. clone(): Quaternion;
  78065. /**
  78066. * Copy a quaternion to the current one
  78067. * @param other defines the other quaternion
  78068. * @returns the updated current quaternion
  78069. */
  78070. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  78071. /**
  78072. * Updates the current quaternion with the given float coordinates
  78073. * @param x defines the x coordinate
  78074. * @param y defines the y coordinate
  78075. * @param z defines the z coordinate
  78076. * @param w defines the w coordinate
  78077. * @returns the updated current quaternion
  78078. */
  78079. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  78080. /**
  78081. * Updates the current quaternion from the given float coordinates
  78082. * @param x defines the x coordinate
  78083. * @param y defines the y coordinate
  78084. * @param z defines the z coordinate
  78085. * @param w defines the w coordinate
  78086. * @returns the updated current quaternion
  78087. */
  78088. set(x: number, y: number, z: number, w: number): Quaternion;
  78089. /**
  78090. * Adds two quaternions
  78091. * @param other defines the second operand
  78092. * @returns a new quaternion as the addition result of the given one and the current quaternion
  78093. */
  78094. add(other: DeepImmutable<Quaternion>): Quaternion;
  78095. /**
  78096. * Add a quaternion to the current one
  78097. * @param other defines the quaternion to add
  78098. * @returns the current quaternion
  78099. */
  78100. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  78101. /**
  78102. * Subtract two quaternions
  78103. * @param other defines the second operand
  78104. * @returns a new quaternion as the subtraction result of the given one from the current one
  78105. */
  78106. subtract(other: Quaternion): Quaternion;
  78107. /**
  78108. * Multiplies the current quaternion by a scale factor
  78109. * @param value defines the scale factor
  78110. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  78111. */
  78112. scale(value: number): Quaternion;
  78113. /**
  78114. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  78115. * @param scale defines the scale factor
  78116. * @param result defines the Quaternion object where to store the result
  78117. * @returns the unmodified current quaternion
  78118. */
  78119. scaleToRef(scale: number, result: Quaternion): Quaternion;
  78120. /**
  78121. * Multiplies in place the current quaternion by a scale factor
  78122. * @param value defines the scale factor
  78123. * @returns the current modified quaternion
  78124. */
  78125. scaleInPlace(value: number): Quaternion;
  78126. /**
  78127. * Scale the current quaternion values by a factor and add the result to a given quaternion
  78128. * @param scale defines the scale factor
  78129. * @param result defines the Quaternion object where to store the result
  78130. * @returns the unmodified current quaternion
  78131. */
  78132. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  78133. /**
  78134. * Multiplies two quaternions
  78135. * @param q1 defines the second operand
  78136. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  78137. */
  78138. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  78139. /**
  78140. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  78141. * @param q1 defines the second operand
  78142. * @param result defines the target quaternion
  78143. * @returns the current quaternion
  78144. */
  78145. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  78146. /**
  78147. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  78148. * @param q1 defines the second operand
  78149. * @returns the currentupdated quaternion
  78150. */
  78151. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  78152. /**
  78153. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  78154. * @param ref defines the target quaternion
  78155. * @returns the current quaternion
  78156. */
  78157. conjugateToRef(ref: Quaternion): Quaternion;
  78158. /**
  78159. * Conjugates in place (1-q) the current quaternion
  78160. * @returns the current updated quaternion
  78161. */
  78162. conjugateInPlace(): Quaternion;
  78163. /**
  78164. * Conjugates in place (1-q) the current quaternion
  78165. * @returns a new quaternion
  78166. */
  78167. conjugate(): Quaternion;
  78168. /**
  78169. * Gets length of current quaternion
  78170. * @returns the quaternion length (float)
  78171. */
  78172. length(): number;
  78173. /**
  78174. * Normalize in place the current quaternion
  78175. * @returns the current updated quaternion
  78176. */
  78177. normalize(): Quaternion;
  78178. /**
  78179. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  78180. * @param order is a reserved parameter and is ignore for now
  78181. * @returns a new Vector3 containing the Euler angles
  78182. */
  78183. toEulerAngles(order?: string): Vector3;
  78184. /**
  78185. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  78186. * @param result defines the vector which will be filled with the Euler angles
  78187. * @param order is a reserved parameter and is ignore for now
  78188. * @returns the current unchanged quaternion
  78189. */
  78190. toEulerAnglesToRef(result: Vector3): Quaternion;
  78191. /**
  78192. * Updates the given rotation matrix with the current quaternion values
  78193. * @param result defines the target matrix
  78194. * @returns the current unchanged quaternion
  78195. */
  78196. toRotationMatrix(result: Matrix): Quaternion;
  78197. /**
  78198. * Updates the current quaternion from the given rotation matrix values
  78199. * @param matrix defines the source matrix
  78200. * @returns the current updated quaternion
  78201. */
  78202. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  78203. /**
  78204. * Creates a new quaternion from a rotation matrix
  78205. * @param matrix defines the source matrix
  78206. * @returns a new quaternion created from the given rotation matrix values
  78207. */
  78208. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  78209. /**
  78210. * Updates the given quaternion with the given rotation matrix values
  78211. * @param matrix defines the source matrix
  78212. * @param result defines the target quaternion
  78213. */
  78214. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  78215. /**
  78216. * Returns the dot product (float) between the quaternions "left" and "right"
  78217. * @param left defines the left operand
  78218. * @param right defines the right operand
  78219. * @returns the dot product
  78220. */
  78221. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  78222. /**
  78223. * Checks if the two quaternions are close to each other
  78224. * @param quat0 defines the first quaternion to check
  78225. * @param quat1 defines the second quaternion to check
  78226. * @returns true if the two quaternions are close to each other
  78227. */
  78228. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  78229. /**
  78230. * Creates an empty quaternion
  78231. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  78232. */
  78233. static Zero(): Quaternion;
  78234. /**
  78235. * Inverse a given quaternion
  78236. * @param q defines the source quaternion
  78237. * @returns a new quaternion as the inverted current quaternion
  78238. */
  78239. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  78240. /**
  78241. * Inverse a given quaternion
  78242. * @param q defines the source quaternion
  78243. * @param result the quaternion the result will be stored in
  78244. * @returns the result quaternion
  78245. */
  78246. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  78247. /**
  78248. * Creates an identity quaternion
  78249. * @returns the identity quaternion
  78250. */
  78251. static Identity(): Quaternion;
  78252. /**
  78253. * Gets a boolean indicating if the given quaternion is identity
  78254. * @param quaternion defines the quaternion to check
  78255. * @returns true if the quaternion is identity
  78256. */
  78257. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  78258. /**
  78259. * Creates a quaternion from a rotation around an axis
  78260. * @param axis defines the axis to use
  78261. * @param angle defines the angle to use
  78262. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  78263. */
  78264. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  78265. /**
  78266. * Creates a rotation around an axis and stores it into the given quaternion
  78267. * @param axis defines the axis to use
  78268. * @param angle defines the angle to use
  78269. * @param result defines the target quaternion
  78270. * @returns the target quaternion
  78271. */
  78272. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  78273. /**
  78274. * Creates a new quaternion from data stored into an array
  78275. * @param array defines the data source
  78276. * @param offset defines the offset in the source array where the data starts
  78277. * @returns a new quaternion
  78278. */
  78279. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  78280. /**
  78281. * Updates the given quaternion "result" from the starting index of the given array.
  78282. * @param array the array to pull values from
  78283. * @param offset the offset into the array to start at
  78284. * @param result the quaternion to store the result in
  78285. */
  78286. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  78287. /**
  78288. * Create a quaternion from Euler rotation angles
  78289. * @param x Pitch
  78290. * @param y Yaw
  78291. * @param z Roll
  78292. * @returns the new Quaternion
  78293. */
  78294. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  78295. /**
  78296. * Updates a quaternion from Euler rotation angles
  78297. * @param x Pitch
  78298. * @param y Yaw
  78299. * @param z Roll
  78300. * @param result the quaternion to store the result
  78301. * @returns the updated quaternion
  78302. */
  78303. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  78304. /**
  78305. * Create a quaternion from Euler rotation vector
  78306. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  78307. * @returns the new Quaternion
  78308. */
  78309. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  78310. /**
  78311. * Updates a quaternion from Euler rotation vector
  78312. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  78313. * @param result the quaternion to store the result
  78314. * @returns the updated quaternion
  78315. */
  78316. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  78317. /**
  78318. * Creates a new quaternion from the given Euler float angles (y, x, z)
  78319. * @param yaw defines the rotation around Y axis
  78320. * @param pitch defines the rotation around X axis
  78321. * @param roll defines the rotation around Z axis
  78322. * @returns the new quaternion
  78323. */
  78324. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  78325. /**
  78326. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  78327. * @param yaw defines the rotation around Y axis
  78328. * @param pitch defines the rotation around X axis
  78329. * @param roll defines the rotation around Z axis
  78330. * @param result defines the target quaternion
  78331. */
  78332. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  78333. /**
  78334. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  78335. * @param alpha defines the rotation around first axis
  78336. * @param beta defines the rotation around second axis
  78337. * @param gamma defines the rotation around third axis
  78338. * @returns the new quaternion
  78339. */
  78340. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  78341. /**
  78342. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  78343. * @param alpha defines the rotation around first axis
  78344. * @param beta defines the rotation around second axis
  78345. * @param gamma defines the rotation around third axis
  78346. * @param result defines the target quaternion
  78347. */
  78348. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  78349. /**
  78350. * 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)
  78351. * @param axis1 defines the first axis
  78352. * @param axis2 defines the second axis
  78353. * @param axis3 defines the third axis
  78354. * @returns the new quaternion
  78355. */
  78356. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  78357. /**
  78358. * 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
  78359. * @param axis1 defines the first axis
  78360. * @param axis2 defines the second axis
  78361. * @param axis3 defines the third axis
  78362. * @param ref defines the target quaternion
  78363. */
  78364. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  78365. /**
  78366. * Interpolates between two quaternions
  78367. * @param left defines first quaternion
  78368. * @param right defines second quaternion
  78369. * @param amount defines the gradient to use
  78370. * @returns the new interpolated quaternion
  78371. */
  78372. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  78373. /**
  78374. * Interpolates between two quaternions and stores it into a target quaternion
  78375. * @param left defines first quaternion
  78376. * @param right defines second quaternion
  78377. * @param amount defines the gradient to use
  78378. * @param result defines the target quaternion
  78379. */
  78380. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  78381. /**
  78382. * Interpolate between two quaternions using Hermite interpolation
  78383. * @param value1 defines first quaternion
  78384. * @param tangent1 defines the incoming tangent
  78385. * @param value2 defines second quaternion
  78386. * @param tangent2 defines the outgoing tangent
  78387. * @param amount defines the target quaternion
  78388. * @returns the new interpolated quaternion
  78389. */
  78390. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  78391. }
  78392. /**
  78393. * Class used to store matrix data (4x4)
  78394. */
  78395. export class Matrix {
  78396. private static _updateFlagSeed;
  78397. private static _identityReadOnly;
  78398. private _isIdentity;
  78399. private _isIdentityDirty;
  78400. private _isIdentity3x2;
  78401. private _isIdentity3x2Dirty;
  78402. /**
  78403. * Gets the update flag of the matrix which is an unique number for the matrix.
  78404. * It will be incremented every time the matrix data change.
  78405. * You can use it to speed the comparison between two versions of the same matrix.
  78406. */
  78407. updateFlag: number;
  78408. private readonly _m;
  78409. /**
  78410. * Gets the internal data of the matrix
  78411. */
  78412. get m(): DeepImmutable<Float32Array>;
  78413. /** @hidden */
  78414. _markAsUpdated(): void;
  78415. /** @hidden */
  78416. private _updateIdentityStatus;
  78417. /**
  78418. * Creates an empty matrix (filled with zeros)
  78419. */
  78420. constructor();
  78421. /**
  78422. * Check if the current matrix is identity
  78423. * @returns true is the matrix is the identity matrix
  78424. */
  78425. isIdentity(): boolean;
  78426. /**
  78427. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  78428. * @returns true is the matrix is the identity matrix
  78429. */
  78430. isIdentityAs3x2(): boolean;
  78431. /**
  78432. * Gets the determinant of the matrix
  78433. * @returns the matrix determinant
  78434. */
  78435. determinant(): number;
  78436. /**
  78437. * Returns the matrix as a Float32Array
  78438. * @returns the matrix underlying array
  78439. */
  78440. toArray(): DeepImmutable<Float32Array>;
  78441. /**
  78442. * Returns the matrix as a Float32Array
  78443. * @returns the matrix underlying array.
  78444. */
  78445. asArray(): DeepImmutable<Float32Array>;
  78446. /**
  78447. * Inverts the current matrix in place
  78448. * @returns the current inverted matrix
  78449. */
  78450. invert(): Matrix;
  78451. /**
  78452. * Sets all the matrix elements to zero
  78453. * @returns the current matrix
  78454. */
  78455. reset(): Matrix;
  78456. /**
  78457. * Adds the current matrix with a second one
  78458. * @param other defines the matrix to add
  78459. * @returns a new matrix as the addition of the current matrix and the given one
  78460. */
  78461. add(other: DeepImmutable<Matrix>): Matrix;
  78462. /**
  78463. * Sets the given matrix "result" to the addition of the current matrix and the given one
  78464. * @param other defines the matrix to add
  78465. * @param result defines the target matrix
  78466. * @returns the current matrix
  78467. */
  78468. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  78469. /**
  78470. * Adds in place the given matrix to the current matrix
  78471. * @param other defines the second operand
  78472. * @returns the current updated matrix
  78473. */
  78474. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  78475. /**
  78476. * Sets the given matrix to the current inverted Matrix
  78477. * @param other defines the target matrix
  78478. * @returns the unmodified current matrix
  78479. */
  78480. invertToRef(other: Matrix): Matrix;
  78481. /**
  78482. * add a value at the specified position in the current Matrix
  78483. * @param index the index of the value within the matrix. between 0 and 15.
  78484. * @param value the value to be added
  78485. * @returns the current updated matrix
  78486. */
  78487. addAtIndex(index: number, value: number): Matrix;
  78488. /**
  78489. * mutiply the specified position in the current Matrix by a value
  78490. * @param index the index of the value within the matrix. between 0 and 15.
  78491. * @param value the value to be added
  78492. * @returns the current updated matrix
  78493. */
  78494. multiplyAtIndex(index: number, value: number): Matrix;
  78495. /**
  78496. * Inserts the translation vector (using 3 floats) in the current matrix
  78497. * @param x defines the 1st component of the translation
  78498. * @param y defines the 2nd component of the translation
  78499. * @param z defines the 3rd component of the translation
  78500. * @returns the current updated matrix
  78501. */
  78502. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  78503. /**
  78504. * Adds the translation vector (using 3 floats) in the current matrix
  78505. * @param x defines the 1st component of the translation
  78506. * @param y defines the 2nd component of the translation
  78507. * @param z defines the 3rd component of the translation
  78508. * @returns the current updated matrix
  78509. */
  78510. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  78511. /**
  78512. * Inserts the translation vector in the current matrix
  78513. * @param vector3 defines the translation to insert
  78514. * @returns the current updated matrix
  78515. */
  78516. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  78517. /**
  78518. * Gets the translation value of the current matrix
  78519. * @returns a new Vector3 as the extracted translation from the matrix
  78520. */
  78521. getTranslation(): Vector3;
  78522. /**
  78523. * Fill a Vector3 with the extracted translation from the matrix
  78524. * @param result defines the Vector3 where to store the translation
  78525. * @returns the current matrix
  78526. */
  78527. getTranslationToRef(result: Vector3): Matrix;
  78528. /**
  78529. * Remove rotation and scaling part from the matrix
  78530. * @returns the updated matrix
  78531. */
  78532. removeRotationAndScaling(): Matrix;
  78533. /**
  78534. * Multiply two matrices
  78535. * @param other defines the second operand
  78536. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  78537. */
  78538. multiply(other: DeepImmutable<Matrix>): Matrix;
  78539. /**
  78540. * Copy the current matrix from the given one
  78541. * @param other defines the source matrix
  78542. * @returns the current updated matrix
  78543. */
  78544. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  78545. /**
  78546. * Populates the given array from the starting index with the current matrix values
  78547. * @param array defines the target array
  78548. * @param offset defines the offset in the target array where to start storing values
  78549. * @returns the current matrix
  78550. */
  78551. copyToArray(array: Float32Array, offset?: number): Matrix;
  78552. /**
  78553. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  78554. * @param other defines the second operand
  78555. * @param result defines the matrix where to store the multiplication
  78556. * @returns the current matrix
  78557. */
  78558. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  78559. /**
  78560. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  78561. * @param other defines the second operand
  78562. * @param result defines the array where to store the multiplication
  78563. * @param offset defines the offset in the target array where to start storing values
  78564. * @returns the current matrix
  78565. */
  78566. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  78567. /**
  78568. * Check equality between this matrix and a second one
  78569. * @param value defines the second matrix to compare
  78570. * @returns true is the current matrix and the given one values are strictly equal
  78571. */
  78572. equals(value: DeepImmutable<Matrix>): boolean;
  78573. /**
  78574. * Clone the current matrix
  78575. * @returns a new matrix from the current matrix
  78576. */
  78577. clone(): Matrix;
  78578. /**
  78579. * Returns the name of the current matrix class
  78580. * @returns the string "Matrix"
  78581. */
  78582. getClassName(): string;
  78583. /**
  78584. * Gets the hash code of the current matrix
  78585. * @returns the hash code
  78586. */
  78587. getHashCode(): number;
  78588. /**
  78589. * Decomposes the current Matrix into a translation, rotation and scaling components
  78590. * @param scale defines the scale vector3 given as a reference to update
  78591. * @param rotation defines the rotation quaternion given as a reference to update
  78592. * @param translation defines the translation vector3 given as a reference to update
  78593. * @returns true if operation was successful
  78594. */
  78595. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  78596. /**
  78597. * Gets specific row of the matrix
  78598. * @param index defines the number of the row to get
  78599. * @returns the index-th row of the current matrix as a new Vector4
  78600. */
  78601. getRow(index: number): Nullable<Vector4>;
  78602. /**
  78603. * Sets the index-th row of the current matrix to the vector4 values
  78604. * @param index defines the number of the row to set
  78605. * @param row defines the target vector4
  78606. * @returns the updated current matrix
  78607. */
  78608. setRow(index: number, row: Vector4): Matrix;
  78609. /**
  78610. * Compute the transpose of the matrix
  78611. * @returns the new transposed matrix
  78612. */
  78613. transpose(): Matrix;
  78614. /**
  78615. * Compute the transpose of the matrix and store it in a given matrix
  78616. * @param result defines the target matrix
  78617. * @returns the current matrix
  78618. */
  78619. transposeToRef(result: Matrix): Matrix;
  78620. /**
  78621. * Sets the index-th row of the current matrix with the given 4 x float values
  78622. * @param index defines the row index
  78623. * @param x defines the x component to set
  78624. * @param y defines the y component to set
  78625. * @param z defines the z component to set
  78626. * @param w defines the w component to set
  78627. * @returns the updated current matrix
  78628. */
  78629. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  78630. /**
  78631. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  78632. * @param scale defines the scale factor
  78633. * @returns a new matrix
  78634. */
  78635. scale(scale: number): Matrix;
  78636. /**
  78637. * Scale the current matrix values by a factor to a given result matrix
  78638. * @param scale defines the scale factor
  78639. * @param result defines the matrix to store the result
  78640. * @returns the current matrix
  78641. */
  78642. scaleToRef(scale: number, result: Matrix): Matrix;
  78643. /**
  78644. * Scale the current matrix values by a factor and add the result to a given matrix
  78645. * @param scale defines the scale factor
  78646. * @param result defines the Matrix to store the result
  78647. * @returns the current matrix
  78648. */
  78649. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  78650. /**
  78651. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  78652. * @param ref matrix to store the result
  78653. */
  78654. toNormalMatrix(ref: Matrix): void;
  78655. /**
  78656. * Gets only rotation part of the current matrix
  78657. * @returns a new matrix sets to the extracted rotation matrix from the current one
  78658. */
  78659. getRotationMatrix(): Matrix;
  78660. /**
  78661. * Extracts the rotation matrix from the current one and sets it as the given "result"
  78662. * @param result defines the target matrix to store data to
  78663. * @returns the current matrix
  78664. */
  78665. getRotationMatrixToRef(result: Matrix): Matrix;
  78666. /**
  78667. * Toggles model matrix from being right handed to left handed in place and vice versa
  78668. */
  78669. toggleModelMatrixHandInPlace(): void;
  78670. /**
  78671. * Toggles projection matrix from being right handed to left handed in place and vice versa
  78672. */
  78673. toggleProjectionMatrixHandInPlace(): void;
  78674. /**
  78675. * Creates a matrix from an array
  78676. * @param array defines the source array
  78677. * @param offset defines an offset in the source array
  78678. * @returns a new Matrix set from the starting index of the given array
  78679. */
  78680. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  78681. /**
  78682. * Copy the content of an array into a given matrix
  78683. * @param array defines the source array
  78684. * @param offset defines an offset in the source array
  78685. * @param result defines the target matrix
  78686. */
  78687. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  78688. /**
  78689. * Stores an array into a matrix after having multiplied each component by a given factor
  78690. * @param array defines the source array
  78691. * @param offset defines the offset in the source array
  78692. * @param scale defines the scaling factor
  78693. * @param result defines the target matrix
  78694. */
  78695. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  78696. /**
  78697. * Gets an identity matrix that must not be updated
  78698. */
  78699. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  78700. /**
  78701. * Stores a list of values (16) inside a given matrix
  78702. * @param initialM11 defines 1st value of 1st row
  78703. * @param initialM12 defines 2nd value of 1st row
  78704. * @param initialM13 defines 3rd value of 1st row
  78705. * @param initialM14 defines 4th value of 1st row
  78706. * @param initialM21 defines 1st value of 2nd row
  78707. * @param initialM22 defines 2nd value of 2nd row
  78708. * @param initialM23 defines 3rd value of 2nd row
  78709. * @param initialM24 defines 4th value of 2nd row
  78710. * @param initialM31 defines 1st value of 3rd row
  78711. * @param initialM32 defines 2nd value of 3rd row
  78712. * @param initialM33 defines 3rd value of 3rd row
  78713. * @param initialM34 defines 4th value of 3rd row
  78714. * @param initialM41 defines 1st value of 4th row
  78715. * @param initialM42 defines 2nd value of 4th row
  78716. * @param initialM43 defines 3rd value of 4th row
  78717. * @param initialM44 defines 4th value of 4th row
  78718. * @param result defines the target matrix
  78719. */
  78720. 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;
  78721. /**
  78722. * Creates new matrix from a list of values (16)
  78723. * @param initialM11 defines 1st value of 1st row
  78724. * @param initialM12 defines 2nd value of 1st row
  78725. * @param initialM13 defines 3rd value of 1st row
  78726. * @param initialM14 defines 4th value of 1st row
  78727. * @param initialM21 defines 1st value of 2nd row
  78728. * @param initialM22 defines 2nd value of 2nd row
  78729. * @param initialM23 defines 3rd value of 2nd row
  78730. * @param initialM24 defines 4th value of 2nd row
  78731. * @param initialM31 defines 1st value of 3rd row
  78732. * @param initialM32 defines 2nd value of 3rd row
  78733. * @param initialM33 defines 3rd value of 3rd row
  78734. * @param initialM34 defines 4th value of 3rd row
  78735. * @param initialM41 defines 1st value of 4th row
  78736. * @param initialM42 defines 2nd value of 4th row
  78737. * @param initialM43 defines 3rd value of 4th row
  78738. * @param initialM44 defines 4th value of 4th row
  78739. * @returns the new matrix
  78740. */
  78741. 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;
  78742. /**
  78743. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  78744. * @param scale defines the scale vector3
  78745. * @param rotation defines the rotation quaternion
  78746. * @param translation defines the translation vector3
  78747. * @returns a new matrix
  78748. */
  78749. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  78750. /**
  78751. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  78752. * @param scale defines the scale vector3
  78753. * @param rotation defines the rotation quaternion
  78754. * @param translation defines the translation vector3
  78755. * @param result defines the target matrix
  78756. */
  78757. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  78758. /**
  78759. * Creates a new identity matrix
  78760. * @returns a new identity matrix
  78761. */
  78762. static Identity(): Matrix;
  78763. /**
  78764. * Creates a new identity matrix and stores the result in a given matrix
  78765. * @param result defines the target matrix
  78766. */
  78767. static IdentityToRef(result: Matrix): void;
  78768. /**
  78769. * Creates a new zero matrix
  78770. * @returns a new zero matrix
  78771. */
  78772. static Zero(): Matrix;
  78773. /**
  78774. * Creates a new rotation matrix for "angle" radians around the X axis
  78775. * @param angle defines the angle (in radians) to use
  78776. * @return the new matrix
  78777. */
  78778. static RotationX(angle: number): Matrix;
  78779. /**
  78780. * Creates a new matrix as the invert of a given matrix
  78781. * @param source defines the source matrix
  78782. * @returns the new matrix
  78783. */
  78784. static Invert(source: DeepImmutable<Matrix>): Matrix;
  78785. /**
  78786. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  78787. * @param angle defines the angle (in radians) to use
  78788. * @param result defines the target matrix
  78789. */
  78790. static RotationXToRef(angle: number, result: Matrix): void;
  78791. /**
  78792. * Creates a new rotation matrix for "angle" radians around the Y axis
  78793. * @param angle defines the angle (in radians) to use
  78794. * @return the new matrix
  78795. */
  78796. static RotationY(angle: number): Matrix;
  78797. /**
  78798. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  78799. * @param angle defines the angle (in radians) to use
  78800. * @param result defines the target matrix
  78801. */
  78802. static RotationYToRef(angle: number, result: Matrix): void;
  78803. /**
  78804. * Creates a new rotation matrix for "angle" radians around the Z axis
  78805. * @param angle defines the angle (in radians) to use
  78806. * @return the new matrix
  78807. */
  78808. static RotationZ(angle: number): Matrix;
  78809. /**
  78810. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  78811. * @param angle defines the angle (in radians) to use
  78812. * @param result defines the target matrix
  78813. */
  78814. static RotationZToRef(angle: number, result: Matrix): void;
  78815. /**
  78816. * Creates a new rotation matrix for "angle" radians around the given axis
  78817. * @param axis defines the axis to use
  78818. * @param angle defines the angle (in radians) to use
  78819. * @return the new matrix
  78820. */
  78821. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  78822. /**
  78823. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  78824. * @param axis defines the axis to use
  78825. * @param angle defines the angle (in radians) to use
  78826. * @param result defines the target matrix
  78827. */
  78828. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  78829. /**
  78830. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  78831. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  78832. * @param from defines the vector to align
  78833. * @param to defines the vector to align to
  78834. * @param result defines the target matrix
  78835. */
  78836. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  78837. /**
  78838. * Creates a rotation matrix
  78839. * @param yaw defines the yaw angle in radians (Y axis)
  78840. * @param pitch defines the pitch angle in radians (X axis)
  78841. * @param roll defines the roll angle in radians (X axis)
  78842. * @returns the new rotation matrix
  78843. */
  78844. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  78845. /**
  78846. * Creates a rotation matrix and stores it in a given matrix
  78847. * @param yaw defines the yaw angle in radians (Y axis)
  78848. * @param pitch defines the pitch angle in radians (X axis)
  78849. * @param roll defines the roll angle in radians (X axis)
  78850. * @param result defines the target matrix
  78851. */
  78852. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  78853. /**
  78854. * Creates a scaling matrix
  78855. * @param x defines the scale factor on X axis
  78856. * @param y defines the scale factor on Y axis
  78857. * @param z defines the scale factor on Z axis
  78858. * @returns the new matrix
  78859. */
  78860. static Scaling(x: number, y: number, z: number): Matrix;
  78861. /**
  78862. * Creates a scaling matrix and stores it in a given matrix
  78863. * @param x defines the scale factor on X axis
  78864. * @param y defines the scale factor on Y axis
  78865. * @param z defines the scale factor on Z axis
  78866. * @param result defines the target matrix
  78867. */
  78868. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  78869. /**
  78870. * Creates a translation matrix
  78871. * @param x defines the translation on X axis
  78872. * @param y defines the translation on Y axis
  78873. * @param z defines the translationon Z axis
  78874. * @returns the new matrix
  78875. */
  78876. static Translation(x: number, y: number, z: number): Matrix;
  78877. /**
  78878. * Creates a translation matrix and stores it in a given matrix
  78879. * @param x defines the translation on X axis
  78880. * @param y defines the translation on Y axis
  78881. * @param z defines the translationon Z axis
  78882. * @param result defines the target matrix
  78883. */
  78884. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  78885. /**
  78886. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  78887. * @param startValue defines the start value
  78888. * @param endValue defines the end value
  78889. * @param gradient defines the gradient factor
  78890. * @returns the new matrix
  78891. */
  78892. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  78893. /**
  78894. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  78895. * @param startValue defines the start value
  78896. * @param endValue defines the end value
  78897. * @param gradient defines the gradient factor
  78898. * @param result defines the Matrix object where to store data
  78899. */
  78900. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  78901. /**
  78902. * Builds a new matrix whose values are computed by:
  78903. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  78904. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  78905. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  78906. * @param startValue defines the first matrix
  78907. * @param endValue defines the second matrix
  78908. * @param gradient defines the gradient between the two matrices
  78909. * @returns the new matrix
  78910. */
  78911. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  78912. /**
  78913. * Update a matrix to values which are computed by:
  78914. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  78915. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  78916. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  78917. * @param startValue defines the first matrix
  78918. * @param endValue defines the second matrix
  78919. * @param gradient defines the gradient between the two matrices
  78920. * @param result defines the target matrix
  78921. */
  78922. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  78923. /**
  78924. * 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"
  78925. * This function works in left handed mode
  78926. * @param eye defines the final position of the entity
  78927. * @param target defines where the entity should look at
  78928. * @param up defines the up vector for the entity
  78929. * @returns the new matrix
  78930. */
  78931. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  78932. /**
  78933. * 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".
  78934. * This function works in left handed mode
  78935. * @param eye defines the final position of the entity
  78936. * @param target defines where the entity should look at
  78937. * @param up defines the up vector for the entity
  78938. * @param result defines the target matrix
  78939. */
  78940. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  78941. /**
  78942. * 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"
  78943. * This function works in right handed mode
  78944. * @param eye defines the final position of the entity
  78945. * @param target defines where the entity should look at
  78946. * @param up defines the up vector for the entity
  78947. * @returns the new matrix
  78948. */
  78949. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  78950. /**
  78951. * 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".
  78952. * This function works in right handed mode
  78953. * @param eye defines the final position of the entity
  78954. * @param target defines where the entity should look at
  78955. * @param up defines the up vector for the entity
  78956. * @param result defines the target matrix
  78957. */
  78958. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  78959. /**
  78960. * Create a left-handed orthographic projection matrix
  78961. * @param width defines the viewport width
  78962. * @param height defines the viewport height
  78963. * @param znear defines the near clip plane
  78964. * @param zfar defines the far clip plane
  78965. * @returns a new matrix as a left-handed orthographic projection matrix
  78966. */
  78967. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  78968. /**
  78969. * Store a left-handed orthographic projection to a given matrix
  78970. * @param width defines the viewport width
  78971. * @param height defines the viewport height
  78972. * @param znear defines the near clip plane
  78973. * @param zfar defines the far clip plane
  78974. * @param result defines the target matrix
  78975. */
  78976. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  78977. /**
  78978. * Create a left-handed orthographic projection matrix
  78979. * @param left defines the viewport left coordinate
  78980. * @param right defines the viewport right coordinate
  78981. * @param bottom defines the viewport bottom coordinate
  78982. * @param top defines the viewport top coordinate
  78983. * @param znear defines the near clip plane
  78984. * @param zfar defines the far clip plane
  78985. * @returns a new matrix as a left-handed orthographic projection matrix
  78986. */
  78987. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  78988. /**
  78989. * Stores a left-handed orthographic projection into a given matrix
  78990. * @param left defines the viewport left coordinate
  78991. * @param right defines the viewport right coordinate
  78992. * @param bottom defines the viewport bottom coordinate
  78993. * @param top defines the viewport top coordinate
  78994. * @param znear defines the near clip plane
  78995. * @param zfar defines the far clip plane
  78996. * @param result defines the target matrix
  78997. */
  78998. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  78999. /**
  79000. * Creates a right-handed orthographic projection matrix
  79001. * @param left defines the viewport left coordinate
  79002. * @param right defines the viewport right coordinate
  79003. * @param bottom defines the viewport bottom coordinate
  79004. * @param top defines the viewport top coordinate
  79005. * @param znear defines the near clip plane
  79006. * @param zfar defines the far clip plane
  79007. * @returns a new matrix as a right-handed orthographic projection matrix
  79008. */
  79009. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  79010. /**
  79011. * Stores a right-handed orthographic projection into a given matrix
  79012. * @param left defines the viewport left coordinate
  79013. * @param right defines the viewport right coordinate
  79014. * @param bottom defines the viewport bottom coordinate
  79015. * @param top defines the viewport top coordinate
  79016. * @param znear defines the near clip plane
  79017. * @param zfar defines the far clip plane
  79018. * @param result defines the target matrix
  79019. */
  79020. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  79021. /**
  79022. * Creates a left-handed perspective projection matrix
  79023. * @param width defines the viewport width
  79024. * @param height defines the viewport height
  79025. * @param znear defines the near clip plane
  79026. * @param zfar defines the far clip plane
  79027. * @returns a new matrix as a left-handed perspective projection matrix
  79028. */
  79029. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  79030. /**
  79031. * Creates a left-handed perspective projection matrix
  79032. * @param fov defines the horizontal field of view
  79033. * @param aspect defines the aspect ratio
  79034. * @param znear defines the near clip plane
  79035. * @param zfar defines the far clip plane
  79036. * @returns a new matrix as a left-handed perspective projection matrix
  79037. */
  79038. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  79039. /**
  79040. * Stores a left-handed perspective projection into a given matrix
  79041. * @param fov defines the horizontal field of view
  79042. * @param aspect defines the aspect ratio
  79043. * @param znear defines the near clip plane
  79044. * @param zfar defines the far clip plane
  79045. * @param result defines the target matrix
  79046. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  79047. */
  79048. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  79049. /**
  79050. * Stores a left-handed perspective projection into a given matrix with depth reversed
  79051. * @param fov defines the horizontal field of view
  79052. * @param aspect defines the aspect ratio
  79053. * @param znear defines the near clip plane
  79054. * @param zfar not used as infinity is used as far clip
  79055. * @param result defines the target matrix
  79056. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  79057. */
  79058. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  79059. /**
  79060. * Creates a right-handed perspective projection matrix
  79061. * @param fov defines the horizontal field of view
  79062. * @param aspect defines the aspect ratio
  79063. * @param znear defines the near clip plane
  79064. * @param zfar defines the far clip plane
  79065. * @returns a new matrix as a right-handed perspective projection matrix
  79066. */
  79067. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  79068. /**
  79069. * Stores a right-handed perspective projection into a given matrix
  79070. * @param fov defines the horizontal field of view
  79071. * @param aspect defines the aspect ratio
  79072. * @param znear defines the near clip plane
  79073. * @param zfar defines the far clip plane
  79074. * @param result defines the target matrix
  79075. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  79076. */
  79077. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  79078. /**
  79079. * Stores a right-handed perspective projection into a given matrix
  79080. * @param fov defines the horizontal field of view
  79081. * @param aspect defines the aspect ratio
  79082. * @param znear defines the near clip plane
  79083. * @param zfar not used as infinity is used as far clip
  79084. * @param result defines the target matrix
  79085. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  79086. */
  79087. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  79088. /**
  79089. * Stores a perspective projection for WebVR info a given matrix
  79090. * @param fov defines the field of view
  79091. * @param znear defines the near clip plane
  79092. * @param zfar defines the far clip plane
  79093. * @param result defines the target matrix
  79094. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  79095. */
  79096. static PerspectiveFovWebVRToRef(fov: {
  79097. upDegrees: number;
  79098. downDegrees: number;
  79099. leftDegrees: number;
  79100. rightDegrees: number;
  79101. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  79102. /**
  79103. * Computes a complete transformation matrix
  79104. * @param viewport defines the viewport to use
  79105. * @param world defines the world matrix
  79106. * @param view defines the view matrix
  79107. * @param projection defines the projection matrix
  79108. * @param zmin defines the near clip plane
  79109. * @param zmax defines the far clip plane
  79110. * @returns the transformation matrix
  79111. */
  79112. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  79113. /**
  79114. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  79115. * @param matrix defines the matrix to use
  79116. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  79117. */
  79118. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  79119. /**
  79120. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  79121. * @param matrix defines the matrix to use
  79122. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  79123. */
  79124. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  79125. /**
  79126. * Compute the transpose of a given matrix
  79127. * @param matrix defines the matrix to transpose
  79128. * @returns the new matrix
  79129. */
  79130. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  79131. /**
  79132. * Compute the transpose of a matrix and store it in a target matrix
  79133. * @param matrix defines the matrix to transpose
  79134. * @param result defines the target matrix
  79135. */
  79136. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  79137. /**
  79138. * Computes a reflection matrix from a plane
  79139. * @param plane defines the reflection plane
  79140. * @returns a new matrix
  79141. */
  79142. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  79143. /**
  79144. * Computes a reflection matrix from a plane
  79145. * @param plane defines the reflection plane
  79146. * @param result defines the target matrix
  79147. */
  79148. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  79149. /**
  79150. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  79151. * @param xaxis defines the value of the 1st axis
  79152. * @param yaxis defines the value of the 2nd axis
  79153. * @param zaxis defines the value of the 3rd axis
  79154. * @param result defines the target matrix
  79155. */
  79156. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  79157. /**
  79158. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  79159. * @param quat defines the quaternion to use
  79160. * @param result defines the target matrix
  79161. */
  79162. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  79163. }
  79164. /**
  79165. * @hidden
  79166. */
  79167. export class TmpVectors {
  79168. static Vector2: Vector2[];
  79169. static Vector3: Vector3[];
  79170. static Vector4: Vector4[];
  79171. static Quaternion: Quaternion[];
  79172. static Matrix: Matrix[];
  79173. }
  79174. }
  79175. declare module BABYLON {
  79176. /**
  79177. * Defines potential orientation for back face culling
  79178. */
  79179. export enum Orientation {
  79180. /**
  79181. * Clockwise
  79182. */
  79183. CW = 0,
  79184. /** Counter clockwise */
  79185. CCW = 1
  79186. }
  79187. /** Class used to represent a Bezier curve */
  79188. export class BezierCurve {
  79189. /**
  79190. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  79191. * @param t defines the time
  79192. * @param x1 defines the left coordinate on X axis
  79193. * @param y1 defines the left coordinate on Y axis
  79194. * @param x2 defines the right coordinate on X axis
  79195. * @param y2 defines the right coordinate on Y axis
  79196. * @returns the interpolated value
  79197. */
  79198. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  79199. }
  79200. /**
  79201. * Defines angle representation
  79202. */
  79203. export class Angle {
  79204. private _radians;
  79205. /**
  79206. * Creates an Angle object of "radians" radians (float).
  79207. * @param radians the angle in radians
  79208. */
  79209. constructor(radians: number);
  79210. /**
  79211. * Get value in degrees
  79212. * @returns the Angle value in degrees (float)
  79213. */
  79214. degrees(): number;
  79215. /**
  79216. * Get value in radians
  79217. * @returns the Angle value in radians (float)
  79218. */
  79219. radians(): number;
  79220. /**
  79221. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  79222. * @param a defines first vector
  79223. * @param b defines second vector
  79224. * @returns a new Angle
  79225. */
  79226. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  79227. /**
  79228. * Gets a new Angle object from the given float in radians
  79229. * @param radians defines the angle value in radians
  79230. * @returns a new Angle
  79231. */
  79232. static FromRadians(radians: number): Angle;
  79233. /**
  79234. * Gets a new Angle object from the given float in degrees
  79235. * @param degrees defines the angle value in degrees
  79236. * @returns a new Angle
  79237. */
  79238. static FromDegrees(degrees: number): Angle;
  79239. }
  79240. /**
  79241. * This represents an arc in a 2d space.
  79242. */
  79243. export class Arc2 {
  79244. /** Defines the start point of the arc */
  79245. startPoint: Vector2;
  79246. /** Defines the mid point of the arc */
  79247. midPoint: Vector2;
  79248. /** Defines the end point of the arc */
  79249. endPoint: Vector2;
  79250. /**
  79251. * Defines the center point of the arc.
  79252. */
  79253. centerPoint: Vector2;
  79254. /**
  79255. * Defines the radius of the arc.
  79256. */
  79257. radius: number;
  79258. /**
  79259. * Defines the angle of the arc (from mid point to end point).
  79260. */
  79261. angle: Angle;
  79262. /**
  79263. * Defines the start angle of the arc (from start point to middle point).
  79264. */
  79265. startAngle: Angle;
  79266. /**
  79267. * Defines the orientation of the arc (clock wise/counter clock wise).
  79268. */
  79269. orientation: Orientation;
  79270. /**
  79271. * Creates an Arc object from the three given points : start, middle and end.
  79272. * @param startPoint Defines the start point of the arc
  79273. * @param midPoint Defines the midlle point of the arc
  79274. * @param endPoint Defines the end point of the arc
  79275. */
  79276. constructor(
  79277. /** Defines the start point of the arc */
  79278. startPoint: Vector2,
  79279. /** Defines the mid point of the arc */
  79280. midPoint: Vector2,
  79281. /** Defines the end point of the arc */
  79282. endPoint: Vector2);
  79283. }
  79284. /**
  79285. * Represents a 2D path made up of multiple 2D points
  79286. */
  79287. export class Path2 {
  79288. private _points;
  79289. private _length;
  79290. /**
  79291. * If the path start and end point are the same
  79292. */
  79293. closed: boolean;
  79294. /**
  79295. * Creates a Path2 object from the starting 2D coordinates x and y.
  79296. * @param x the starting points x value
  79297. * @param y the starting points y value
  79298. */
  79299. constructor(x: number, y: number);
  79300. /**
  79301. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  79302. * @param x the added points x value
  79303. * @param y the added points y value
  79304. * @returns the updated Path2.
  79305. */
  79306. addLineTo(x: number, y: number): Path2;
  79307. /**
  79308. * 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.
  79309. * @param midX middle point x value
  79310. * @param midY middle point y value
  79311. * @param endX end point x value
  79312. * @param endY end point y value
  79313. * @param numberOfSegments (default: 36)
  79314. * @returns the updated Path2.
  79315. */
  79316. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  79317. /**
  79318. * Closes the Path2.
  79319. * @returns the Path2.
  79320. */
  79321. close(): Path2;
  79322. /**
  79323. * Gets the sum of the distance between each sequential point in the path
  79324. * @returns the Path2 total length (float).
  79325. */
  79326. length(): number;
  79327. /**
  79328. * Gets the points which construct the path
  79329. * @returns the Path2 internal array of points.
  79330. */
  79331. getPoints(): Vector2[];
  79332. /**
  79333. * Retreives the point at the distance aways from the starting point
  79334. * @param normalizedLengthPosition the length along the path to retreive the point from
  79335. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  79336. */
  79337. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  79338. /**
  79339. * Creates a new path starting from an x and y position
  79340. * @param x starting x value
  79341. * @param y starting y value
  79342. * @returns a new Path2 starting at the coordinates (x, y).
  79343. */
  79344. static StartingAt(x: number, y: number): Path2;
  79345. }
  79346. /**
  79347. * Represents a 3D path made up of multiple 3D points
  79348. */
  79349. export class Path3D {
  79350. /**
  79351. * an array of Vector3, the curve axis of the Path3D
  79352. */
  79353. path: Vector3[];
  79354. private _curve;
  79355. private _distances;
  79356. private _tangents;
  79357. private _normals;
  79358. private _binormals;
  79359. private _raw;
  79360. private _alignTangentsWithPath;
  79361. private readonly _pointAtData;
  79362. /**
  79363. * new Path3D(path, normal, raw)
  79364. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  79365. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  79366. * @param path an array of Vector3, the curve axis of the Path3D
  79367. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  79368. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  79369. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  79370. */
  79371. constructor(
  79372. /**
  79373. * an array of Vector3, the curve axis of the Path3D
  79374. */
  79375. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  79376. /**
  79377. * Returns the Path3D array of successive Vector3 designing its curve.
  79378. * @returns the Path3D array of successive Vector3 designing its curve.
  79379. */
  79380. getCurve(): Vector3[];
  79381. /**
  79382. * Returns the Path3D array of successive Vector3 designing its curve.
  79383. * @returns the Path3D array of successive Vector3 designing its curve.
  79384. */
  79385. getPoints(): Vector3[];
  79386. /**
  79387. * @returns the computed length (float) of the path.
  79388. */
  79389. length(): number;
  79390. /**
  79391. * Returns an array populated with tangent vectors on each Path3D curve point.
  79392. * @returns an array populated with tangent vectors on each Path3D curve point.
  79393. */
  79394. getTangents(): Vector3[];
  79395. /**
  79396. * Returns an array populated with normal vectors on each Path3D curve point.
  79397. * @returns an array populated with normal vectors on each Path3D curve point.
  79398. */
  79399. getNormals(): Vector3[];
  79400. /**
  79401. * Returns an array populated with binormal vectors on each Path3D curve point.
  79402. * @returns an array populated with binormal vectors on each Path3D curve point.
  79403. */
  79404. getBinormals(): Vector3[];
  79405. /**
  79406. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  79407. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  79408. */
  79409. getDistances(): number[];
  79410. /**
  79411. * Returns an interpolated point along this path
  79412. * @param position the position of the point along this path, from 0.0 to 1.0
  79413. * @returns a new Vector3 as the point
  79414. */
  79415. getPointAt(position: number): Vector3;
  79416. /**
  79417. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  79418. * @param position the position of the point along this path, from 0.0 to 1.0
  79419. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  79420. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  79421. */
  79422. getTangentAt(position: number, interpolated?: boolean): Vector3;
  79423. /**
  79424. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  79425. * @param position the position of the point along this path, from 0.0 to 1.0
  79426. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  79427. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  79428. */
  79429. getNormalAt(position: number, interpolated?: boolean): Vector3;
  79430. /**
  79431. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  79432. * @param position the position of the point along this path, from 0.0 to 1.0
  79433. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  79434. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  79435. */
  79436. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  79437. /**
  79438. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  79439. * @param position the position of the point along this path, from 0.0 to 1.0
  79440. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  79441. */
  79442. getDistanceAt(position: number): number;
  79443. /**
  79444. * Returns the array index of the previous point of an interpolated point along this path
  79445. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  79446. * @returns the array index
  79447. */
  79448. getPreviousPointIndexAt(position: number): number;
  79449. /**
  79450. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  79451. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  79452. * @returns the sub position
  79453. */
  79454. getSubPositionAt(position: number): number;
  79455. /**
  79456. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  79457. * @param target the vector of which to get the closest position to
  79458. * @returns the position of the closest virtual point on this path to the target vector
  79459. */
  79460. getClosestPositionTo(target: Vector3): number;
  79461. /**
  79462. * Returns a sub path (slice) of this path
  79463. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  79464. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  79465. * @returns a sub path (slice) of this path
  79466. */
  79467. slice(start?: number, end?: number): Path3D;
  79468. /**
  79469. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  79470. * @param path path which all values are copied into the curves points
  79471. * @param firstNormal which should be projected onto the curve
  79472. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  79473. * @returns the same object updated.
  79474. */
  79475. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  79476. private _compute;
  79477. private _getFirstNonNullVector;
  79478. private _getLastNonNullVector;
  79479. private _normalVector;
  79480. /**
  79481. * Updates the point at data for an interpolated point along this curve
  79482. * @param position the position of the point along this curve, from 0.0 to 1.0
  79483. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  79484. * @returns the (updated) point at data
  79485. */
  79486. private _updatePointAtData;
  79487. /**
  79488. * Updates the point at data from the specified parameters
  79489. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  79490. * @param point the interpolated point
  79491. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  79492. */
  79493. private _setPointAtData;
  79494. /**
  79495. * Updates the point at interpolation matrix for the tangents, normals and binormals
  79496. */
  79497. private _updateInterpolationMatrix;
  79498. }
  79499. /**
  79500. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  79501. * A Curve3 is designed from a series of successive Vector3.
  79502. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  79503. */
  79504. export class Curve3 {
  79505. private _points;
  79506. private _length;
  79507. /**
  79508. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  79509. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  79510. * @param v1 (Vector3) the control point
  79511. * @param v2 (Vector3) the end point of the Quadratic Bezier
  79512. * @param nbPoints (integer) the wanted number of points in the curve
  79513. * @returns the created Curve3
  79514. */
  79515. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  79516. /**
  79517. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  79518. * @param v0 (Vector3) the origin point of the Cubic Bezier
  79519. * @param v1 (Vector3) the first control point
  79520. * @param v2 (Vector3) the second control point
  79521. * @param v3 (Vector3) the end point of the Cubic Bezier
  79522. * @param nbPoints (integer) the wanted number of points in the curve
  79523. * @returns the created Curve3
  79524. */
  79525. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  79526. /**
  79527. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  79528. * @param p1 (Vector3) the origin point of the Hermite Spline
  79529. * @param t1 (Vector3) the tangent vector at the origin point
  79530. * @param p2 (Vector3) the end point of the Hermite Spline
  79531. * @param t2 (Vector3) the tangent vector at the end point
  79532. * @param nbPoints (integer) the wanted number of points in the curve
  79533. * @returns the created Curve3
  79534. */
  79535. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  79536. /**
  79537. * Returns a Curve3 object along a CatmullRom Spline curve :
  79538. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  79539. * @param nbPoints (integer) the wanted number of points between each curve control points
  79540. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  79541. * @returns the created Curve3
  79542. */
  79543. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  79544. /**
  79545. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  79546. * A Curve3 is designed from a series of successive Vector3.
  79547. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  79548. * @param points points which make up the curve
  79549. */
  79550. constructor(points: Vector3[]);
  79551. /**
  79552. * @returns the Curve3 stored array of successive Vector3
  79553. */
  79554. getPoints(): Vector3[];
  79555. /**
  79556. * @returns the computed length (float) of the curve.
  79557. */
  79558. length(): number;
  79559. /**
  79560. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  79561. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  79562. * curveA and curveB keep unchanged.
  79563. * @param curve the curve to continue from this curve
  79564. * @returns the newly constructed curve
  79565. */
  79566. continue(curve: DeepImmutable<Curve3>): Curve3;
  79567. private _computeLength;
  79568. }
  79569. }
  79570. declare module BABYLON {
  79571. /**
  79572. * This represents the main contract an easing function should follow.
  79573. * Easing functions are used throughout the animation system.
  79574. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79575. */
  79576. export interface IEasingFunction {
  79577. /**
  79578. * Given an input gradient between 0 and 1, this returns the corrseponding value
  79579. * of the easing function.
  79580. * The link below provides some of the most common examples of easing functions.
  79581. * @see https://easings.net/
  79582. * @param gradient Defines the value between 0 and 1 we want the easing value for
  79583. * @returns the corresponding value on the curve defined by the easing function
  79584. */
  79585. ease(gradient: number): number;
  79586. }
  79587. /**
  79588. * Base class used for every default easing function.
  79589. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79590. */
  79591. export class EasingFunction implements IEasingFunction {
  79592. /**
  79593. * Interpolation follows the mathematical formula associated with the easing function.
  79594. */
  79595. static readonly EASINGMODE_EASEIN: number;
  79596. /**
  79597. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  79598. */
  79599. static readonly EASINGMODE_EASEOUT: number;
  79600. /**
  79601. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  79602. */
  79603. static readonly EASINGMODE_EASEINOUT: number;
  79604. private _easingMode;
  79605. /**
  79606. * Sets the easing mode of the current function.
  79607. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  79608. */
  79609. setEasingMode(easingMode: number): void;
  79610. /**
  79611. * Gets the current easing mode.
  79612. * @returns the easing mode
  79613. */
  79614. getEasingMode(): number;
  79615. /**
  79616. * @hidden
  79617. */
  79618. easeInCore(gradient: number): number;
  79619. /**
  79620. * Given an input gradient between 0 and 1, this returns the corresponding value
  79621. * of the easing function.
  79622. * @param gradient Defines the value between 0 and 1 we want the easing value for
  79623. * @returns the corresponding value on the curve defined by the easing function
  79624. */
  79625. ease(gradient: number): number;
  79626. }
  79627. /**
  79628. * Easing function with a circle shape (see link below).
  79629. * @see https://easings.net/#easeInCirc
  79630. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79631. */
  79632. export class CircleEase extends EasingFunction implements IEasingFunction {
  79633. /** @hidden */
  79634. easeInCore(gradient: number): number;
  79635. }
  79636. /**
  79637. * Easing function with a ease back shape (see link below).
  79638. * @see https://easings.net/#easeInBack
  79639. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79640. */
  79641. export class BackEase extends EasingFunction implements IEasingFunction {
  79642. /** Defines the amplitude of the function */
  79643. amplitude: number;
  79644. /**
  79645. * Instantiates a back ease easing
  79646. * @see https://easings.net/#easeInBack
  79647. * @param amplitude Defines the amplitude of the function
  79648. */
  79649. constructor(
  79650. /** Defines the amplitude of the function */
  79651. amplitude?: number);
  79652. /** @hidden */
  79653. easeInCore(gradient: number): number;
  79654. }
  79655. /**
  79656. * Easing function with a bouncing shape (see link below).
  79657. * @see https://easings.net/#easeInBounce
  79658. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79659. */
  79660. export class BounceEase extends EasingFunction implements IEasingFunction {
  79661. /** Defines the number of bounces */
  79662. bounces: number;
  79663. /** Defines the amplitude of the bounce */
  79664. bounciness: number;
  79665. /**
  79666. * Instantiates a bounce easing
  79667. * @see https://easings.net/#easeInBounce
  79668. * @param bounces Defines the number of bounces
  79669. * @param bounciness Defines the amplitude of the bounce
  79670. */
  79671. constructor(
  79672. /** Defines the number of bounces */
  79673. bounces?: number,
  79674. /** Defines the amplitude of the bounce */
  79675. bounciness?: number);
  79676. /** @hidden */
  79677. easeInCore(gradient: number): number;
  79678. }
  79679. /**
  79680. * Easing function with a power of 3 shape (see link below).
  79681. * @see https://easings.net/#easeInCubic
  79682. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79683. */
  79684. export class CubicEase extends EasingFunction implements IEasingFunction {
  79685. /** @hidden */
  79686. easeInCore(gradient: number): number;
  79687. }
  79688. /**
  79689. * Easing function with an elastic shape (see link below).
  79690. * @see https://easings.net/#easeInElastic
  79691. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79692. */
  79693. export class ElasticEase extends EasingFunction implements IEasingFunction {
  79694. /** Defines the number of oscillations*/
  79695. oscillations: number;
  79696. /** Defines the amplitude of the oscillations*/
  79697. springiness: number;
  79698. /**
  79699. * Instantiates an elastic easing function
  79700. * @see https://easings.net/#easeInElastic
  79701. * @param oscillations Defines the number of oscillations
  79702. * @param springiness Defines the amplitude of the oscillations
  79703. */
  79704. constructor(
  79705. /** Defines the number of oscillations*/
  79706. oscillations?: number,
  79707. /** Defines the amplitude of the oscillations*/
  79708. springiness?: number);
  79709. /** @hidden */
  79710. easeInCore(gradient: number): number;
  79711. }
  79712. /**
  79713. * Easing function with an exponential shape (see link below).
  79714. * @see https://easings.net/#easeInExpo
  79715. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79716. */
  79717. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  79718. /** Defines the exponent of the function */
  79719. exponent: number;
  79720. /**
  79721. * Instantiates an exponential easing function
  79722. * @see https://easings.net/#easeInExpo
  79723. * @param exponent Defines the exponent of the function
  79724. */
  79725. constructor(
  79726. /** Defines the exponent of the function */
  79727. exponent?: number);
  79728. /** @hidden */
  79729. easeInCore(gradient: number): number;
  79730. }
  79731. /**
  79732. * Easing function with a power shape (see link below).
  79733. * @see https://easings.net/#easeInQuad
  79734. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79735. */
  79736. export class PowerEase extends EasingFunction implements IEasingFunction {
  79737. /** Defines the power of the function */
  79738. power: number;
  79739. /**
  79740. * Instantiates an power base easing function
  79741. * @see https://easings.net/#easeInQuad
  79742. * @param power Defines the power of the function
  79743. */
  79744. constructor(
  79745. /** Defines the power of the function */
  79746. power?: number);
  79747. /** @hidden */
  79748. easeInCore(gradient: number): number;
  79749. }
  79750. /**
  79751. * Easing function with a power of 2 shape (see link below).
  79752. * @see https://easings.net/#easeInQuad
  79753. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79754. */
  79755. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  79756. /** @hidden */
  79757. easeInCore(gradient: number): number;
  79758. }
  79759. /**
  79760. * Easing function with a power of 4 shape (see link below).
  79761. * @see https://easings.net/#easeInQuart
  79762. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79763. */
  79764. export class QuarticEase extends EasingFunction implements IEasingFunction {
  79765. /** @hidden */
  79766. easeInCore(gradient: number): number;
  79767. }
  79768. /**
  79769. * Easing function with a power of 5 shape (see link below).
  79770. * @see https://easings.net/#easeInQuint
  79771. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79772. */
  79773. export class QuinticEase extends EasingFunction implements IEasingFunction {
  79774. /** @hidden */
  79775. easeInCore(gradient: number): number;
  79776. }
  79777. /**
  79778. * Easing function with a sin shape (see link below).
  79779. * @see https://easings.net/#easeInSine
  79780. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79781. */
  79782. export class SineEase extends EasingFunction implements IEasingFunction {
  79783. /** @hidden */
  79784. easeInCore(gradient: number): number;
  79785. }
  79786. /**
  79787. * Easing function with a bezier shape (see link below).
  79788. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  79789. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79790. */
  79791. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  79792. /** Defines the x component of the start tangent in the bezier curve */
  79793. x1: number;
  79794. /** Defines the y component of the start tangent in the bezier curve */
  79795. y1: number;
  79796. /** Defines the x component of the end tangent in the bezier curve */
  79797. x2: number;
  79798. /** Defines the y component of the end tangent in the bezier curve */
  79799. y2: number;
  79800. /**
  79801. * Instantiates a bezier function
  79802. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  79803. * @param x1 Defines the x component of the start tangent in the bezier curve
  79804. * @param y1 Defines the y component of the start tangent in the bezier curve
  79805. * @param x2 Defines the x component of the end tangent in the bezier curve
  79806. * @param y2 Defines the y component of the end tangent in the bezier curve
  79807. */
  79808. constructor(
  79809. /** Defines the x component of the start tangent in the bezier curve */
  79810. x1?: number,
  79811. /** Defines the y component of the start tangent in the bezier curve */
  79812. y1?: number,
  79813. /** Defines the x component of the end tangent in the bezier curve */
  79814. x2?: number,
  79815. /** Defines the y component of the end tangent in the bezier curve */
  79816. y2?: number);
  79817. /** @hidden */
  79818. easeInCore(gradient: number): number;
  79819. }
  79820. }
  79821. declare module BABYLON {
  79822. /**
  79823. * Class used to hold a RBG color
  79824. */
  79825. export class Color3 {
  79826. /**
  79827. * Defines the red component (between 0 and 1, default is 0)
  79828. */
  79829. r: number;
  79830. /**
  79831. * Defines the green component (between 0 and 1, default is 0)
  79832. */
  79833. g: number;
  79834. /**
  79835. * Defines the blue component (between 0 and 1, default is 0)
  79836. */
  79837. b: number;
  79838. /**
  79839. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  79840. * @param r defines the red component (between 0 and 1, default is 0)
  79841. * @param g defines the green component (between 0 and 1, default is 0)
  79842. * @param b defines the blue component (between 0 and 1, default is 0)
  79843. */
  79844. constructor(
  79845. /**
  79846. * Defines the red component (between 0 and 1, default is 0)
  79847. */
  79848. r?: number,
  79849. /**
  79850. * Defines the green component (between 0 and 1, default is 0)
  79851. */
  79852. g?: number,
  79853. /**
  79854. * Defines the blue component (between 0 and 1, default is 0)
  79855. */
  79856. b?: number);
  79857. /**
  79858. * Creates a string with the Color3 current values
  79859. * @returns the string representation of the Color3 object
  79860. */
  79861. toString(): string;
  79862. /**
  79863. * Returns the string "Color3"
  79864. * @returns "Color3"
  79865. */
  79866. getClassName(): string;
  79867. /**
  79868. * Compute the Color3 hash code
  79869. * @returns an unique number that can be used to hash Color3 objects
  79870. */
  79871. getHashCode(): number;
  79872. /**
  79873. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  79874. * @param array defines the array where to store the r,g,b components
  79875. * @param index defines an optional index in the target array to define where to start storing values
  79876. * @returns the current Color3 object
  79877. */
  79878. toArray(array: FloatArray, index?: number): Color3;
  79879. /**
  79880. * Returns a new Color4 object from the current Color3 and the given alpha
  79881. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  79882. * @returns a new Color4 object
  79883. */
  79884. toColor4(alpha?: number): Color4;
  79885. /**
  79886. * Returns a new array populated with 3 numeric elements : red, green and blue values
  79887. * @returns the new array
  79888. */
  79889. asArray(): number[];
  79890. /**
  79891. * Returns the luminance value
  79892. * @returns a float value
  79893. */
  79894. toLuminance(): number;
  79895. /**
  79896. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  79897. * @param otherColor defines the second operand
  79898. * @returns the new Color3 object
  79899. */
  79900. multiply(otherColor: DeepImmutable<Color3>): Color3;
  79901. /**
  79902. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  79903. * @param otherColor defines the second operand
  79904. * @param result defines the Color3 object where to store the result
  79905. * @returns the current Color3
  79906. */
  79907. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  79908. /**
  79909. * Determines equality between Color3 objects
  79910. * @param otherColor defines the second operand
  79911. * @returns true if the rgb values are equal to the given ones
  79912. */
  79913. equals(otherColor: DeepImmutable<Color3>): boolean;
  79914. /**
  79915. * Determines equality between the current Color3 object and a set of r,b,g values
  79916. * @param r defines the red component to check
  79917. * @param g defines the green component to check
  79918. * @param b defines the blue component to check
  79919. * @returns true if the rgb values are equal to the given ones
  79920. */
  79921. equalsFloats(r: number, g: number, b: number): boolean;
  79922. /**
  79923. * Multiplies in place each rgb value by scale
  79924. * @param scale defines the scaling factor
  79925. * @returns the updated Color3
  79926. */
  79927. scale(scale: number): Color3;
  79928. /**
  79929. * Multiplies the rgb values by scale and stores the result into "result"
  79930. * @param scale defines the scaling factor
  79931. * @param result defines the Color3 object where to store the result
  79932. * @returns the unmodified current Color3
  79933. */
  79934. scaleToRef(scale: number, result: Color3): Color3;
  79935. /**
  79936. * Scale the current Color3 values by a factor and add the result to a given Color3
  79937. * @param scale defines the scale factor
  79938. * @param result defines color to store the result into
  79939. * @returns the unmodified current Color3
  79940. */
  79941. scaleAndAddToRef(scale: number, result: Color3): Color3;
  79942. /**
  79943. * Clamps the rgb values by the min and max values and stores the result into "result"
  79944. * @param min defines minimum clamping value (default is 0)
  79945. * @param max defines maximum clamping value (default is 1)
  79946. * @param result defines color to store the result into
  79947. * @returns the original Color3
  79948. */
  79949. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  79950. /**
  79951. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  79952. * @param otherColor defines the second operand
  79953. * @returns the new Color3
  79954. */
  79955. add(otherColor: DeepImmutable<Color3>): Color3;
  79956. /**
  79957. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  79958. * @param otherColor defines the second operand
  79959. * @param result defines Color3 object to store the result into
  79960. * @returns the unmodified current Color3
  79961. */
  79962. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  79963. /**
  79964. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  79965. * @param otherColor defines the second operand
  79966. * @returns the new Color3
  79967. */
  79968. subtract(otherColor: DeepImmutable<Color3>): Color3;
  79969. /**
  79970. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  79971. * @param otherColor defines the second operand
  79972. * @param result defines Color3 object to store the result into
  79973. * @returns the unmodified current Color3
  79974. */
  79975. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  79976. /**
  79977. * Copy the current object
  79978. * @returns a new Color3 copied the current one
  79979. */
  79980. clone(): Color3;
  79981. /**
  79982. * Copies the rgb values from the source in the current Color3
  79983. * @param source defines the source Color3 object
  79984. * @returns the updated Color3 object
  79985. */
  79986. copyFrom(source: DeepImmutable<Color3>): Color3;
  79987. /**
  79988. * Updates the Color3 rgb values from the given floats
  79989. * @param r defines the red component to read from
  79990. * @param g defines the green component to read from
  79991. * @param b defines the blue component to read from
  79992. * @returns the current Color3 object
  79993. */
  79994. copyFromFloats(r: number, g: number, b: number): Color3;
  79995. /**
  79996. * Updates the Color3 rgb values from the given floats
  79997. * @param r defines the red component to read from
  79998. * @param g defines the green component to read from
  79999. * @param b defines the blue component to read from
  80000. * @returns the current Color3 object
  80001. */
  80002. set(r: number, g: number, b: number): Color3;
  80003. /**
  80004. * Compute the Color3 hexadecimal code as a string
  80005. * @returns a string containing the hexadecimal representation of the Color3 object
  80006. */
  80007. toHexString(): string;
  80008. /**
  80009. * Computes a new Color3 converted from the current one to linear space
  80010. * @returns a new Color3 object
  80011. */
  80012. toLinearSpace(): Color3;
  80013. /**
  80014. * Converts current color in rgb space to HSV values
  80015. * @returns a new color3 representing the HSV values
  80016. */
  80017. toHSV(): Color3;
  80018. /**
  80019. * Converts current color in rgb space to HSV values
  80020. * @param result defines the Color3 where to store the HSV values
  80021. */
  80022. toHSVToRef(result: Color3): void;
  80023. /**
  80024. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  80025. * @param convertedColor defines the Color3 object where to store the linear space version
  80026. * @returns the unmodified Color3
  80027. */
  80028. toLinearSpaceToRef(convertedColor: Color3): Color3;
  80029. /**
  80030. * Computes a new Color3 converted from the current one to gamma space
  80031. * @returns a new Color3 object
  80032. */
  80033. toGammaSpace(): Color3;
  80034. /**
  80035. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  80036. * @param convertedColor defines the Color3 object where to store the gamma space version
  80037. * @returns the unmodified Color3
  80038. */
  80039. toGammaSpaceToRef(convertedColor: Color3): Color3;
  80040. private static _BlackReadOnly;
  80041. /**
  80042. * Convert Hue, saturation and value to a Color3 (RGB)
  80043. * @param hue defines the hue
  80044. * @param saturation defines the saturation
  80045. * @param value defines the value
  80046. * @param result defines the Color3 where to store the RGB values
  80047. */
  80048. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  80049. /**
  80050. * Creates a new Color3 from the string containing valid hexadecimal values
  80051. * @param hex defines a string containing valid hexadecimal values
  80052. * @returns a new Color3 object
  80053. */
  80054. static FromHexString(hex: string): Color3;
  80055. /**
  80056. * Creates a new Color3 from the starting index of the given array
  80057. * @param array defines the source array
  80058. * @param offset defines an offset in the source array
  80059. * @returns a new Color3 object
  80060. */
  80061. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  80062. /**
  80063. * Creates a new Color3 from integer values (< 256)
  80064. * @param r defines the red component to read from (value between 0 and 255)
  80065. * @param g defines the green component to read from (value between 0 and 255)
  80066. * @param b defines the blue component to read from (value between 0 and 255)
  80067. * @returns a new Color3 object
  80068. */
  80069. static FromInts(r: number, g: number, b: number): Color3;
  80070. /**
  80071. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  80072. * @param start defines the start Color3 value
  80073. * @param end defines the end Color3 value
  80074. * @param amount defines the gradient value between start and end
  80075. * @returns a new Color3 object
  80076. */
  80077. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  80078. /**
  80079. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  80080. * @param left defines the start value
  80081. * @param right defines the end value
  80082. * @param amount defines the gradient factor
  80083. * @param result defines the Color3 object where to store the result
  80084. */
  80085. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  80086. /**
  80087. * Returns a Color3 value containing a red color
  80088. * @returns a new Color3 object
  80089. */
  80090. static Red(): Color3;
  80091. /**
  80092. * Returns a Color3 value containing a green color
  80093. * @returns a new Color3 object
  80094. */
  80095. static Green(): Color3;
  80096. /**
  80097. * Returns a Color3 value containing a blue color
  80098. * @returns a new Color3 object
  80099. */
  80100. static Blue(): Color3;
  80101. /**
  80102. * Returns a Color3 value containing a black color
  80103. * @returns a new Color3 object
  80104. */
  80105. static Black(): Color3;
  80106. /**
  80107. * Gets a Color3 value containing a black color that must not be updated
  80108. */
  80109. static get BlackReadOnly(): DeepImmutable<Color3>;
  80110. /**
  80111. * Returns a Color3 value containing a white color
  80112. * @returns a new Color3 object
  80113. */
  80114. static White(): Color3;
  80115. /**
  80116. * Returns a Color3 value containing a purple color
  80117. * @returns a new Color3 object
  80118. */
  80119. static Purple(): Color3;
  80120. /**
  80121. * Returns a Color3 value containing a magenta color
  80122. * @returns a new Color3 object
  80123. */
  80124. static Magenta(): Color3;
  80125. /**
  80126. * Returns a Color3 value containing a yellow color
  80127. * @returns a new Color3 object
  80128. */
  80129. static Yellow(): Color3;
  80130. /**
  80131. * Returns a Color3 value containing a gray color
  80132. * @returns a new Color3 object
  80133. */
  80134. static Gray(): Color3;
  80135. /**
  80136. * Returns a Color3 value containing a teal color
  80137. * @returns a new Color3 object
  80138. */
  80139. static Teal(): Color3;
  80140. /**
  80141. * Returns a Color3 value containing a random color
  80142. * @returns a new Color3 object
  80143. */
  80144. static Random(): Color3;
  80145. }
  80146. /**
  80147. * Class used to hold a RBGA color
  80148. */
  80149. export class Color4 {
  80150. /**
  80151. * Defines the red component (between 0 and 1, default is 0)
  80152. */
  80153. r: number;
  80154. /**
  80155. * Defines the green component (between 0 and 1, default is 0)
  80156. */
  80157. g: number;
  80158. /**
  80159. * Defines the blue component (between 0 and 1, default is 0)
  80160. */
  80161. b: number;
  80162. /**
  80163. * Defines the alpha component (between 0 and 1, default is 1)
  80164. */
  80165. a: number;
  80166. /**
  80167. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  80168. * @param r defines the red component (between 0 and 1, default is 0)
  80169. * @param g defines the green component (between 0 and 1, default is 0)
  80170. * @param b defines the blue component (between 0 and 1, default is 0)
  80171. * @param a defines the alpha component (between 0 and 1, default is 1)
  80172. */
  80173. constructor(
  80174. /**
  80175. * Defines the red component (between 0 and 1, default is 0)
  80176. */
  80177. r?: number,
  80178. /**
  80179. * Defines the green component (between 0 and 1, default is 0)
  80180. */
  80181. g?: number,
  80182. /**
  80183. * Defines the blue component (between 0 and 1, default is 0)
  80184. */
  80185. b?: number,
  80186. /**
  80187. * Defines the alpha component (between 0 and 1, default is 1)
  80188. */
  80189. a?: number);
  80190. /**
  80191. * Adds in place the given Color4 values to the current Color4 object
  80192. * @param right defines the second operand
  80193. * @returns the current updated Color4 object
  80194. */
  80195. addInPlace(right: DeepImmutable<Color4>): Color4;
  80196. /**
  80197. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  80198. * @returns the new array
  80199. */
  80200. asArray(): number[];
  80201. /**
  80202. * Stores from the starting index in the given array the Color4 successive values
  80203. * @param array defines the array where to store the r,g,b components
  80204. * @param index defines an optional index in the target array to define where to start storing values
  80205. * @returns the current Color4 object
  80206. */
  80207. toArray(array: number[], index?: number): Color4;
  80208. /**
  80209. * Determines equality between Color4 objects
  80210. * @param otherColor defines the second operand
  80211. * @returns true if the rgba values are equal to the given ones
  80212. */
  80213. equals(otherColor: DeepImmutable<Color4>): boolean;
  80214. /**
  80215. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  80216. * @param right defines the second operand
  80217. * @returns a new Color4 object
  80218. */
  80219. add(right: DeepImmutable<Color4>): Color4;
  80220. /**
  80221. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  80222. * @param right defines the second operand
  80223. * @returns a new Color4 object
  80224. */
  80225. subtract(right: DeepImmutable<Color4>): Color4;
  80226. /**
  80227. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  80228. * @param right defines the second operand
  80229. * @param result defines the Color4 object where to store the result
  80230. * @returns the current Color4 object
  80231. */
  80232. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  80233. /**
  80234. * Creates a new Color4 with the current Color4 values multiplied by scale
  80235. * @param scale defines the scaling factor to apply
  80236. * @returns a new Color4 object
  80237. */
  80238. scale(scale: number): Color4;
  80239. /**
  80240. * Multiplies the current Color4 values by scale and stores the result in "result"
  80241. * @param scale defines the scaling factor to apply
  80242. * @param result defines the Color4 object where to store the result
  80243. * @returns the current unmodified Color4
  80244. */
  80245. scaleToRef(scale: number, result: Color4): Color4;
  80246. /**
  80247. * Scale the current Color4 values by a factor and add the result to a given Color4
  80248. * @param scale defines the scale factor
  80249. * @param result defines the Color4 object where to store the result
  80250. * @returns the unmodified current Color4
  80251. */
  80252. scaleAndAddToRef(scale: number, result: Color4): Color4;
  80253. /**
  80254. * Clamps the rgb values by the min and max values and stores the result into "result"
  80255. * @param min defines minimum clamping value (default is 0)
  80256. * @param max defines maximum clamping value (default is 1)
  80257. * @param result defines color to store the result into.
  80258. * @returns the cuurent Color4
  80259. */
  80260. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  80261. /**
  80262. * Multipy an Color4 value by another and return a new Color4 object
  80263. * @param color defines the Color4 value to multiply by
  80264. * @returns a new Color4 object
  80265. */
  80266. multiply(color: Color4): Color4;
  80267. /**
  80268. * Multipy a Color4 value by another and push the result in a reference value
  80269. * @param color defines the Color4 value to multiply by
  80270. * @param result defines the Color4 to fill the result in
  80271. * @returns the result Color4
  80272. */
  80273. multiplyToRef(color: Color4, result: Color4): Color4;
  80274. /**
  80275. * Creates a string with the Color4 current values
  80276. * @returns the string representation of the Color4 object
  80277. */
  80278. toString(): string;
  80279. /**
  80280. * Returns the string "Color4"
  80281. * @returns "Color4"
  80282. */
  80283. getClassName(): string;
  80284. /**
  80285. * Compute the Color4 hash code
  80286. * @returns an unique number that can be used to hash Color4 objects
  80287. */
  80288. getHashCode(): number;
  80289. /**
  80290. * Creates a new Color4 copied from the current one
  80291. * @returns a new Color4 object
  80292. */
  80293. clone(): Color4;
  80294. /**
  80295. * Copies the given Color4 values into the current one
  80296. * @param source defines the source Color4 object
  80297. * @returns the current updated Color4 object
  80298. */
  80299. copyFrom(source: Color4): Color4;
  80300. /**
  80301. * Copies the given float values into the current one
  80302. * @param r defines the red component to read from
  80303. * @param g defines the green component to read from
  80304. * @param b defines the blue component to read from
  80305. * @param a defines the alpha component to read from
  80306. * @returns the current updated Color4 object
  80307. */
  80308. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  80309. /**
  80310. * Copies the given float values into the current one
  80311. * @param r defines the red component to read from
  80312. * @param g defines the green component to read from
  80313. * @param b defines the blue component to read from
  80314. * @param a defines the alpha component to read from
  80315. * @returns the current updated Color4 object
  80316. */
  80317. set(r: number, g: number, b: number, a: number): Color4;
  80318. /**
  80319. * Compute the Color4 hexadecimal code as a string
  80320. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  80321. * @returns a string containing the hexadecimal representation of the Color4 object
  80322. */
  80323. toHexString(returnAsColor3?: boolean): string;
  80324. /**
  80325. * Computes a new Color4 converted from the current one to linear space
  80326. * @returns a new Color4 object
  80327. */
  80328. toLinearSpace(): Color4;
  80329. /**
  80330. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  80331. * @param convertedColor defines the Color4 object where to store the linear space version
  80332. * @returns the unmodified Color4
  80333. */
  80334. toLinearSpaceToRef(convertedColor: Color4): Color4;
  80335. /**
  80336. * Computes a new Color4 converted from the current one to gamma space
  80337. * @returns a new Color4 object
  80338. */
  80339. toGammaSpace(): Color4;
  80340. /**
  80341. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  80342. * @param convertedColor defines the Color4 object where to store the gamma space version
  80343. * @returns the unmodified Color4
  80344. */
  80345. toGammaSpaceToRef(convertedColor: Color4): Color4;
  80346. /**
  80347. * Creates a new Color4 from the string containing valid hexadecimal values
  80348. * @param hex defines a string containing valid hexadecimal values
  80349. * @returns a new Color4 object
  80350. */
  80351. static FromHexString(hex: string): Color4;
  80352. /**
  80353. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  80354. * @param left defines the start value
  80355. * @param right defines the end value
  80356. * @param amount defines the gradient factor
  80357. * @returns a new Color4 object
  80358. */
  80359. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  80360. /**
  80361. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  80362. * @param left defines the start value
  80363. * @param right defines the end value
  80364. * @param amount defines the gradient factor
  80365. * @param result defines the Color4 object where to store data
  80366. */
  80367. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  80368. /**
  80369. * Creates a new Color4 from a Color3 and an alpha value
  80370. * @param color3 defines the source Color3 to read from
  80371. * @param alpha defines the alpha component (1.0 by default)
  80372. * @returns a new Color4 object
  80373. */
  80374. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  80375. /**
  80376. * Creates a new Color4 from the starting index element of the given array
  80377. * @param array defines the source array to read from
  80378. * @param offset defines the offset in the source array
  80379. * @returns a new Color4 object
  80380. */
  80381. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  80382. /**
  80383. * Creates a new Color3 from integer values (< 256)
  80384. * @param r defines the red component to read from (value between 0 and 255)
  80385. * @param g defines the green component to read from (value between 0 and 255)
  80386. * @param b defines the blue component to read from (value between 0 and 255)
  80387. * @param a defines the alpha component to read from (value between 0 and 255)
  80388. * @returns a new Color3 object
  80389. */
  80390. static FromInts(r: number, g: number, b: number, a: number): Color4;
  80391. /**
  80392. * Check the content of a given array and convert it to an array containing RGBA data
  80393. * If the original array was already containing count * 4 values then it is returned directly
  80394. * @param colors defines the array to check
  80395. * @param count defines the number of RGBA data to expect
  80396. * @returns an array containing count * 4 values (RGBA)
  80397. */
  80398. static CheckColors4(colors: number[], count: number): number[];
  80399. }
  80400. /**
  80401. * @hidden
  80402. */
  80403. export class TmpColors {
  80404. static Color3: Color3[];
  80405. static Color4: Color4[];
  80406. }
  80407. }
  80408. declare module BABYLON {
  80409. /**
  80410. * Defines an interface which represents an animation key frame
  80411. */
  80412. export interface IAnimationKey {
  80413. /**
  80414. * Frame of the key frame
  80415. */
  80416. frame: number;
  80417. /**
  80418. * Value at the specifies key frame
  80419. */
  80420. value: any;
  80421. /**
  80422. * The input tangent for the cubic hermite spline
  80423. */
  80424. inTangent?: any;
  80425. /**
  80426. * The output tangent for the cubic hermite spline
  80427. */
  80428. outTangent?: any;
  80429. /**
  80430. * The animation interpolation type
  80431. */
  80432. interpolation?: AnimationKeyInterpolation;
  80433. }
  80434. /**
  80435. * Enum for the animation key frame interpolation type
  80436. */
  80437. export enum AnimationKeyInterpolation {
  80438. /**
  80439. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  80440. */
  80441. STEP = 1
  80442. }
  80443. }
  80444. declare module BABYLON {
  80445. /**
  80446. * Represents the range of an animation
  80447. */
  80448. export class AnimationRange {
  80449. /**The name of the animation range**/
  80450. name: string;
  80451. /**The starting frame of the animation */
  80452. from: number;
  80453. /**The ending frame of the animation*/
  80454. to: number;
  80455. /**
  80456. * Initializes the range of an animation
  80457. * @param name The name of the animation range
  80458. * @param from The starting frame of the animation
  80459. * @param to The ending frame of the animation
  80460. */
  80461. constructor(
  80462. /**The name of the animation range**/
  80463. name: string,
  80464. /**The starting frame of the animation */
  80465. from: number,
  80466. /**The ending frame of the animation*/
  80467. to: number);
  80468. /**
  80469. * Makes a copy of the animation range
  80470. * @returns A copy of the animation range
  80471. */
  80472. clone(): AnimationRange;
  80473. }
  80474. }
  80475. declare module BABYLON {
  80476. /**
  80477. * Composed of a frame, and an action function
  80478. */
  80479. export class AnimationEvent {
  80480. /** The frame for which the event is triggered **/
  80481. frame: number;
  80482. /** The event to perform when triggered **/
  80483. action: (currentFrame: number) => void;
  80484. /** Specifies if the event should be triggered only once**/
  80485. onlyOnce?: boolean | undefined;
  80486. /**
  80487. * Specifies if the animation event is done
  80488. */
  80489. isDone: boolean;
  80490. /**
  80491. * Initializes the animation event
  80492. * @param frame The frame for which the event is triggered
  80493. * @param action The event to perform when triggered
  80494. * @param onlyOnce Specifies if the event should be triggered only once
  80495. */
  80496. constructor(
  80497. /** The frame for which the event is triggered **/
  80498. frame: number,
  80499. /** The event to perform when triggered **/
  80500. action: (currentFrame: number) => void,
  80501. /** Specifies if the event should be triggered only once**/
  80502. onlyOnce?: boolean | undefined);
  80503. /** @hidden */
  80504. _clone(): AnimationEvent;
  80505. }
  80506. }
  80507. declare module BABYLON {
  80508. /**
  80509. * Interface used to define a behavior
  80510. */
  80511. export interface Behavior<T> {
  80512. /** gets or sets behavior's name */
  80513. name: string;
  80514. /**
  80515. * Function called when the behavior needs to be initialized (after attaching it to a target)
  80516. */
  80517. init(): void;
  80518. /**
  80519. * Called when the behavior is attached to a target
  80520. * @param target defines the target where the behavior is attached to
  80521. */
  80522. attach(target: T): void;
  80523. /**
  80524. * Called when the behavior is detached from its target
  80525. */
  80526. detach(): void;
  80527. }
  80528. /**
  80529. * Interface implemented by classes supporting behaviors
  80530. */
  80531. export interface IBehaviorAware<T> {
  80532. /**
  80533. * Attach a behavior
  80534. * @param behavior defines the behavior to attach
  80535. * @returns the current host
  80536. */
  80537. addBehavior(behavior: Behavior<T>): T;
  80538. /**
  80539. * Remove a behavior from the current object
  80540. * @param behavior defines the behavior to detach
  80541. * @returns the current host
  80542. */
  80543. removeBehavior(behavior: Behavior<T>): T;
  80544. /**
  80545. * Gets a behavior using its name to search
  80546. * @param name defines the name to search
  80547. * @returns the behavior or null if not found
  80548. */
  80549. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  80550. }
  80551. }
  80552. declare module BABYLON {
  80553. /**
  80554. * Defines an array and its length.
  80555. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  80556. */
  80557. export interface ISmartArrayLike<T> {
  80558. /**
  80559. * The data of the array.
  80560. */
  80561. data: Array<T>;
  80562. /**
  80563. * The active length of the array.
  80564. */
  80565. length: number;
  80566. }
  80567. /**
  80568. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  80569. */
  80570. export class SmartArray<T> implements ISmartArrayLike<T> {
  80571. /**
  80572. * The full set of data from the array.
  80573. */
  80574. data: Array<T>;
  80575. /**
  80576. * The active length of the array.
  80577. */
  80578. length: number;
  80579. protected _id: number;
  80580. /**
  80581. * Instantiates a Smart Array.
  80582. * @param capacity defines the default capacity of the array.
  80583. */
  80584. constructor(capacity: number);
  80585. /**
  80586. * Pushes a value at the end of the active data.
  80587. * @param value defines the object to push in the array.
  80588. */
  80589. push(value: T): void;
  80590. /**
  80591. * Iterates over the active data and apply the lambda to them.
  80592. * @param func defines the action to apply on each value.
  80593. */
  80594. forEach(func: (content: T) => void): void;
  80595. /**
  80596. * Sorts the full sets of data.
  80597. * @param compareFn defines the comparison function to apply.
  80598. */
  80599. sort(compareFn: (a: T, b: T) => number): void;
  80600. /**
  80601. * Resets the active data to an empty array.
  80602. */
  80603. reset(): void;
  80604. /**
  80605. * Releases all the data from the array as well as the array.
  80606. */
  80607. dispose(): void;
  80608. /**
  80609. * Concats the active data with a given array.
  80610. * @param array defines the data to concatenate with.
  80611. */
  80612. concat(array: any): void;
  80613. /**
  80614. * Returns the position of a value in the active data.
  80615. * @param value defines the value to find the index for
  80616. * @returns the index if found in the active data otherwise -1
  80617. */
  80618. indexOf(value: T): number;
  80619. /**
  80620. * Returns whether an element is part of the active data.
  80621. * @param value defines the value to look for
  80622. * @returns true if found in the active data otherwise false
  80623. */
  80624. contains(value: T): boolean;
  80625. private static _GlobalId;
  80626. }
  80627. /**
  80628. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  80629. * The data in this array can only be present once
  80630. */
  80631. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  80632. private _duplicateId;
  80633. /**
  80634. * Pushes a value at the end of the active data.
  80635. * THIS DOES NOT PREVENT DUPPLICATE DATA
  80636. * @param value defines the object to push in the array.
  80637. */
  80638. push(value: T): void;
  80639. /**
  80640. * Pushes a value at the end of the active data.
  80641. * If the data is already present, it won t be added again
  80642. * @param value defines the object to push in the array.
  80643. * @returns true if added false if it was already present
  80644. */
  80645. pushNoDuplicate(value: T): boolean;
  80646. /**
  80647. * Resets the active data to an empty array.
  80648. */
  80649. reset(): void;
  80650. /**
  80651. * Concats the active data with a given array.
  80652. * This ensures no dupplicate will be present in the result.
  80653. * @param array defines the data to concatenate with.
  80654. */
  80655. concatWithNoDuplicate(array: any): void;
  80656. }
  80657. }
  80658. declare module BABYLON {
  80659. /**
  80660. * @ignore
  80661. * This is a list of all the different input types that are available in the application.
  80662. * Fo instance: ArcRotateCameraGamepadInput...
  80663. */
  80664. export var CameraInputTypes: {};
  80665. /**
  80666. * This is the contract to implement in order to create a new input class.
  80667. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  80668. */
  80669. export interface ICameraInput<TCamera extends Camera> {
  80670. /**
  80671. * Defines the camera the input is attached to.
  80672. */
  80673. camera: Nullable<TCamera>;
  80674. /**
  80675. * Gets the class name of the current intput.
  80676. * @returns the class name
  80677. */
  80678. getClassName(): string;
  80679. /**
  80680. * Get the friendly name associated with the input class.
  80681. * @returns the input friendly name
  80682. */
  80683. getSimpleName(): string;
  80684. /**
  80685. * Attach the input controls to a specific dom element to get the input from.
  80686. * @param element Defines the element the controls should be listened from
  80687. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80688. */
  80689. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80690. /**
  80691. * Detach the current controls from the specified dom element.
  80692. * @param element Defines the element to stop listening the inputs from
  80693. */
  80694. detachControl(element: Nullable<HTMLElement>): void;
  80695. /**
  80696. * Update the current camera state depending on the inputs that have been used this frame.
  80697. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  80698. */
  80699. checkInputs?: () => void;
  80700. }
  80701. /**
  80702. * Represents a map of input types to input instance or input index to input instance.
  80703. */
  80704. export interface CameraInputsMap<TCamera extends Camera> {
  80705. /**
  80706. * Accessor to the input by input type.
  80707. */
  80708. [name: string]: ICameraInput<TCamera>;
  80709. /**
  80710. * Accessor to the input by input index.
  80711. */
  80712. [idx: number]: ICameraInput<TCamera>;
  80713. }
  80714. /**
  80715. * This represents the input manager used within a camera.
  80716. * It helps dealing with all the different kind of input attached to a camera.
  80717. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80718. */
  80719. export class CameraInputsManager<TCamera extends Camera> {
  80720. /**
  80721. * Defines the list of inputs attahed to the camera.
  80722. */
  80723. attached: CameraInputsMap<TCamera>;
  80724. /**
  80725. * Defines the dom element the camera is collecting inputs from.
  80726. * This is null if the controls have not been attached.
  80727. */
  80728. attachedElement: Nullable<HTMLElement>;
  80729. /**
  80730. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80731. */
  80732. noPreventDefault: boolean;
  80733. /**
  80734. * Defined the camera the input manager belongs to.
  80735. */
  80736. camera: TCamera;
  80737. /**
  80738. * Update the current camera state depending on the inputs that have been used this frame.
  80739. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  80740. */
  80741. checkInputs: () => void;
  80742. /**
  80743. * Instantiate a new Camera Input Manager.
  80744. * @param camera Defines the camera the input manager blongs to
  80745. */
  80746. constructor(camera: TCamera);
  80747. /**
  80748. * Add an input method to a camera
  80749. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80750. * @param input camera input method
  80751. */
  80752. add(input: ICameraInput<TCamera>): void;
  80753. /**
  80754. * Remove a specific input method from a camera
  80755. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  80756. * @param inputToRemove camera input method
  80757. */
  80758. remove(inputToRemove: ICameraInput<TCamera>): void;
  80759. /**
  80760. * Remove a specific input type from a camera
  80761. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  80762. * @param inputType the type of the input to remove
  80763. */
  80764. removeByType(inputType: string): void;
  80765. private _addCheckInputs;
  80766. /**
  80767. * Attach the input controls to the currently attached dom element to listen the events from.
  80768. * @param input Defines the input to attach
  80769. */
  80770. attachInput(input: ICameraInput<TCamera>): void;
  80771. /**
  80772. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  80773. * @param element Defines the dom element to collect the events from
  80774. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80775. */
  80776. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  80777. /**
  80778. * Detach the current manager inputs controls from a specific dom element.
  80779. * @param element Defines the dom element to collect the events from
  80780. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  80781. */
  80782. detachElement(element: HTMLElement, disconnect?: boolean): void;
  80783. /**
  80784. * Rebuild the dynamic inputCheck function from the current list of
  80785. * defined inputs in the manager.
  80786. */
  80787. rebuildInputCheck(): void;
  80788. /**
  80789. * Remove all attached input methods from a camera
  80790. */
  80791. clear(): void;
  80792. /**
  80793. * Serialize the current input manager attached to a camera.
  80794. * This ensures than once parsed,
  80795. * the input associated to the camera will be identical to the current ones
  80796. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  80797. */
  80798. serialize(serializedCamera: any): void;
  80799. /**
  80800. * Parses an input manager serialized JSON to restore the previous list of inputs
  80801. * and states associated to a camera.
  80802. * @param parsedCamera Defines the JSON to parse
  80803. */
  80804. parse(parsedCamera: any): void;
  80805. }
  80806. }
  80807. declare module BABYLON {
  80808. /**
  80809. * Class used to store data that will be store in GPU memory
  80810. */
  80811. export class Buffer {
  80812. private _engine;
  80813. private _buffer;
  80814. /** @hidden */
  80815. _data: Nullable<DataArray>;
  80816. private _updatable;
  80817. private _instanced;
  80818. private _divisor;
  80819. /**
  80820. * Gets the byte stride.
  80821. */
  80822. readonly byteStride: number;
  80823. /**
  80824. * Constructor
  80825. * @param engine the engine
  80826. * @param data the data to use for this buffer
  80827. * @param updatable whether the data is updatable
  80828. * @param stride the stride (optional)
  80829. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  80830. * @param instanced whether the buffer is instanced (optional)
  80831. * @param useBytes set to true if the stride in in bytes (optional)
  80832. * @param divisor sets an optional divisor for instances (1 by default)
  80833. */
  80834. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  80835. /**
  80836. * Create a new VertexBuffer based on the current buffer
  80837. * @param kind defines the vertex buffer kind (position, normal, etc.)
  80838. * @param offset defines offset in the buffer (0 by default)
  80839. * @param size defines the size in floats of attributes (position is 3 for instance)
  80840. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  80841. * @param instanced defines if the vertex buffer contains indexed data
  80842. * @param useBytes defines if the offset and stride are in bytes *
  80843. * @param divisor sets an optional divisor for instances (1 by default)
  80844. * @returns the new vertex buffer
  80845. */
  80846. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  80847. /**
  80848. * Gets a boolean indicating if the Buffer is updatable?
  80849. * @returns true if the buffer is updatable
  80850. */
  80851. isUpdatable(): boolean;
  80852. /**
  80853. * Gets current buffer's data
  80854. * @returns a DataArray or null
  80855. */
  80856. getData(): Nullable<DataArray>;
  80857. /**
  80858. * Gets underlying native buffer
  80859. * @returns underlying native buffer
  80860. */
  80861. getBuffer(): Nullable<DataBuffer>;
  80862. /**
  80863. * Gets the stride in float32 units (i.e. byte stride / 4).
  80864. * May not be an integer if the byte stride is not divisible by 4.
  80865. * @returns the stride in float32 units
  80866. * @deprecated Please use byteStride instead.
  80867. */
  80868. getStrideSize(): number;
  80869. /**
  80870. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  80871. * @param data defines the data to store
  80872. */
  80873. create(data?: Nullable<DataArray>): void;
  80874. /** @hidden */
  80875. _rebuild(): void;
  80876. /**
  80877. * Update current buffer data
  80878. * @param data defines the data to store
  80879. */
  80880. update(data: DataArray): void;
  80881. /**
  80882. * Updates the data directly.
  80883. * @param data the new data
  80884. * @param offset the new offset
  80885. * @param vertexCount the vertex count (optional)
  80886. * @param useBytes set to true if the offset is in bytes
  80887. */
  80888. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  80889. /**
  80890. * Release all resources
  80891. */
  80892. dispose(): void;
  80893. }
  80894. /**
  80895. * Specialized buffer used to store vertex data
  80896. */
  80897. export class VertexBuffer {
  80898. /** @hidden */
  80899. _buffer: Buffer;
  80900. private _kind;
  80901. private _size;
  80902. private _ownsBuffer;
  80903. private _instanced;
  80904. private _instanceDivisor;
  80905. /**
  80906. * The byte type.
  80907. */
  80908. static readonly BYTE: number;
  80909. /**
  80910. * The unsigned byte type.
  80911. */
  80912. static readonly UNSIGNED_BYTE: number;
  80913. /**
  80914. * The short type.
  80915. */
  80916. static readonly SHORT: number;
  80917. /**
  80918. * The unsigned short type.
  80919. */
  80920. static readonly UNSIGNED_SHORT: number;
  80921. /**
  80922. * The integer type.
  80923. */
  80924. static readonly INT: number;
  80925. /**
  80926. * The unsigned integer type.
  80927. */
  80928. static readonly UNSIGNED_INT: number;
  80929. /**
  80930. * The float type.
  80931. */
  80932. static readonly FLOAT: number;
  80933. /**
  80934. * Gets or sets the instance divisor when in instanced mode
  80935. */
  80936. get instanceDivisor(): number;
  80937. set instanceDivisor(value: number);
  80938. /**
  80939. * Gets the byte stride.
  80940. */
  80941. readonly byteStride: number;
  80942. /**
  80943. * Gets the byte offset.
  80944. */
  80945. readonly byteOffset: number;
  80946. /**
  80947. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  80948. */
  80949. readonly normalized: boolean;
  80950. /**
  80951. * Gets the data type of each component in the array.
  80952. */
  80953. readonly type: number;
  80954. /**
  80955. * Constructor
  80956. * @param engine the engine
  80957. * @param data the data to use for this vertex buffer
  80958. * @param kind the vertex buffer kind
  80959. * @param updatable whether the data is updatable
  80960. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  80961. * @param stride the stride (optional)
  80962. * @param instanced whether the buffer is instanced (optional)
  80963. * @param offset the offset of the data (optional)
  80964. * @param size the number of components (optional)
  80965. * @param type the type of the component (optional)
  80966. * @param normalized whether the data contains normalized data (optional)
  80967. * @param useBytes set to true if stride and offset are in bytes (optional)
  80968. * @param divisor defines the instance divisor to use (1 by default)
  80969. */
  80970. 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, divisor?: number);
  80971. /** @hidden */
  80972. _rebuild(): void;
  80973. /**
  80974. * Returns the kind of the VertexBuffer (string)
  80975. * @returns a string
  80976. */
  80977. getKind(): string;
  80978. /**
  80979. * Gets a boolean indicating if the VertexBuffer is updatable?
  80980. * @returns true if the buffer is updatable
  80981. */
  80982. isUpdatable(): boolean;
  80983. /**
  80984. * Gets current buffer's data
  80985. * @returns a DataArray or null
  80986. */
  80987. getData(): Nullable<DataArray>;
  80988. /**
  80989. * Gets underlying native buffer
  80990. * @returns underlying native buffer
  80991. */
  80992. getBuffer(): Nullable<DataBuffer>;
  80993. /**
  80994. * Gets the stride in float32 units (i.e. byte stride / 4).
  80995. * May not be an integer if the byte stride is not divisible by 4.
  80996. * @returns the stride in float32 units
  80997. * @deprecated Please use byteStride instead.
  80998. */
  80999. getStrideSize(): number;
  81000. /**
  81001. * Returns the offset as a multiple of the type byte length.
  81002. * @returns the offset in bytes
  81003. * @deprecated Please use byteOffset instead.
  81004. */
  81005. getOffset(): number;
  81006. /**
  81007. * Returns the number of components per vertex attribute (integer)
  81008. * @returns the size in float
  81009. */
  81010. getSize(): number;
  81011. /**
  81012. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  81013. * @returns true if this buffer is instanced
  81014. */
  81015. getIsInstanced(): boolean;
  81016. /**
  81017. * Returns the instancing divisor, zero for non-instanced (integer).
  81018. * @returns a number
  81019. */
  81020. getInstanceDivisor(): number;
  81021. /**
  81022. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  81023. * @param data defines the data to store
  81024. */
  81025. create(data?: DataArray): void;
  81026. /**
  81027. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  81028. * This function will create a new buffer if the current one is not updatable
  81029. * @param data defines the data to store
  81030. */
  81031. update(data: DataArray): void;
  81032. /**
  81033. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  81034. * Returns the directly updated WebGLBuffer.
  81035. * @param data the new data
  81036. * @param offset the new offset
  81037. * @param useBytes set to true if the offset is in bytes
  81038. */
  81039. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  81040. /**
  81041. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  81042. */
  81043. dispose(): void;
  81044. /**
  81045. * Enumerates each value of this vertex buffer as numbers.
  81046. * @param count the number of values to enumerate
  81047. * @param callback the callback function called for each value
  81048. */
  81049. forEach(count: number, callback: (value: number, index: number) => void): void;
  81050. /**
  81051. * Positions
  81052. */
  81053. static readonly PositionKind: string;
  81054. /**
  81055. * Normals
  81056. */
  81057. static readonly NormalKind: string;
  81058. /**
  81059. * Tangents
  81060. */
  81061. static readonly TangentKind: string;
  81062. /**
  81063. * Texture coordinates
  81064. */
  81065. static readonly UVKind: string;
  81066. /**
  81067. * Texture coordinates 2
  81068. */
  81069. static readonly UV2Kind: string;
  81070. /**
  81071. * Texture coordinates 3
  81072. */
  81073. static readonly UV3Kind: string;
  81074. /**
  81075. * Texture coordinates 4
  81076. */
  81077. static readonly UV4Kind: string;
  81078. /**
  81079. * Texture coordinates 5
  81080. */
  81081. static readonly UV5Kind: string;
  81082. /**
  81083. * Texture coordinates 6
  81084. */
  81085. static readonly UV6Kind: string;
  81086. /**
  81087. * Colors
  81088. */
  81089. static readonly ColorKind: string;
  81090. /**
  81091. * Matrix indices (for bones)
  81092. */
  81093. static readonly MatricesIndicesKind: string;
  81094. /**
  81095. * Matrix weights (for bones)
  81096. */
  81097. static readonly MatricesWeightsKind: string;
  81098. /**
  81099. * Additional matrix indices (for bones)
  81100. */
  81101. static readonly MatricesIndicesExtraKind: string;
  81102. /**
  81103. * Additional matrix weights (for bones)
  81104. */
  81105. static readonly MatricesWeightsExtraKind: string;
  81106. /**
  81107. * Deduces the stride given a kind.
  81108. * @param kind The kind string to deduce
  81109. * @returns The deduced stride
  81110. */
  81111. static DeduceStride(kind: string): number;
  81112. /**
  81113. * Gets the byte length of the given type.
  81114. * @param type the type
  81115. * @returns the number of bytes
  81116. */
  81117. static GetTypeByteLength(type: number): number;
  81118. /**
  81119. * Enumerates each value of the given parameters as numbers.
  81120. * @param data the data to enumerate
  81121. * @param byteOffset the byte offset of the data
  81122. * @param byteStride the byte stride of the data
  81123. * @param componentCount the number of components per element
  81124. * @param componentType the type of the component
  81125. * @param count the number of values to enumerate
  81126. * @param normalized whether the data is normalized
  81127. * @param callback the callback function called for each value
  81128. */
  81129. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  81130. private static _GetFloatValue;
  81131. }
  81132. }
  81133. declare module BABYLON {
  81134. /**
  81135. * @hidden
  81136. */
  81137. export class IntersectionInfo {
  81138. bu: Nullable<number>;
  81139. bv: Nullable<number>;
  81140. distance: number;
  81141. faceId: number;
  81142. subMeshId: number;
  81143. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  81144. }
  81145. }
  81146. declare module BABYLON {
  81147. /**
  81148. * Represens a plane by the equation ax + by + cz + d = 0
  81149. */
  81150. export class Plane {
  81151. private static _TmpMatrix;
  81152. /**
  81153. * Normal of the plane (a,b,c)
  81154. */
  81155. normal: Vector3;
  81156. /**
  81157. * d component of the plane
  81158. */
  81159. d: number;
  81160. /**
  81161. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  81162. * @param a a component of the plane
  81163. * @param b b component of the plane
  81164. * @param c c component of the plane
  81165. * @param d d component of the plane
  81166. */
  81167. constructor(a: number, b: number, c: number, d: number);
  81168. /**
  81169. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  81170. */
  81171. asArray(): number[];
  81172. /**
  81173. * @returns a new plane copied from the current Plane.
  81174. */
  81175. clone(): Plane;
  81176. /**
  81177. * @returns the string "Plane".
  81178. */
  81179. getClassName(): string;
  81180. /**
  81181. * @returns the Plane hash code.
  81182. */
  81183. getHashCode(): number;
  81184. /**
  81185. * Normalize the current Plane in place.
  81186. * @returns the updated Plane.
  81187. */
  81188. normalize(): Plane;
  81189. /**
  81190. * Applies a transformation the plane and returns the result
  81191. * @param transformation the transformation matrix to be applied to the plane
  81192. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  81193. */
  81194. transform(transformation: DeepImmutable<Matrix>): Plane;
  81195. /**
  81196. * Calcualtte the dot product between the point and the plane normal
  81197. * @param point point to calculate the dot product with
  81198. * @returns the dot product (float) of the point coordinates and the plane normal.
  81199. */
  81200. dotCoordinate(point: DeepImmutable<Vector3>): number;
  81201. /**
  81202. * Updates the current Plane from the plane defined by the three given points.
  81203. * @param point1 one of the points used to contruct the plane
  81204. * @param point2 one of the points used to contruct the plane
  81205. * @param point3 one of the points used to contruct the plane
  81206. * @returns the updated Plane.
  81207. */
  81208. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  81209. /**
  81210. * Checks if the plane is facing a given direction
  81211. * @param direction the direction to check if the plane is facing
  81212. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  81213. * @returns True is the vector "direction" is the same side than the plane normal.
  81214. */
  81215. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  81216. /**
  81217. * Calculates the distance to a point
  81218. * @param point point to calculate distance to
  81219. * @returns the signed distance (float) from the given point to the Plane.
  81220. */
  81221. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  81222. /**
  81223. * Creates a plane from an array
  81224. * @param array the array to create a plane from
  81225. * @returns a new Plane from the given array.
  81226. */
  81227. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  81228. /**
  81229. * Creates a plane from three points
  81230. * @param point1 point used to create the plane
  81231. * @param point2 point used to create the plane
  81232. * @param point3 point used to create the plane
  81233. * @returns a new Plane defined by the three given points.
  81234. */
  81235. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  81236. /**
  81237. * Creates a plane from an origin point and a normal
  81238. * @param origin origin of the plane to be constructed
  81239. * @param normal normal of the plane to be constructed
  81240. * @returns a new Plane the normal vector to this plane at the given origin point.
  81241. * Note : the vector "normal" is updated because normalized.
  81242. */
  81243. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  81244. /**
  81245. * Calculates the distance from a plane and a point
  81246. * @param origin origin of the plane to be constructed
  81247. * @param normal normal of the plane to be constructed
  81248. * @param point point to calculate distance to
  81249. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  81250. */
  81251. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  81252. }
  81253. }
  81254. declare module BABYLON {
  81255. /**
  81256. * Class used to store bounding sphere information
  81257. */
  81258. export class BoundingSphere {
  81259. /**
  81260. * Gets the center of the bounding sphere in local space
  81261. */
  81262. readonly center: Vector3;
  81263. /**
  81264. * Radius of the bounding sphere in local space
  81265. */
  81266. radius: number;
  81267. /**
  81268. * Gets the center of the bounding sphere in world space
  81269. */
  81270. readonly centerWorld: Vector3;
  81271. /**
  81272. * Radius of the bounding sphere in world space
  81273. */
  81274. radiusWorld: number;
  81275. /**
  81276. * Gets the minimum vector in local space
  81277. */
  81278. readonly minimum: Vector3;
  81279. /**
  81280. * Gets the maximum vector in local space
  81281. */
  81282. readonly maximum: Vector3;
  81283. private _worldMatrix;
  81284. private static readonly TmpVector3;
  81285. /**
  81286. * Creates a new bounding sphere
  81287. * @param min defines the minimum vector (in local space)
  81288. * @param max defines the maximum vector (in local space)
  81289. * @param worldMatrix defines the new world matrix
  81290. */
  81291. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  81292. /**
  81293. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  81294. * @param min defines the new minimum vector (in local space)
  81295. * @param max defines the new maximum vector (in local space)
  81296. * @param worldMatrix defines the new world matrix
  81297. */
  81298. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  81299. /**
  81300. * Scale the current bounding sphere by applying a scale factor
  81301. * @param factor defines the scale factor to apply
  81302. * @returns the current bounding box
  81303. */
  81304. scale(factor: number): BoundingSphere;
  81305. /**
  81306. * Gets the world matrix of the bounding box
  81307. * @returns a matrix
  81308. */
  81309. getWorldMatrix(): DeepImmutable<Matrix>;
  81310. /** @hidden */
  81311. _update(worldMatrix: DeepImmutable<Matrix>): void;
  81312. /**
  81313. * Tests if the bounding sphere is intersecting the frustum planes
  81314. * @param frustumPlanes defines the frustum planes to test
  81315. * @returns true if there is an intersection
  81316. */
  81317. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81318. /**
  81319. * Tests if the bounding sphere center is in between the frustum planes.
  81320. * Used for optimistic fast inclusion.
  81321. * @param frustumPlanes defines the frustum planes to test
  81322. * @returns true if the sphere center is in between the frustum planes
  81323. */
  81324. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81325. /**
  81326. * Tests if a point is inside the bounding sphere
  81327. * @param point defines the point to test
  81328. * @returns true if the point is inside the bounding sphere
  81329. */
  81330. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  81331. /**
  81332. * Checks if two sphere intersct
  81333. * @param sphere0 sphere 0
  81334. * @param sphere1 sphere 1
  81335. * @returns true if the speres intersect
  81336. */
  81337. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  81338. }
  81339. }
  81340. declare module BABYLON {
  81341. /**
  81342. * Class used to store bounding box information
  81343. */
  81344. export class BoundingBox implements ICullable {
  81345. /**
  81346. * Gets the 8 vectors representing the bounding box in local space
  81347. */
  81348. readonly vectors: Vector3[];
  81349. /**
  81350. * Gets the center of the bounding box in local space
  81351. */
  81352. readonly center: Vector3;
  81353. /**
  81354. * Gets the center of the bounding box in world space
  81355. */
  81356. readonly centerWorld: Vector3;
  81357. /**
  81358. * Gets the extend size in local space
  81359. */
  81360. readonly extendSize: Vector3;
  81361. /**
  81362. * Gets the extend size in world space
  81363. */
  81364. readonly extendSizeWorld: Vector3;
  81365. /**
  81366. * Gets the OBB (object bounding box) directions
  81367. */
  81368. readonly directions: Vector3[];
  81369. /**
  81370. * Gets the 8 vectors representing the bounding box in world space
  81371. */
  81372. readonly vectorsWorld: Vector3[];
  81373. /**
  81374. * Gets the minimum vector in world space
  81375. */
  81376. readonly minimumWorld: Vector3;
  81377. /**
  81378. * Gets the maximum vector in world space
  81379. */
  81380. readonly maximumWorld: Vector3;
  81381. /**
  81382. * Gets the minimum vector in local space
  81383. */
  81384. readonly minimum: Vector3;
  81385. /**
  81386. * Gets the maximum vector in local space
  81387. */
  81388. readonly maximum: Vector3;
  81389. private _worldMatrix;
  81390. private static readonly TmpVector3;
  81391. /**
  81392. * @hidden
  81393. */
  81394. _tag: number;
  81395. /**
  81396. * Creates a new bounding box
  81397. * @param min defines the minimum vector (in local space)
  81398. * @param max defines the maximum vector (in local space)
  81399. * @param worldMatrix defines the new world matrix
  81400. */
  81401. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  81402. /**
  81403. * Recreates the entire bounding box from scratch as if we call the constructor in place
  81404. * @param min defines the new minimum vector (in local space)
  81405. * @param max defines the new maximum vector (in local space)
  81406. * @param worldMatrix defines the new world matrix
  81407. */
  81408. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  81409. /**
  81410. * Scale the current bounding box by applying a scale factor
  81411. * @param factor defines the scale factor to apply
  81412. * @returns the current bounding box
  81413. */
  81414. scale(factor: number): BoundingBox;
  81415. /**
  81416. * Gets the world matrix of the bounding box
  81417. * @returns a matrix
  81418. */
  81419. getWorldMatrix(): DeepImmutable<Matrix>;
  81420. /** @hidden */
  81421. _update(world: DeepImmutable<Matrix>): void;
  81422. /**
  81423. * Tests if the bounding box is intersecting the frustum planes
  81424. * @param frustumPlanes defines the frustum planes to test
  81425. * @returns true if there is an intersection
  81426. */
  81427. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81428. /**
  81429. * Tests if the bounding box is entirely inside the frustum planes
  81430. * @param frustumPlanes defines the frustum planes to test
  81431. * @returns true if there is an inclusion
  81432. */
  81433. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81434. /**
  81435. * Tests if a point is inside the bounding box
  81436. * @param point defines the point to test
  81437. * @returns true if the point is inside the bounding box
  81438. */
  81439. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  81440. /**
  81441. * Tests if the bounding box intersects with a bounding sphere
  81442. * @param sphere defines the sphere to test
  81443. * @returns true if there is an intersection
  81444. */
  81445. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  81446. /**
  81447. * Tests if the bounding box intersects with a box defined by a min and max vectors
  81448. * @param min defines the min vector to use
  81449. * @param max defines the max vector to use
  81450. * @returns true if there is an intersection
  81451. */
  81452. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  81453. /**
  81454. * Tests if two bounding boxes are intersections
  81455. * @param box0 defines the first box to test
  81456. * @param box1 defines the second box to test
  81457. * @returns true if there is an intersection
  81458. */
  81459. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  81460. /**
  81461. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  81462. * @param minPoint defines the minimum vector of the bounding box
  81463. * @param maxPoint defines the maximum vector of the bounding box
  81464. * @param sphereCenter defines the sphere center
  81465. * @param sphereRadius defines the sphere radius
  81466. * @returns true if there is an intersection
  81467. */
  81468. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  81469. /**
  81470. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  81471. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  81472. * @param frustumPlanes defines the frustum planes to test
  81473. * @return true if there is an inclusion
  81474. */
  81475. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81476. /**
  81477. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  81478. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  81479. * @param frustumPlanes defines the frustum planes to test
  81480. * @return true if there is an intersection
  81481. */
  81482. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81483. }
  81484. }
  81485. declare module BABYLON {
  81486. /** @hidden */
  81487. export class Collider {
  81488. /** Define if a collision was found */
  81489. collisionFound: boolean;
  81490. /**
  81491. * Define last intersection point in local space
  81492. */
  81493. intersectionPoint: Vector3;
  81494. /**
  81495. * Define last collided mesh
  81496. */
  81497. collidedMesh: Nullable<AbstractMesh>;
  81498. private _collisionPoint;
  81499. private _planeIntersectionPoint;
  81500. private _tempVector;
  81501. private _tempVector2;
  81502. private _tempVector3;
  81503. private _tempVector4;
  81504. private _edge;
  81505. private _baseToVertex;
  81506. private _destinationPoint;
  81507. private _slidePlaneNormal;
  81508. private _displacementVector;
  81509. /** @hidden */
  81510. _radius: Vector3;
  81511. /** @hidden */
  81512. _retry: number;
  81513. private _velocity;
  81514. private _basePoint;
  81515. private _epsilon;
  81516. /** @hidden */
  81517. _velocityWorldLength: number;
  81518. /** @hidden */
  81519. _basePointWorld: Vector3;
  81520. private _velocityWorld;
  81521. private _normalizedVelocity;
  81522. /** @hidden */
  81523. _initialVelocity: Vector3;
  81524. /** @hidden */
  81525. _initialPosition: Vector3;
  81526. private _nearestDistance;
  81527. private _collisionMask;
  81528. get collisionMask(): number;
  81529. set collisionMask(mask: number);
  81530. /**
  81531. * Gets the plane normal used to compute the sliding response (in local space)
  81532. */
  81533. get slidePlaneNormal(): Vector3;
  81534. /** @hidden */
  81535. _initialize(source: Vector3, dir: Vector3, e: number): void;
  81536. /** @hidden */
  81537. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  81538. /** @hidden */
  81539. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  81540. /** @hidden */
  81541. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  81542. /** @hidden */
  81543. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  81544. /** @hidden */
  81545. _getResponse(pos: Vector3, vel: Vector3): void;
  81546. }
  81547. }
  81548. declare module BABYLON {
  81549. /**
  81550. * Interface for cullable objects
  81551. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  81552. */
  81553. export interface ICullable {
  81554. /**
  81555. * Checks if the object or part of the object is in the frustum
  81556. * @param frustumPlanes Camera near/planes
  81557. * @returns true if the object is in frustum otherwise false
  81558. */
  81559. isInFrustum(frustumPlanes: Plane[]): boolean;
  81560. /**
  81561. * Checks if a cullable object (mesh...) is in the camera frustum
  81562. * Unlike isInFrustum this cheks the full bounding box
  81563. * @param frustumPlanes Camera near/planes
  81564. * @returns true if the object is in frustum otherwise false
  81565. */
  81566. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  81567. }
  81568. /**
  81569. * Info for a bounding data of a mesh
  81570. */
  81571. export class BoundingInfo implements ICullable {
  81572. /**
  81573. * Bounding box for the mesh
  81574. */
  81575. readonly boundingBox: BoundingBox;
  81576. /**
  81577. * Bounding sphere for the mesh
  81578. */
  81579. readonly boundingSphere: BoundingSphere;
  81580. private _isLocked;
  81581. private static readonly TmpVector3;
  81582. /**
  81583. * Constructs bounding info
  81584. * @param minimum min vector of the bounding box/sphere
  81585. * @param maximum max vector of the bounding box/sphere
  81586. * @param worldMatrix defines the new world matrix
  81587. */
  81588. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  81589. /**
  81590. * Recreates the entire bounding info from scratch as if we call the constructor in place
  81591. * @param min defines the new minimum vector (in local space)
  81592. * @param max defines the new maximum vector (in local space)
  81593. * @param worldMatrix defines the new world matrix
  81594. */
  81595. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  81596. /**
  81597. * min vector of the bounding box/sphere
  81598. */
  81599. get minimum(): Vector3;
  81600. /**
  81601. * max vector of the bounding box/sphere
  81602. */
  81603. get maximum(): Vector3;
  81604. /**
  81605. * If the info is locked and won't be updated to avoid perf overhead
  81606. */
  81607. get isLocked(): boolean;
  81608. set isLocked(value: boolean);
  81609. /**
  81610. * Updates the bounding sphere and box
  81611. * @param world world matrix to be used to update
  81612. */
  81613. update(world: DeepImmutable<Matrix>): void;
  81614. /**
  81615. * Recreate the bounding info to be centered around a specific point given a specific extend.
  81616. * @param center New center of the bounding info
  81617. * @param extend New extend of the bounding info
  81618. * @returns the current bounding info
  81619. */
  81620. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  81621. /**
  81622. * Scale the current bounding info by applying a scale factor
  81623. * @param factor defines the scale factor to apply
  81624. * @returns the current bounding info
  81625. */
  81626. scale(factor: number): BoundingInfo;
  81627. /**
  81628. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  81629. * @param frustumPlanes defines the frustum to test
  81630. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  81631. * @returns true if the bounding info is in the frustum planes
  81632. */
  81633. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  81634. /**
  81635. * Gets the world distance between the min and max points of the bounding box
  81636. */
  81637. get diagonalLength(): number;
  81638. /**
  81639. * Checks if a cullable object (mesh...) is in the camera frustum
  81640. * Unlike isInFrustum this cheks the full bounding box
  81641. * @param frustumPlanes Camera near/planes
  81642. * @returns true if the object is in frustum otherwise false
  81643. */
  81644. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81645. /** @hidden */
  81646. _checkCollision(collider: Collider): boolean;
  81647. /**
  81648. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  81649. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  81650. * @param point the point to check intersection with
  81651. * @returns if the point intersects
  81652. */
  81653. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  81654. /**
  81655. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  81656. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  81657. * @param boundingInfo the bounding info to check intersection with
  81658. * @param precise if the intersection should be done using OBB
  81659. * @returns if the bounding info intersects
  81660. */
  81661. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  81662. }
  81663. }
  81664. declare module BABYLON {
  81665. /**
  81666. * Extracts minimum and maximum values from a list of indexed positions
  81667. * @param positions defines the positions to use
  81668. * @param indices defines the indices to the positions
  81669. * @param indexStart defines the start index
  81670. * @param indexCount defines the end index
  81671. * @param bias defines bias value to add to the result
  81672. * @return minimum and maximum values
  81673. */
  81674. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  81675. minimum: Vector3;
  81676. maximum: Vector3;
  81677. };
  81678. /**
  81679. * Extracts minimum and maximum values from a list of positions
  81680. * @param positions defines the positions to use
  81681. * @param start defines the start index in the positions array
  81682. * @param count defines the number of positions to handle
  81683. * @param bias defines bias value to add to the result
  81684. * @param stride defines the stride size to use (distance between two positions in the positions array)
  81685. * @return minimum and maximum values
  81686. */
  81687. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  81688. minimum: Vector3;
  81689. maximum: Vector3;
  81690. };
  81691. }
  81692. declare module BABYLON {
  81693. /** @hidden */
  81694. export class WebGLDataBuffer extends DataBuffer {
  81695. private _buffer;
  81696. constructor(resource: WebGLBuffer);
  81697. get underlyingResource(): any;
  81698. }
  81699. }
  81700. declare module BABYLON {
  81701. /** @hidden */
  81702. export class WebGLPipelineContext implements IPipelineContext {
  81703. engine: ThinEngine;
  81704. program: Nullable<WebGLProgram>;
  81705. context?: WebGLRenderingContext;
  81706. vertexShader?: WebGLShader;
  81707. fragmentShader?: WebGLShader;
  81708. isParallelCompiled: boolean;
  81709. onCompiled?: () => void;
  81710. transformFeedback?: WebGLTransformFeedback | null;
  81711. vertexCompilationError: Nullable<string>;
  81712. fragmentCompilationError: Nullable<string>;
  81713. programLinkError: Nullable<string>;
  81714. programValidationError: Nullable<string>;
  81715. get isAsync(): boolean;
  81716. get isReady(): boolean;
  81717. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  81718. _getVertexShaderCode(): string | null;
  81719. _getFragmentShaderCode(): string | null;
  81720. }
  81721. }
  81722. declare module BABYLON {
  81723. interface ThinEngine {
  81724. /**
  81725. * Create an uniform buffer
  81726. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  81727. * @param elements defines the content of the uniform buffer
  81728. * @returns the webGL uniform buffer
  81729. */
  81730. createUniformBuffer(elements: FloatArray): DataBuffer;
  81731. /**
  81732. * Create a dynamic uniform buffer
  81733. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  81734. * @param elements defines the content of the uniform buffer
  81735. * @returns the webGL uniform buffer
  81736. */
  81737. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  81738. /**
  81739. * Update an existing uniform buffer
  81740. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  81741. * @param uniformBuffer defines the target uniform buffer
  81742. * @param elements defines the content to update
  81743. * @param offset defines the offset in the uniform buffer where update should start
  81744. * @param count defines the size of the data to update
  81745. */
  81746. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  81747. /**
  81748. * Bind an uniform buffer to the current webGL context
  81749. * @param buffer defines the buffer to bind
  81750. */
  81751. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  81752. /**
  81753. * Bind a buffer to the current webGL context at a given location
  81754. * @param buffer defines the buffer to bind
  81755. * @param location defines the index where to bind the buffer
  81756. */
  81757. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  81758. /**
  81759. * Bind a specific block at a given index in a specific shader program
  81760. * @param pipelineContext defines the pipeline context to use
  81761. * @param blockName defines the block name
  81762. * @param index defines the index where to bind the block
  81763. */
  81764. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  81765. }
  81766. }
  81767. declare module BABYLON {
  81768. /**
  81769. * Uniform buffer objects.
  81770. *
  81771. * Handles blocks of uniform on the GPU.
  81772. *
  81773. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  81774. *
  81775. * For more information, please refer to :
  81776. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  81777. */
  81778. export class UniformBuffer {
  81779. private _engine;
  81780. private _buffer;
  81781. private _data;
  81782. private _bufferData;
  81783. private _dynamic?;
  81784. private _uniformLocations;
  81785. private _uniformSizes;
  81786. private _uniformLocationPointer;
  81787. private _needSync;
  81788. private _noUBO;
  81789. private _currentEffect;
  81790. /** @hidden */
  81791. _alreadyBound: boolean;
  81792. private static _MAX_UNIFORM_SIZE;
  81793. private static _tempBuffer;
  81794. /**
  81795. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  81796. * This is dynamic to allow compat with webgl 1 and 2.
  81797. * You will need to pass the name of the uniform as well as the value.
  81798. */
  81799. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  81800. /**
  81801. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  81802. * This is dynamic to allow compat with webgl 1 and 2.
  81803. * You will need to pass the name of the uniform as well as the value.
  81804. */
  81805. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  81806. /**
  81807. * Lambda to Update a single float in a uniform buffer.
  81808. * This is dynamic to allow compat with webgl 1 and 2.
  81809. * You will need to pass the name of the uniform as well as the value.
  81810. */
  81811. updateFloat: (name: string, x: number) => void;
  81812. /**
  81813. * Lambda to Update a vec2 of float in a uniform buffer.
  81814. * This is dynamic to allow compat with webgl 1 and 2.
  81815. * You will need to pass the name of the uniform as well as the value.
  81816. */
  81817. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  81818. /**
  81819. * Lambda to Update a vec3 of float in a uniform buffer.
  81820. * This is dynamic to allow compat with webgl 1 and 2.
  81821. * You will need to pass the name of the uniform as well as the value.
  81822. */
  81823. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  81824. /**
  81825. * Lambda to Update a vec4 of float in a uniform buffer.
  81826. * This is dynamic to allow compat with webgl 1 and 2.
  81827. * You will need to pass the name of the uniform as well as the value.
  81828. */
  81829. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  81830. /**
  81831. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  81832. * This is dynamic to allow compat with webgl 1 and 2.
  81833. * You will need to pass the name of the uniform as well as the value.
  81834. */
  81835. updateMatrix: (name: string, mat: Matrix) => void;
  81836. /**
  81837. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  81838. * This is dynamic to allow compat with webgl 1 and 2.
  81839. * You will need to pass the name of the uniform as well as the value.
  81840. */
  81841. updateVector3: (name: string, vector: Vector3) => void;
  81842. /**
  81843. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  81844. * This is dynamic to allow compat with webgl 1 and 2.
  81845. * You will need to pass the name of the uniform as well as the value.
  81846. */
  81847. updateVector4: (name: string, vector: Vector4) => void;
  81848. /**
  81849. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  81850. * This is dynamic to allow compat with webgl 1 and 2.
  81851. * You will need to pass the name of the uniform as well as the value.
  81852. */
  81853. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  81854. /**
  81855. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  81856. * This is dynamic to allow compat with webgl 1 and 2.
  81857. * You will need to pass the name of the uniform as well as the value.
  81858. */
  81859. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  81860. /**
  81861. * Instantiates a new Uniform buffer objects.
  81862. *
  81863. * Handles blocks of uniform on the GPU.
  81864. *
  81865. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  81866. *
  81867. * For more information, please refer to :
  81868. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  81869. * @param engine Define the engine the buffer is associated with
  81870. * @param data Define the data contained in the buffer
  81871. * @param dynamic Define if the buffer is updatable
  81872. */
  81873. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  81874. /**
  81875. * Indicates if the buffer is using the WebGL2 UBO implementation,
  81876. * or just falling back on setUniformXXX calls.
  81877. */
  81878. get useUbo(): boolean;
  81879. /**
  81880. * Indicates if the WebGL underlying uniform buffer is in sync
  81881. * with the javascript cache data.
  81882. */
  81883. get isSync(): boolean;
  81884. /**
  81885. * Indicates if the WebGL underlying uniform buffer is dynamic.
  81886. * Also, a dynamic UniformBuffer will disable cache verification and always
  81887. * update the underlying WebGL uniform buffer to the GPU.
  81888. * @returns if Dynamic, otherwise false
  81889. */
  81890. isDynamic(): boolean;
  81891. /**
  81892. * The data cache on JS side.
  81893. * @returns the underlying data as a float array
  81894. */
  81895. getData(): Float32Array;
  81896. /**
  81897. * The underlying WebGL Uniform buffer.
  81898. * @returns the webgl buffer
  81899. */
  81900. getBuffer(): Nullable<DataBuffer>;
  81901. /**
  81902. * std140 layout specifies how to align data within an UBO structure.
  81903. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  81904. * for specs.
  81905. */
  81906. private _fillAlignment;
  81907. /**
  81908. * Adds an uniform in the buffer.
  81909. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  81910. * for the layout to be correct !
  81911. * @param name Name of the uniform, as used in the uniform block in the shader.
  81912. * @param size Data size, or data directly.
  81913. */
  81914. addUniform(name: string, size: number | number[]): void;
  81915. /**
  81916. * Adds a Matrix 4x4 to the uniform buffer.
  81917. * @param name Name of the uniform, as used in the uniform block in the shader.
  81918. * @param mat A 4x4 matrix.
  81919. */
  81920. addMatrix(name: string, mat: Matrix): void;
  81921. /**
  81922. * Adds a vec2 to the uniform buffer.
  81923. * @param name Name of the uniform, as used in the uniform block in the shader.
  81924. * @param x Define the x component value of the vec2
  81925. * @param y Define the y component value of the vec2
  81926. */
  81927. addFloat2(name: string, x: number, y: number): void;
  81928. /**
  81929. * Adds a vec3 to the uniform buffer.
  81930. * @param name Name of the uniform, as used in the uniform block in the shader.
  81931. * @param x Define the x component value of the vec3
  81932. * @param y Define the y component value of the vec3
  81933. * @param z Define the z component value of the vec3
  81934. */
  81935. addFloat3(name: string, x: number, y: number, z: number): void;
  81936. /**
  81937. * Adds a vec3 to the uniform buffer.
  81938. * @param name Name of the uniform, as used in the uniform block in the shader.
  81939. * @param color Define the vec3 from a Color
  81940. */
  81941. addColor3(name: string, color: Color3): void;
  81942. /**
  81943. * Adds a vec4 to the uniform buffer.
  81944. * @param name Name of the uniform, as used in the uniform block in the shader.
  81945. * @param color Define the rgb components from a Color
  81946. * @param alpha Define the a component of the vec4
  81947. */
  81948. addColor4(name: string, color: Color3, alpha: number): void;
  81949. /**
  81950. * Adds a vec3 to the uniform buffer.
  81951. * @param name Name of the uniform, as used in the uniform block in the shader.
  81952. * @param vector Define the vec3 components from a Vector
  81953. */
  81954. addVector3(name: string, vector: Vector3): void;
  81955. /**
  81956. * Adds a Matrix 3x3 to the uniform buffer.
  81957. * @param name Name of the uniform, as used in the uniform block in the shader.
  81958. */
  81959. addMatrix3x3(name: string): void;
  81960. /**
  81961. * Adds a Matrix 2x2 to the uniform buffer.
  81962. * @param name Name of the uniform, as used in the uniform block in the shader.
  81963. */
  81964. addMatrix2x2(name: string): void;
  81965. /**
  81966. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  81967. */
  81968. create(): void;
  81969. /** @hidden */
  81970. _rebuild(): void;
  81971. /**
  81972. * Updates the WebGL Uniform Buffer on the GPU.
  81973. * If the `dynamic` flag is set to true, no cache comparison is done.
  81974. * Otherwise, the buffer will be updated only if the cache differs.
  81975. */
  81976. update(): void;
  81977. /**
  81978. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  81979. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  81980. * @param data Define the flattened data
  81981. * @param size Define the size of the data.
  81982. */
  81983. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  81984. private _valueCache;
  81985. private _cacheMatrix;
  81986. private _updateMatrix3x3ForUniform;
  81987. private _updateMatrix3x3ForEffect;
  81988. private _updateMatrix2x2ForEffect;
  81989. private _updateMatrix2x2ForUniform;
  81990. private _updateFloatForEffect;
  81991. private _updateFloatForUniform;
  81992. private _updateFloat2ForEffect;
  81993. private _updateFloat2ForUniform;
  81994. private _updateFloat3ForEffect;
  81995. private _updateFloat3ForUniform;
  81996. private _updateFloat4ForEffect;
  81997. private _updateFloat4ForUniform;
  81998. private _updateMatrixForEffect;
  81999. private _updateMatrixForUniform;
  82000. private _updateVector3ForEffect;
  82001. private _updateVector3ForUniform;
  82002. private _updateVector4ForEffect;
  82003. private _updateVector4ForUniform;
  82004. private _updateColor3ForEffect;
  82005. private _updateColor3ForUniform;
  82006. private _updateColor4ForEffect;
  82007. private _updateColor4ForUniform;
  82008. /**
  82009. * Sets a sampler uniform on the effect.
  82010. * @param name Define the name of the sampler.
  82011. * @param texture Define the texture to set in the sampler
  82012. */
  82013. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  82014. /**
  82015. * Directly updates the value of the uniform in the cache AND on the GPU.
  82016. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  82017. * @param data Define the flattened data
  82018. */
  82019. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  82020. /**
  82021. * Binds this uniform buffer to an effect.
  82022. * @param effect Define the effect to bind the buffer to
  82023. * @param name Name of the uniform block in the shader.
  82024. */
  82025. bindToEffect(effect: Effect, name: string): void;
  82026. /**
  82027. * Disposes the uniform buffer.
  82028. */
  82029. dispose(): void;
  82030. }
  82031. }
  82032. declare module BABYLON {
  82033. /**
  82034. * Enum that determines the text-wrapping mode to use.
  82035. */
  82036. export enum InspectableType {
  82037. /**
  82038. * Checkbox for booleans
  82039. */
  82040. Checkbox = 0,
  82041. /**
  82042. * Sliders for numbers
  82043. */
  82044. Slider = 1,
  82045. /**
  82046. * Vector3
  82047. */
  82048. Vector3 = 2,
  82049. /**
  82050. * Quaternions
  82051. */
  82052. Quaternion = 3,
  82053. /**
  82054. * Color3
  82055. */
  82056. Color3 = 4,
  82057. /**
  82058. * String
  82059. */
  82060. String = 5
  82061. }
  82062. /**
  82063. * Interface used to define custom inspectable properties.
  82064. * This interface is used by the inspector to display custom property grids
  82065. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82066. */
  82067. export interface IInspectable {
  82068. /**
  82069. * Gets the label to display
  82070. */
  82071. label: string;
  82072. /**
  82073. * Gets the name of the property to edit
  82074. */
  82075. propertyName: string;
  82076. /**
  82077. * Gets the type of the editor to use
  82078. */
  82079. type: InspectableType;
  82080. /**
  82081. * Gets the minimum value of the property when using in "slider" mode
  82082. */
  82083. min?: number;
  82084. /**
  82085. * Gets the maximum value of the property when using in "slider" mode
  82086. */
  82087. max?: number;
  82088. /**
  82089. * Gets the setp to use when using in "slider" mode
  82090. */
  82091. step?: number;
  82092. }
  82093. }
  82094. declare module BABYLON {
  82095. /**
  82096. * Class used to provide helper for timing
  82097. */
  82098. export class TimingTools {
  82099. /**
  82100. * Polyfill for setImmediate
  82101. * @param action defines the action to execute after the current execution block
  82102. */
  82103. static SetImmediate(action: () => void): void;
  82104. }
  82105. }
  82106. declare module BABYLON {
  82107. /**
  82108. * Class used to enable instatition of objects by class name
  82109. */
  82110. export class InstantiationTools {
  82111. /**
  82112. * Use this object to register external classes like custom textures or material
  82113. * to allow the laoders to instantiate them
  82114. */
  82115. static RegisteredExternalClasses: {
  82116. [key: string]: Object;
  82117. };
  82118. /**
  82119. * Tries to instantiate a new object from a given class name
  82120. * @param className defines the class name to instantiate
  82121. * @returns the new object or null if the system was not able to do the instantiation
  82122. */
  82123. static Instantiate(className: string): any;
  82124. }
  82125. }
  82126. declare module BABYLON {
  82127. /**
  82128. * Define options used to create a depth texture
  82129. */
  82130. export class DepthTextureCreationOptions {
  82131. /** Specifies whether or not a stencil should be allocated in the texture */
  82132. generateStencil?: boolean;
  82133. /** Specifies whether or not bilinear filtering is enable on the texture */
  82134. bilinearFiltering?: boolean;
  82135. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  82136. comparisonFunction?: number;
  82137. /** Specifies if the created texture is a cube texture */
  82138. isCube?: boolean;
  82139. }
  82140. }
  82141. declare module BABYLON {
  82142. interface ThinEngine {
  82143. /**
  82144. * Creates a depth stencil cube texture.
  82145. * This is only available in WebGL 2.
  82146. * @param size The size of face edge in the cube texture.
  82147. * @param options The options defining the cube texture.
  82148. * @returns The cube texture
  82149. */
  82150. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  82151. /**
  82152. * Creates a cube texture
  82153. * @param rootUrl defines the url where the files to load is located
  82154. * @param scene defines the current scene
  82155. * @param files defines the list of files to load (1 per face)
  82156. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  82157. * @param onLoad defines an optional callback raised when the texture is loaded
  82158. * @param onError defines an optional callback raised if there is an issue to load the texture
  82159. * @param format defines the format of the data
  82160. * @param forcedExtension defines the extension to use to pick the right loader
  82161. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  82162. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  82163. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  82164. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  82165. * @returns the cube texture as an InternalTexture
  82166. */
  82167. 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>): InternalTexture;
  82168. /**
  82169. * Creates a cube texture
  82170. * @param rootUrl defines the url where the files to load is located
  82171. * @param scene defines the current scene
  82172. * @param files defines the list of files to load (1 per face)
  82173. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  82174. * @param onLoad defines an optional callback raised when the texture is loaded
  82175. * @param onError defines an optional callback raised if there is an issue to load the texture
  82176. * @param format defines the format of the data
  82177. * @param forcedExtension defines the extension to use to pick the right loader
  82178. * @returns the cube texture as an InternalTexture
  82179. */
  82180. 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;
  82181. /**
  82182. * Creates a cube texture
  82183. * @param rootUrl defines the url where the files to load is located
  82184. * @param scene defines the current scene
  82185. * @param files defines the list of files to load (1 per face)
  82186. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  82187. * @param onLoad defines an optional callback raised when the texture is loaded
  82188. * @param onError defines an optional callback raised if there is an issue to load the texture
  82189. * @param format defines the format of the data
  82190. * @param forcedExtension defines the extension to use to pick the right loader
  82191. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  82192. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  82193. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  82194. * @returns the cube texture as an InternalTexture
  82195. */
  82196. 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;
  82197. /** @hidden */
  82198. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  82199. /** @hidden */
  82200. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  82201. /** @hidden */
  82202. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  82203. /** @hidden */
  82204. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  82205. /**
  82206. * @hidden
  82207. */
  82208. _setCubeMapTextureParams(loadMipmap: boolean): void;
  82209. }
  82210. }
  82211. declare module BABYLON {
  82212. /**
  82213. * Class for creating a cube texture
  82214. */
  82215. export class CubeTexture extends BaseTexture {
  82216. private _delayedOnLoad;
  82217. /**
  82218. * Observable triggered once the texture has been loaded.
  82219. */
  82220. onLoadObservable: Observable<CubeTexture>;
  82221. /**
  82222. * The url of the texture
  82223. */
  82224. url: string;
  82225. /**
  82226. * Gets or sets the center of the bounding box associated with the cube texture.
  82227. * It must define where the camera used to render the texture was set
  82228. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  82229. */
  82230. boundingBoxPosition: Vector3;
  82231. private _boundingBoxSize;
  82232. /**
  82233. * Gets or sets the size of the bounding box associated with the cube texture
  82234. * When defined, the cubemap will switch to local mode
  82235. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  82236. * @example https://www.babylonjs-playground.com/#RNASML
  82237. */
  82238. set boundingBoxSize(value: Vector3);
  82239. /**
  82240. * Returns the bounding box size
  82241. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  82242. */
  82243. get boundingBoxSize(): Vector3;
  82244. protected _rotationY: number;
  82245. /**
  82246. * Sets texture matrix rotation angle around Y axis in radians.
  82247. */
  82248. set rotationY(value: number);
  82249. /**
  82250. * Gets texture matrix rotation angle around Y axis radians.
  82251. */
  82252. get rotationY(): number;
  82253. /**
  82254. * Are mip maps generated for this texture or not.
  82255. */
  82256. get noMipmap(): boolean;
  82257. private _noMipmap;
  82258. private _files;
  82259. protected _forcedExtension: Nullable<string>;
  82260. private _extensions;
  82261. private _textureMatrix;
  82262. private _format;
  82263. private _createPolynomials;
  82264. /** @hidden */
  82265. _prefiltered: boolean;
  82266. /**
  82267. * Creates a cube texture from an array of image urls
  82268. * @param files defines an array of image urls
  82269. * @param scene defines the hosting scene
  82270. * @param noMipmap specifies if mip maps are not used
  82271. * @returns a cube texture
  82272. */
  82273. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  82274. /**
  82275. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  82276. * @param url defines the url of the prefiltered texture
  82277. * @param scene defines the scene the texture is attached to
  82278. * @param forcedExtension defines the extension of the file if different from the url
  82279. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  82280. * @return the prefiltered texture
  82281. */
  82282. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  82283. /**
  82284. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  82285. * as prefiltered data.
  82286. * @param rootUrl defines the url of the texture or the root name of the six images
  82287. * @param scene defines the scene the texture is attached to
  82288. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  82289. * @param noMipmap defines if mipmaps should be created or not
  82290. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  82291. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  82292. * @param onError defines a callback triggered in case of error during load
  82293. * @param format defines the internal format to use for the texture once loaded
  82294. * @param prefiltered defines whether or not the texture is created from prefiltered data
  82295. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  82296. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  82297. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  82298. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  82299. * @return the cube texture
  82300. */
  82301. 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);
  82302. /**
  82303. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  82304. */
  82305. get isPrefiltered(): boolean;
  82306. /**
  82307. * Get the current class name of the texture useful for serialization or dynamic coding.
  82308. * @returns "CubeTexture"
  82309. */
  82310. getClassName(): string;
  82311. /**
  82312. * Update the url (and optional buffer) of this texture if url was null during construction.
  82313. * @param url the url of the texture
  82314. * @param forcedExtension defines the extension to use
  82315. * @param onLoad callback called when the texture is loaded (defaults to null)
  82316. * @param prefiltered Defines whether the updated texture is prefiltered or not
  82317. */
  82318. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  82319. /**
  82320. * Delays loading of the cube texture
  82321. * @param forcedExtension defines the extension to use
  82322. */
  82323. delayLoad(forcedExtension?: string): void;
  82324. /**
  82325. * Returns the reflection texture matrix
  82326. * @returns the reflection texture matrix
  82327. */
  82328. getReflectionTextureMatrix(): Matrix;
  82329. /**
  82330. * Sets the reflection texture matrix
  82331. * @param value Reflection texture matrix
  82332. */
  82333. setReflectionTextureMatrix(value: Matrix): void;
  82334. /**
  82335. * Parses text to create a cube texture
  82336. * @param parsedTexture define the serialized text to read from
  82337. * @param scene defines the hosting scene
  82338. * @param rootUrl defines the root url of the cube texture
  82339. * @returns a cube texture
  82340. */
  82341. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  82342. /**
  82343. * Makes a clone, or deep copy, of the cube texture
  82344. * @returns a new cube texture
  82345. */
  82346. clone(): CubeTexture;
  82347. }
  82348. }
  82349. declare module BABYLON {
  82350. /**
  82351. * Manages the defines for the Material
  82352. */
  82353. export class MaterialDefines {
  82354. /** @hidden */
  82355. protected _keys: string[];
  82356. private _isDirty;
  82357. /** @hidden */
  82358. _renderId: number;
  82359. /** @hidden */
  82360. _areLightsDirty: boolean;
  82361. /** @hidden */
  82362. _areLightsDisposed: boolean;
  82363. /** @hidden */
  82364. _areAttributesDirty: boolean;
  82365. /** @hidden */
  82366. _areTexturesDirty: boolean;
  82367. /** @hidden */
  82368. _areFresnelDirty: boolean;
  82369. /** @hidden */
  82370. _areMiscDirty: boolean;
  82371. /** @hidden */
  82372. _areImageProcessingDirty: boolean;
  82373. /** @hidden */
  82374. _normals: boolean;
  82375. /** @hidden */
  82376. _uvs: boolean;
  82377. /** @hidden */
  82378. _needNormals: boolean;
  82379. /** @hidden */
  82380. _needUVs: boolean;
  82381. [id: string]: any;
  82382. /**
  82383. * Specifies if the material needs to be re-calculated
  82384. */
  82385. get isDirty(): boolean;
  82386. /**
  82387. * Marks the material to indicate that it has been re-calculated
  82388. */
  82389. markAsProcessed(): void;
  82390. /**
  82391. * Marks the material to indicate that it needs to be re-calculated
  82392. */
  82393. markAsUnprocessed(): void;
  82394. /**
  82395. * Marks the material to indicate all of its defines need to be re-calculated
  82396. */
  82397. markAllAsDirty(): void;
  82398. /**
  82399. * Marks the material to indicate that image processing needs to be re-calculated
  82400. */
  82401. markAsImageProcessingDirty(): void;
  82402. /**
  82403. * Marks the material to indicate the lights need to be re-calculated
  82404. * @param disposed Defines whether the light is dirty due to dispose or not
  82405. */
  82406. markAsLightDirty(disposed?: boolean): void;
  82407. /**
  82408. * Marks the attribute state as changed
  82409. */
  82410. markAsAttributesDirty(): void;
  82411. /**
  82412. * Marks the texture state as changed
  82413. */
  82414. markAsTexturesDirty(): void;
  82415. /**
  82416. * Marks the fresnel state as changed
  82417. */
  82418. markAsFresnelDirty(): void;
  82419. /**
  82420. * Marks the misc state as changed
  82421. */
  82422. markAsMiscDirty(): void;
  82423. /**
  82424. * Rebuilds the material defines
  82425. */
  82426. rebuild(): void;
  82427. /**
  82428. * Specifies if two material defines are equal
  82429. * @param other - A material define instance to compare to
  82430. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  82431. */
  82432. isEqual(other: MaterialDefines): boolean;
  82433. /**
  82434. * Clones this instance's defines to another instance
  82435. * @param other - material defines to clone values to
  82436. */
  82437. cloneTo(other: MaterialDefines): void;
  82438. /**
  82439. * Resets the material define values
  82440. */
  82441. reset(): void;
  82442. /**
  82443. * Converts the material define values to a string
  82444. * @returns - String of material define information
  82445. */
  82446. toString(): string;
  82447. }
  82448. }
  82449. declare module BABYLON {
  82450. /**
  82451. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  82452. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  82453. * 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;
  82454. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  82455. */
  82456. export class ColorCurves {
  82457. private _dirty;
  82458. private _tempColor;
  82459. private _globalCurve;
  82460. private _highlightsCurve;
  82461. private _midtonesCurve;
  82462. private _shadowsCurve;
  82463. private _positiveCurve;
  82464. private _negativeCurve;
  82465. private _globalHue;
  82466. private _globalDensity;
  82467. private _globalSaturation;
  82468. private _globalExposure;
  82469. /**
  82470. * Gets the global Hue value.
  82471. * 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).
  82472. */
  82473. get globalHue(): number;
  82474. /**
  82475. * Sets the global Hue value.
  82476. * 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).
  82477. */
  82478. set globalHue(value: number);
  82479. /**
  82480. * Gets the global Density value.
  82481. * 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.
  82482. * Values less than zero provide a filter of opposite hue.
  82483. */
  82484. get globalDensity(): number;
  82485. /**
  82486. * Sets the global Density value.
  82487. * 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.
  82488. * Values less than zero provide a filter of opposite hue.
  82489. */
  82490. set globalDensity(value: number);
  82491. /**
  82492. * Gets the global Saturation value.
  82493. * 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.
  82494. */
  82495. get globalSaturation(): number;
  82496. /**
  82497. * Sets the global Saturation value.
  82498. * 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.
  82499. */
  82500. set globalSaturation(value: number);
  82501. /**
  82502. * Gets the global Exposure value.
  82503. * 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.
  82504. */
  82505. get globalExposure(): number;
  82506. /**
  82507. * Sets the global Exposure value.
  82508. * 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.
  82509. */
  82510. set globalExposure(value: number);
  82511. private _highlightsHue;
  82512. private _highlightsDensity;
  82513. private _highlightsSaturation;
  82514. private _highlightsExposure;
  82515. /**
  82516. * Gets the highlights Hue value.
  82517. * 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).
  82518. */
  82519. get highlightsHue(): number;
  82520. /**
  82521. * Sets the highlights Hue value.
  82522. * 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).
  82523. */
  82524. set highlightsHue(value: number);
  82525. /**
  82526. * Gets the highlights Density value.
  82527. * 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.
  82528. * Values less than zero provide a filter of opposite hue.
  82529. */
  82530. get highlightsDensity(): number;
  82531. /**
  82532. * Sets the highlights Density value.
  82533. * 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.
  82534. * Values less than zero provide a filter of opposite hue.
  82535. */
  82536. set highlightsDensity(value: number);
  82537. /**
  82538. * Gets the highlights Saturation value.
  82539. * 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.
  82540. */
  82541. get highlightsSaturation(): number;
  82542. /**
  82543. * Sets the highlights Saturation value.
  82544. * 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.
  82545. */
  82546. set highlightsSaturation(value: number);
  82547. /**
  82548. * Gets the highlights Exposure value.
  82549. * 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.
  82550. */
  82551. get highlightsExposure(): number;
  82552. /**
  82553. * Sets the highlights Exposure value.
  82554. * 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.
  82555. */
  82556. set highlightsExposure(value: number);
  82557. private _midtonesHue;
  82558. private _midtonesDensity;
  82559. private _midtonesSaturation;
  82560. private _midtonesExposure;
  82561. /**
  82562. * Gets the midtones Hue value.
  82563. * 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).
  82564. */
  82565. get midtonesHue(): number;
  82566. /**
  82567. * Sets the midtones Hue value.
  82568. * 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).
  82569. */
  82570. set midtonesHue(value: number);
  82571. /**
  82572. * Gets the midtones Density value.
  82573. * 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.
  82574. * Values less than zero provide a filter of opposite hue.
  82575. */
  82576. get midtonesDensity(): number;
  82577. /**
  82578. * Sets the midtones Density value.
  82579. * 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.
  82580. * Values less than zero provide a filter of opposite hue.
  82581. */
  82582. set midtonesDensity(value: number);
  82583. /**
  82584. * Gets the midtones Saturation value.
  82585. * 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.
  82586. */
  82587. get midtonesSaturation(): number;
  82588. /**
  82589. * Sets the midtones Saturation value.
  82590. * 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.
  82591. */
  82592. set midtonesSaturation(value: number);
  82593. /**
  82594. * Gets the midtones Exposure value.
  82595. * 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.
  82596. */
  82597. get midtonesExposure(): number;
  82598. /**
  82599. * Sets the midtones Exposure value.
  82600. * 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.
  82601. */
  82602. set midtonesExposure(value: number);
  82603. private _shadowsHue;
  82604. private _shadowsDensity;
  82605. private _shadowsSaturation;
  82606. private _shadowsExposure;
  82607. /**
  82608. * Gets the shadows Hue value.
  82609. * 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).
  82610. */
  82611. get shadowsHue(): number;
  82612. /**
  82613. * Sets the shadows Hue value.
  82614. * 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).
  82615. */
  82616. set shadowsHue(value: number);
  82617. /**
  82618. * Gets the shadows Density value.
  82619. * 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.
  82620. * Values less than zero provide a filter of opposite hue.
  82621. */
  82622. get shadowsDensity(): number;
  82623. /**
  82624. * Sets the shadows Density value.
  82625. * 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.
  82626. * Values less than zero provide a filter of opposite hue.
  82627. */
  82628. set shadowsDensity(value: number);
  82629. /**
  82630. * Gets the shadows Saturation value.
  82631. * 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.
  82632. */
  82633. get shadowsSaturation(): number;
  82634. /**
  82635. * Sets the shadows Saturation value.
  82636. * 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.
  82637. */
  82638. set shadowsSaturation(value: number);
  82639. /**
  82640. * Gets the shadows Exposure value.
  82641. * 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.
  82642. */
  82643. get shadowsExposure(): number;
  82644. /**
  82645. * Sets the shadows Exposure value.
  82646. * 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.
  82647. */
  82648. set shadowsExposure(value: number);
  82649. /**
  82650. * Returns the class name
  82651. * @returns The class name
  82652. */
  82653. getClassName(): string;
  82654. /**
  82655. * Binds the color curves to the shader.
  82656. * @param colorCurves The color curve to bind
  82657. * @param effect The effect to bind to
  82658. * @param positiveUniform The positive uniform shader parameter
  82659. * @param neutralUniform The neutral uniform shader parameter
  82660. * @param negativeUniform The negative uniform shader parameter
  82661. */
  82662. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  82663. /**
  82664. * Prepare the list of uniforms associated with the ColorCurves effects.
  82665. * @param uniformsList The list of uniforms used in the effect
  82666. */
  82667. static PrepareUniforms(uniformsList: string[]): void;
  82668. /**
  82669. * Returns color grading data based on a hue, density, saturation and exposure value.
  82670. * @param filterHue The hue of the color filter.
  82671. * @param filterDensity The density of the color filter.
  82672. * @param saturation The saturation.
  82673. * @param exposure The exposure.
  82674. * @param result The result data container.
  82675. */
  82676. private getColorGradingDataToRef;
  82677. /**
  82678. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  82679. * @param value The input slider value in range [-100,100].
  82680. * @returns Adjusted value.
  82681. */
  82682. private static applyColorGradingSliderNonlinear;
  82683. /**
  82684. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  82685. * @param hue The hue (H) input.
  82686. * @param saturation The saturation (S) input.
  82687. * @param brightness The brightness (B) input.
  82688. * @result An RGBA color represented as Vector4.
  82689. */
  82690. private static fromHSBToRef;
  82691. /**
  82692. * Returns a value clamped between min and max
  82693. * @param value The value to clamp
  82694. * @param min The minimum of value
  82695. * @param max The maximum of value
  82696. * @returns The clamped value.
  82697. */
  82698. private static clamp;
  82699. /**
  82700. * Clones the current color curve instance.
  82701. * @return The cloned curves
  82702. */
  82703. clone(): ColorCurves;
  82704. /**
  82705. * Serializes the current color curve instance to a json representation.
  82706. * @return a JSON representation
  82707. */
  82708. serialize(): any;
  82709. /**
  82710. * Parses the color curve from a json representation.
  82711. * @param source the JSON source to parse
  82712. * @return The parsed curves
  82713. */
  82714. static Parse(source: any): ColorCurves;
  82715. }
  82716. }
  82717. declare module BABYLON {
  82718. /**
  82719. * Interface to follow in your material defines to integrate easily the
  82720. * Image proccessing functions.
  82721. * @hidden
  82722. */
  82723. export interface IImageProcessingConfigurationDefines {
  82724. IMAGEPROCESSING: boolean;
  82725. VIGNETTE: boolean;
  82726. VIGNETTEBLENDMODEMULTIPLY: boolean;
  82727. VIGNETTEBLENDMODEOPAQUE: boolean;
  82728. TONEMAPPING: boolean;
  82729. TONEMAPPING_ACES: boolean;
  82730. CONTRAST: boolean;
  82731. EXPOSURE: boolean;
  82732. COLORCURVES: boolean;
  82733. COLORGRADING: boolean;
  82734. COLORGRADING3D: boolean;
  82735. SAMPLER3DGREENDEPTH: boolean;
  82736. SAMPLER3DBGRMAP: boolean;
  82737. IMAGEPROCESSINGPOSTPROCESS: boolean;
  82738. }
  82739. /**
  82740. * @hidden
  82741. */
  82742. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  82743. IMAGEPROCESSING: boolean;
  82744. VIGNETTE: boolean;
  82745. VIGNETTEBLENDMODEMULTIPLY: boolean;
  82746. VIGNETTEBLENDMODEOPAQUE: boolean;
  82747. TONEMAPPING: boolean;
  82748. TONEMAPPING_ACES: boolean;
  82749. CONTRAST: boolean;
  82750. COLORCURVES: boolean;
  82751. COLORGRADING: boolean;
  82752. COLORGRADING3D: boolean;
  82753. SAMPLER3DGREENDEPTH: boolean;
  82754. SAMPLER3DBGRMAP: boolean;
  82755. IMAGEPROCESSINGPOSTPROCESS: boolean;
  82756. EXPOSURE: boolean;
  82757. constructor();
  82758. }
  82759. /**
  82760. * This groups together the common properties used for image processing either in direct forward pass
  82761. * or through post processing effect depending on the use of the image processing pipeline in your scene
  82762. * or not.
  82763. */
  82764. export class ImageProcessingConfiguration {
  82765. /**
  82766. * Default tone mapping applied in BabylonJS.
  82767. */
  82768. static readonly TONEMAPPING_STANDARD: number;
  82769. /**
  82770. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  82771. * to other engines rendering to increase portability.
  82772. */
  82773. static readonly TONEMAPPING_ACES: number;
  82774. /**
  82775. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  82776. */
  82777. colorCurves: Nullable<ColorCurves>;
  82778. private _colorCurvesEnabled;
  82779. /**
  82780. * Gets wether the color curves effect is enabled.
  82781. */
  82782. get colorCurvesEnabled(): boolean;
  82783. /**
  82784. * Sets wether the color curves effect is enabled.
  82785. */
  82786. set colorCurvesEnabled(value: boolean);
  82787. private _colorGradingTexture;
  82788. /**
  82789. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  82790. */
  82791. get colorGradingTexture(): Nullable<BaseTexture>;
  82792. /**
  82793. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  82794. */
  82795. set colorGradingTexture(value: Nullable<BaseTexture>);
  82796. private _colorGradingEnabled;
  82797. /**
  82798. * Gets wether the color grading effect is enabled.
  82799. */
  82800. get colorGradingEnabled(): boolean;
  82801. /**
  82802. * Sets wether the color grading effect is enabled.
  82803. */
  82804. set colorGradingEnabled(value: boolean);
  82805. private _colorGradingWithGreenDepth;
  82806. /**
  82807. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  82808. */
  82809. get colorGradingWithGreenDepth(): boolean;
  82810. /**
  82811. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  82812. */
  82813. set colorGradingWithGreenDepth(value: boolean);
  82814. private _colorGradingBGR;
  82815. /**
  82816. * Gets wether the color grading texture contains BGR values.
  82817. */
  82818. get colorGradingBGR(): boolean;
  82819. /**
  82820. * Sets wether the color grading texture contains BGR values.
  82821. */
  82822. set colorGradingBGR(value: boolean);
  82823. /** @hidden */
  82824. _exposure: number;
  82825. /**
  82826. * Gets the Exposure used in the effect.
  82827. */
  82828. get exposure(): number;
  82829. /**
  82830. * Sets the Exposure used in the effect.
  82831. */
  82832. set exposure(value: number);
  82833. private _toneMappingEnabled;
  82834. /**
  82835. * Gets wether the tone mapping effect is enabled.
  82836. */
  82837. get toneMappingEnabled(): boolean;
  82838. /**
  82839. * Sets wether the tone mapping effect is enabled.
  82840. */
  82841. set toneMappingEnabled(value: boolean);
  82842. private _toneMappingType;
  82843. /**
  82844. * Gets the type of tone mapping effect.
  82845. */
  82846. get toneMappingType(): number;
  82847. /**
  82848. * Sets the type of tone mapping effect used in BabylonJS.
  82849. */
  82850. set toneMappingType(value: number);
  82851. protected _contrast: number;
  82852. /**
  82853. * Gets the contrast used in the effect.
  82854. */
  82855. get contrast(): number;
  82856. /**
  82857. * Sets the contrast used in the effect.
  82858. */
  82859. set contrast(value: number);
  82860. /**
  82861. * Vignette stretch size.
  82862. */
  82863. vignetteStretch: number;
  82864. /**
  82865. * Vignette centre X Offset.
  82866. */
  82867. vignetteCentreX: number;
  82868. /**
  82869. * Vignette centre Y Offset.
  82870. */
  82871. vignetteCentreY: number;
  82872. /**
  82873. * Vignette weight or intensity of the vignette effect.
  82874. */
  82875. vignetteWeight: number;
  82876. /**
  82877. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  82878. * if vignetteEnabled is set to true.
  82879. */
  82880. vignetteColor: Color4;
  82881. /**
  82882. * Camera field of view used by the Vignette effect.
  82883. */
  82884. vignetteCameraFov: number;
  82885. private _vignetteBlendMode;
  82886. /**
  82887. * Gets the vignette blend mode allowing different kind of effect.
  82888. */
  82889. get vignetteBlendMode(): number;
  82890. /**
  82891. * Sets the vignette blend mode allowing different kind of effect.
  82892. */
  82893. set vignetteBlendMode(value: number);
  82894. private _vignetteEnabled;
  82895. /**
  82896. * Gets wether the vignette effect is enabled.
  82897. */
  82898. get vignetteEnabled(): boolean;
  82899. /**
  82900. * Sets wether the vignette effect is enabled.
  82901. */
  82902. set vignetteEnabled(value: boolean);
  82903. private _applyByPostProcess;
  82904. /**
  82905. * Gets wether the image processing is applied through a post process or not.
  82906. */
  82907. get applyByPostProcess(): boolean;
  82908. /**
  82909. * Sets wether the image processing is applied through a post process or not.
  82910. */
  82911. set applyByPostProcess(value: boolean);
  82912. private _isEnabled;
  82913. /**
  82914. * Gets wether the image processing is enabled or not.
  82915. */
  82916. get isEnabled(): boolean;
  82917. /**
  82918. * Sets wether the image processing is enabled or not.
  82919. */
  82920. set isEnabled(value: boolean);
  82921. /**
  82922. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  82923. */
  82924. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  82925. /**
  82926. * Method called each time the image processing information changes requires to recompile the effect.
  82927. */
  82928. protected _updateParameters(): void;
  82929. /**
  82930. * Gets the current class name.
  82931. * @return "ImageProcessingConfiguration"
  82932. */
  82933. getClassName(): string;
  82934. /**
  82935. * Prepare the list of uniforms associated with the Image Processing effects.
  82936. * @param uniforms The list of uniforms used in the effect
  82937. * @param defines the list of defines currently in use
  82938. */
  82939. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  82940. /**
  82941. * Prepare the list of samplers associated with the Image Processing effects.
  82942. * @param samplersList The list of uniforms used in the effect
  82943. * @param defines the list of defines currently in use
  82944. */
  82945. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  82946. /**
  82947. * Prepare the list of defines associated to the shader.
  82948. * @param defines the list of defines to complete
  82949. * @param forPostProcess Define if we are currently in post process mode or not
  82950. */
  82951. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  82952. /**
  82953. * Returns true if all the image processing information are ready.
  82954. * @returns True if ready, otherwise, false
  82955. */
  82956. isReady(): boolean;
  82957. /**
  82958. * Binds the image processing to the shader.
  82959. * @param effect The effect to bind to
  82960. * @param overrideAspectRatio Override the aspect ratio of the effect
  82961. */
  82962. bind(effect: Effect, overrideAspectRatio?: number): void;
  82963. /**
  82964. * Clones the current image processing instance.
  82965. * @return The cloned image processing
  82966. */
  82967. clone(): ImageProcessingConfiguration;
  82968. /**
  82969. * Serializes the current image processing instance to a json representation.
  82970. * @return a JSON representation
  82971. */
  82972. serialize(): any;
  82973. /**
  82974. * Parses the image processing from a json representation.
  82975. * @param source the JSON source to parse
  82976. * @return The parsed image processing
  82977. */
  82978. static Parse(source: any): ImageProcessingConfiguration;
  82979. private static _VIGNETTEMODE_MULTIPLY;
  82980. private static _VIGNETTEMODE_OPAQUE;
  82981. /**
  82982. * Used to apply the vignette as a mix with the pixel color.
  82983. */
  82984. static get VIGNETTEMODE_MULTIPLY(): number;
  82985. /**
  82986. * Used to apply the vignette as a replacement of the pixel color.
  82987. */
  82988. static get VIGNETTEMODE_OPAQUE(): number;
  82989. }
  82990. }
  82991. declare module BABYLON {
  82992. /** @hidden */
  82993. export var postprocessVertexShader: {
  82994. name: string;
  82995. shader: string;
  82996. };
  82997. }
  82998. declare module BABYLON {
  82999. interface ThinEngine {
  83000. /**
  83001. * Creates a new render target texture
  83002. * @param size defines the size of the texture
  83003. * @param options defines the options used to create the texture
  83004. * @returns a new render target texture stored in an InternalTexture
  83005. */
  83006. createRenderTargetTexture(size: number | {
  83007. width: number;
  83008. height: number;
  83009. layers?: number;
  83010. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  83011. /**
  83012. * Creates a depth stencil texture.
  83013. * This is only available in WebGL 2 or with the depth texture extension available.
  83014. * @param size The size of face edge in the texture.
  83015. * @param options The options defining the texture.
  83016. * @returns The texture
  83017. */
  83018. createDepthStencilTexture(size: number | {
  83019. width: number;
  83020. height: number;
  83021. layers?: number;
  83022. }, options: DepthTextureCreationOptions): InternalTexture;
  83023. /** @hidden */
  83024. _createDepthStencilTexture(size: number | {
  83025. width: number;
  83026. height: number;
  83027. layers?: number;
  83028. }, options: DepthTextureCreationOptions): InternalTexture;
  83029. }
  83030. }
  83031. declare module BABYLON {
  83032. /** Defines supported spaces */
  83033. export enum Space {
  83034. /** Local (object) space */
  83035. LOCAL = 0,
  83036. /** World space */
  83037. WORLD = 1,
  83038. /** Bone space */
  83039. BONE = 2
  83040. }
  83041. /** Defines the 3 main axes */
  83042. export class Axis {
  83043. /** X axis */
  83044. static X: Vector3;
  83045. /** Y axis */
  83046. static Y: Vector3;
  83047. /** Z axis */
  83048. static Z: Vector3;
  83049. }
  83050. }
  83051. declare module BABYLON {
  83052. /**
  83053. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  83054. * This is the base of the follow, arc rotate cameras and Free camera
  83055. * @see http://doc.babylonjs.com/features/cameras
  83056. */
  83057. export class TargetCamera extends Camera {
  83058. private static _RigCamTransformMatrix;
  83059. private static _TargetTransformMatrix;
  83060. private static _TargetFocalPoint;
  83061. /**
  83062. * Define the current direction the camera is moving to
  83063. */
  83064. cameraDirection: Vector3;
  83065. /**
  83066. * Define the current rotation the camera is rotating to
  83067. */
  83068. cameraRotation: Vector2;
  83069. /**
  83070. * When set, the up vector of the camera will be updated by the rotation of the camera
  83071. */
  83072. updateUpVectorFromRotation: boolean;
  83073. private _tmpQuaternion;
  83074. /**
  83075. * Define the current rotation of the camera
  83076. */
  83077. rotation: Vector3;
  83078. /**
  83079. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  83080. */
  83081. rotationQuaternion: Quaternion;
  83082. /**
  83083. * Define the current speed of the camera
  83084. */
  83085. speed: number;
  83086. /**
  83087. * Add constraint to the camera to prevent it to move freely in all directions and
  83088. * around all axis.
  83089. */
  83090. noRotationConstraint: boolean;
  83091. /**
  83092. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  83093. * panning
  83094. */
  83095. invertRotation: boolean;
  83096. /**
  83097. * Speed multiplier for inverse camera panning
  83098. */
  83099. inverseRotationSpeed: number;
  83100. /**
  83101. * Define the current target of the camera as an object or a position.
  83102. */
  83103. lockedTarget: any;
  83104. /** @hidden */
  83105. _currentTarget: Vector3;
  83106. /** @hidden */
  83107. _initialFocalDistance: number;
  83108. /** @hidden */
  83109. _viewMatrix: Matrix;
  83110. /** @hidden */
  83111. _camMatrix: Matrix;
  83112. /** @hidden */
  83113. _cameraTransformMatrix: Matrix;
  83114. /** @hidden */
  83115. _cameraRotationMatrix: Matrix;
  83116. /** @hidden */
  83117. _referencePoint: Vector3;
  83118. /** @hidden */
  83119. _transformedReferencePoint: Vector3;
  83120. protected _globalCurrentTarget: Vector3;
  83121. protected _globalCurrentUpVector: Vector3;
  83122. /** @hidden */
  83123. _reset: () => void;
  83124. private _defaultUp;
  83125. /**
  83126. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  83127. * This is the base of the follow, arc rotate cameras and Free camera
  83128. * @see http://doc.babylonjs.com/features/cameras
  83129. * @param name Defines the name of the camera in the scene
  83130. * @param position Defines the start position of the camera in the scene
  83131. * @param scene Defines the scene the camera belongs to
  83132. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  83133. */
  83134. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  83135. /**
  83136. * Gets the position in front of the camera at a given distance.
  83137. * @param distance The distance from the camera we want the position to be
  83138. * @returns the position
  83139. */
  83140. getFrontPosition(distance: number): Vector3;
  83141. /** @hidden */
  83142. _getLockedTargetPosition(): Nullable<Vector3>;
  83143. private _storedPosition;
  83144. private _storedRotation;
  83145. private _storedRotationQuaternion;
  83146. /**
  83147. * Store current camera state of the camera (fov, position, rotation, etc..)
  83148. * @returns the camera
  83149. */
  83150. storeState(): Camera;
  83151. /**
  83152. * Restored camera state. You must call storeState() first
  83153. * @returns whether it was successful or not
  83154. * @hidden
  83155. */
  83156. _restoreStateValues(): boolean;
  83157. /** @hidden */
  83158. _initCache(): void;
  83159. /** @hidden */
  83160. _updateCache(ignoreParentClass?: boolean): void;
  83161. /** @hidden */
  83162. _isSynchronizedViewMatrix(): boolean;
  83163. /** @hidden */
  83164. _computeLocalCameraSpeed(): number;
  83165. /**
  83166. * Defines the target the camera should look at.
  83167. * @param target Defines the new target as a Vector or a mesh
  83168. */
  83169. setTarget(target: Vector3): void;
  83170. /**
  83171. * Return the current target position of the camera. This value is expressed in local space.
  83172. * @returns the target position
  83173. */
  83174. getTarget(): Vector3;
  83175. /** @hidden */
  83176. _decideIfNeedsToMove(): boolean;
  83177. /** @hidden */
  83178. _updatePosition(): void;
  83179. /** @hidden */
  83180. _checkInputs(): void;
  83181. protected _updateCameraRotationMatrix(): void;
  83182. /**
  83183. * 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)
  83184. * @returns the current camera
  83185. */
  83186. private _rotateUpVectorWithCameraRotationMatrix;
  83187. private _cachedRotationZ;
  83188. private _cachedQuaternionRotationZ;
  83189. /** @hidden */
  83190. _getViewMatrix(): Matrix;
  83191. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  83192. /**
  83193. * @hidden
  83194. */
  83195. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  83196. /**
  83197. * @hidden
  83198. */
  83199. _updateRigCameras(): void;
  83200. private _getRigCamPositionAndTarget;
  83201. /**
  83202. * Gets the current object class name.
  83203. * @return the class name
  83204. */
  83205. getClassName(): string;
  83206. }
  83207. }
  83208. declare module BABYLON {
  83209. /**
  83210. * Gather the list of keyboard event types as constants.
  83211. */
  83212. export class KeyboardEventTypes {
  83213. /**
  83214. * The keydown event is fired when a key becomes active (pressed).
  83215. */
  83216. static readonly KEYDOWN: number;
  83217. /**
  83218. * The keyup event is fired when a key has been released.
  83219. */
  83220. static readonly KEYUP: number;
  83221. }
  83222. /**
  83223. * This class is used to store keyboard related info for the onKeyboardObservable event.
  83224. */
  83225. export class KeyboardInfo {
  83226. /**
  83227. * Defines the type of event (KeyboardEventTypes)
  83228. */
  83229. type: number;
  83230. /**
  83231. * Defines the related dom event
  83232. */
  83233. event: KeyboardEvent;
  83234. /**
  83235. * Instantiates a new keyboard info.
  83236. * This class is used to store keyboard related info for the onKeyboardObservable event.
  83237. * @param type Defines the type of event (KeyboardEventTypes)
  83238. * @param event Defines the related dom event
  83239. */
  83240. constructor(
  83241. /**
  83242. * Defines the type of event (KeyboardEventTypes)
  83243. */
  83244. type: number,
  83245. /**
  83246. * Defines the related dom event
  83247. */
  83248. event: KeyboardEvent);
  83249. }
  83250. /**
  83251. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  83252. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  83253. */
  83254. export class KeyboardInfoPre extends KeyboardInfo {
  83255. /**
  83256. * Defines the type of event (KeyboardEventTypes)
  83257. */
  83258. type: number;
  83259. /**
  83260. * Defines the related dom event
  83261. */
  83262. event: KeyboardEvent;
  83263. /**
  83264. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  83265. */
  83266. skipOnPointerObservable: boolean;
  83267. /**
  83268. * Instantiates a new keyboard pre info.
  83269. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  83270. * @param type Defines the type of event (KeyboardEventTypes)
  83271. * @param event Defines the related dom event
  83272. */
  83273. constructor(
  83274. /**
  83275. * Defines the type of event (KeyboardEventTypes)
  83276. */
  83277. type: number,
  83278. /**
  83279. * Defines the related dom event
  83280. */
  83281. event: KeyboardEvent);
  83282. }
  83283. }
  83284. declare module BABYLON {
  83285. /**
  83286. * Manage the keyboard inputs to control the movement of a free camera.
  83287. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  83288. */
  83289. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  83290. /**
  83291. * Defines the camera the input is attached to.
  83292. */
  83293. camera: FreeCamera;
  83294. /**
  83295. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  83296. */
  83297. keysUp: number[];
  83298. /**
  83299. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  83300. */
  83301. keysUpward: number[];
  83302. /**
  83303. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  83304. */
  83305. keysDown: number[];
  83306. /**
  83307. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  83308. */
  83309. keysDownward: number[];
  83310. /**
  83311. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  83312. */
  83313. keysLeft: number[];
  83314. /**
  83315. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  83316. */
  83317. keysRight: number[];
  83318. private _keys;
  83319. private _onCanvasBlurObserver;
  83320. private _onKeyboardObserver;
  83321. private _engine;
  83322. private _scene;
  83323. /**
  83324. * Attach the input controls to a specific dom element to get the input from.
  83325. * @param element Defines the element the controls should be listened from
  83326. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83327. */
  83328. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83329. /**
  83330. * Detach the current controls from the specified dom element.
  83331. * @param element Defines the element to stop listening the inputs from
  83332. */
  83333. detachControl(element: Nullable<HTMLElement>): void;
  83334. /**
  83335. * Update the current camera state depending on the inputs that have been used this frame.
  83336. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  83337. */
  83338. checkInputs(): void;
  83339. /**
  83340. * Gets the class name of the current intput.
  83341. * @returns the class name
  83342. */
  83343. getClassName(): string;
  83344. /** @hidden */
  83345. _onLostFocus(): void;
  83346. /**
  83347. * Get the friendly name associated with the input class.
  83348. * @returns the input friendly name
  83349. */
  83350. getSimpleName(): string;
  83351. }
  83352. }
  83353. declare module BABYLON {
  83354. /**
  83355. * Interface describing all the common properties and methods a shadow light needs to implement.
  83356. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  83357. * as well as binding the different shadow properties to the effects.
  83358. */
  83359. export interface IShadowLight extends Light {
  83360. /**
  83361. * The light id in the scene (used in scene.findLighById for instance)
  83362. */
  83363. id: string;
  83364. /**
  83365. * The position the shdow will be casted from.
  83366. */
  83367. position: Vector3;
  83368. /**
  83369. * In 2d mode (needCube being false), the direction used to cast the shadow.
  83370. */
  83371. direction: Vector3;
  83372. /**
  83373. * The transformed position. Position of the light in world space taking parenting in account.
  83374. */
  83375. transformedPosition: Vector3;
  83376. /**
  83377. * The transformed direction. Direction of the light in world space taking parenting in account.
  83378. */
  83379. transformedDirection: Vector3;
  83380. /**
  83381. * The friendly name of the light in the scene.
  83382. */
  83383. name: string;
  83384. /**
  83385. * Defines the shadow projection clipping minimum z value.
  83386. */
  83387. shadowMinZ: number;
  83388. /**
  83389. * Defines the shadow projection clipping maximum z value.
  83390. */
  83391. shadowMaxZ: number;
  83392. /**
  83393. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  83394. * @returns true if the information has been computed, false if it does not need to (no parenting)
  83395. */
  83396. computeTransformedInformation(): boolean;
  83397. /**
  83398. * Gets the scene the light belongs to.
  83399. * @returns The scene
  83400. */
  83401. getScene(): Scene;
  83402. /**
  83403. * Callback defining a custom Projection Matrix Builder.
  83404. * This can be used to override the default projection matrix computation.
  83405. */
  83406. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  83407. /**
  83408. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  83409. * @param matrix The materix to updated with the projection information
  83410. * @param viewMatrix The transform matrix of the light
  83411. * @param renderList The list of mesh to render in the map
  83412. * @returns The current light
  83413. */
  83414. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  83415. /**
  83416. * Gets the current depth scale used in ESM.
  83417. * @returns The scale
  83418. */
  83419. getDepthScale(): number;
  83420. /**
  83421. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  83422. * @returns true if a cube texture needs to be use
  83423. */
  83424. needCube(): boolean;
  83425. /**
  83426. * Detects if the projection matrix requires to be recomputed this frame.
  83427. * @returns true if it requires to be recomputed otherwise, false.
  83428. */
  83429. needProjectionMatrixCompute(): boolean;
  83430. /**
  83431. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  83432. */
  83433. forceProjectionMatrixCompute(): void;
  83434. /**
  83435. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  83436. * @param faceIndex The index of the face we are computed the direction to generate shadow
  83437. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  83438. */
  83439. getShadowDirection(faceIndex?: number): Vector3;
  83440. /**
  83441. * Gets the minZ used for shadow according to both the scene and the light.
  83442. * @param activeCamera The camera we are returning the min for
  83443. * @returns the depth min z
  83444. */
  83445. getDepthMinZ(activeCamera: Camera): number;
  83446. /**
  83447. * Gets the maxZ used for shadow according to both the scene and the light.
  83448. * @param activeCamera The camera we are returning the max for
  83449. * @returns the depth max z
  83450. */
  83451. getDepthMaxZ(activeCamera: Camera): number;
  83452. }
  83453. /**
  83454. * Base implementation IShadowLight
  83455. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  83456. */
  83457. export abstract class ShadowLight extends Light implements IShadowLight {
  83458. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  83459. protected _position: Vector3;
  83460. protected _setPosition(value: Vector3): void;
  83461. /**
  83462. * Sets the position the shadow will be casted from. Also use as the light position for both
  83463. * point and spot lights.
  83464. */
  83465. get position(): Vector3;
  83466. /**
  83467. * Sets the position the shadow will be casted from. Also use as the light position for both
  83468. * point and spot lights.
  83469. */
  83470. set position(value: Vector3);
  83471. protected _direction: Vector3;
  83472. protected _setDirection(value: Vector3): void;
  83473. /**
  83474. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  83475. * Also use as the light direction on spot and directional lights.
  83476. */
  83477. get direction(): Vector3;
  83478. /**
  83479. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  83480. * Also use as the light direction on spot and directional lights.
  83481. */
  83482. set direction(value: Vector3);
  83483. protected _shadowMinZ: number;
  83484. /**
  83485. * Gets the shadow projection clipping minimum z value.
  83486. */
  83487. get shadowMinZ(): number;
  83488. /**
  83489. * Sets the shadow projection clipping minimum z value.
  83490. */
  83491. set shadowMinZ(value: number);
  83492. protected _shadowMaxZ: number;
  83493. /**
  83494. * Sets the shadow projection clipping maximum z value.
  83495. */
  83496. get shadowMaxZ(): number;
  83497. /**
  83498. * Gets the shadow projection clipping maximum z value.
  83499. */
  83500. set shadowMaxZ(value: number);
  83501. /**
  83502. * Callback defining a custom Projection Matrix Builder.
  83503. * This can be used to override the default projection matrix computation.
  83504. */
  83505. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  83506. /**
  83507. * The transformed position. Position of the light in world space taking parenting in account.
  83508. */
  83509. transformedPosition: Vector3;
  83510. /**
  83511. * The transformed direction. Direction of the light in world space taking parenting in account.
  83512. */
  83513. transformedDirection: Vector3;
  83514. private _needProjectionMatrixCompute;
  83515. /**
  83516. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  83517. * @returns true if the information has been computed, false if it does not need to (no parenting)
  83518. */
  83519. computeTransformedInformation(): boolean;
  83520. /**
  83521. * Return the depth scale used for the shadow map.
  83522. * @returns the depth scale.
  83523. */
  83524. getDepthScale(): number;
  83525. /**
  83526. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  83527. * @param faceIndex The index of the face we are computed the direction to generate shadow
  83528. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  83529. */
  83530. getShadowDirection(faceIndex?: number): Vector3;
  83531. /**
  83532. * Returns the ShadowLight absolute position in the World.
  83533. * @returns the position vector in world space
  83534. */
  83535. getAbsolutePosition(): Vector3;
  83536. /**
  83537. * Sets the ShadowLight direction toward the passed target.
  83538. * @param target The point to target in local space
  83539. * @returns the updated ShadowLight direction
  83540. */
  83541. setDirectionToTarget(target: Vector3): Vector3;
  83542. /**
  83543. * Returns the light rotation in euler definition.
  83544. * @returns the x y z rotation in local space.
  83545. */
  83546. getRotation(): Vector3;
  83547. /**
  83548. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  83549. * @returns true if a cube texture needs to be use
  83550. */
  83551. needCube(): boolean;
  83552. /**
  83553. * Detects if the projection matrix requires to be recomputed this frame.
  83554. * @returns true if it requires to be recomputed otherwise, false.
  83555. */
  83556. needProjectionMatrixCompute(): boolean;
  83557. /**
  83558. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  83559. */
  83560. forceProjectionMatrixCompute(): void;
  83561. /** @hidden */
  83562. _initCache(): void;
  83563. /** @hidden */
  83564. _isSynchronized(): boolean;
  83565. /**
  83566. * Computes the world matrix of the node
  83567. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  83568. * @returns the world matrix
  83569. */
  83570. computeWorldMatrix(force?: boolean): Matrix;
  83571. /**
  83572. * Gets the minZ used for shadow according to both the scene and the light.
  83573. * @param activeCamera The camera we are returning the min for
  83574. * @returns the depth min z
  83575. */
  83576. getDepthMinZ(activeCamera: Camera): number;
  83577. /**
  83578. * Gets the maxZ used for shadow according to both the scene and the light.
  83579. * @param activeCamera The camera we are returning the max for
  83580. * @returns the depth max z
  83581. */
  83582. getDepthMaxZ(activeCamera: Camera): number;
  83583. /**
  83584. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  83585. * @param matrix The materix to updated with the projection information
  83586. * @param viewMatrix The transform matrix of the light
  83587. * @param renderList The list of mesh to render in the map
  83588. * @returns The current light
  83589. */
  83590. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  83591. }
  83592. }
  83593. declare module BABYLON {
  83594. /**
  83595. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  83596. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  83597. */
  83598. export class EffectFallbacks implements IEffectFallbacks {
  83599. private _defines;
  83600. private _currentRank;
  83601. private _maxRank;
  83602. private _mesh;
  83603. /**
  83604. * Removes the fallback from the bound mesh.
  83605. */
  83606. unBindMesh(): void;
  83607. /**
  83608. * Adds a fallback on the specified property.
  83609. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  83610. * @param define The name of the define in the shader
  83611. */
  83612. addFallback(rank: number, define: string): void;
  83613. /**
  83614. * Sets the mesh to use CPU skinning when needing to fallback.
  83615. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  83616. * @param mesh The mesh to use the fallbacks.
  83617. */
  83618. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  83619. /**
  83620. * Checks to see if more fallbacks are still availible.
  83621. */
  83622. get hasMoreFallbacks(): boolean;
  83623. /**
  83624. * Removes the defines that should be removed when falling back.
  83625. * @param currentDefines defines the current define statements for the shader.
  83626. * @param effect defines the current effect we try to compile
  83627. * @returns The resulting defines with defines of the current rank removed.
  83628. */
  83629. reduce(currentDefines: string, effect: Effect): string;
  83630. }
  83631. }
  83632. declare module BABYLON {
  83633. /**
  83634. * "Static Class" containing the most commonly used helper while dealing with material for
  83635. * rendering purpose.
  83636. *
  83637. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  83638. *
  83639. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  83640. */
  83641. export class MaterialHelper {
  83642. /**
  83643. * Bind the current view position to an effect.
  83644. * @param effect The effect to be bound
  83645. * @param scene The scene the eyes position is used from
  83646. */
  83647. static BindEyePosition(effect: Effect, scene: Scene): void;
  83648. /**
  83649. * Helps preparing the defines values about the UVs in used in the effect.
  83650. * UVs are shared as much as we can accross channels in the shaders.
  83651. * @param texture The texture we are preparing the UVs for
  83652. * @param defines The defines to update
  83653. * @param key The channel key "diffuse", "specular"... used in the shader
  83654. */
  83655. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  83656. /**
  83657. * Binds a texture matrix value to its corrsponding uniform
  83658. * @param texture The texture to bind the matrix for
  83659. * @param uniformBuffer The uniform buffer receivin the data
  83660. * @param key The channel key "diffuse", "specular"... used in the shader
  83661. */
  83662. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  83663. /**
  83664. * Gets the current status of the fog (should it be enabled?)
  83665. * @param mesh defines the mesh to evaluate for fog support
  83666. * @param scene defines the hosting scene
  83667. * @returns true if fog must be enabled
  83668. */
  83669. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  83670. /**
  83671. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  83672. * @param mesh defines the current mesh
  83673. * @param scene defines the current scene
  83674. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  83675. * @param pointsCloud defines if point cloud rendering has to be turned on
  83676. * @param fogEnabled defines if fog has to be turned on
  83677. * @param alphaTest defines if alpha testing has to be turned on
  83678. * @param defines defines the current list of defines
  83679. */
  83680. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  83681. /**
  83682. * Helper used to prepare the list of defines associated with frame values for shader compilation
  83683. * @param scene defines the current scene
  83684. * @param engine defines the current engine
  83685. * @param defines specifies the list of active defines
  83686. * @param useInstances defines if instances have to be turned on
  83687. * @param useClipPlane defines if clip plane have to be turned on
  83688. */
  83689. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  83690. /**
  83691. * Prepares the defines for bones
  83692. * @param mesh The mesh containing the geometry data we will draw
  83693. * @param defines The defines to update
  83694. */
  83695. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  83696. /**
  83697. * Prepares the defines for morph targets
  83698. * @param mesh The mesh containing the geometry data we will draw
  83699. * @param defines The defines to update
  83700. */
  83701. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  83702. /**
  83703. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  83704. * @param mesh The mesh containing the geometry data we will draw
  83705. * @param defines The defines to update
  83706. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  83707. * @param useBones Precise whether bones should be used or not (override mesh info)
  83708. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  83709. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  83710. * @returns false if defines are considered not dirty and have not been checked
  83711. */
  83712. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  83713. /**
  83714. * Prepares the defines related to multiview
  83715. * @param scene The scene we are intending to draw
  83716. * @param defines The defines to update
  83717. */
  83718. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  83719. /**
  83720. * Prepares the defines related to the light information passed in parameter
  83721. * @param scene The scene we are intending to draw
  83722. * @param mesh The mesh the effect is compiling for
  83723. * @param light The light the effect is compiling for
  83724. * @param lightIndex The index of the light
  83725. * @param defines The defines to update
  83726. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  83727. * @param state Defines the current state regarding what is needed (normals, etc...)
  83728. */
  83729. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  83730. needNormals: boolean;
  83731. needRebuild: boolean;
  83732. shadowEnabled: boolean;
  83733. specularEnabled: boolean;
  83734. lightmapMode: boolean;
  83735. }): void;
  83736. /**
  83737. * Prepares the defines related to the light information passed in parameter
  83738. * @param scene The scene we are intending to draw
  83739. * @param mesh The mesh the effect is compiling for
  83740. * @param defines The defines to update
  83741. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  83742. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  83743. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  83744. * @returns true if normals will be required for the rest of the effect
  83745. */
  83746. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  83747. /**
  83748. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  83749. * @param lightIndex defines the light index
  83750. * @param uniformsList The uniform list
  83751. * @param samplersList The sampler list
  83752. * @param projectedLightTexture defines if projected texture must be used
  83753. * @param uniformBuffersList defines an optional list of uniform buffers
  83754. */
  83755. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  83756. /**
  83757. * Prepares the uniforms and samplers list to be used in the effect
  83758. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  83759. * @param samplersList The sampler list
  83760. * @param defines The defines helping in the list generation
  83761. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  83762. */
  83763. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  83764. /**
  83765. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  83766. * @param defines The defines to update while falling back
  83767. * @param fallbacks The authorized effect fallbacks
  83768. * @param maxSimultaneousLights The maximum number of lights allowed
  83769. * @param rank the current rank of the Effect
  83770. * @returns The newly affected rank
  83771. */
  83772. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  83773. private static _TmpMorphInfluencers;
  83774. /**
  83775. * Prepares the list of attributes required for morph targets according to the effect defines.
  83776. * @param attribs The current list of supported attribs
  83777. * @param mesh The mesh to prepare the morph targets attributes for
  83778. * @param influencers The number of influencers
  83779. */
  83780. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  83781. /**
  83782. * Prepares the list of attributes required for morph targets according to the effect defines.
  83783. * @param attribs The current list of supported attribs
  83784. * @param mesh The mesh to prepare the morph targets attributes for
  83785. * @param defines The current Defines of the effect
  83786. */
  83787. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  83788. /**
  83789. * Prepares the list of attributes required for bones according to the effect defines.
  83790. * @param attribs The current list of supported attribs
  83791. * @param mesh The mesh to prepare the bones attributes for
  83792. * @param defines The current Defines of the effect
  83793. * @param fallbacks The current efffect fallback strategy
  83794. */
  83795. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  83796. /**
  83797. * Check and prepare the list of attributes required for instances according to the effect defines.
  83798. * @param attribs The current list of supported attribs
  83799. * @param defines The current MaterialDefines of the effect
  83800. */
  83801. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  83802. /**
  83803. * Add the list of attributes required for instances to the attribs array.
  83804. * @param attribs The current list of supported attribs
  83805. */
  83806. static PushAttributesForInstances(attribs: string[]): void;
  83807. /**
  83808. * Binds the light information to the effect.
  83809. * @param light The light containing the generator
  83810. * @param effect The effect we are binding the data to
  83811. * @param lightIndex The light index in the effect used to render
  83812. */
  83813. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  83814. /**
  83815. * Binds the lights information from the scene to the effect for the given mesh.
  83816. * @param light Light to bind
  83817. * @param lightIndex Light index
  83818. * @param scene The scene where the light belongs to
  83819. * @param effect The effect we are binding the data to
  83820. * @param useSpecular Defines if specular is supported
  83821. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  83822. */
  83823. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  83824. /**
  83825. * Binds the lights information from the scene to the effect for the given mesh.
  83826. * @param scene The scene the lights belongs to
  83827. * @param mesh The mesh we are binding the information to render
  83828. * @param effect The effect we are binding the data to
  83829. * @param defines The generated defines for the effect
  83830. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  83831. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  83832. */
  83833. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  83834. private static _tempFogColor;
  83835. /**
  83836. * Binds the fog information from the scene to the effect for the given mesh.
  83837. * @param scene The scene the lights belongs to
  83838. * @param mesh The mesh we are binding the information to render
  83839. * @param effect The effect we are binding the data to
  83840. * @param linearSpace Defines if the fog effect is applied in linear space
  83841. */
  83842. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  83843. /**
  83844. * Binds the bones information from the mesh to the effect.
  83845. * @param mesh The mesh we are binding the information to render
  83846. * @param effect The effect we are binding the data to
  83847. */
  83848. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  83849. /**
  83850. * Binds the morph targets information from the mesh to the effect.
  83851. * @param abstractMesh The mesh we are binding the information to render
  83852. * @param effect The effect we are binding the data to
  83853. */
  83854. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  83855. /**
  83856. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  83857. * @param defines The generated defines used in the effect
  83858. * @param effect The effect we are binding the data to
  83859. * @param scene The scene we are willing to render with logarithmic scale for
  83860. */
  83861. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  83862. /**
  83863. * Binds the clip plane information from the scene to the effect.
  83864. * @param scene The scene the clip plane information are extracted from
  83865. * @param effect The effect we are binding the data to
  83866. */
  83867. static BindClipPlane(effect: Effect, scene: Scene): void;
  83868. }
  83869. }
  83870. declare module BABYLON {
  83871. /** @hidden */
  83872. export var packingFunctions: {
  83873. name: string;
  83874. shader: string;
  83875. };
  83876. }
  83877. declare module BABYLON {
  83878. /** @hidden */
  83879. export var shadowMapFragmentDeclaration: {
  83880. name: string;
  83881. shader: string;
  83882. };
  83883. }
  83884. declare module BABYLON {
  83885. /** @hidden */
  83886. export var clipPlaneFragmentDeclaration: {
  83887. name: string;
  83888. shader: string;
  83889. };
  83890. }
  83891. declare module BABYLON {
  83892. /** @hidden */
  83893. export var clipPlaneFragment: {
  83894. name: string;
  83895. shader: string;
  83896. };
  83897. }
  83898. declare module BABYLON {
  83899. /** @hidden */
  83900. export var shadowMapFragment: {
  83901. name: string;
  83902. shader: string;
  83903. };
  83904. }
  83905. declare module BABYLON {
  83906. /** @hidden */
  83907. export var shadowMapPixelShader: {
  83908. name: string;
  83909. shader: string;
  83910. };
  83911. }
  83912. declare module BABYLON {
  83913. /** @hidden */
  83914. export var bonesDeclaration: {
  83915. name: string;
  83916. shader: string;
  83917. };
  83918. }
  83919. declare module BABYLON {
  83920. /** @hidden */
  83921. export var morphTargetsVertexGlobalDeclaration: {
  83922. name: string;
  83923. shader: string;
  83924. };
  83925. }
  83926. declare module BABYLON {
  83927. /** @hidden */
  83928. export var morphTargetsVertexDeclaration: {
  83929. name: string;
  83930. shader: string;
  83931. };
  83932. }
  83933. declare module BABYLON {
  83934. /** @hidden */
  83935. export var instancesDeclaration: {
  83936. name: string;
  83937. shader: string;
  83938. };
  83939. }
  83940. declare module BABYLON {
  83941. /** @hidden */
  83942. export var helperFunctions: {
  83943. name: string;
  83944. shader: string;
  83945. };
  83946. }
  83947. declare module BABYLON {
  83948. /** @hidden */
  83949. export var shadowMapVertexDeclaration: {
  83950. name: string;
  83951. shader: string;
  83952. };
  83953. }
  83954. declare module BABYLON {
  83955. /** @hidden */
  83956. export var clipPlaneVertexDeclaration: {
  83957. name: string;
  83958. shader: string;
  83959. };
  83960. }
  83961. declare module BABYLON {
  83962. /** @hidden */
  83963. export var morphTargetsVertex: {
  83964. name: string;
  83965. shader: string;
  83966. };
  83967. }
  83968. declare module BABYLON {
  83969. /** @hidden */
  83970. export var instancesVertex: {
  83971. name: string;
  83972. shader: string;
  83973. };
  83974. }
  83975. declare module BABYLON {
  83976. /** @hidden */
  83977. export var bonesVertex: {
  83978. name: string;
  83979. shader: string;
  83980. };
  83981. }
  83982. declare module BABYLON {
  83983. /** @hidden */
  83984. export var shadowMapVertexNormalBias: {
  83985. name: string;
  83986. shader: string;
  83987. };
  83988. }
  83989. declare module BABYLON {
  83990. /** @hidden */
  83991. export var shadowMapVertexMetric: {
  83992. name: string;
  83993. shader: string;
  83994. };
  83995. }
  83996. declare module BABYLON {
  83997. /** @hidden */
  83998. export var clipPlaneVertex: {
  83999. name: string;
  84000. shader: string;
  84001. };
  84002. }
  84003. declare module BABYLON {
  84004. /** @hidden */
  84005. export var shadowMapVertexShader: {
  84006. name: string;
  84007. shader: string;
  84008. };
  84009. }
  84010. declare module BABYLON {
  84011. /** @hidden */
  84012. export var depthBoxBlurPixelShader: {
  84013. name: string;
  84014. shader: string;
  84015. };
  84016. }
  84017. declare module BABYLON {
  84018. /**
  84019. * Class representing a ray with position and direction
  84020. */
  84021. export class Ray {
  84022. /** origin point */
  84023. origin: Vector3;
  84024. /** direction */
  84025. direction: Vector3;
  84026. /** length of the ray */
  84027. length: number;
  84028. private static readonly TmpVector3;
  84029. private _tmpRay;
  84030. /**
  84031. * Creates a new ray
  84032. * @param origin origin point
  84033. * @param direction direction
  84034. * @param length length of the ray
  84035. */
  84036. constructor(
  84037. /** origin point */
  84038. origin: Vector3,
  84039. /** direction */
  84040. direction: Vector3,
  84041. /** length of the ray */
  84042. length?: number);
  84043. /**
  84044. * Checks if the ray intersects a box
  84045. * This does not account for the ray lenght by design to improve perfs.
  84046. * @param minimum bound of the box
  84047. * @param maximum bound of the box
  84048. * @param intersectionTreshold extra extend to be added to the box in all direction
  84049. * @returns if the box was hit
  84050. */
  84051. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  84052. /**
  84053. * Checks if the ray intersects a box
  84054. * This does not account for the ray lenght by design to improve perfs.
  84055. * @param box the bounding box to check
  84056. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  84057. * @returns if the box was hit
  84058. */
  84059. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  84060. /**
  84061. * If the ray hits a sphere
  84062. * @param sphere the bounding sphere to check
  84063. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  84064. * @returns true if it hits the sphere
  84065. */
  84066. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  84067. /**
  84068. * If the ray hits a triange
  84069. * @param vertex0 triangle vertex
  84070. * @param vertex1 triangle vertex
  84071. * @param vertex2 triangle vertex
  84072. * @returns intersection information if hit
  84073. */
  84074. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  84075. /**
  84076. * Checks if ray intersects a plane
  84077. * @param plane the plane to check
  84078. * @returns the distance away it was hit
  84079. */
  84080. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  84081. /**
  84082. * Calculate the intercept of a ray on a given axis
  84083. * @param axis to check 'x' | 'y' | 'z'
  84084. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  84085. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  84086. */
  84087. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  84088. /**
  84089. * Checks if ray intersects a mesh
  84090. * @param mesh the mesh to check
  84091. * @param fastCheck defines if the first intersection will be used (and not the closest)
  84092. * @returns picking info of the intersecton
  84093. */
  84094. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  84095. /**
  84096. * Checks if ray intersects a mesh
  84097. * @param meshes the meshes to check
  84098. * @param fastCheck defines if the first intersection will be used (and not the closest)
  84099. * @param results array to store result in
  84100. * @returns Array of picking infos
  84101. */
  84102. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  84103. private _comparePickingInfo;
  84104. private static smallnum;
  84105. private static rayl;
  84106. /**
  84107. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  84108. * @param sega the first point of the segment to test the intersection against
  84109. * @param segb the second point of the segment to test the intersection against
  84110. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  84111. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  84112. */
  84113. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  84114. /**
  84115. * Update the ray from viewport position
  84116. * @param x position
  84117. * @param y y position
  84118. * @param viewportWidth viewport width
  84119. * @param viewportHeight viewport height
  84120. * @param world world matrix
  84121. * @param view view matrix
  84122. * @param projection projection matrix
  84123. * @returns this ray updated
  84124. */
  84125. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  84126. /**
  84127. * Creates a ray with origin and direction of 0,0,0
  84128. * @returns the new ray
  84129. */
  84130. static Zero(): Ray;
  84131. /**
  84132. * Creates a new ray from screen space and viewport
  84133. * @param x position
  84134. * @param y y position
  84135. * @param viewportWidth viewport width
  84136. * @param viewportHeight viewport height
  84137. * @param world world matrix
  84138. * @param view view matrix
  84139. * @param projection projection matrix
  84140. * @returns new ray
  84141. */
  84142. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  84143. /**
  84144. * 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
  84145. * transformed to the given world matrix.
  84146. * @param origin The origin point
  84147. * @param end The end point
  84148. * @param world a matrix to transform the ray to. Default is the identity matrix.
  84149. * @returns the new ray
  84150. */
  84151. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  84152. /**
  84153. * Transforms a ray by a matrix
  84154. * @param ray ray to transform
  84155. * @param matrix matrix to apply
  84156. * @returns the resulting new ray
  84157. */
  84158. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  84159. /**
  84160. * Transforms a ray by a matrix
  84161. * @param ray ray to transform
  84162. * @param matrix matrix to apply
  84163. * @param result ray to store result in
  84164. */
  84165. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  84166. /**
  84167. * Unproject a ray from screen space to object space
  84168. * @param sourceX defines the screen space x coordinate to use
  84169. * @param sourceY defines the screen space y coordinate to use
  84170. * @param viewportWidth defines the current width of the viewport
  84171. * @param viewportHeight defines the current height of the viewport
  84172. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  84173. * @param view defines the view matrix to use
  84174. * @param projection defines the projection matrix to use
  84175. */
  84176. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  84177. }
  84178. /**
  84179. * Type used to define predicate used to select faces when a mesh intersection is detected
  84180. */
  84181. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  84182. interface Scene {
  84183. /** @hidden */
  84184. _tempPickingRay: Nullable<Ray>;
  84185. /** @hidden */
  84186. _cachedRayForTransform: Ray;
  84187. /** @hidden */
  84188. _pickWithRayInverseMatrix: Matrix;
  84189. /** @hidden */
  84190. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  84191. /** @hidden */
  84192. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  84193. }
  84194. }
  84195. declare module BABYLON {
  84196. /**
  84197. * Groups all the scene component constants in one place to ease maintenance.
  84198. * @hidden
  84199. */
  84200. export class SceneComponentConstants {
  84201. static readonly NAME_EFFECTLAYER: string;
  84202. static readonly NAME_LAYER: string;
  84203. static readonly NAME_LENSFLARESYSTEM: string;
  84204. static readonly NAME_BOUNDINGBOXRENDERER: string;
  84205. static readonly NAME_PARTICLESYSTEM: string;
  84206. static readonly NAME_GAMEPAD: string;
  84207. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  84208. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  84209. static readonly NAME_DEPTHRENDERER: string;
  84210. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  84211. static readonly NAME_SPRITE: string;
  84212. static readonly NAME_OUTLINERENDERER: string;
  84213. static readonly NAME_PROCEDURALTEXTURE: string;
  84214. static readonly NAME_SHADOWGENERATOR: string;
  84215. static readonly NAME_OCTREE: string;
  84216. static readonly NAME_PHYSICSENGINE: string;
  84217. static readonly NAME_AUDIO: string;
  84218. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  84219. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  84220. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  84221. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  84222. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  84223. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  84224. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  84225. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  84226. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  84227. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  84228. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  84229. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  84230. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  84231. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  84232. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  84233. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  84234. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  84235. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  84236. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  84237. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  84238. static readonly STEP_AFTERRENDER_AUDIO: number;
  84239. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  84240. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  84241. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  84242. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  84243. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  84244. static readonly STEP_POINTERMOVE_SPRITE: number;
  84245. static readonly STEP_POINTERDOWN_SPRITE: number;
  84246. static readonly STEP_POINTERUP_SPRITE: number;
  84247. }
  84248. /**
  84249. * This represents a scene component.
  84250. *
  84251. * This is used to decouple the dependency the scene is having on the different workloads like
  84252. * layers, post processes...
  84253. */
  84254. export interface ISceneComponent {
  84255. /**
  84256. * The name of the component. Each component must have a unique name.
  84257. */
  84258. name: string;
  84259. /**
  84260. * The scene the component belongs to.
  84261. */
  84262. scene: Scene;
  84263. /**
  84264. * Register the component to one instance of a scene.
  84265. */
  84266. register(): void;
  84267. /**
  84268. * Rebuilds the elements related to this component in case of
  84269. * context lost for instance.
  84270. */
  84271. rebuild(): void;
  84272. /**
  84273. * Disposes the component and the associated ressources.
  84274. */
  84275. dispose(): void;
  84276. }
  84277. /**
  84278. * This represents a SERIALIZABLE scene component.
  84279. *
  84280. * This extends Scene Component to add Serialization methods on top.
  84281. */
  84282. export interface ISceneSerializableComponent extends ISceneComponent {
  84283. /**
  84284. * Adds all the elements from the container to the scene
  84285. * @param container the container holding the elements
  84286. */
  84287. addFromContainer(container: AbstractScene): void;
  84288. /**
  84289. * Removes all the elements in the container from the scene
  84290. * @param container contains the elements to remove
  84291. * @param dispose if the removed element should be disposed (default: false)
  84292. */
  84293. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  84294. /**
  84295. * Serializes the component data to the specified json object
  84296. * @param serializationObject The object to serialize to
  84297. */
  84298. serialize(serializationObject: any): void;
  84299. }
  84300. /**
  84301. * Strong typing of a Mesh related stage step action
  84302. */
  84303. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  84304. /**
  84305. * Strong typing of a Evaluate Sub Mesh related stage step action
  84306. */
  84307. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  84308. /**
  84309. * Strong typing of a Active Mesh related stage step action
  84310. */
  84311. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  84312. /**
  84313. * Strong typing of a Camera related stage step action
  84314. */
  84315. export type CameraStageAction = (camera: Camera) => void;
  84316. /**
  84317. * Strong typing of a Camera Frame buffer related stage step action
  84318. */
  84319. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  84320. /**
  84321. * Strong typing of a Render Target related stage step action
  84322. */
  84323. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  84324. /**
  84325. * Strong typing of a RenderingGroup related stage step action
  84326. */
  84327. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  84328. /**
  84329. * Strong typing of a Mesh Render related stage step action
  84330. */
  84331. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  84332. /**
  84333. * Strong typing of a simple stage step action
  84334. */
  84335. export type SimpleStageAction = () => void;
  84336. /**
  84337. * Strong typing of a render target action.
  84338. */
  84339. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  84340. /**
  84341. * Strong typing of a pointer move action.
  84342. */
  84343. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  84344. /**
  84345. * Strong typing of a pointer up/down action.
  84346. */
  84347. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  84348. /**
  84349. * Representation of a stage in the scene (Basically a list of ordered steps)
  84350. * @hidden
  84351. */
  84352. export class Stage<T extends Function> extends Array<{
  84353. index: number;
  84354. component: ISceneComponent;
  84355. action: T;
  84356. }> {
  84357. /**
  84358. * Hide ctor from the rest of the world.
  84359. * @param items The items to add.
  84360. */
  84361. private constructor();
  84362. /**
  84363. * Creates a new Stage.
  84364. * @returns A new instance of a Stage
  84365. */
  84366. static Create<T extends Function>(): Stage<T>;
  84367. /**
  84368. * Registers a step in an ordered way in the targeted stage.
  84369. * @param index Defines the position to register the step in
  84370. * @param component Defines the component attached to the step
  84371. * @param action Defines the action to launch during the step
  84372. */
  84373. registerStep(index: number, component: ISceneComponent, action: T): void;
  84374. /**
  84375. * Clears all the steps from the stage.
  84376. */
  84377. clear(): void;
  84378. }
  84379. }
  84380. declare module BABYLON {
  84381. interface Scene {
  84382. /** @hidden */
  84383. _pointerOverSprite: Nullable<Sprite>;
  84384. /** @hidden */
  84385. _pickedDownSprite: Nullable<Sprite>;
  84386. /** @hidden */
  84387. _tempSpritePickingRay: Nullable<Ray>;
  84388. /**
  84389. * All of the sprite managers added to this scene
  84390. * @see http://doc.babylonjs.com/babylon101/sprites
  84391. */
  84392. spriteManagers: Array<ISpriteManager>;
  84393. /**
  84394. * An event triggered when sprites rendering is about to start
  84395. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  84396. */
  84397. onBeforeSpritesRenderingObservable: Observable<Scene>;
  84398. /**
  84399. * An event triggered when sprites rendering is done
  84400. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  84401. */
  84402. onAfterSpritesRenderingObservable: Observable<Scene>;
  84403. /** @hidden */
  84404. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84405. /** Launch a ray to try to pick a sprite in the scene
  84406. * @param x position on screen
  84407. * @param y position on screen
  84408. * @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
  84409. * @param fastCheck defines if the first intersection will be used (and not the closest)
  84410. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  84411. * @returns a PickingInfo
  84412. */
  84413. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84414. /** Use the given ray to pick a sprite in the scene
  84415. * @param ray The ray (in world space) to use to pick meshes
  84416. * @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
  84417. * @param fastCheck defines if the first intersection will be used (and not the closest)
  84418. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  84419. * @returns a PickingInfo
  84420. */
  84421. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84422. /** @hidden */
  84423. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84424. /** Launch a ray to try to pick sprites in the scene
  84425. * @param x position on screen
  84426. * @param y position on screen
  84427. * @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
  84428. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  84429. * @returns a PickingInfo array
  84430. */
  84431. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84432. /** Use the given ray to pick sprites in the scene
  84433. * @param ray The ray (in world space) to use to pick meshes
  84434. * @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
  84435. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  84436. * @returns a PickingInfo array
  84437. */
  84438. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84439. /**
  84440. * Force the sprite under the pointer
  84441. * @param sprite defines the sprite to use
  84442. */
  84443. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  84444. /**
  84445. * Gets the sprite under the pointer
  84446. * @returns a Sprite or null if no sprite is under the pointer
  84447. */
  84448. getPointerOverSprite(): Nullable<Sprite>;
  84449. }
  84450. /**
  84451. * Defines the sprite scene component responsible to manage sprites
  84452. * in a given scene.
  84453. */
  84454. export class SpriteSceneComponent implements ISceneComponent {
  84455. /**
  84456. * The component name helpfull to identify the component in the list of scene components.
  84457. */
  84458. readonly name: string;
  84459. /**
  84460. * The scene the component belongs to.
  84461. */
  84462. scene: Scene;
  84463. /** @hidden */
  84464. private _spritePredicate;
  84465. /**
  84466. * Creates a new instance of the component for the given scene
  84467. * @param scene Defines the scene to register the component in
  84468. */
  84469. constructor(scene: Scene);
  84470. /**
  84471. * Registers the component in a given scene
  84472. */
  84473. register(): void;
  84474. /**
  84475. * Rebuilds the elements related to this component in case of
  84476. * context lost for instance.
  84477. */
  84478. rebuild(): void;
  84479. /**
  84480. * Disposes the component and the associated ressources.
  84481. */
  84482. dispose(): void;
  84483. private _pickSpriteButKeepRay;
  84484. private _pointerMove;
  84485. private _pointerDown;
  84486. private _pointerUp;
  84487. }
  84488. }
  84489. declare module BABYLON {
  84490. /** @hidden */
  84491. export var fogFragmentDeclaration: {
  84492. name: string;
  84493. shader: string;
  84494. };
  84495. }
  84496. declare module BABYLON {
  84497. /** @hidden */
  84498. export var fogFragment: {
  84499. name: string;
  84500. shader: string;
  84501. };
  84502. }
  84503. declare module BABYLON {
  84504. /** @hidden */
  84505. export var spritesPixelShader: {
  84506. name: string;
  84507. shader: string;
  84508. };
  84509. }
  84510. declare module BABYLON {
  84511. /** @hidden */
  84512. export var fogVertexDeclaration: {
  84513. name: string;
  84514. shader: string;
  84515. };
  84516. }
  84517. declare module BABYLON {
  84518. /** @hidden */
  84519. export var spritesVertexShader: {
  84520. name: string;
  84521. shader: string;
  84522. };
  84523. }
  84524. declare module BABYLON {
  84525. /**
  84526. * Defines the minimum interface to fullfil in order to be a sprite manager.
  84527. */
  84528. export interface ISpriteManager extends IDisposable {
  84529. /**
  84530. * Restricts the camera to viewing objects with the same layerMask.
  84531. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  84532. */
  84533. layerMask: number;
  84534. /**
  84535. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  84536. */
  84537. isPickable: boolean;
  84538. /**
  84539. * Specifies the rendering group id for this mesh (0 by default)
  84540. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  84541. */
  84542. renderingGroupId: number;
  84543. /**
  84544. * Defines the list of sprites managed by the manager.
  84545. */
  84546. sprites: Array<Sprite>;
  84547. /**
  84548. * Tests the intersection of a sprite with a specific ray.
  84549. * @param ray The ray we are sending to test the collision
  84550. * @param camera The camera space we are sending rays in
  84551. * @param predicate A predicate allowing excluding sprites from the list of object to test
  84552. * @param fastCheck defines if the first intersection will be used (and not the closest)
  84553. * @returns picking info or null.
  84554. */
  84555. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  84556. /**
  84557. * Intersects the sprites with a ray
  84558. * @param ray defines the ray to intersect with
  84559. * @param camera defines the current active camera
  84560. * @param predicate defines a predicate used to select candidate sprites
  84561. * @returns null if no hit or a PickingInfo array
  84562. */
  84563. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  84564. /**
  84565. * Renders the list of sprites on screen.
  84566. */
  84567. render(): void;
  84568. }
  84569. /**
  84570. * Class used to manage multiple sprites on the same spritesheet
  84571. * @see http://doc.babylonjs.com/babylon101/sprites
  84572. */
  84573. export class SpriteManager implements ISpriteManager {
  84574. /** defines the manager's name */
  84575. name: string;
  84576. /** Gets the list of sprites */
  84577. sprites: Sprite[];
  84578. /** Gets or sets the rendering group id (0 by default) */
  84579. renderingGroupId: number;
  84580. /** Gets or sets camera layer mask */
  84581. layerMask: number;
  84582. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  84583. fogEnabled: boolean;
  84584. /** Gets or sets a boolean indicating if the sprites are pickable */
  84585. isPickable: boolean;
  84586. /** Defines the default width of a cell in the spritesheet */
  84587. cellWidth: number;
  84588. /** Defines the default height of a cell in the spritesheet */
  84589. cellHeight: number;
  84590. /** Associative array from JSON sprite data file */
  84591. private _cellData;
  84592. /** Array of sprite names from JSON sprite data file */
  84593. private _spriteMap;
  84594. /** True when packed cell data from JSON file is ready*/
  84595. private _packedAndReady;
  84596. private _textureContent;
  84597. /**
  84598. * An event triggered when the manager is disposed.
  84599. */
  84600. onDisposeObservable: Observable<SpriteManager>;
  84601. private _onDisposeObserver;
  84602. /**
  84603. * Callback called when the manager is disposed
  84604. */
  84605. set onDispose(callback: () => void);
  84606. private _capacity;
  84607. private _fromPacked;
  84608. private _spriteTexture;
  84609. private _epsilon;
  84610. private _scene;
  84611. private _vertexData;
  84612. private _buffer;
  84613. private _vertexBuffers;
  84614. private _indexBuffer;
  84615. private _effectBase;
  84616. private _effectFog;
  84617. /**
  84618. * Gets or sets the spritesheet texture
  84619. */
  84620. get texture(): Texture;
  84621. set texture(value: Texture);
  84622. private _blendMode;
  84623. /**
  84624. * Blend mode use to render the particle, it can be any of
  84625. * the static Constants.ALPHA_x properties provided in this class.
  84626. * Default value is Constants.ALPHA_COMBINE
  84627. */
  84628. get blendMode(): number;
  84629. set blendMode(blendMode: number);
  84630. /** Disables writing to the depth buffer when rendering the sprites.
  84631. * It can be handy to disable depth writing when using textures without alpha channel
  84632. * and setting some specific blend modes.
  84633. */
  84634. disableDepthWrite: boolean;
  84635. /**
  84636. * Creates a new sprite manager
  84637. * @param name defines the manager's name
  84638. * @param imgUrl defines the sprite sheet url
  84639. * @param capacity defines the maximum allowed number of sprites
  84640. * @param cellSize defines the size of a sprite cell
  84641. * @param scene defines the hosting scene
  84642. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  84643. * @param samplingMode defines the smapling mode to use with spritesheet
  84644. * @param fromPacked set to false; do not alter
  84645. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  84646. */
  84647. constructor(
  84648. /** defines the manager's name */
  84649. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  84650. private _makePacked;
  84651. private _appendSpriteVertex;
  84652. private _checkTextureAlpha;
  84653. /**
  84654. * Intersects the sprites with a ray
  84655. * @param ray defines the ray to intersect with
  84656. * @param camera defines the current active camera
  84657. * @param predicate defines a predicate used to select candidate sprites
  84658. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  84659. * @returns null if no hit or a PickingInfo
  84660. */
  84661. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  84662. /**
  84663. * Intersects the sprites with a ray
  84664. * @param ray defines the ray to intersect with
  84665. * @param camera defines the current active camera
  84666. * @param predicate defines a predicate used to select candidate sprites
  84667. * @returns null if no hit or a PickingInfo array
  84668. */
  84669. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  84670. /**
  84671. * Render all child sprites
  84672. */
  84673. render(): void;
  84674. /**
  84675. * Release associated resources
  84676. */
  84677. dispose(): void;
  84678. }
  84679. }
  84680. declare module BABYLON {
  84681. /** Interface used by value gradients (color, factor, ...) */
  84682. export interface IValueGradient {
  84683. /**
  84684. * Gets or sets the gradient value (between 0 and 1)
  84685. */
  84686. gradient: number;
  84687. }
  84688. /** Class used to store color4 gradient */
  84689. export class ColorGradient implements IValueGradient {
  84690. /**
  84691. * Gets or sets the gradient value (between 0 and 1)
  84692. */
  84693. gradient: number;
  84694. /**
  84695. * Gets or sets first associated color
  84696. */
  84697. color1: Color4;
  84698. /**
  84699. * Gets or sets second associated color
  84700. */
  84701. color2?: Color4 | undefined;
  84702. /**
  84703. * Creates a new color4 gradient
  84704. * @param gradient gets or sets the gradient value (between 0 and 1)
  84705. * @param color1 gets or sets first associated color
  84706. * @param color2 gets or sets first second color
  84707. */
  84708. constructor(
  84709. /**
  84710. * Gets or sets the gradient value (between 0 and 1)
  84711. */
  84712. gradient: number,
  84713. /**
  84714. * Gets or sets first associated color
  84715. */
  84716. color1: Color4,
  84717. /**
  84718. * Gets or sets second associated color
  84719. */
  84720. color2?: Color4 | undefined);
  84721. /**
  84722. * Will get a color picked randomly between color1 and color2.
  84723. * If color2 is undefined then color1 will be used
  84724. * @param result defines the target Color4 to store the result in
  84725. */
  84726. getColorToRef(result: Color4): void;
  84727. }
  84728. /** Class used to store color 3 gradient */
  84729. export class Color3Gradient implements IValueGradient {
  84730. /**
  84731. * Gets or sets the gradient value (between 0 and 1)
  84732. */
  84733. gradient: number;
  84734. /**
  84735. * Gets or sets the associated color
  84736. */
  84737. color: Color3;
  84738. /**
  84739. * Creates a new color3 gradient
  84740. * @param gradient gets or sets the gradient value (between 0 and 1)
  84741. * @param color gets or sets associated color
  84742. */
  84743. constructor(
  84744. /**
  84745. * Gets or sets the gradient value (between 0 and 1)
  84746. */
  84747. gradient: number,
  84748. /**
  84749. * Gets or sets the associated color
  84750. */
  84751. color: Color3);
  84752. }
  84753. /** Class used to store factor gradient */
  84754. export class FactorGradient implements IValueGradient {
  84755. /**
  84756. * Gets or sets the gradient value (between 0 and 1)
  84757. */
  84758. gradient: number;
  84759. /**
  84760. * Gets or sets first associated factor
  84761. */
  84762. factor1: number;
  84763. /**
  84764. * Gets or sets second associated factor
  84765. */
  84766. factor2?: number | undefined;
  84767. /**
  84768. * Creates a new factor gradient
  84769. * @param gradient gets or sets the gradient value (between 0 and 1)
  84770. * @param factor1 gets or sets first associated factor
  84771. * @param factor2 gets or sets second associated factor
  84772. */
  84773. constructor(
  84774. /**
  84775. * Gets or sets the gradient value (between 0 and 1)
  84776. */
  84777. gradient: number,
  84778. /**
  84779. * Gets or sets first associated factor
  84780. */
  84781. factor1: number,
  84782. /**
  84783. * Gets or sets second associated factor
  84784. */
  84785. factor2?: number | undefined);
  84786. /**
  84787. * Will get a number picked randomly between factor1 and factor2.
  84788. * If factor2 is undefined then factor1 will be used
  84789. * @returns the picked number
  84790. */
  84791. getFactor(): number;
  84792. }
  84793. /**
  84794. * Helper used to simplify some generic gradient tasks
  84795. */
  84796. export class GradientHelper {
  84797. /**
  84798. * Gets the current gradient from an array of IValueGradient
  84799. * @param ratio defines the current ratio to get
  84800. * @param gradients defines the array of IValueGradient
  84801. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  84802. */
  84803. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  84804. }
  84805. }
  84806. declare module BABYLON {
  84807. /**
  84808. * Interface for the size containing width and height
  84809. */
  84810. export interface ISize {
  84811. /**
  84812. * Width
  84813. */
  84814. width: number;
  84815. /**
  84816. * Heighht
  84817. */
  84818. height: number;
  84819. }
  84820. /**
  84821. * Size containing widht and height
  84822. */
  84823. export class Size implements ISize {
  84824. /**
  84825. * Width
  84826. */
  84827. width: number;
  84828. /**
  84829. * Height
  84830. */
  84831. height: number;
  84832. /**
  84833. * Creates a Size object from the given width and height (floats).
  84834. * @param width width of the new size
  84835. * @param height height of the new size
  84836. */
  84837. constructor(width: number, height: number);
  84838. /**
  84839. * Returns a string with the Size width and height
  84840. * @returns a string with the Size width and height
  84841. */
  84842. toString(): string;
  84843. /**
  84844. * "Size"
  84845. * @returns the string "Size"
  84846. */
  84847. getClassName(): string;
  84848. /**
  84849. * Returns the Size hash code.
  84850. * @returns a hash code for a unique width and height
  84851. */
  84852. getHashCode(): number;
  84853. /**
  84854. * Updates the current size from the given one.
  84855. * @param src the given size
  84856. */
  84857. copyFrom(src: Size): void;
  84858. /**
  84859. * Updates in place the current Size from the given floats.
  84860. * @param width width of the new size
  84861. * @param height height of the new size
  84862. * @returns the updated Size.
  84863. */
  84864. copyFromFloats(width: number, height: number): Size;
  84865. /**
  84866. * Updates in place the current Size from the given floats.
  84867. * @param width width to set
  84868. * @param height height to set
  84869. * @returns the updated Size.
  84870. */
  84871. set(width: number, height: number): Size;
  84872. /**
  84873. * Multiplies the width and height by numbers
  84874. * @param w factor to multiple the width by
  84875. * @param h factor to multiple the height by
  84876. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  84877. */
  84878. multiplyByFloats(w: number, h: number): Size;
  84879. /**
  84880. * Clones the size
  84881. * @returns a new Size copied from the given one.
  84882. */
  84883. clone(): Size;
  84884. /**
  84885. * True if the current Size and the given one width and height are strictly equal.
  84886. * @param other the other size to compare against
  84887. * @returns True if the current Size and the given one width and height are strictly equal.
  84888. */
  84889. equals(other: Size): boolean;
  84890. /**
  84891. * The surface of the Size : width * height (float).
  84892. */
  84893. get surface(): number;
  84894. /**
  84895. * Create a new size of zero
  84896. * @returns a new Size set to (0.0, 0.0)
  84897. */
  84898. static Zero(): Size;
  84899. /**
  84900. * Sums the width and height of two sizes
  84901. * @param otherSize size to add to this size
  84902. * @returns a new Size set as the addition result of the current Size and the given one.
  84903. */
  84904. add(otherSize: Size): Size;
  84905. /**
  84906. * Subtracts the width and height of two
  84907. * @param otherSize size to subtract to this size
  84908. * @returns a new Size set as the subtraction result of the given one from the current Size.
  84909. */
  84910. subtract(otherSize: Size): Size;
  84911. /**
  84912. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  84913. * @param start starting size to lerp between
  84914. * @param end end size to lerp between
  84915. * @param amount amount to lerp between the start and end values
  84916. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  84917. */
  84918. static Lerp(start: Size, end: Size, amount: number): Size;
  84919. }
  84920. }
  84921. declare module BABYLON {
  84922. interface ThinEngine {
  84923. /**
  84924. * Creates a dynamic texture
  84925. * @param width defines the width of the texture
  84926. * @param height defines the height of the texture
  84927. * @param generateMipMaps defines if the engine should generate the mip levels
  84928. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84929. * @returns the dynamic texture inside an InternalTexture
  84930. */
  84931. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  84932. /**
  84933. * Update the content of a dynamic texture
  84934. * @param texture defines the texture to update
  84935. * @param canvas defines the canvas containing the source
  84936. * @param invertY defines if data must be stored with Y axis inverted
  84937. * @param premulAlpha defines if alpha is stored as premultiplied
  84938. * @param format defines the format of the data
  84939. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  84940. */
  84941. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  84942. }
  84943. }
  84944. declare module BABYLON {
  84945. /**
  84946. * Helper class used to generate a canvas to manipulate images
  84947. */
  84948. export class CanvasGenerator {
  84949. /**
  84950. * Create a new canvas (or offscreen canvas depending on the context)
  84951. * @param width defines the expected width
  84952. * @param height defines the expected height
  84953. * @return a new canvas or offscreen canvas
  84954. */
  84955. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  84956. }
  84957. }
  84958. declare module BABYLON {
  84959. /**
  84960. * A class extending Texture allowing drawing on a texture
  84961. * @see http://doc.babylonjs.com/how_to/dynamictexture
  84962. */
  84963. export class DynamicTexture extends Texture {
  84964. private _generateMipMaps;
  84965. private _canvas;
  84966. private _context;
  84967. private _engine;
  84968. /**
  84969. * Creates a DynamicTexture
  84970. * @param name defines the name of the texture
  84971. * @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
  84972. * @param scene defines the scene where you want the texture
  84973. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  84974. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  84975. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  84976. */
  84977. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  84978. /**
  84979. * Get the current class name of the texture useful for serialization or dynamic coding.
  84980. * @returns "DynamicTexture"
  84981. */
  84982. getClassName(): string;
  84983. /**
  84984. * Gets the current state of canRescale
  84985. */
  84986. get canRescale(): boolean;
  84987. private _recreate;
  84988. /**
  84989. * Scales the texture
  84990. * @param ratio the scale factor to apply to both width and height
  84991. */
  84992. scale(ratio: number): void;
  84993. /**
  84994. * Resizes the texture
  84995. * @param width the new width
  84996. * @param height the new height
  84997. */
  84998. scaleTo(width: number, height: number): void;
  84999. /**
  85000. * Gets the context of the canvas used by the texture
  85001. * @returns the canvas context of the dynamic texture
  85002. */
  85003. getContext(): CanvasRenderingContext2D;
  85004. /**
  85005. * Clears the texture
  85006. */
  85007. clear(): void;
  85008. /**
  85009. * Updates the texture
  85010. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  85011. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  85012. */
  85013. update(invertY?: boolean, premulAlpha?: boolean): void;
  85014. /**
  85015. * Draws text onto the texture
  85016. * @param text defines the text to be drawn
  85017. * @param x defines the placement of the text from the left
  85018. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  85019. * @param font defines the font to be used with font-style, font-size, font-name
  85020. * @param color defines the color used for the text
  85021. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  85022. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  85023. * @param update defines whether texture is immediately update (default is true)
  85024. */
  85025. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  85026. /**
  85027. * Clones the texture
  85028. * @returns the clone of the texture.
  85029. */
  85030. clone(): DynamicTexture;
  85031. /**
  85032. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  85033. * @returns a serialized dynamic texture object
  85034. */
  85035. serialize(): any;
  85036. /** @hidden */
  85037. _rebuild(): void;
  85038. }
  85039. }
  85040. declare module BABYLON {
  85041. interface ThinEngine {
  85042. /**
  85043. * Creates a raw texture
  85044. * @param data defines the data to store in the texture
  85045. * @param width defines the width of the texture
  85046. * @param height defines the height of the texture
  85047. * @param format defines the format of the data
  85048. * @param generateMipMaps defines if the engine should generate the mip levels
  85049. * @param invertY defines if data must be stored with Y axis inverted
  85050. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85051. * @param compression defines the compression used (null by default)
  85052. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85053. * @returns the raw texture inside an InternalTexture
  85054. */
  85055. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  85056. /**
  85057. * Update a raw texture
  85058. * @param texture defines the texture to update
  85059. * @param data defines the data to store in the texture
  85060. * @param format defines the format of the data
  85061. * @param invertY defines if data must be stored with Y axis inverted
  85062. */
  85063. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  85064. /**
  85065. * Update a raw texture
  85066. * @param texture defines the texture to update
  85067. * @param data defines the data to store in the texture
  85068. * @param format defines the format of the data
  85069. * @param invertY defines if data must be stored with Y axis inverted
  85070. * @param compression defines the compression used (null by default)
  85071. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85072. */
  85073. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  85074. /**
  85075. * Creates a new raw cube texture
  85076. * @param data defines the array of data to use to create each face
  85077. * @param size defines the size of the textures
  85078. * @param format defines the format of the data
  85079. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85080. * @param generateMipMaps defines if the engine should generate the mip levels
  85081. * @param invertY defines if data must be stored with Y axis inverted
  85082. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85083. * @param compression defines the compression used (null by default)
  85084. * @returns the cube texture as an InternalTexture
  85085. */
  85086. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  85087. /**
  85088. * Update a raw cube texture
  85089. * @param texture defines the texture to udpdate
  85090. * @param data defines the data to store
  85091. * @param format defines the data format
  85092. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85093. * @param invertY defines if data must be stored with Y axis inverted
  85094. */
  85095. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  85096. /**
  85097. * Update a raw cube texture
  85098. * @param texture defines the texture to udpdate
  85099. * @param data defines the data to store
  85100. * @param format defines the data format
  85101. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85102. * @param invertY defines if data must be stored with Y axis inverted
  85103. * @param compression defines the compression used (null by default)
  85104. */
  85105. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  85106. /**
  85107. * Update a raw cube texture
  85108. * @param texture defines the texture to udpdate
  85109. * @param data defines the data to store
  85110. * @param format defines the data format
  85111. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85112. * @param invertY defines if data must be stored with Y axis inverted
  85113. * @param compression defines the compression used (null by default)
  85114. * @param level defines which level of the texture to update
  85115. */
  85116. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  85117. /**
  85118. * Creates a new raw cube texture from a specified url
  85119. * @param url defines the url where the data is located
  85120. * @param scene defines the current scene
  85121. * @param size defines the size of the textures
  85122. * @param format defines the format of the data
  85123. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85124. * @param noMipmap defines if the engine should avoid generating the mip levels
  85125. * @param callback defines a callback used to extract texture data from loaded data
  85126. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  85127. * @param onLoad defines a callback called when texture is loaded
  85128. * @param onError defines a callback called if there is an error
  85129. * @returns the cube texture as an InternalTexture
  85130. */
  85131. 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;
  85132. /**
  85133. * Creates a new raw cube texture from a specified url
  85134. * @param url defines the url where the data is located
  85135. * @param scene defines the current scene
  85136. * @param size defines the size of the textures
  85137. * @param format defines the format of the data
  85138. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85139. * @param noMipmap defines if the engine should avoid generating the mip levels
  85140. * @param callback defines a callback used to extract texture data from loaded data
  85141. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  85142. * @param onLoad defines a callback called when texture is loaded
  85143. * @param onError defines a callback called if there is an error
  85144. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85145. * @param invertY defines if data must be stored with Y axis inverted
  85146. * @returns the cube texture as an InternalTexture
  85147. */
  85148. 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;
  85149. /**
  85150. * Creates a new raw 3D texture
  85151. * @param data defines the data used to create the texture
  85152. * @param width defines the width of the texture
  85153. * @param height defines the height of the texture
  85154. * @param depth defines the depth of the texture
  85155. * @param format defines the format of the texture
  85156. * @param generateMipMaps defines if the engine must generate mip levels
  85157. * @param invertY defines if data must be stored with Y axis inverted
  85158. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85159. * @param compression defines the compressed used (can be null)
  85160. * @param textureType defines the compressed used (can be null)
  85161. * @returns a new raw 3D texture (stored in an InternalTexture)
  85162. */
  85163. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  85164. /**
  85165. * Update a raw 3D texture
  85166. * @param texture defines the texture to update
  85167. * @param data defines the data to store
  85168. * @param format defines the data format
  85169. * @param invertY defines if data must be stored with Y axis inverted
  85170. */
  85171. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  85172. /**
  85173. * Update a raw 3D texture
  85174. * @param texture defines the texture to update
  85175. * @param data defines the data to store
  85176. * @param format defines the data format
  85177. * @param invertY defines if data must be stored with Y axis inverted
  85178. * @param compression defines the used compression (can be null)
  85179. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  85180. */
  85181. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  85182. /**
  85183. * Creates a new raw 2D array texture
  85184. * @param data defines the data used to create the texture
  85185. * @param width defines the width of the texture
  85186. * @param height defines the height of the texture
  85187. * @param depth defines the number of layers of the texture
  85188. * @param format defines the format of the texture
  85189. * @param generateMipMaps defines if the engine must generate mip levels
  85190. * @param invertY defines if data must be stored with Y axis inverted
  85191. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85192. * @param compression defines the compressed used (can be null)
  85193. * @param textureType defines the compressed used (can be null)
  85194. * @returns a new raw 2D array texture (stored in an InternalTexture)
  85195. */
  85196. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  85197. /**
  85198. * Update a raw 2D array texture
  85199. * @param texture defines the texture to update
  85200. * @param data defines the data to store
  85201. * @param format defines the data format
  85202. * @param invertY defines if data must be stored with Y axis inverted
  85203. */
  85204. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  85205. /**
  85206. * Update a raw 2D array texture
  85207. * @param texture defines the texture to update
  85208. * @param data defines the data to store
  85209. * @param format defines the data format
  85210. * @param invertY defines if data must be stored with Y axis inverted
  85211. * @param compression defines the used compression (can be null)
  85212. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  85213. */
  85214. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  85215. }
  85216. }
  85217. declare module BABYLON {
  85218. /**
  85219. * Raw texture can help creating a texture directly from an array of data.
  85220. * This can be super useful if you either get the data from an uncompressed source or
  85221. * if you wish to create your texture pixel by pixel.
  85222. */
  85223. export class RawTexture extends Texture {
  85224. /**
  85225. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  85226. */
  85227. format: number;
  85228. private _engine;
  85229. /**
  85230. * Instantiates a new RawTexture.
  85231. * Raw texture can help creating a texture directly from an array of data.
  85232. * This can be super useful if you either get the data from an uncompressed source or
  85233. * if you wish to create your texture pixel by pixel.
  85234. * @param data define the array of data to use to create the texture
  85235. * @param width define the width of the texture
  85236. * @param height define the height of the texture
  85237. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  85238. * @param scene define the scene the texture belongs to
  85239. * @param generateMipMaps define whether mip maps should be generated or not
  85240. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85241. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85242. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85243. */
  85244. constructor(data: ArrayBufferView, width: number, height: number,
  85245. /**
  85246. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  85247. */
  85248. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  85249. /**
  85250. * Updates the texture underlying data.
  85251. * @param data Define the new data of the texture
  85252. */
  85253. update(data: ArrayBufferView): void;
  85254. /**
  85255. * Creates a luminance texture from some data.
  85256. * @param data Define the texture data
  85257. * @param width Define the width of the texture
  85258. * @param height Define the height of the texture
  85259. * @param scene Define the scene the texture belongs to
  85260. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85261. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85262. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85263. * @returns the luminance texture
  85264. */
  85265. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  85266. /**
  85267. * Creates a luminance alpha texture from some data.
  85268. * @param data Define the texture data
  85269. * @param width Define the width of the texture
  85270. * @param height Define the height of the texture
  85271. * @param scene Define the scene the texture belongs to
  85272. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85273. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85274. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85275. * @returns the luminance alpha texture
  85276. */
  85277. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  85278. /**
  85279. * Creates an alpha texture from some data.
  85280. * @param data Define the texture data
  85281. * @param width Define the width of the texture
  85282. * @param height Define the height of the texture
  85283. * @param scene Define the scene the texture belongs to
  85284. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85285. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85286. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85287. * @returns the alpha texture
  85288. */
  85289. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  85290. /**
  85291. * Creates a RGB texture from some data.
  85292. * @param data Define the texture data
  85293. * @param width Define the width of the texture
  85294. * @param height Define the height of the texture
  85295. * @param scene Define the scene the texture belongs to
  85296. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85297. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85298. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85299. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85300. * @returns the RGB alpha texture
  85301. */
  85302. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85303. /**
  85304. * Creates a RGBA texture from some data.
  85305. * @param data Define the texture data
  85306. * @param width Define the width of the texture
  85307. * @param height Define the height of the texture
  85308. * @param scene Define the scene the texture belongs to
  85309. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85310. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85311. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85312. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85313. * @returns the RGBA texture
  85314. */
  85315. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85316. /**
  85317. * Creates a R texture from some data.
  85318. * @param data Define the texture data
  85319. * @param width Define the width of the texture
  85320. * @param height Define the height of the texture
  85321. * @param scene Define the scene the texture belongs to
  85322. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85323. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85324. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85325. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85326. * @returns the R texture
  85327. */
  85328. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85329. }
  85330. }
  85331. declare module BABYLON {
  85332. interface AbstractScene {
  85333. /**
  85334. * The list of procedural textures added to the scene
  85335. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85336. */
  85337. proceduralTextures: Array<ProceduralTexture>;
  85338. }
  85339. /**
  85340. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  85341. * in a given scene.
  85342. */
  85343. export class ProceduralTextureSceneComponent implements ISceneComponent {
  85344. /**
  85345. * The component name helpfull to identify the component in the list of scene components.
  85346. */
  85347. readonly name: string;
  85348. /**
  85349. * The scene the component belongs to.
  85350. */
  85351. scene: Scene;
  85352. /**
  85353. * Creates a new instance of the component for the given scene
  85354. * @param scene Defines the scene to register the component in
  85355. */
  85356. constructor(scene: Scene);
  85357. /**
  85358. * Registers the component in a given scene
  85359. */
  85360. register(): void;
  85361. /**
  85362. * Rebuilds the elements related to this component in case of
  85363. * context lost for instance.
  85364. */
  85365. rebuild(): void;
  85366. /**
  85367. * Disposes the component and the associated ressources.
  85368. */
  85369. dispose(): void;
  85370. private _beforeClear;
  85371. }
  85372. }
  85373. declare module BABYLON {
  85374. interface ThinEngine {
  85375. /**
  85376. * Creates a new render target cube texture
  85377. * @param size defines the size of the texture
  85378. * @param options defines the options used to create the texture
  85379. * @returns a new render target cube texture stored in an InternalTexture
  85380. */
  85381. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  85382. }
  85383. }
  85384. declare module BABYLON {
  85385. /** @hidden */
  85386. export var proceduralVertexShader: {
  85387. name: string;
  85388. shader: string;
  85389. };
  85390. }
  85391. declare module BABYLON {
  85392. /**
  85393. * 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.
  85394. * This is the base class of any Procedural texture and contains most of the shareable code.
  85395. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85396. */
  85397. export class ProceduralTexture extends Texture {
  85398. isCube: boolean;
  85399. /**
  85400. * Define if the texture is enabled or not (disabled texture will not render)
  85401. */
  85402. isEnabled: boolean;
  85403. /**
  85404. * Define if the texture must be cleared before rendering (default is true)
  85405. */
  85406. autoClear: boolean;
  85407. /**
  85408. * Callback called when the texture is generated
  85409. */
  85410. onGenerated: () => void;
  85411. /**
  85412. * Event raised when the texture is generated
  85413. */
  85414. onGeneratedObservable: Observable<ProceduralTexture>;
  85415. /** @hidden */
  85416. _generateMipMaps: boolean;
  85417. /** @hidden **/
  85418. _effect: Effect;
  85419. /** @hidden */
  85420. _textures: {
  85421. [key: string]: Texture;
  85422. };
  85423. /** @hidden */
  85424. protected _fallbackTexture: Nullable<Texture>;
  85425. private _size;
  85426. private _currentRefreshId;
  85427. private _frameId;
  85428. private _refreshRate;
  85429. private _vertexBuffers;
  85430. private _indexBuffer;
  85431. private _uniforms;
  85432. private _samplers;
  85433. private _fragment;
  85434. private _floats;
  85435. private _ints;
  85436. private _floatsArrays;
  85437. private _colors3;
  85438. private _colors4;
  85439. private _vectors2;
  85440. private _vectors3;
  85441. private _matrices;
  85442. private _fallbackTextureUsed;
  85443. private _engine;
  85444. private _cachedDefines;
  85445. private _contentUpdateId;
  85446. private _contentData;
  85447. /**
  85448. * Instantiates a new procedural texture.
  85449. * 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.
  85450. * This is the base class of any Procedural texture and contains most of the shareable code.
  85451. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85452. * @param name Define the name of the texture
  85453. * @param size Define the size of the texture to create
  85454. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  85455. * @param scene Define the scene the texture belongs to
  85456. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  85457. * @param generateMipMaps Define if the texture should creates mip maps or not
  85458. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  85459. */
  85460. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  85461. /**
  85462. * The effect that is created when initializing the post process.
  85463. * @returns The created effect corresponding the the postprocess.
  85464. */
  85465. getEffect(): Effect;
  85466. /**
  85467. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  85468. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  85469. */
  85470. getContent(): Nullable<ArrayBufferView>;
  85471. private _createIndexBuffer;
  85472. /** @hidden */
  85473. _rebuild(): void;
  85474. /**
  85475. * Resets the texture in order to recreate its associated resources.
  85476. * This can be called in case of context loss
  85477. */
  85478. reset(): void;
  85479. protected _getDefines(): string;
  85480. /**
  85481. * Is the texture ready to be used ? (rendered at least once)
  85482. * @returns true if ready, otherwise, false.
  85483. */
  85484. isReady(): boolean;
  85485. /**
  85486. * Resets the refresh counter of the texture and start bak from scratch.
  85487. * Could be useful to regenerate the texture if it is setup to render only once.
  85488. */
  85489. resetRefreshCounter(): void;
  85490. /**
  85491. * Set the fragment shader to use in order to render the texture.
  85492. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  85493. */
  85494. setFragment(fragment: any): void;
  85495. /**
  85496. * Define the refresh rate of the texture or the rendering frequency.
  85497. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  85498. */
  85499. get refreshRate(): number;
  85500. set refreshRate(value: number);
  85501. /** @hidden */
  85502. _shouldRender(): boolean;
  85503. /**
  85504. * Get the size the texture is rendering at.
  85505. * @returns the size (texture is always squared)
  85506. */
  85507. getRenderSize(): number;
  85508. /**
  85509. * Resize the texture to new value.
  85510. * @param size Define the new size the texture should have
  85511. * @param generateMipMaps Define whether the new texture should create mip maps
  85512. */
  85513. resize(size: number, generateMipMaps: boolean): void;
  85514. private _checkUniform;
  85515. /**
  85516. * Set a texture in the shader program used to render.
  85517. * @param name Define the name of the uniform samplers as defined in the shader
  85518. * @param texture Define the texture to bind to this sampler
  85519. * @return the texture itself allowing "fluent" like uniform updates
  85520. */
  85521. setTexture(name: string, texture: Texture): ProceduralTexture;
  85522. /**
  85523. * Set a float in the shader.
  85524. * @param name Define the name of the uniform as defined in the shader
  85525. * @param value Define the value to give to the uniform
  85526. * @return the texture itself allowing "fluent" like uniform updates
  85527. */
  85528. setFloat(name: string, value: number): ProceduralTexture;
  85529. /**
  85530. * Set a int in the shader.
  85531. * @param name Define the name of the uniform as defined in the shader
  85532. * @param value Define the value to give to the uniform
  85533. * @return the texture itself allowing "fluent" like uniform updates
  85534. */
  85535. setInt(name: string, value: number): ProceduralTexture;
  85536. /**
  85537. * Set an array of floats in the shader.
  85538. * @param name Define the name of the uniform as defined in the shader
  85539. * @param value Define the value to give to the uniform
  85540. * @return the texture itself allowing "fluent" like uniform updates
  85541. */
  85542. setFloats(name: string, value: number[]): ProceduralTexture;
  85543. /**
  85544. * Set a vec3 in the shader from a Color3.
  85545. * @param name Define the name of the uniform as defined in the shader
  85546. * @param value Define the value to give to the uniform
  85547. * @return the texture itself allowing "fluent" like uniform updates
  85548. */
  85549. setColor3(name: string, value: Color3): ProceduralTexture;
  85550. /**
  85551. * Set a vec4 in the shader from a Color4.
  85552. * @param name Define the name of the uniform as defined in the shader
  85553. * @param value Define the value to give to the uniform
  85554. * @return the texture itself allowing "fluent" like uniform updates
  85555. */
  85556. setColor4(name: string, value: Color4): ProceduralTexture;
  85557. /**
  85558. * Set a vec2 in the shader from a Vector2.
  85559. * @param name Define the name of the uniform as defined in the shader
  85560. * @param value Define the value to give to the uniform
  85561. * @return the texture itself allowing "fluent" like uniform updates
  85562. */
  85563. setVector2(name: string, value: Vector2): ProceduralTexture;
  85564. /**
  85565. * Set a vec3 in the shader from a Vector3.
  85566. * @param name Define the name of the uniform as defined in the shader
  85567. * @param value Define the value to give to the uniform
  85568. * @return the texture itself allowing "fluent" like uniform updates
  85569. */
  85570. setVector3(name: string, value: Vector3): ProceduralTexture;
  85571. /**
  85572. * Set a mat4 in the shader from a MAtrix.
  85573. * @param name Define the name of the uniform as defined in the shader
  85574. * @param value Define the value to give to the uniform
  85575. * @return the texture itself allowing "fluent" like uniform updates
  85576. */
  85577. setMatrix(name: string, value: Matrix): ProceduralTexture;
  85578. /**
  85579. * Render the texture to its associated render target.
  85580. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  85581. */
  85582. render(useCameraPostProcess?: boolean): void;
  85583. /**
  85584. * Clone the texture.
  85585. * @returns the cloned texture
  85586. */
  85587. clone(): ProceduralTexture;
  85588. /**
  85589. * Dispose the texture and release its asoociated resources.
  85590. */
  85591. dispose(): void;
  85592. }
  85593. }
  85594. declare module BABYLON {
  85595. /**
  85596. * This represents the base class for particle system in Babylon.
  85597. * 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.
  85598. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85599. * @example https://doc.babylonjs.com/babylon101/particles
  85600. */
  85601. export class BaseParticleSystem {
  85602. /**
  85603. * Source color is added to the destination color without alpha affecting the result
  85604. */
  85605. static BLENDMODE_ONEONE: number;
  85606. /**
  85607. * Blend current color and particle color using particle’s alpha
  85608. */
  85609. static BLENDMODE_STANDARD: number;
  85610. /**
  85611. * Add current color and particle color multiplied by particle’s alpha
  85612. */
  85613. static BLENDMODE_ADD: number;
  85614. /**
  85615. * Multiply current color with particle color
  85616. */
  85617. static BLENDMODE_MULTIPLY: number;
  85618. /**
  85619. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  85620. */
  85621. static BLENDMODE_MULTIPLYADD: number;
  85622. /**
  85623. * List of animations used by the particle system.
  85624. */
  85625. animations: Animation[];
  85626. /**
  85627. * Gets or sets the unique id of the particle system
  85628. */
  85629. uniqueId: number;
  85630. /**
  85631. * The id of the Particle system.
  85632. */
  85633. id: string;
  85634. /**
  85635. * The friendly name of the Particle system.
  85636. */
  85637. name: string;
  85638. /**
  85639. * Snippet ID if the particle system was created from the snippet server
  85640. */
  85641. snippetId: string;
  85642. /**
  85643. * The rendering group used by the Particle system to chose when to render.
  85644. */
  85645. renderingGroupId: number;
  85646. /**
  85647. * The emitter represents the Mesh or position we are attaching the particle system to.
  85648. */
  85649. emitter: Nullable<AbstractMesh | Vector3>;
  85650. /**
  85651. * The maximum number of particles to emit per frame
  85652. */
  85653. emitRate: number;
  85654. /**
  85655. * If you want to launch only a few particles at once, that can be done, as well.
  85656. */
  85657. manualEmitCount: number;
  85658. /**
  85659. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85660. */
  85661. updateSpeed: number;
  85662. /**
  85663. * The amount of time the particle system is running (depends of the overall update speed).
  85664. */
  85665. targetStopDuration: number;
  85666. /**
  85667. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85668. */
  85669. disposeOnStop: boolean;
  85670. /**
  85671. * Minimum power of emitting particles.
  85672. */
  85673. minEmitPower: number;
  85674. /**
  85675. * Maximum power of emitting particles.
  85676. */
  85677. maxEmitPower: number;
  85678. /**
  85679. * Minimum life time of emitting particles.
  85680. */
  85681. minLifeTime: number;
  85682. /**
  85683. * Maximum life time of emitting particles.
  85684. */
  85685. maxLifeTime: number;
  85686. /**
  85687. * Minimum Size of emitting particles.
  85688. */
  85689. minSize: number;
  85690. /**
  85691. * Maximum Size of emitting particles.
  85692. */
  85693. maxSize: number;
  85694. /**
  85695. * Minimum scale of emitting particles on X axis.
  85696. */
  85697. minScaleX: number;
  85698. /**
  85699. * Maximum scale of emitting particles on X axis.
  85700. */
  85701. maxScaleX: number;
  85702. /**
  85703. * Minimum scale of emitting particles on Y axis.
  85704. */
  85705. minScaleY: number;
  85706. /**
  85707. * Maximum scale of emitting particles on Y axis.
  85708. */
  85709. maxScaleY: number;
  85710. /**
  85711. * Gets or sets the minimal initial rotation in radians.
  85712. */
  85713. minInitialRotation: number;
  85714. /**
  85715. * Gets or sets the maximal initial rotation in radians.
  85716. */
  85717. maxInitialRotation: number;
  85718. /**
  85719. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85720. */
  85721. minAngularSpeed: number;
  85722. /**
  85723. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85724. */
  85725. maxAngularSpeed: number;
  85726. /**
  85727. * The texture used to render each particle. (this can be a spritesheet)
  85728. */
  85729. particleTexture: Nullable<Texture>;
  85730. /**
  85731. * The layer mask we are rendering the particles through.
  85732. */
  85733. layerMask: number;
  85734. /**
  85735. * This can help using your own shader to render the particle system.
  85736. * The according effect will be created
  85737. */
  85738. customShader: any;
  85739. /**
  85740. * By default particle system starts as soon as they are created. This prevents the
  85741. * automatic start to happen and let you decide when to start emitting particles.
  85742. */
  85743. preventAutoStart: boolean;
  85744. private _noiseTexture;
  85745. /**
  85746. * Gets or sets a texture used to add random noise to particle positions
  85747. */
  85748. get noiseTexture(): Nullable<ProceduralTexture>;
  85749. set noiseTexture(value: Nullable<ProceduralTexture>);
  85750. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85751. noiseStrength: Vector3;
  85752. /**
  85753. * Callback triggered when the particle animation is ending.
  85754. */
  85755. onAnimationEnd: Nullable<() => void>;
  85756. /**
  85757. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  85758. */
  85759. blendMode: number;
  85760. /**
  85761. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  85762. * to override the particles.
  85763. */
  85764. forceDepthWrite: boolean;
  85765. /** 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 */
  85766. preWarmCycles: number;
  85767. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  85768. preWarmStepOffset: number;
  85769. /**
  85770. * 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)
  85771. */
  85772. spriteCellChangeSpeed: number;
  85773. /**
  85774. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85775. */
  85776. startSpriteCellID: number;
  85777. /**
  85778. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85779. */
  85780. endSpriteCellID: number;
  85781. /**
  85782. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85783. */
  85784. spriteCellWidth: number;
  85785. /**
  85786. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85787. */
  85788. spriteCellHeight: number;
  85789. /**
  85790. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85791. */
  85792. spriteRandomStartCell: boolean;
  85793. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85794. translationPivot: Vector2;
  85795. /** @hidden */
  85796. protected _isAnimationSheetEnabled: boolean;
  85797. /**
  85798. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85799. */
  85800. beginAnimationOnStart: boolean;
  85801. /**
  85802. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85803. */
  85804. beginAnimationFrom: number;
  85805. /**
  85806. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85807. */
  85808. beginAnimationTo: number;
  85809. /**
  85810. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85811. */
  85812. beginAnimationLoop: boolean;
  85813. /**
  85814. * Gets or sets a world offset applied to all particles
  85815. */
  85816. worldOffset: Vector3;
  85817. /**
  85818. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  85819. */
  85820. get isAnimationSheetEnabled(): boolean;
  85821. set isAnimationSheetEnabled(value: boolean);
  85822. /**
  85823. * Get hosting scene
  85824. * @returns the scene
  85825. */
  85826. getScene(): Scene;
  85827. /**
  85828. * You can use gravity if you want to give an orientation to your particles.
  85829. */
  85830. gravity: Vector3;
  85831. protected _colorGradients: Nullable<Array<ColorGradient>>;
  85832. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  85833. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  85834. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  85835. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  85836. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  85837. protected _dragGradients: Nullable<Array<FactorGradient>>;
  85838. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  85839. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  85840. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  85841. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  85842. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  85843. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  85844. /**
  85845. * Defines the delay in milliseconds before starting the system (0 by default)
  85846. */
  85847. startDelay: number;
  85848. /**
  85849. * Gets the current list of drag gradients.
  85850. * You must use addDragGradient and removeDragGradient to udpate this list
  85851. * @returns the list of drag gradients
  85852. */
  85853. getDragGradients(): Nullable<Array<FactorGradient>>;
  85854. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85855. limitVelocityDamping: number;
  85856. /**
  85857. * Gets the current list of limit velocity gradients.
  85858. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85859. * @returns the list of limit velocity gradients
  85860. */
  85861. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85862. /**
  85863. * Gets the current list of color gradients.
  85864. * You must use addColorGradient and removeColorGradient to udpate this list
  85865. * @returns the list of color gradients
  85866. */
  85867. getColorGradients(): Nullable<Array<ColorGradient>>;
  85868. /**
  85869. * Gets the current list of size gradients.
  85870. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85871. * @returns the list of size gradients
  85872. */
  85873. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85874. /**
  85875. * Gets the current list of color remap gradients.
  85876. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85877. * @returns the list of color remap gradients
  85878. */
  85879. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85880. /**
  85881. * Gets the current list of alpha remap gradients.
  85882. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85883. * @returns the list of alpha remap gradients
  85884. */
  85885. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85886. /**
  85887. * Gets the current list of life time gradients.
  85888. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85889. * @returns the list of life time gradients
  85890. */
  85891. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85892. /**
  85893. * Gets the current list of angular speed gradients.
  85894. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85895. * @returns the list of angular speed gradients
  85896. */
  85897. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85898. /**
  85899. * Gets the current list of velocity gradients.
  85900. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85901. * @returns the list of velocity gradients
  85902. */
  85903. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85904. /**
  85905. * Gets the current list of start size gradients.
  85906. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85907. * @returns the list of start size gradients
  85908. */
  85909. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85910. /**
  85911. * Gets the current list of emit rate gradients.
  85912. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85913. * @returns the list of emit rate gradients
  85914. */
  85915. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85916. /**
  85917. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85918. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85919. */
  85920. get direction1(): Vector3;
  85921. set direction1(value: Vector3);
  85922. /**
  85923. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85924. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85925. */
  85926. get direction2(): Vector3;
  85927. set direction2(value: Vector3);
  85928. /**
  85929. * 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.
  85930. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85931. */
  85932. get minEmitBox(): Vector3;
  85933. set minEmitBox(value: Vector3);
  85934. /**
  85935. * 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.
  85936. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85937. */
  85938. get maxEmitBox(): Vector3;
  85939. set maxEmitBox(value: Vector3);
  85940. /**
  85941. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85942. */
  85943. color1: Color4;
  85944. /**
  85945. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85946. */
  85947. color2: Color4;
  85948. /**
  85949. * Color the particle will have at the end of its lifetime
  85950. */
  85951. colorDead: Color4;
  85952. /**
  85953. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  85954. */
  85955. textureMask: Color4;
  85956. /**
  85957. * The particle emitter type defines the emitter used by the particle system.
  85958. * It can be for example box, sphere, or cone...
  85959. */
  85960. particleEmitterType: IParticleEmitterType;
  85961. /** @hidden */
  85962. _isSubEmitter: boolean;
  85963. /**
  85964. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85965. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85966. */
  85967. billboardMode: number;
  85968. protected _isBillboardBased: boolean;
  85969. /**
  85970. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85971. */
  85972. get isBillboardBased(): boolean;
  85973. set isBillboardBased(value: boolean);
  85974. /**
  85975. * The scene the particle system belongs to.
  85976. */
  85977. protected _scene: Scene;
  85978. /**
  85979. * Local cache of defines for image processing.
  85980. */
  85981. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  85982. /**
  85983. * Default configuration related to image processing available in the standard Material.
  85984. */
  85985. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  85986. /**
  85987. * Gets the image processing configuration used either in this material.
  85988. */
  85989. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  85990. /**
  85991. * Sets the Default image processing configuration used either in the this material.
  85992. *
  85993. * If sets to null, the scene one is in use.
  85994. */
  85995. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  85996. /**
  85997. * Attaches a new image processing configuration to the Standard Material.
  85998. * @param configuration
  85999. */
  86000. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  86001. /** @hidden */
  86002. protected _reset(): void;
  86003. /** @hidden */
  86004. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  86005. /**
  86006. * Instantiates a particle system.
  86007. * 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.
  86008. * @param name The name of the particle system
  86009. */
  86010. constructor(name: string);
  86011. /**
  86012. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  86013. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86014. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86015. * @returns the emitter
  86016. */
  86017. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  86018. /**
  86019. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  86020. * @param radius The radius of the hemisphere to emit from
  86021. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86022. * @returns the emitter
  86023. */
  86024. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  86025. /**
  86026. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  86027. * @param radius The radius of the sphere to emit from
  86028. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86029. * @returns the emitter
  86030. */
  86031. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  86032. /**
  86033. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86034. * @param radius The radius of the sphere to emit from
  86035. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86036. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86037. * @returns the emitter
  86038. */
  86039. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  86040. /**
  86041. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86042. * @param radius The radius of the emission cylinder
  86043. * @param height The height of the emission cylinder
  86044. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86045. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86046. * @returns the emitter
  86047. */
  86048. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  86049. /**
  86050. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86051. * @param radius The radius of the cylinder to emit from
  86052. * @param height The height of the emission cylinder
  86053. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86054. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86055. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86056. * @returns the emitter
  86057. */
  86058. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  86059. /**
  86060. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86061. * @param radius The radius of the cone to emit from
  86062. * @param angle The base angle of the cone
  86063. * @returns the emitter
  86064. */
  86065. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  86066. /**
  86067. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86068. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86069. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86070. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86071. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86072. * @returns the emitter
  86073. */
  86074. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86075. }
  86076. }
  86077. declare module BABYLON {
  86078. /**
  86079. * Type of sub emitter
  86080. */
  86081. export enum SubEmitterType {
  86082. /**
  86083. * Attached to the particle over it's lifetime
  86084. */
  86085. ATTACHED = 0,
  86086. /**
  86087. * Created when the particle dies
  86088. */
  86089. END = 1
  86090. }
  86091. /**
  86092. * Sub emitter class used to emit particles from an existing particle
  86093. */
  86094. export class SubEmitter {
  86095. /**
  86096. * the particle system to be used by the sub emitter
  86097. */
  86098. particleSystem: ParticleSystem;
  86099. /**
  86100. * Type of the submitter (Default: END)
  86101. */
  86102. type: SubEmitterType;
  86103. /**
  86104. * 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)
  86105. * Note: This only is supported when using an emitter of type Mesh
  86106. */
  86107. inheritDirection: boolean;
  86108. /**
  86109. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  86110. */
  86111. inheritedVelocityAmount: number;
  86112. /**
  86113. * Creates a sub emitter
  86114. * @param particleSystem the particle system to be used by the sub emitter
  86115. */
  86116. constructor(
  86117. /**
  86118. * the particle system to be used by the sub emitter
  86119. */
  86120. particleSystem: ParticleSystem);
  86121. /**
  86122. * Clones the sub emitter
  86123. * @returns the cloned sub emitter
  86124. */
  86125. clone(): SubEmitter;
  86126. /**
  86127. * Serialize current object to a JSON object
  86128. * @returns the serialized object
  86129. */
  86130. serialize(): any;
  86131. /** @hidden */
  86132. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  86133. /**
  86134. * Creates a new SubEmitter from a serialized JSON version
  86135. * @param serializationObject defines the JSON object to read from
  86136. * @param scene defines the hosting scene
  86137. * @param rootUrl defines the rootUrl for data loading
  86138. * @returns a new SubEmitter
  86139. */
  86140. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  86141. /** Release associated resources */
  86142. dispose(): void;
  86143. }
  86144. }
  86145. declare module BABYLON {
  86146. /** @hidden */
  86147. export var imageProcessingDeclaration: {
  86148. name: string;
  86149. shader: string;
  86150. };
  86151. }
  86152. declare module BABYLON {
  86153. /** @hidden */
  86154. export var imageProcessingFunctions: {
  86155. name: string;
  86156. shader: string;
  86157. };
  86158. }
  86159. declare module BABYLON {
  86160. /** @hidden */
  86161. export var particlesPixelShader: {
  86162. name: string;
  86163. shader: string;
  86164. };
  86165. }
  86166. declare module BABYLON {
  86167. /** @hidden */
  86168. export var particlesVertexShader: {
  86169. name: string;
  86170. shader: string;
  86171. };
  86172. }
  86173. declare module BABYLON {
  86174. /**
  86175. * This represents a particle system in Babylon.
  86176. * 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.
  86177. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  86178. * @example https://doc.babylonjs.com/babylon101/particles
  86179. */
  86180. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  86181. /**
  86182. * Billboard mode will only apply to Y axis
  86183. */
  86184. static readonly BILLBOARDMODE_Y: number;
  86185. /**
  86186. * Billboard mode will apply to all axes
  86187. */
  86188. static readonly BILLBOARDMODE_ALL: number;
  86189. /**
  86190. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  86191. */
  86192. static readonly BILLBOARDMODE_STRETCHED: number;
  86193. /**
  86194. * This function can be defined to provide custom update for active particles.
  86195. * This function will be called instead of regular update (age, position, color, etc.).
  86196. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  86197. */
  86198. updateFunction: (particles: Particle[]) => void;
  86199. private _emitterWorldMatrix;
  86200. /**
  86201. * This function can be defined to specify initial direction for every new particle.
  86202. * It by default use the emitterType defined function
  86203. */
  86204. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  86205. /**
  86206. * This function can be defined to specify initial position for every new particle.
  86207. * It by default use the emitterType defined function
  86208. */
  86209. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  86210. /**
  86211. * @hidden
  86212. */
  86213. _inheritedVelocityOffset: Vector3;
  86214. /**
  86215. * An event triggered when the system is disposed
  86216. */
  86217. onDisposeObservable: Observable<ParticleSystem>;
  86218. private _onDisposeObserver;
  86219. /**
  86220. * Sets a callback that will be triggered when the system is disposed
  86221. */
  86222. set onDispose(callback: () => void);
  86223. private _particles;
  86224. private _epsilon;
  86225. private _capacity;
  86226. private _stockParticles;
  86227. private _newPartsExcess;
  86228. private _vertexData;
  86229. private _vertexBuffer;
  86230. private _vertexBuffers;
  86231. private _spriteBuffer;
  86232. private _indexBuffer;
  86233. private _effect;
  86234. private _customEffect;
  86235. private _cachedDefines;
  86236. private _scaledColorStep;
  86237. private _colorDiff;
  86238. private _scaledDirection;
  86239. private _scaledGravity;
  86240. private _currentRenderId;
  86241. private _alive;
  86242. private _useInstancing;
  86243. private _started;
  86244. private _stopped;
  86245. private _actualFrame;
  86246. private _scaledUpdateSpeed;
  86247. private _vertexBufferSize;
  86248. /** @hidden */
  86249. _currentEmitRateGradient: Nullable<FactorGradient>;
  86250. /** @hidden */
  86251. _currentEmitRate1: number;
  86252. /** @hidden */
  86253. _currentEmitRate2: number;
  86254. /** @hidden */
  86255. _currentStartSizeGradient: Nullable<FactorGradient>;
  86256. /** @hidden */
  86257. _currentStartSize1: number;
  86258. /** @hidden */
  86259. _currentStartSize2: number;
  86260. private readonly _rawTextureWidth;
  86261. private _rampGradientsTexture;
  86262. private _useRampGradients;
  86263. /** Gets or sets a boolean indicating that ramp gradients must be used
  86264. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86265. */
  86266. get useRampGradients(): boolean;
  86267. set useRampGradients(value: boolean);
  86268. /**
  86269. * 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.
  86270. * 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: [])
  86271. */
  86272. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  86273. private _subEmitters;
  86274. /**
  86275. * @hidden
  86276. * If the particle systems emitter should be disposed when the particle system is disposed
  86277. */
  86278. _disposeEmitterOnDispose: boolean;
  86279. /**
  86280. * The current active Sub-systems, this property is used by the root particle system only.
  86281. */
  86282. activeSubSystems: Array<ParticleSystem>;
  86283. /**
  86284. * Specifies if the particles are updated in emitter local space or world space
  86285. */
  86286. isLocal: boolean;
  86287. private _rootParticleSystem;
  86288. /**
  86289. * Gets the current list of active particles
  86290. */
  86291. get particles(): Particle[];
  86292. /**
  86293. * Gets the number of particles active at the same time.
  86294. * @returns The number of active particles.
  86295. */
  86296. getActiveCount(): number;
  86297. /**
  86298. * Returns the string "ParticleSystem"
  86299. * @returns a string containing the class name
  86300. */
  86301. getClassName(): string;
  86302. /**
  86303. * Gets a boolean indicating that the system is stopping
  86304. * @returns true if the system is currently stopping
  86305. */
  86306. isStopping(): boolean;
  86307. /**
  86308. * Instantiates a particle system.
  86309. * 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.
  86310. * @param name The name of the particle system
  86311. * @param capacity The max number of particles alive at the same time
  86312. * @param scene The scene the particle system belongs to
  86313. * @param customEffect a custom effect used to change the way particles are rendered by default
  86314. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  86315. * @param epsilon Offset used to render the particles
  86316. */
  86317. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  86318. private _addFactorGradient;
  86319. private _removeFactorGradient;
  86320. /**
  86321. * Adds a new life time gradient
  86322. * @param gradient defines the gradient to use (between 0 and 1)
  86323. * @param factor defines the life time factor to affect to the specified gradient
  86324. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86325. * @returns the current particle system
  86326. */
  86327. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86328. /**
  86329. * Remove a specific life time gradient
  86330. * @param gradient defines the gradient to remove
  86331. * @returns the current particle system
  86332. */
  86333. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86334. /**
  86335. * Adds a new size gradient
  86336. * @param gradient defines the gradient to use (between 0 and 1)
  86337. * @param factor defines the size factor to affect to the specified gradient
  86338. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86339. * @returns the current particle system
  86340. */
  86341. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86342. /**
  86343. * Remove a specific size gradient
  86344. * @param gradient defines the gradient to remove
  86345. * @returns the current particle system
  86346. */
  86347. removeSizeGradient(gradient: number): IParticleSystem;
  86348. /**
  86349. * Adds a new color remap gradient
  86350. * @param gradient defines the gradient to use (between 0 and 1)
  86351. * @param min defines the color remap minimal range
  86352. * @param max defines the color remap maximal range
  86353. * @returns the current particle system
  86354. */
  86355. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86356. /**
  86357. * Remove a specific color remap gradient
  86358. * @param gradient defines the gradient to remove
  86359. * @returns the current particle system
  86360. */
  86361. removeColorRemapGradient(gradient: number): IParticleSystem;
  86362. /**
  86363. * Adds a new alpha remap gradient
  86364. * @param gradient defines the gradient to use (between 0 and 1)
  86365. * @param min defines the alpha remap minimal range
  86366. * @param max defines the alpha remap maximal range
  86367. * @returns the current particle system
  86368. */
  86369. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86370. /**
  86371. * Remove a specific alpha remap gradient
  86372. * @param gradient defines the gradient to remove
  86373. * @returns the current particle system
  86374. */
  86375. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  86376. /**
  86377. * Adds a new angular speed gradient
  86378. * @param gradient defines the gradient to use (between 0 and 1)
  86379. * @param factor defines the angular speed to affect to the specified gradient
  86380. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86381. * @returns the current particle system
  86382. */
  86383. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86384. /**
  86385. * Remove a specific angular speed gradient
  86386. * @param gradient defines the gradient to remove
  86387. * @returns the current particle system
  86388. */
  86389. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86390. /**
  86391. * Adds a new velocity gradient
  86392. * @param gradient defines the gradient to use (between 0 and 1)
  86393. * @param factor defines the velocity to affect to the specified gradient
  86394. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86395. * @returns the current particle system
  86396. */
  86397. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86398. /**
  86399. * Remove a specific velocity gradient
  86400. * @param gradient defines the gradient to remove
  86401. * @returns the current particle system
  86402. */
  86403. removeVelocityGradient(gradient: number): IParticleSystem;
  86404. /**
  86405. * Adds a new limit velocity gradient
  86406. * @param gradient defines the gradient to use (between 0 and 1)
  86407. * @param factor defines the limit velocity value to affect to the specified gradient
  86408. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86409. * @returns the current particle system
  86410. */
  86411. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86412. /**
  86413. * Remove a specific limit velocity gradient
  86414. * @param gradient defines the gradient to remove
  86415. * @returns the current particle system
  86416. */
  86417. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86418. /**
  86419. * Adds a new drag gradient
  86420. * @param gradient defines the gradient to use (between 0 and 1)
  86421. * @param factor defines the drag value to affect to the specified gradient
  86422. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86423. * @returns the current particle system
  86424. */
  86425. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86426. /**
  86427. * Remove a specific drag gradient
  86428. * @param gradient defines the gradient to remove
  86429. * @returns the current particle system
  86430. */
  86431. removeDragGradient(gradient: number): IParticleSystem;
  86432. /**
  86433. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86434. * @param gradient defines the gradient to use (between 0 and 1)
  86435. * @param factor defines the emit rate value to affect to the specified gradient
  86436. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86437. * @returns the current particle system
  86438. */
  86439. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86440. /**
  86441. * Remove a specific emit rate gradient
  86442. * @param gradient defines the gradient to remove
  86443. * @returns the current particle system
  86444. */
  86445. removeEmitRateGradient(gradient: number): IParticleSystem;
  86446. /**
  86447. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86448. * @param gradient defines the gradient to use (between 0 and 1)
  86449. * @param factor defines the start size value to affect to the specified gradient
  86450. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86451. * @returns the current particle system
  86452. */
  86453. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86454. /**
  86455. * Remove a specific start size gradient
  86456. * @param gradient defines the gradient to remove
  86457. * @returns the current particle system
  86458. */
  86459. removeStartSizeGradient(gradient: number): IParticleSystem;
  86460. private _createRampGradientTexture;
  86461. /**
  86462. * Gets the current list of ramp gradients.
  86463. * You must use addRampGradient and removeRampGradient to udpate this list
  86464. * @returns the list of ramp gradients
  86465. */
  86466. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86467. /** Force the system to rebuild all gradients that need to be resync */
  86468. forceRefreshGradients(): void;
  86469. private _syncRampGradientTexture;
  86470. /**
  86471. * Adds a new ramp gradient used to remap particle colors
  86472. * @param gradient defines the gradient to use (between 0 and 1)
  86473. * @param color defines the color to affect to the specified gradient
  86474. * @returns the current particle system
  86475. */
  86476. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  86477. /**
  86478. * Remove a specific ramp gradient
  86479. * @param gradient defines the gradient to remove
  86480. * @returns the current particle system
  86481. */
  86482. removeRampGradient(gradient: number): ParticleSystem;
  86483. /**
  86484. * Adds a new color gradient
  86485. * @param gradient defines the gradient to use (between 0 and 1)
  86486. * @param color1 defines the color to affect to the specified gradient
  86487. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86488. * @returns this particle system
  86489. */
  86490. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86491. /**
  86492. * Remove a specific color gradient
  86493. * @param gradient defines the gradient to remove
  86494. * @returns this particle system
  86495. */
  86496. removeColorGradient(gradient: number): IParticleSystem;
  86497. private _fetchR;
  86498. protected _reset(): void;
  86499. private _resetEffect;
  86500. private _createVertexBuffers;
  86501. private _createIndexBuffer;
  86502. /**
  86503. * Gets the maximum number of particles active at the same time.
  86504. * @returns The max number of active particles.
  86505. */
  86506. getCapacity(): number;
  86507. /**
  86508. * Gets whether there are still active particles in the system.
  86509. * @returns True if it is alive, otherwise false.
  86510. */
  86511. isAlive(): boolean;
  86512. /**
  86513. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86514. * @returns True if it has been started, otherwise false.
  86515. */
  86516. isStarted(): boolean;
  86517. private _prepareSubEmitterInternalArray;
  86518. /**
  86519. * Starts the particle system and begins to emit
  86520. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  86521. */
  86522. start(delay?: number): void;
  86523. /**
  86524. * Stops the particle system.
  86525. * @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.
  86526. */
  86527. stop(stopSubEmitters?: boolean): void;
  86528. /**
  86529. * Remove all active particles
  86530. */
  86531. reset(): void;
  86532. /**
  86533. * @hidden (for internal use only)
  86534. */
  86535. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  86536. /**
  86537. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  86538. * Its lifetime will start back at 0.
  86539. */
  86540. recycleParticle: (particle: Particle) => void;
  86541. private _stopSubEmitters;
  86542. private _createParticle;
  86543. private _removeFromRoot;
  86544. private _emitFromParticle;
  86545. private _update;
  86546. /** @hidden */
  86547. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  86548. /** @hidden */
  86549. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  86550. /** @hidden */
  86551. private _getEffect;
  86552. /**
  86553. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  86554. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  86555. */
  86556. animate(preWarmOnly?: boolean): void;
  86557. private _appendParticleVertices;
  86558. /**
  86559. * Rebuilds the particle system.
  86560. */
  86561. rebuild(): void;
  86562. /**
  86563. * Is this system ready to be used/rendered
  86564. * @return true if the system is ready
  86565. */
  86566. isReady(): boolean;
  86567. private _render;
  86568. /**
  86569. * Renders the particle system in its current state.
  86570. * @returns the current number of particles
  86571. */
  86572. render(): number;
  86573. /**
  86574. * Disposes the particle system and free the associated resources
  86575. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86576. */
  86577. dispose(disposeTexture?: boolean): void;
  86578. /**
  86579. * Clones the particle system.
  86580. * @param name The name of the cloned object
  86581. * @param newEmitter The new emitter to use
  86582. * @returns the cloned particle system
  86583. */
  86584. clone(name: string, newEmitter: any): ParticleSystem;
  86585. /**
  86586. * Serializes the particle system to a JSON object
  86587. * @param serializeTexture defines if the texture must be serialized as well
  86588. * @returns the JSON object
  86589. */
  86590. serialize(serializeTexture?: boolean): any;
  86591. /** @hidden */
  86592. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  86593. /** @hidden */
  86594. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  86595. /**
  86596. * Parses a JSON object to create a particle system.
  86597. * @param parsedParticleSystem The JSON object to parse
  86598. * @param scene The scene to create the particle system in
  86599. * @param rootUrl The root url to use to load external dependencies like texture
  86600. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  86601. * @returns the Parsed particle system
  86602. */
  86603. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  86604. }
  86605. }
  86606. declare module BABYLON {
  86607. /**
  86608. * A particle represents one of the element emitted by a particle system.
  86609. * This is mainly define by its coordinates, direction, velocity and age.
  86610. */
  86611. export class Particle {
  86612. /**
  86613. * The particle system the particle belongs to.
  86614. */
  86615. particleSystem: ParticleSystem;
  86616. private static _Count;
  86617. /**
  86618. * Unique ID of the particle
  86619. */
  86620. id: number;
  86621. /**
  86622. * The world position of the particle in the scene.
  86623. */
  86624. position: Vector3;
  86625. /**
  86626. * The world direction of the particle in the scene.
  86627. */
  86628. direction: Vector3;
  86629. /**
  86630. * The color of the particle.
  86631. */
  86632. color: Color4;
  86633. /**
  86634. * The color change of the particle per step.
  86635. */
  86636. colorStep: Color4;
  86637. /**
  86638. * Defines how long will the life of the particle be.
  86639. */
  86640. lifeTime: number;
  86641. /**
  86642. * The current age of the particle.
  86643. */
  86644. age: number;
  86645. /**
  86646. * The current size of the particle.
  86647. */
  86648. size: number;
  86649. /**
  86650. * The current scale of the particle.
  86651. */
  86652. scale: Vector2;
  86653. /**
  86654. * The current angle of the particle.
  86655. */
  86656. angle: number;
  86657. /**
  86658. * Defines how fast is the angle changing.
  86659. */
  86660. angularSpeed: number;
  86661. /**
  86662. * Defines the cell index used by the particle to be rendered from a sprite.
  86663. */
  86664. cellIndex: number;
  86665. /**
  86666. * The information required to support color remapping
  86667. */
  86668. remapData: Vector4;
  86669. /** @hidden */
  86670. _randomCellOffset?: number;
  86671. /** @hidden */
  86672. _initialDirection: Nullable<Vector3>;
  86673. /** @hidden */
  86674. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  86675. /** @hidden */
  86676. _initialStartSpriteCellID: number;
  86677. /** @hidden */
  86678. _initialEndSpriteCellID: number;
  86679. /** @hidden */
  86680. _currentColorGradient: Nullable<ColorGradient>;
  86681. /** @hidden */
  86682. _currentColor1: Color4;
  86683. /** @hidden */
  86684. _currentColor2: Color4;
  86685. /** @hidden */
  86686. _currentSizeGradient: Nullable<FactorGradient>;
  86687. /** @hidden */
  86688. _currentSize1: number;
  86689. /** @hidden */
  86690. _currentSize2: number;
  86691. /** @hidden */
  86692. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  86693. /** @hidden */
  86694. _currentAngularSpeed1: number;
  86695. /** @hidden */
  86696. _currentAngularSpeed2: number;
  86697. /** @hidden */
  86698. _currentVelocityGradient: Nullable<FactorGradient>;
  86699. /** @hidden */
  86700. _currentVelocity1: number;
  86701. /** @hidden */
  86702. _currentVelocity2: number;
  86703. /** @hidden */
  86704. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  86705. /** @hidden */
  86706. _currentLimitVelocity1: number;
  86707. /** @hidden */
  86708. _currentLimitVelocity2: number;
  86709. /** @hidden */
  86710. _currentDragGradient: Nullable<FactorGradient>;
  86711. /** @hidden */
  86712. _currentDrag1: number;
  86713. /** @hidden */
  86714. _currentDrag2: number;
  86715. /** @hidden */
  86716. _randomNoiseCoordinates1: Vector3;
  86717. /** @hidden */
  86718. _randomNoiseCoordinates2: Vector3;
  86719. /** @hidden */
  86720. _localPosition?: Vector3;
  86721. /**
  86722. * Creates a new instance Particle
  86723. * @param particleSystem the particle system the particle belongs to
  86724. */
  86725. constructor(
  86726. /**
  86727. * The particle system the particle belongs to.
  86728. */
  86729. particleSystem: ParticleSystem);
  86730. private updateCellInfoFromSystem;
  86731. /**
  86732. * Defines how the sprite cell index is updated for the particle
  86733. */
  86734. updateCellIndex(): void;
  86735. /** @hidden */
  86736. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  86737. /** @hidden */
  86738. _inheritParticleInfoToSubEmitters(): void;
  86739. /** @hidden */
  86740. _reset(): void;
  86741. /**
  86742. * Copy the properties of particle to another one.
  86743. * @param other the particle to copy the information to.
  86744. */
  86745. copyTo(other: Particle): void;
  86746. }
  86747. }
  86748. declare module BABYLON {
  86749. /**
  86750. * Particle emitter represents a volume emitting particles.
  86751. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  86752. */
  86753. export interface IParticleEmitterType {
  86754. /**
  86755. * Called by the particle System when the direction is computed for the created particle.
  86756. * @param worldMatrix is the world matrix of the particle system
  86757. * @param directionToUpdate is the direction vector to update with the result
  86758. * @param particle is the particle we are computed the direction for
  86759. * @param isLocal defines if the direction should be set in local space
  86760. */
  86761. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86762. /**
  86763. * Called by the particle System when the position is computed for the created particle.
  86764. * @param worldMatrix is the world matrix of the particle system
  86765. * @param positionToUpdate is the position vector to update with the result
  86766. * @param particle is the particle we are computed the position for
  86767. * @param isLocal defines if the position should be set in local space
  86768. */
  86769. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86770. /**
  86771. * Clones the current emitter and returns a copy of it
  86772. * @returns the new emitter
  86773. */
  86774. clone(): IParticleEmitterType;
  86775. /**
  86776. * Called by the GPUParticleSystem to setup the update shader
  86777. * @param effect defines the update shader
  86778. */
  86779. applyToShader(effect: Effect): void;
  86780. /**
  86781. * Returns a string to use to update the GPU particles update shader
  86782. * @returns the effect defines string
  86783. */
  86784. getEffectDefines(): string;
  86785. /**
  86786. * Returns a string representing the class name
  86787. * @returns a string containing the class name
  86788. */
  86789. getClassName(): string;
  86790. /**
  86791. * Serializes the particle system to a JSON object.
  86792. * @returns the JSON object
  86793. */
  86794. serialize(): any;
  86795. /**
  86796. * Parse properties from a JSON object
  86797. * @param serializationObject defines the JSON object
  86798. * @param scene defines the hosting scene
  86799. */
  86800. parse(serializationObject: any, scene: Scene): void;
  86801. }
  86802. }
  86803. declare module BABYLON {
  86804. /**
  86805. * Particle emitter emitting particles from the inside of a box.
  86806. * It emits the particles randomly between 2 given directions.
  86807. */
  86808. export class BoxParticleEmitter implements IParticleEmitterType {
  86809. /**
  86810. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86811. */
  86812. direction1: Vector3;
  86813. /**
  86814. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86815. */
  86816. direction2: Vector3;
  86817. /**
  86818. * 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.
  86819. */
  86820. minEmitBox: Vector3;
  86821. /**
  86822. * 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.
  86823. */
  86824. maxEmitBox: Vector3;
  86825. /**
  86826. * Creates a new instance BoxParticleEmitter
  86827. */
  86828. constructor();
  86829. /**
  86830. * Called by the particle System when the direction is computed for the created particle.
  86831. * @param worldMatrix is the world matrix of the particle system
  86832. * @param directionToUpdate is the direction vector to update with the result
  86833. * @param particle is the particle we are computed the direction for
  86834. * @param isLocal defines if the direction should be set in local space
  86835. */
  86836. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86837. /**
  86838. * Called by the particle System when the position is computed for the created particle.
  86839. * @param worldMatrix is the world matrix of the particle system
  86840. * @param positionToUpdate is the position vector to update with the result
  86841. * @param particle is the particle we are computed the position for
  86842. * @param isLocal defines if the position should be set in local space
  86843. */
  86844. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86845. /**
  86846. * Clones the current emitter and returns a copy of it
  86847. * @returns the new emitter
  86848. */
  86849. clone(): BoxParticleEmitter;
  86850. /**
  86851. * Called by the GPUParticleSystem to setup the update shader
  86852. * @param effect defines the update shader
  86853. */
  86854. applyToShader(effect: Effect): void;
  86855. /**
  86856. * Returns a string to use to update the GPU particles update shader
  86857. * @returns a string containng the defines string
  86858. */
  86859. getEffectDefines(): string;
  86860. /**
  86861. * Returns the string "BoxParticleEmitter"
  86862. * @returns a string containing the class name
  86863. */
  86864. getClassName(): string;
  86865. /**
  86866. * Serializes the particle system to a JSON object.
  86867. * @returns the JSON object
  86868. */
  86869. serialize(): any;
  86870. /**
  86871. * Parse properties from a JSON object
  86872. * @param serializationObject defines the JSON object
  86873. */
  86874. parse(serializationObject: any): void;
  86875. }
  86876. }
  86877. declare module BABYLON {
  86878. /**
  86879. * Particle emitter emitting particles from the inside of a cone.
  86880. * It emits the particles alongside the cone volume from the base to the particle.
  86881. * The emission direction might be randomized.
  86882. */
  86883. export class ConeParticleEmitter implements IParticleEmitterType {
  86884. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86885. directionRandomizer: number;
  86886. private _radius;
  86887. private _angle;
  86888. private _height;
  86889. /**
  86890. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  86891. */
  86892. radiusRange: number;
  86893. /**
  86894. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  86895. */
  86896. heightRange: number;
  86897. /**
  86898. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  86899. */
  86900. emitFromSpawnPointOnly: boolean;
  86901. /**
  86902. * Gets or sets the radius of the emission cone
  86903. */
  86904. get radius(): number;
  86905. set radius(value: number);
  86906. /**
  86907. * Gets or sets the angle of the emission cone
  86908. */
  86909. get angle(): number;
  86910. set angle(value: number);
  86911. private _buildHeight;
  86912. /**
  86913. * Creates a new instance ConeParticleEmitter
  86914. * @param radius the radius of the emission cone (1 by default)
  86915. * @param angle the cone base angle (PI by default)
  86916. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  86917. */
  86918. constructor(radius?: number, angle?: number,
  86919. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86920. directionRandomizer?: number);
  86921. /**
  86922. * Called by the particle System when the direction is computed for the created particle.
  86923. * @param worldMatrix is the world matrix of the particle system
  86924. * @param directionToUpdate is the direction vector to update with the result
  86925. * @param particle is the particle we are computed the direction for
  86926. * @param isLocal defines if the direction should be set in local space
  86927. */
  86928. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86929. /**
  86930. * Called by the particle System when the position is computed for the created particle.
  86931. * @param worldMatrix is the world matrix of the particle system
  86932. * @param positionToUpdate is the position vector to update with the result
  86933. * @param particle is the particle we are computed the position for
  86934. * @param isLocal defines if the position should be set in local space
  86935. */
  86936. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86937. /**
  86938. * Clones the current emitter and returns a copy of it
  86939. * @returns the new emitter
  86940. */
  86941. clone(): ConeParticleEmitter;
  86942. /**
  86943. * Called by the GPUParticleSystem to setup the update shader
  86944. * @param effect defines the update shader
  86945. */
  86946. applyToShader(effect: Effect): void;
  86947. /**
  86948. * Returns a string to use to update the GPU particles update shader
  86949. * @returns a string containng the defines string
  86950. */
  86951. getEffectDefines(): string;
  86952. /**
  86953. * Returns the string "ConeParticleEmitter"
  86954. * @returns a string containing the class name
  86955. */
  86956. getClassName(): string;
  86957. /**
  86958. * Serializes the particle system to a JSON object.
  86959. * @returns the JSON object
  86960. */
  86961. serialize(): any;
  86962. /**
  86963. * Parse properties from a JSON object
  86964. * @param serializationObject defines the JSON object
  86965. */
  86966. parse(serializationObject: any): void;
  86967. }
  86968. }
  86969. declare module BABYLON {
  86970. /**
  86971. * Particle emitter emitting particles from the inside of a cylinder.
  86972. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  86973. */
  86974. export class CylinderParticleEmitter implements IParticleEmitterType {
  86975. /**
  86976. * The radius of the emission cylinder.
  86977. */
  86978. radius: number;
  86979. /**
  86980. * The height of the emission cylinder.
  86981. */
  86982. height: number;
  86983. /**
  86984. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86985. */
  86986. radiusRange: number;
  86987. /**
  86988. * How much to randomize the particle direction [0-1].
  86989. */
  86990. directionRandomizer: number;
  86991. /**
  86992. * Creates a new instance CylinderParticleEmitter
  86993. * @param radius the radius of the emission cylinder (1 by default)
  86994. * @param height the height of the emission cylinder (1 by default)
  86995. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86996. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86997. */
  86998. constructor(
  86999. /**
  87000. * The radius of the emission cylinder.
  87001. */
  87002. radius?: number,
  87003. /**
  87004. * The height of the emission cylinder.
  87005. */
  87006. height?: number,
  87007. /**
  87008. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87009. */
  87010. radiusRange?: number,
  87011. /**
  87012. * How much to randomize the particle direction [0-1].
  87013. */
  87014. directionRandomizer?: number);
  87015. /**
  87016. * Called by the particle System when the direction is computed for the created particle.
  87017. * @param worldMatrix is the world matrix of the particle system
  87018. * @param directionToUpdate is the direction vector to update with the result
  87019. * @param particle is the particle we are computed the direction for
  87020. * @param isLocal defines if the direction should be set in local space
  87021. */
  87022. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87023. /**
  87024. * Called by the particle System when the position is computed for the created particle.
  87025. * @param worldMatrix is the world matrix of the particle system
  87026. * @param positionToUpdate is the position vector to update with the result
  87027. * @param particle is the particle we are computed the position for
  87028. * @param isLocal defines if the position should be set in local space
  87029. */
  87030. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87031. /**
  87032. * Clones the current emitter and returns a copy of it
  87033. * @returns the new emitter
  87034. */
  87035. clone(): CylinderParticleEmitter;
  87036. /**
  87037. * Called by the GPUParticleSystem to setup the update shader
  87038. * @param effect defines the update shader
  87039. */
  87040. applyToShader(effect: Effect): void;
  87041. /**
  87042. * Returns a string to use to update the GPU particles update shader
  87043. * @returns a string containng the defines string
  87044. */
  87045. getEffectDefines(): string;
  87046. /**
  87047. * Returns the string "CylinderParticleEmitter"
  87048. * @returns a string containing the class name
  87049. */
  87050. getClassName(): string;
  87051. /**
  87052. * Serializes the particle system to a JSON object.
  87053. * @returns the JSON object
  87054. */
  87055. serialize(): any;
  87056. /**
  87057. * Parse properties from a JSON object
  87058. * @param serializationObject defines the JSON object
  87059. */
  87060. parse(serializationObject: any): void;
  87061. }
  87062. /**
  87063. * Particle emitter emitting particles from the inside of a cylinder.
  87064. * It emits the particles randomly between two vectors.
  87065. */
  87066. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  87067. /**
  87068. * The min limit of the emission direction.
  87069. */
  87070. direction1: Vector3;
  87071. /**
  87072. * The max limit of the emission direction.
  87073. */
  87074. direction2: Vector3;
  87075. /**
  87076. * Creates a new instance CylinderDirectedParticleEmitter
  87077. * @param radius the radius of the emission cylinder (1 by default)
  87078. * @param height the height of the emission cylinder (1 by default)
  87079. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87080. * @param direction1 the min limit of the emission direction (up vector by default)
  87081. * @param direction2 the max limit of the emission direction (up vector by default)
  87082. */
  87083. constructor(radius?: number, height?: number, radiusRange?: number,
  87084. /**
  87085. * The min limit of the emission direction.
  87086. */
  87087. direction1?: Vector3,
  87088. /**
  87089. * The max limit of the emission direction.
  87090. */
  87091. direction2?: Vector3);
  87092. /**
  87093. * Called by the particle System when the direction is computed for the created particle.
  87094. * @param worldMatrix is the world matrix of the particle system
  87095. * @param directionToUpdate is the direction vector to update with the result
  87096. * @param particle is the particle we are computed the direction for
  87097. */
  87098. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87099. /**
  87100. * Clones the current emitter and returns a copy of it
  87101. * @returns the new emitter
  87102. */
  87103. clone(): CylinderDirectedParticleEmitter;
  87104. /**
  87105. * Called by the GPUParticleSystem to setup the update shader
  87106. * @param effect defines the update shader
  87107. */
  87108. applyToShader(effect: Effect): void;
  87109. /**
  87110. * Returns a string to use to update the GPU particles update shader
  87111. * @returns a string containng the defines string
  87112. */
  87113. getEffectDefines(): string;
  87114. /**
  87115. * Returns the string "CylinderDirectedParticleEmitter"
  87116. * @returns a string containing the class name
  87117. */
  87118. getClassName(): string;
  87119. /**
  87120. * Serializes the particle system to a JSON object.
  87121. * @returns the JSON object
  87122. */
  87123. serialize(): any;
  87124. /**
  87125. * Parse properties from a JSON object
  87126. * @param serializationObject defines the JSON object
  87127. */
  87128. parse(serializationObject: any): void;
  87129. }
  87130. }
  87131. declare module BABYLON {
  87132. /**
  87133. * Particle emitter emitting particles from the inside of a hemisphere.
  87134. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  87135. */
  87136. export class HemisphericParticleEmitter implements IParticleEmitterType {
  87137. /**
  87138. * The radius of the emission hemisphere.
  87139. */
  87140. radius: number;
  87141. /**
  87142. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87143. */
  87144. radiusRange: number;
  87145. /**
  87146. * How much to randomize the particle direction [0-1].
  87147. */
  87148. directionRandomizer: number;
  87149. /**
  87150. * Creates a new instance HemisphericParticleEmitter
  87151. * @param radius the radius of the emission hemisphere (1 by default)
  87152. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87153. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  87154. */
  87155. constructor(
  87156. /**
  87157. * The radius of the emission hemisphere.
  87158. */
  87159. radius?: number,
  87160. /**
  87161. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87162. */
  87163. radiusRange?: number,
  87164. /**
  87165. * How much to randomize the particle direction [0-1].
  87166. */
  87167. directionRandomizer?: number);
  87168. /**
  87169. * Called by the particle System when the direction is computed for the created particle.
  87170. * @param worldMatrix is the world matrix of the particle system
  87171. * @param directionToUpdate is the direction vector to update with the result
  87172. * @param particle is the particle we are computed the direction for
  87173. * @param isLocal defines if the direction should be set in local space
  87174. */
  87175. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87176. /**
  87177. * Called by the particle System when the position is computed for the created particle.
  87178. * @param worldMatrix is the world matrix of the particle system
  87179. * @param positionToUpdate is the position vector to update with the result
  87180. * @param particle is the particle we are computed the position for
  87181. * @param isLocal defines if the position should be set in local space
  87182. */
  87183. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87184. /**
  87185. * Clones the current emitter and returns a copy of it
  87186. * @returns the new emitter
  87187. */
  87188. clone(): HemisphericParticleEmitter;
  87189. /**
  87190. * Called by the GPUParticleSystem to setup the update shader
  87191. * @param effect defines the update shader
  87192. */
  87193. applyToShader(effect: Effect): void;
  87194. /**
  87195. * Returns a string to use to update the GPU particles update shader
  87196. * @returns a string containng the defines string
  87197. */
  87198. getEffectDefines(): string;
  87199. /**
  87200. * Returns the string "HemisphericParticleEmitter"
  87201. * @returns a string containing the class name
  87202. */
  87203. getClassName(): string;
  87204. /**
  87205. * Serializes the particle system to a JSON object.
  87206. * @returns the JSON object
  87207. */
  87208. serialize(): any;
  87209. /**
  87210. * Parse properties from a JSON object
  87211. * @param serializationObject defines the JSON object
  87212. */
  87213. parse(serializationObject: any): void;
  87214. }
  87215. }
  87216. declare module BABYLON {
  87217. /**
  87218. * Particle emitter emitting particles from a point.
  87219. * It emits the particles randomly between 2 given directions.
  87220. */
  87221. export class PointParticleEmitter implements IParticleEmitterType {
  87222. /**
  87223. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87224. */
  87225. direction1: Vector3;
  87226. /**
  87227. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87228. */
  87229. direction2: Vector3;
  87230. /**
  87231. * Creates a new instance PointParticleEmitter
  87232. */
  87233. constructor();
  87234. /**
  87235. * Called by the particle System when the direction is computed for the created particle.
  87236. * @param worldMatrix is the world matrix of the particle system
  87237. * @param directionToUpdate is the direction vector to update with the result
  87238. * @param particle is the particle we are computed the direction for
  87239. * @param isLocal defines if the direction should be set in local space
  87240. */
  87241. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87242. /**
  87243. * Called by the particle System when the position is computed for the created particle.
  87244. * @param worldMatrix is the world matrix of the particle system
  87245. * @param positionToUpdate is the position vector to update with the result
  87246. * @param particle is the particle we are computed the position for
  87247. * @param isLocal defines if the position should be set in local space
  87248. */
  87249. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87250. /**
  87251. * Clones the current emitter and returns a copy of it
  87252. * @returns the new emitter
  87253. */
  87254. clone(): PointParticleEmitter;
  87255. /**
  87256. * Called by the GPUParticleSystem to setup the update shader
  87257. * @param effect defines the update shader
  87258. */
  87259. applyToShader(effect: Effect): void;
  87260. /**
  87261. * Returns a string to use to update the GPU particles update shader
  87262. * @returns a string containng the defines string
  87263. */
  87264. getEffectDefines(): string;
  87265. /**
  87266. * Returns the string "PointParticleEmitter"
  87267. * @returns a string containing the class name
  87268. */
  87269. getClassName(): string;
  87270. /**
  87271. * Serializes the particle system to a JSON object.
  87272. * @returns the JSON object
  87273. */
  87274. serialize(): any;
  87275. /**
  87276. * Parse properties from a JSON object
  87277. * @param serializationObject defines the JSON object
  87278. */
  87279. parse(serializationObject: any): void;
  87280. }
  87281. }
  87282. declare module BABYLON {
  87283. /**
  87284. * Particle emitter emitting particles from the inside of a sphere.
  87285. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  87286. */
  87287. export class SphereParticleEmitter implements IParticleEmitterType {
  87288. /**
  87289. * The radius of the emission sphere.
  87290. */
  87291. radius: number;
  87292. /**
  87293. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87294. */
  87295. radiusRange: number;
  87296. /**
  87297. * How much to randomize the particle direction [0-1].
  87298. */
  87299. directionRandomizer: number;
  87300. /**
  87301. * Creates a new instance SphereParticleEmitter
  87302. * @param radius the radius of the emission sphere (1 by default)
  87303. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87304. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  87305. */
  87306. constructor(
  87307. /**
  87308. * The radius of the emission sphere.
  87309. */
  87310. radius?: number,
  87311. /**
  87312. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87313. */
  87314. radiusRange?: number,
  87315. /**
  87316. * How much to randomize the particle direction [0-1].
  87317. */
  87318. directionRandomizer?: number);
  87319. /**
  87320. * Called by the particle System when the direction is computed for the created particle.
  87321. * @param worldMatrix is the world matrix of the particle system
  87322. * @param directionToUpdate is the direction vector to update with the result
  87323. * @param particle is the particle we are computed the direction for
  87324. * @param isLocal defines if the direction should be set in local space
  87325. */
  87326. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87327. /**
  87328. * Called by the particle System when the position is computed for the created particle.
  87329. * @param worldMatrix is the world matrix of the particle system
  87330. * @param positionToUpdate is the position vector to update with the result
  87331. * @param particle is the particle we are computed the position for
  87332. * @param isLocal defines if the position should be set in local space
  87333. */
  87334. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87335. /**
  87336. * Clones the current emitter and returns a copy of it
  87337. * @returns the new emitter
  87338. */
  87339. clone(): SphereParticleEmitter;
  87340. /**
  87341. * Called by the GPUParticleSystem to setup the update shader
  87342. * @param effect defines the update shader
  87343. */
  87344. applyToShader(effect: Effect): void;
  87345. /**
  87346. * Returns a string to use to update the GPU particles update shader
  87347. * @returns a string containng the defines string
  87348. */
  87349. getEffectDefines(): string;
  87350. /**
  87351. * Returns the string "SphereParticleEmitter"
  87352. * @returns a string containing the class name
  87353. */
  87354. getClassName(): string;
  87355. /**
  87356. * Serializes the particle system to a JSON object.
  87357. * @returns the JSON object
  87358. */
  87359. serialize(): any;
  87360. /**
  87361. * Parse properties from a JSON object
  87362. * @param serializationObject defines the JSON object
  87363. */
  87364. parse(serializationObject: any): void;
  87365. }
  87366. /**
  87367. * Particle emitter emitting particles from the inside of a sphere.
  87368. * It emits the particles randomly between two vectors.
  87369. */
  87370. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  87371. /**
  87372. * The min limit of the emission direction.
  87373. */
  87374. direction1: Vector3;
  87375. /**
  87376. * The max limit of the emission direction.
  87377. */
  87378. direction2: Vector3;
  87379. /**
  87380. * Creates a new instance SphereDirectedParticleEmitter
  87381. * @param radius the radius of the emission sphere (1 by default)
  87382. * @param direction1 the min limit of the emission direction (up vector by default)
  87383. * @param direction2 the max limit of the emission direction (up vector by default)
  87384. */
  87385. constructor(radius?: number,
  87386. /**
  87387. * The min limit of the emission direction.
  87388. */
  87389. direction1?: Vector3,
  87390. /**
  87391. * The max limit of the emission direction.
  87392. */
  87393. direction2?: Vector3);
  87394. /**
  87395. * Called by the particle System when the direction is computed for the created particle.
  87396. * @param worldMatrix is the world matrix of the particle system
  87397. * @param directionToUpdate is the direction vector to update with the result
  87398. * @param particle is the particle we are computed the direction for
  87399. */
  87400. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87401. /**
  87402. * Clones the current emitter and returns a copy of it
  87403. * @returns the new emitter
  87404. */
  87405. clone(): SphereDirectedParticleEmitter;
  87406. /**
  87407. * Called by the GPUParticleSystem to setup the update shader
  87408. * @param effect defines the update shader
  87409. */
  87410. applyToShader(effect: Effect): void;
  87411. /**
  87412. * Returns a string to use to update the GPU particles update shader
  87413. * @returns a string containng the defines string
  87414. */
  87415. getEffectDefines(): string;
  87416. /**
  87417. * Returns the string "SphereDirectedParticleEmitter"
  87418. * @returns a string containing the class name
  87419. */
  87420. getClassName(): string;
  87421. /**
  87422. * Serializes the particle system to a JSON object.
  87423. * @returns the JSON object
  87424. */
  87425. serialize(): any;
  87426. /**
  87427. * Parse properties from a JSON object
  87428. * @param serializationObject defines the JSON object
  87429. */
  87430. parse(serializationObject: any): void;
  87431. }
  87432. }
  87433. declare module BABYLON {
  87434. /**
  87435. * Particle emitter emitting particles from a custom list of positions.
  87436. */
  87437. export class CustomParticleEmitter implements IParticleEmitterType {
  87438. /**
  87439. * Gets or sets the position generator that will create the inital position of each particle.
  87440. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  87441. */
  87442. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  87443. /**
  87444. * Gets or sets the destination generator that will create the final destination of each particle.
  87445. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  87446. */
  87447. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  87448. /**
  87449. * Creates a new instance CustomParticleEmitter
  87450. */
  87451. constructor();
  87452. /**
  87453. * Called by the particle System when the direction is computed for the created particle.
  87454. * @param worldMatrix is the world matrix of the particle system
  87455. * @param directionToUpdate is the direction vector to update with the result
  87456. * @param particle is the particle we are computed the direction for
  87457. * @param isLocal defines if the direction should be set in local space
  87458. */
  87459. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87460. /**
  87461. * Called by the particle System when the position is computed for the created particle.
  87462. * @param worldMatrix is the world matrix of the particle system
  87463. * @param positionToUpdate is the position vector to update with the result
  87464. * @param particle is the particle we are computed the position for
  87465. * @param isLocal defines if the position should be set in local space
  87466. */
  87467. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87468. /**
  87469. * Clones the current emitter and returns a copy of it
  87470. * @returns the new emitter
  87471. */
  87472. clone(): CustomParticleEmitter;
  87473. /**
  87474. * Called by the GPUParticleSystem to setup the update shader
  87475. * @param effect defines the update shader
  87476. */
  87477. applyToShader(effect: Effect): void;
  87478. /**
  87479. * Returns a string to use to update the GPU particles update shader
  87480. * @returns a string containng the defines string
  87481. */
  87482. getEffectDefines(): string;
  87483. /**
  87484. * Returns the string "PointParticleEmitter"
  87485. * @returns a string containing the class name
  87486. */
  87487. getClassName(): string;
  87488. /**
  87489. * Serializes the particle system to a JSON object.
  87490. * @returns the JSON object
  87491. */
  87492. serialize(): any;
  87493. /**
  87494. * Parse properties from a JSON object
  87495. * @param serializationObject defines the JSON object
  87496. */
  87497. parse(serializationObject: any): void;
  87498. }
  87499. }
  87500. declare module BABYLON {
  87501. /**
  87502. * Particle emitter emitting particles from the inside of a box.
  87503. * It emits the particles randomly between 2 given directions.
  87504. */
  87505. export class MeshParticleEmitter implements IParticleEmitterType {
  87506. private _indices;
  87507. private _positions;
  87508. private _normals;
  87509. private _storedNormal;
  87510. private _mesh;
  87511. /**
  87512. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87513. */
  87514. direction1: Vector3;
  87515. /**
  87516. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87517. */
  87518. direction2: Vector3;
  87519. /**
  87520. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  87521. */
  87522. useMeshNormalsForDirection: boolean;
  87523. /** Defines the mesh to use as source */
  87524. get mesh(): Nullable<AbstractMesh>;
  87525. set mesh(value: Nullable<AbstractMesh>);
  87526. /**
  87527. * Creates a new instance MeshParticleEmitter
  87528. * @param mesh defines the mesh to use as source
  87529. */
  87530. constructor(mesh?: Nullable<AbstractMesh>);
  87531. /**
  87532. * Called by the particle System when the direction is computed for the created particle.
  87533. * @param worldMatrix is the world matrix of the particle system
  87534. * @param directionToUpdate is the direction vector to update with the result
  87535. * @param particle is the particle we are computed the direction for
  87536. * @param isLocal defines if the direction should be set in local space
  87537. */
  87538. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87539. /**
  87540. * Called by the particle System when the position is computed for the created particle.
  87541. * @param worldMatrix is the world matrix of the particle system
  87542. * @param positionToUpdate is the position vector to update with the result
  87543. * @param particle is the particle we are computed the position for
  87544. * @param isLocal defines if the position should be set in local space
  87545. */
  87546. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87547. /**
  87548. * Clones the current emitter and returns a copy of it
  87549. * @returns the new emitter
  87550. */
  87551. clone(): MeshParticleEmitter;
  87552. /**
  87553. * Called by the GPUParticleSystem to setup the update shader
  87554. * @param effect defines the update shader
  87555. */
  87556. applyToShader(effect: Effect): void;
  87557. /**
  87558. * Returns a string to use to update the GPU particles update shader
  87559. * @returns a string containng the defines string
  87560. */
  87561. getEffectDefines(): string;
  87562. /**
  87563. * Returns the string "BoxParticleEmitter"
  87564. * @returns a string containing the class name
  87565. */
  87566. getClassName(): string;
  87567. /**
  87568. * Serializes the particle system to a JSON object.
  87569. * @returns the JSON object
  87570. */
  87571. serialize(): any;
  87572. /**
  87573. * Parse properties from a JSON object
  87574. * @param serializationObject defines the JSON object
  87575. * @param scene defines the hosting scene
  87576. */
  87577. parse(serializationObject: any, scene: Scene): void;
  87578. }
  87579. }
  87580. declare module BABYLON {
  87581. /**
  87582. * Interface representing a particle system in Babylon.js.
  87583. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  87584. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  87585. */
  87586. export interface IParticleSystem {
  87587. /**
  87588. * List of animations used by the particle system.
  87589. */
  87590. animations: Animation[];
  87591. /**
  87592. * The id of the Particle system.
  87593. */
  87594. id: string;
  87595. /**
  87596. * The name of the Particle system.
  87597. */
  87598. name: string;
  87599. /**
  87600. * The emitter represents the Mesh or position we are attaching the particle system to.
  87601. */
  87602. emitter: Nullable<AbstractMesh | Vector3>;
  87603. /**
  87604. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  87605. */
  87606. isBillboardBased: boolean;
  87607. /**
  87608. * The rendering group used by the Particle system to chose when to render.
  87609. */
  87610. renderingGroupId: number;
  87611. /**
  87612. * The layer mask we are rendering the particles through.
  87613. */
  87614. layerMask: number;
  87615. /**
  87616. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  87617. */
  87618. updateSpeed: number;
  87619. /**
  87620. * The amount of time the particle system is running (depends of the overall update speed).
  87621. */
  87622. targetStopDuration: number;
  87623. /**
  87624. * The texture used to render each particle. (this can be a spritesheet)
  87625. */
  87626. particleTexture: Nullable<Texture>;
  87627. /**
  87628. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  87629. */
  87630. blendMode: number;
  87631. /**
  87632. * Minimum life time of emitting particles.
  87633. */
  87634. minLifeTime: number;
  87635. /**
  87636. * Maximum life time of emitting particles.
  87637. */
  87638. maxLifeTime: number;
  87639. /**
  87640. * Minimum Size of emitting particles.
  87641. */
  87642. minSize: number;
  87643. /**
  87644. * Maximum Size of emitting particles.
  87645. */
  87646. maxSize: number;
  87647. /**
  87648. * Minimum scale of emitting particles on X axis.
  87649. */
  87650. minScaleX: number;
  87651. /**
  87652. * Maximum scale of emitting particles on X axis.
  87653. */
  87654. maxScaleX: number;
  87655. /**
  87656. * Minimum scale of emitting particles on Y axis.
  87657. */
  87658. minScaleY: number;
  87659. /**
  87660. * Maximum scale of emitting particles on Y axis.
  87661. */
  87662. maxScaleY: number;
  87663. /**
  87664. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87665. */
  87666. color1: Color4;
  87667. /**
  87668. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87669. */
  87670. color2: Color4;
  87671. /**
  87672. * Color the particle will have at the end of its lifetime.
  87673. */
  87674. colorDead: Color4;
  87675. /**
  87676. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  87677. */
  87678. emitRate: number;
  87679. /**
  87680. * You can use gravity if you want to give an orientation to your particles.
  87681. */
  87682. gravity: Vector3;
  87683. /**
  87684. * Minimum power of emitting particles.
  87685. */
  87686. minEmitPower: number;
  87687. /**
  87688. * Maximum power of emitting particles.
  87689. */
  87690. maxEmitPower: number;
  87691. /**
  87692. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  87693. */
  87694. minAngularSpeed: number;
  87695. /**
  87696. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  87697. */
  87698. maxAngularSpeed: number;
  87699. /**
  87700. * Gets or sets the minimal initial rotation in radians.
  87701. */
  87702. minInitialRotation: number;
  87703. /**
  87704. * Gets or sets the maximal initial rotation in radians.
  87705. */
  87706. maxInitialRotation: number;
  87707. /**
  87708. * The particle emitter type defines the emitter used by the particle system.
  87709. * It can be for example box, sphere, or cone...
  87710. */
  87711. particleEmitterType: Nullable<IParticleEmitterType>;
  87712. /**
  87713. * Defines the delay in milliseconds before starting the system (0 by default)
  87714. */
  87715. startDelay: number;
  87716. /**
  87717. * 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
  87718. */
  87719. preWarmCycles: number;
  87720. /**
  87721. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  87722. */
  87723. preWarmStepOffset: number;
  87724. /**
  87725. * 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)
  87726. */
  87727. spriteCellChangeSpeed: number;
  87728. /**
  87729. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  87730. */
  87731. startSpriteCellID: number;
  87732. /**
  87733. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  87734. */
  87735. endSpriteCellID: number;
  87736. /**
  87737. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  87738. */
  87739. spriteCellWidth: number;
  87740. /**
  87741. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  87742. */
  87743. spriteCellHeight: number;
  87744. /**
  87745. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  87746. */
  87747. spriteRandomStartCell: boolean;
  87748. /**
  87749. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  87750. */
  87751. isAnimationSheetEnabled: boolean;
  87752. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  87753. translationPivot: Vector2;
  87754. /**
  87755. * Gets or sets a texture used to add random noise to particle positions
  87756. */
  87757. noiseTexture: Nullable<BaseTexture>;
  87758. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  87759. noiseStrength: Vector3;
  87760. /**
  87761. * Gets or sets the billboard mode to use when isBillboardBased = true.
  87762. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  87763. */
  87764. billboardMode: number;
  87765. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  87766. limitVelocityDamping: number;
  87767. /**
  87768. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  87769. */
  87770. beginAnimationOnStart: boolean;
  87771. /**
  87772. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  87773. */
  87774. beginAnimationFrom: number;
  87775. /**
  87776. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  87777. */
  87778. beginAnimationTo: number;
  87779. /**
  87780. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  87781. */
  87782. beginAnimationLoop: boolean;
  87783. /**
  87784. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  87785. */
  87786. disposeOnStop: boolean;
  87787. /**
  87788. * Specifies if the particles are updated in emitter local space or world space
  87789. */
  87790. isLocal: boolean;
  87791. /** Snippet ID if the particle system was created from the snippet server */
  87792. snippetId: string;
  87793. /**
  87794. * Gets the maximum number of particles active at the same time.
  87795. * @returns The max number of active particles.
  87796. */
  87797. getCapacity(): number;
  87798. /**
  87799. * Gets the number of particles active at the same time.
  87800. * @returns The number of active particles.
  87801. */
  87802. getActiveCount(): number;
  87803. /**
  87804. * Gets if the system has been started. (Note: this will still be true after stop is called)
  87805. * @returns True if it has been started, otherwise false.
  87806. */
  87807. isStarted(): boolean;
  87808. /**
  87809. * Animates the particle system for this frame.
  87810. */
  87811. animate(): void;
  87812. /**
  87813. * Renders the particle system in its current state.
  87814. * @returns the current number of particles
  87815. */
  87816. render(): number;
  87817. /**
  87818. * Dispose the particle system and frees its associated resources.
  87819. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  87820. */
  87821. dispose(disposeTexture?: boolean): void;
  87822. /**
  87823. * Clones the particle system.
  87824. * @param name The name of the cloned object
  87825. * @param newEmitter The new emitter to use
  87826. * @returns the cloned particle system
  87827. */
  87828. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  87829. /**
  87830. * Serializes the particle system to a JSON object
  87831. * @param serializeTexture defines if the texture must be serialized as well
  87832. * @returns the JSON object
  87833. */
  87834. serialize(serializeTexture: boolean): any;
  87835. /**
  87836. * Rebuild the particle system
  87837. */
  87838. rebuild(): void;
  87839. /** Force the system to rebuild all gradients that need to be resync */
  87840. forceRefreshGradients(): void;
  87841. /**
  87842. * Starts the particle system and begins to emit
  87843. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  87844. */
  87845. start(delay?: number): void;
  87846. /**
  87847. * Stops the particle system.
  87848. */
  87849. stop(): void;
  87850. /**
  87851. * Remove all active particles
  87852. */
  87853. reset(): void;
  87854. /**
  87855. * Gets a boolean indicating that the system is stopping
  87856. * @returns true if the system is currently stopping
  87857. */
  87858. isStopping(): boolean;
  87859. /**
  87860. * Is this system ready to be used/rendered
  87861. * @return true if the system is ready
  87862. */
  87863. isReady(): boolean;
  87864. /**
  87865. * Returns the string "ParticleSystem"
  87866. * @returns a string containing the class name
  87867. */
  87868. getClassName(): string;
  87869. /**
  87870. * Adds a new color gradient
  87871. * @param gradient defines the gradient to use (between 0 and 1)
  87872. * @param color1 defines the color to affect to the specified gradient
  87873. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  87874. * @returns the current particle system
  87875. */
  87876. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  87877. /**
  87878. * Remove a specific color gradient
  87879. * @param gradient defines the gradient to remove
  87880. * @returns the current particle system
  87881. */
  87882. removeColorGradient(gradient: number): IParticleSystem;
  87883. /**
  87884. * Adds a new size gradient
  87885. * @param gradient defines the gradient to use (between 0 and 1)
  87886. * @param factor defines the size factor to affect to the specified gradient
  87887. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87888. * @returns the current particle system
  87889. */
  87890. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87891. /**
  87892. * Remove a specific size gradient
  87893. * @param gradient defines the gradient to remove
  87894. * @returns the current particle system
  87895. */
  87896. removeSizeGradient(gradient: number): IParticleSystem;
  87897. /**
  87898. * Gets the current list of color gradients.
  87899. * You must use addColorGradient and removeColorGradient to udpate this list
  87900. * @returns the list of color gradients
  87901. */
  87902. getColorGradients(): Nullable<Array<ColorGradient>>;
  87903. /**
  87904. * Gets the current list of size gradients.
  87905. * You must use addSizeGradient and removeSizeGradient to udpate this list
  87906. * @returns the list of size gradients
  87907. */
  87908. getSizeGradients(): Nullable<Array<FactorGradient>>;
  87909. /**
  87910. * Gets the current list of angular speed gradients.
  87911. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  87912. * @returns the list of angular speed gradients
  87913. */
  87914. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  87915. /**
  87916. * Adds a new angular speed gradient
  87917. * @param gradient defines the gradient to use (between 0 and 1)
  87918. * @param factor defines the angular speed to affect to the specified gradient
  87919. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87920. * @returns the current particle system
  87921. */
  87922. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87923. /**
  87924. * Remove a specific angular speed gradient
  87925. * @param gradient defines the gradient to remove
  87926. * @returns the current particle system
  87927. */
  87928. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  87929. /**
  87930. * Gets the current list of velocity gradients.
  87931. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  87932. * @returns the list of velocity gradients
  87933. */
  87934. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  87935. /**
  87936. * Adds a new velocity gradient
  87937. * @param gradient defines the gradient to use (between 0 and 1)
  87938. * @param factor defines the velocity to affect to the specified gradient
  87939. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87940. * @returns the current particle system
  87941. */
  87942. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87943. /**
  87944. * Remove a specific velocity gradient
  87945. * @param gradient defines the gradient to remove
  87946. * @returns the current particle system
  87947. */
  87948. removeVelocityGradient(gradient: number): IParticleSystem;
  87949. /**
  87950. * Gets the current list of limit velocity gradients.
  87951. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  87952. * @returns the list of limit velocity gradients
  87953. */
  87954. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  87955. /**
  87956. * Adds a new limit velocity gradient
  87957. * @param gradient defines the gradient to use (between 0 and 1)
  87958. * @param factor defines the limit velocity to affect to the specified gradient
  87959. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87960. * @returns the current particle system
  87961. */
  87962. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87963. /**
  87964. * Remove a specific limit velocity gradient
  87965. * @param gradient defines the gradient to remove
  87966. * @returns the current particle system
  87967. */
  87968. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  87969. /**
  87970. * Adds a new drag gradient
  87971. * @param gradient defines the gradient to use (between 0 and 1)
  87972. * @param factor defines the drag to affect to the specified gradient
  87973. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87974. * @returns the current particle system
  87975. */
  87976. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87977. /**
  87978. * Remove a specific drag gradient
  87979. * @param gradient defines the gradient to remove
  87980. * @returns the current particle system
  87981. */
  87982. removeDragGradient(gradient: number): IParticleSystem;
  87983. /**
  87984. * Gets the current list of drag gradients.
  87985. * You must use addDragGradient and removeDragGradient to udpate this list
  87986. * @returns the list of drag gradients
  87987. */
  87988. getDragGradients(): Nullable<Array<FactorGradient>>;
  87989. /**
  87990. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  87991. * @param gradient defines the gradient to use (between 0 and 1)
  87992. * @param factor defines the emit rate to affect to the specified gradient
  87993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87994. * @returns the current particle system
  87995. */
  87996. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87997. /**
  87998. * Remove a specific emit rate gradient
  87999. * @param gradient defines the gradient to remove
  88000. * @returns the current particle system
  88001. */
  88002. removeEmitRateGradient(gradient: number): IParticleSystem;
  88003. /**
  88004. * Gets the current list of emit rate gradients.
  88005. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  88006. * @returns the list of emit rate gradients
  88007. */
  88008. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  88009. /**
  88010. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  88011. * @param gradient defines the gradient to use (between 0 and 1)
  88012. * @param factor defines the start size to affect to the specified gradient
  88013. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88014. * @returns the current particle system
  88015. */
  88016. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88017. /**
  88018. * Remove a specific start size gradient
  88019. * @param gradient defines the gradient to remove
  88020. * @returns the current particle system
  88021. */
  88022. removeStartSizeGradient(gradient: number): IParticleSystem;
  88023. /**
  88024. * Gets the current list of start size gradients.
  88025. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  88026. * @returns the list of start size gradients
  88027. */
  88028. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  88029. /**
  88030. * Adds a new life time gradient
  88031. * @param gradient defines the gradient to use (between 0 and 1)
  88032. * @param factor defines the life time factor to affect to the specified gradient
  88033. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88034. * @returns the current particle system
  88035. */
  88036. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88037. /**
  88038. * Remove a specific life time gradient
  88039. * @param gradient defines the gradient to remove
  88040. * @returns the current particle system
  88041. */
  88042. removeLifeTimeGradient(gradient: number): IParticleSystem;
  88043. /**
  88044. * Gets the current list of life time gradients.
  88045. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  88046. * @returns the list of life time gradients
  88047. */
  88048. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  88049. /**
  88050. * Gets the current list of color gradients.
  88051. * You must use addColorGradient and removeColorGradient to udpate this list
  88052. * @returns the list of color gradients
  88053. */
  88054. getColorGradients(): Nullable<Array<ColorGradient>>;
  88055. /**
  88056. * Adds a new ramp gradient used to remap particle colors
  88057. * @param gradient defines the gradient to use (between 0 and 1)
  88058. * @param color defines the color to affect to the specified gradient
  88059. * @returns the current particle system
  88060. */
  88061. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  88062. /**
  88063. * Gets the current list of ramp gradients.
  88064. * You must use addRampGradient and removeRampGradient to udpate this list
  88065. * @returns the list of ramp gradients
  88066. */
  88067. getRampGradients(): Nullable<Array<Color3Gradient>>;
  88068. /** Gets or sets a boolean indicating that ramp gradients must be used
  88069. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  88070. */
  88071. useRampGradients: boolean;
  88072. /**
  88073. * Adds a new color remap gradient
  88074. * @param gradient defines the gradient to use (between 0 and 1)
  88075. * @param min defines the color remap minimal range
  88076. * @param max defines the color remap maximal range
  88077. * @returns the current particle system
  88078. */
  88079. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  88080. /**
  88081. * Gets the current list of color remap gradients.
  88082. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  88083. * @returns the list of color remap gradients
  88084. */
  88085. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  88086. /**
  88087. * Adds a new alpha remap gradient
  88088. * @param gradient defines the gradient to use (between 0 and 1)
  88089. * @param min defines the alpha remap minimal range
  88090. * @param max defines the alpha remap maximal range
  88091. * @returns the current particle system
  88092. */
  88093. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  88094. /**
  88095. * Gets the current list of alpha remap gradients.
  88096. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  88097. * @returns the list of alpha remap gradients
  88098. */
  88099. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  88100. /**
  88101. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  88102. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  88103. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  88104. * @returns the emitter
  88105. */
  88106. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  88107. /**
  88108. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  88109. * @param radius The radius of the hemisphere to emit from
  88110. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  88111. * @returns the emitter
  88112. */
  88113. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  88114. /**
  88115. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  88116. * @param radius The radius of the sphere to emit from
  88117. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  88118. * @returns the emitter
  88119. */
  88120. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  88121. /**
  88122. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  88123. * @param radius The radius of the sphere to emit from
  88124. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  88125. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  88126. * @returns the emitter
  88127. */
  88128. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  88129. /**
  88130. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  88131. * @param radius The radius of the emission cylinder
  88132. * @param height The height of the emission cylinder
  88133. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  88134. * @param directionRandomizer How much to randomize the particle direction [0-1]
  88135. * @returns the emitter
  88136. */
  88137. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  88138. /**
  88139. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  88140. * @param radius The radius of the cylinder to emit from
  88141. * @param height The height of the emission cylinder
  88142. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88143. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  88144. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  88145. * @returns the emitter
  88146. */
  88147. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  88148. /**
  88149. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  88150. * @param radius The radius of the cone to emit from
  88151. * @param angle The base angle of the cone
  88152. * @returns the emitter
  88153. */
  88154. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  88155. /**
  88156. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  88157. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  88158. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  88159. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  88160. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  88161. * @returns the emitter
  88162. */
  88163. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  88164. /**
  88165. * Get hosting scene
  88166. * @returns the scene
  88167. */
  88168. getScene(): Scene;
  88169. }
  88170. }
  88171. declare module BABYLON {
  88172. /**
  88173. * 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.
  88174. * @see https://doc.babylonjs.com/how_to/transformnode
  88175. */
  88176. export class TransformNode extends Node {
  88177. /**
  88178. * Object will not rotate to face the camera
  88179. */
  88180. static BILLBOARDMODE_NONE: number;
  88181. /**
  88182. * Object will rotate to face the camera but only on the x axis
  88183. */
  88184. static BILLBOARDMODE_X: number;
  88185. /**
  88186. * Object will rotate to face the camera but only on the y axis
  88187. */
  88188. static BILLBOARDMODE_Y: number;
  88189. /**
  88190. * Object will rotate to face the camera but only on the z axis
  88191. */
  88192. static BILLBOARDMODE_Z: number;
  88193. /**
  88194. * Object will rotate to face the camera
  88195. */
  88196. static BILLBOARDMODE_ALL: number;
  88197. /**
  88198. * Object will rotate to face the camera's position instead of orientation
  88199. */
  88200. static BILLBOARDMODE_USE_POSITION: number;
  88201. private _forward;
  88202. private _forwardInverted;
  88203. private _up;
  88204. private _right;
  88205. private _rightInverted;
  88206. private _position;
  88207. private _rotation;
  88208. private _rotationQuaternion;
  88209. protected _scaling: Vector3;
  88210. protected _isDirty: boolean;
  88211. private _transformToBoneReferal;
  88212. private _isAbsoluteSynced;
  88213. private _billboardMode;
  88214. /**
  88215. * Gets or sets the billboard mode. Default is 0.
  88216. *
  88217. * | Value | Type | Description |
  88218. * | --- | --- | --- |
  88219. * | 0 | BILLBOARDMODE_NONE | |
  88220. * | 1 | BILLBOARDMODE_X | |
  88221. * | 2 | BILLBOARDMODE_Y | |
  88222. * | 4 | BILLBOARDMODE_Z | |
  88223. * | 7 | BILLBOARDMODE_ALL | |
  88224. *
  88225. */
  88226. get billboardMode(): number;
  88227. set billboardMode(value: number);
  88228. private _preserveParentRotationForBillboard;
  88229. /**
  88230. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  88231. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  88232. */
  88233. get preserveParentRotationForBillboard(): boolean;
  88234. set preserveParentRotationForBillboard(value: boolean);
  88235. /**
  88236. * 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
  88237. */
  88238. scalingDeterminant: number;
  88239. private _infiniteDistance;
  88240. /**
  88241. * Gets or sets the distance of the object to max, often used by skybox
  88242. */
  88243. get infiniteDistance(): boolean;
  88244. set infiniteDistance(value: boolean);
  88245. /**
  88246. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  88247. * By default the system will update normals to compensate
  88248. */
  88249. ignoreNonUniformScaling: boolean;
  88250. /**
  88251. * 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
  88252. */
  88253. reIntegrateRotationIntoRotationQuaternion: boolean;
  88254. /** @hidden */
  88255. _poseMatrix: Nullable<Matrix>;
  88256. /** @hidden */
  88257. _localMatrix: Matrix;
  88258. private _usePivotMatrix;
  88259. private _absolutePosition;
  88260. private _absoluteScaling;
  88261. private _absoluteRotationQuaternion;
  88262. private _pivotMatrix;
  88263. private _pivotMatrixInverse;
  88264. protected _postMultiplyPivotMatrix: boolean;
  88265. protected _isWorldMatrixFrozen: boolean;
  88266. /** @hidden */
  88267. _indexInSceneTransformNodesArray: number;
  88268. /**
  88269. * An event triggered after the world matrix is updated
  88270. */
  88271. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  88272. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  88273. /**
  88274. * Gets a string identifying the name of the class
  88275. * @returns "TransformNode" string
  88276. */
  88277. getClassName(): string;
  88278. /**
  88279. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  88280. */
  88281. get position(): Vector3;
  88282. set position(newPosition: Vector3);
  88283. /**
  88284. * 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)).
  88285. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  88286. */
  88287. get rotation(): Vector3;
  88288. set rotation(newRotation: Vector3);
  88289. /**
  88290. * 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)).
  88291. */
  88292. get scaling(): Vector3;
  88293. set scaling(newScaling: Vector3);
  88294. /**
  88295. * 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).
  88296. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  88297. */
  88298. get rotationQuaternion(): Nullable<Quaternion>;
  88299. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  88300. /**
  88301. * The forward direction of that transform in world space.
  88302. */
  88303. get forward(): Vector3;
  88304. /**
  88305. * The up direction of that transform in world space.
  88306. */
  88307. get up(): Vector3;
  88308. /**
  88309. * The right direction of that transform in world space.
  88310. */
  88311. get right(): Vector3;
  88312. /**
  88313. * Copies the parameter passed Matrix into the mesh Pose matrix.
  88314. * @param matrix the matrix to copy the pose from
  88315. * @returns this TransformNode.
  88316. */
  88317. updatePoseMatrix(matrix: Matrix): TransformNode;
  88318. /**
  88319. * Returns the mesh Pose matrix.
  88320. * @returns the pose matrix
  88321. */
  88322. getPoseMatrix(): Matrix;
  88323. /** @hidden */
  88324. _isSynchronized(): boolean;
  88325. /** @hidden */
  88326. _initCache(): void;
  88327. /**
  88328. * Flag the transform node as dirty (Forcing it to update everything)
  88329. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  88330. * @returns this transform node
  88331. */
  88332. markAsDirty(property: string): TransformNode;
  88333. /**
  88334. * Returns the current mesh absolute position.
  88335. * Returns a Vector3.
  88336. */
  88337. get absolutePosition(): Vector3;
  88338. /**
  88339. * Returns the current mesh absolute scaling.
  88340. * Returns a Vector3.
  88341. */
  88342. get absoluteScaling(): Vector3;
  88343. /**
  88344. * Returns the current mesh absolute rotation.
  88345. * Returns a Quaternion.
  88346. */
  88347. get absoluteRotationQuaternion(): Quaternion;
  88348. /**
  88349. * Sets a new matrix to apply before all other transformation
  88350. * @param matrix defines the transform matrix
  88351. * @returns the current TransformNode
  88352. */
  88353. setPreTransformMatrix(matrix: Matrix): TransformNode;
  88354. /**
  88355. * Sets a new pivot matrix to the current node
  88356. * @param matrix defines the new pivot matrix to use
  88357. * @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
  88358. * @returns the current TransformNode
  88359. */
  88360. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  88361. /**
  88362. * Returns the mesh pivot matrix.
  88363. * Default : Identity.
  88364. * @returns the matrix
  88365. */
  88366. getPivotMatrix(): Matrix;
  88367. /**
  88368. * Instantiate (when possible) or clone that node with its hierarchy
  88369. * @param newParent defines the new parent to use for the instance (or clone)
  88370. * @param options defines options to configure how copy is done
  88371. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  88372. * @returns an instance (or a clone) of the current node with its hiearchy
  88373. */
  88374. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  88375. doNotInstantiate: boolean;
  88376. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  88377. /**
  88378. * Prevents the World matrix to be computed any longer
  88379. * @param newWorldMatrix defines an optional matrix to use as world matrix
  88380. * @returns the TransformNode.
  88381. */
  88382. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  88383. /**
  88384. * Allows back the World matrix computation.
  88385. * @returns the TransformNode.
  88386. */
  88387. unfreezeWorldMatrix(): this;
  88388. /**
  88389. * True if the World matrix has been frozen.
  88390. */
  88391. get isWorldMatrixFrozen(): boolean;
  88392. /**
  88393. * Retuns the mesh absolute position in the World.
  88394. * @returns a Vector3.
  88395. */
  88396. getAbsolutePosition(): Vector3;
  88397. /**
  88398. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  88399. * @param absolutePosition the absolute position to set
  88400. * @returns the TransformNode.
  88401. */
  88402. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  88403. /**
  88404. * Sets the mesh position in its local space.
  88405. * @param vector3 the position to set in localspace
  88406. * @returns the TransformNode.
  88407. */
  88408. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  88409. /**
  88410. * Returns the mesh position in the local space from the current World matrix values.
  88411. * @returns a new Vector3.
  88412. */
  88413. getPositionExpressedInLocalSpace(): Vector3;
  88414. /**
  88415. * Translates the mesh along the passed Vector3 in its local space.
  88416. * @param vector3 the distance to translate in localspace
  88417. * @returns the TransformNode.
  88418. */
  88419. locallyTranslate(vector3: Vector3): TransformNode;
  88420. private static _lookAtVectorCache;
  88421. /**
  88422. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  88423. * @param targetPoint the position (must be in same space as current mesh) to look at
  88424. * @param yawCor optional yaw (y-axis) correction in radians
  88425. * @param pitchCor optional pitch (x-axis) correction in radians
  88426. * @param rollCor optional roll (z-axis) correction in radians
  88427. * @param space the choosen space of the target
  88428. * @returns the TransformNode.
  88429. */
  88430. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  88431. /**
  88432. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  88433. * This Vector3 is expressed in the World space.
  88434. * @param localAxis axis to rotate
  88435. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  88436. */
  88437. getDirection(localAxis: Vector3): Vector3;
  88438. /**
  88439. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  88440. * localAxis is expressed in the mesh local space.
  88441. * result is computed in the Wordl space from the mesh World matrix.
  88442. * @param localAxis axis to rotate
  88443. * @param result the resulting transformnode
  88444. * @returns this TransformNode.
  88445. */
  88446. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  88447. /**
  88448. * Sets this transform node rotation to the given local axis.
  88449. * @param localAxis the axis in local space
  88450. * @param yawCor optional yaw (y-axis) correction in radians
  88451. * @param pitchCor optional pitch (x-axis) correction in radians
  88452. * @param rollCor optional roll (z-axis) correction in radians
  88453. * @returns this TransformNode
  88454. */
  88455. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  88456. /**
  88457. * Sets a new pivot point to the current node
  88458. * @param point defines the new pivot point to use
  88459. * @param space defines if the point is in world or local space (local by default)
  88460. * @returns the current TransformNode
  88461. */
  88462. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  88463. /**
  88464. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  88465. * @returns the pivot point
  88466. */
  88467. getPivotPoint(): Vector3;
  88468. /**
  88469. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  88470. * @param result the vector3 to store the result
  88471. * @returns this TransformNode.
  88472. */
  88473. getPivotPointToRef(result: Vector3): TransformNode;
  88474. /**
  88475. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  88476. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  88477. */
  88478. getAbsolutePivotPoint(): Vector3;
  88479. /**
  88480. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  88481. * @param result vector3 to store the result
  88482. * @returns this TransformNode.
  88483. */
  88484. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  88485. /**
  88486. * Defines the passed node as the parent of the current node.
  88487. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  88488. * @see https://doc.babylonjs.com/how_to/parenting
  88489. * @param node the node ot set as the parent
  88490. * @returns this TransformNode.
  88491. */
  88492. setParent(node: Nullable<Node>): TransformNode;
  88493. private _nonUniformScaling;
  88494. /**
  88495. * True if the scaling property of this object is non uniform eg. (1,2,1)
  88496. */
  88497. get nonUniformScaling(): boolean;
  88498. /** @hidden */
  88499. _updateNonUniformScalingState(value: boolean): boolean;
  88500. /**
  88501. * Attach the current TransformNode to another TransformNode associated with a bone
  88502. * @param bone Bone affecting the TransformNode
  88503. * @param affectedTransformNode TransformNode associated with the bone
  88504. * @returns this object
  88505. */
  88506. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  88507. /**
  88508. * Detach the transform node if its associated with a bone
  88509. * @returns this object
  88510. */
  88511. detachFromBone(): TransformNode;
  88512. private static _rotationAxisCache;
  88513. /**
  88514. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  88515. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  88516. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  88517. * The passed axis is also normalized.
  88518. * @param axis the axis to rotate around
  88519. * @param amount the amount to rotate in radians
  88520. * @param space Space to rotate in (Default: local)
  88521. * @returns the TransformNode.
  88522. */
  88523. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  88524. /**
  88525. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  88526. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  88527. * The passed axis is also normalized. .
  88528. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  88529. * @param point the point to rotate around
  88530. * @param axis the axis to rotate around
  88531. * @param amount the amount to rotate in radians
  88532. * @returns the TransformNode
  88533. */
  88534. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  88535. /**
  88536. * Translates the mesh along the axis vector for the passed distance in the given space.
  88537. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  88538. * @param axis the axis to translate in
  88539. * @param distance the distance to translate
  88540. * @param space Space to rotate in (Default: local)
  88541. * @returns the TransformNode.
  88542. */
  88543. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  88544. /**
  88545. * Adds a rotation step to the mesh current rotation.
  88546. * x, y, z are Euler angles expressed in radians.
  88547. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  88548. * This means this rotation is made in the mesh local space only.
  88549. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  88550. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  88551. * ```javascript
  88552. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  88553. * ```
  88554. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  88555. * 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.
  88556. * @param x Rotation to add
  88557. * @param y Rotation to add
  88558. * @param z Rotation to add
  88559. * @returns the TransformNode.
  88560. */
  88561. addRotation(x: number, y: number, z: number): TransformNode;
  88562. /**
  88563. * @hidden
  88564. */
  88565. protected _getEffectiveParent(): Nullable<Node>;
  88566. /**
  88567. * Computes the world matrix of the node
  88568. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88569. * @returns the world matrix
  88570. */
  88571. computeWorldMatrix(force?: boolean): Matrix;
  88572. /**
  88573. * Resets this nodeTransform's local matrix to Matrix.Identity().
  88574. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  88575. */
  88576. resetLocalMatrix(independentOfChildren?: boolean): void;
  88577. protected _afterComputeWorldMatrix(): void;
  88578. /**
  88579. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  88580. * @param func callback function to add
  88581. *
  88582. * @returns the TransformNode.
  88583. */
  88584. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  88585. /**
  88586. * Removes a registered callback function.
  88587. * @param func callback function to remove
  88588. * @returns the TransformNode.
  88589. */
  88590. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  88591. /**
  88592. * Gets the position of the current mesh in camera space
  88593. * @param camera defines the camera to use
  88594. * @returns a position
  88595. */
  88596. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  88597. /**
  88598. * Returns the distance from the mesh to the active camera
  88599. * @param camera defines the camera to use
  88600. * @returns the distance
  88601. */
  88602. getDistanceToCamera(camera?: Nullable<Camera>): number;
  88603. /**
  88604. * Clone the current transform node
  88605. * @param name Name of the new clone
  88606. * @param newParent New parent for the clone
  88607. * @param doNotCloneChildren Do not clone children hierarchy
  88608. * @returns the new transform node
  88609. */
  88610. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  88611. /**
  88612. * Serializes the objects information.
  88613. * @param currentSerializationObject defines the object to serialize in
  88614. * @returns the serialized object
  88615. */
  88616. serialize(currentSerializationObject?: any): any;
  88617. /**
  88618. * Returns a new TransformNode object parsed from the source provided.
  88619. * @param parsedTransformNode is the source.
  88620. * @param scene the scne the object belongs to
  88621. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  88622. * @returns a new TransformNode object parsed from the source provided.
  88623. */
  88624. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  88625. /**
  88626. * Get all child-transformNodes of this node
  88627. * @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
  88628. * @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
  88629. * @returns an array of TransformNode
  88630. */
  88631. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  88632. /**
  88633. * Releases resources associated with this transform node.
  88634. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88635. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88636. */
  88637. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88638. /**
  88639. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  88640. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  88641. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  88642. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  88643. * @returns the current mesh
  88644. */
  88645. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  88646. private _syncAbsoluteScalingAndRotation;
  88647. }
  88648. }
  88649. declare module BABYLON {
  88650. /**
  88651. * Class used to override all child animations of a given target
  88652. */
  88653. export class AnimationPropertiesOverride {
  88654. /**
  88655. * Gets or sets a value indicating if animation blending must be used
  88656. */
  88657. enableBlending: boolean;
  88658. /**
  88659. * Gets or sets the blending speed to use when enableBlending is true
  88660. */
  88661. blendingSpeed: number;
  88662. /**
  88663. * Gets or sets the default loop mode to use
  88664. */
  88665. loopMode: number;
  88666. }
  88667. }
  88668. declare module BABYLON {
  88669. /**
  88670. * Class used to store bone information
  88671. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  88672. */
  88673. export class Bone extends Node {
  88674. /**
  88675. * defines the bone name
  88676. */
  88677. name: string;
  88678. private static _tmpVecs;
  88679. private static _tmpQuat;
  88680. private static _tmpMats;
  88681. /**
  88682. * Gets the list of child bones
  88683. */
  88684. children: Bone[];
  88685. /** Gets the animations associated with this bone */
  88686. animations: Animation[];
  88687. /**
  88688. * Gets or sets bone length
  88689. */
  88690. length: number;
  88691. /**
  88692. * @hidden Internal only
  88693. * Set this value to map this bone to a different index in the transform matrices
  88694. * Set this value to -1 to exclude the bone from the transform matrices
  88695. */
  88696. _index: Nullable<number>;
  88697. private _skeleton;
  88698. private _localMatrix;
  88699. private _restPose;
  88700. private _baseMatrix;
  88701. private _absoluteTransform;
  88702. private _invertedAbsoluteTransform;
  88703. private _parent;
  88704. private _scalingDeterminant;
  88705. private _worldTransform;
  88706. private _localScaling;
  88707. private _localRotation;
  88708. private _localPosition;
  88709. private _needToDecompose;
  88710. private _needToCompose;
  88711. /** @hidden */
  88712. _linkedTransformNode: Nullable<TransformNode>;
  88713. /** @hidden */
  88714. _waitingTransformNodeId: Nullable<string>;
  88715. /** @hidden */
  88716. get _matrix(): Matrix;
  88717. /** @hidden */
  88718. set _matrix(value: Matrix);
  88719. /**
  88720. * Create a new bone
  88721. * @param name defines the bone name
  88722. * @param skeleton defines the parent skeleton
  88723. * @param parentBone defines the parent (can be null if the bone is the root)
  88724. * @param localMatrix defines the local matrix
  88725. * @param restPose defines the rest pose matrix
  88726. * @param baseMatrix defines the base matrix
  88727. * @param index defines index of the bone in the hiearchy
  88728. */
  88729. constructor(
  88730. /**
  88731. * defines the bone name
  88732. */
  88733. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  88734. /**
  88735. * Gets the current object class name.
  88736. * @return the class name
  88737. */
  88738. getClassName(): string;
  88739. /**
  88740. * Gets the parent skeleton
  88741. * @returns a skeleton
  88742. */
  88743. getSkeleton(): Skeleton;
  88744. /**
  88745. * Gets parent bone
  88746. * @returns a bone or null if the bone is the root of the bone hierarchy
  88747. */
  88748. getParent(): Nullable<Bone>;
  88749. /**
  88750. * Returns an array containing the root bones
  88751. * @returns an array containing the root bones
  88752. */
  88753. getChildren(): Array<Bone>;
  88754. /**
  88755. * Gets the node index in matrix array generated for rendering
  88756. * @returns the node index
  88757. */
  88758. getIndex(): number;
  88759. /**
  88760. * Sets the parent bone
  88761. * @param parent defines the parent (can be null if the bone is the root)
  88762. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  88763. */
  88764. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  88765. /**
  88766. * Gets the local matrix
  88767. * @returns a matrix
  88768. */
  88769. getLocalMatrix(): Matrix;
  88770. /**
  88771. * Gets the base matrix (initial matrix which remains unchanged)
  88772. * @returns a matrix
  88773. */
  88774. getBaseMatrix(): Matrix;
  88775. /**
  88776. * Gets the rest pose matrix
  88777. * @returns a matrix
  88778. */
  88779. getRestPose(): Matrix;
  88780. /**
  88781. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  88782. */
  88783. getWorldMatrix(): Matrix;
  88784. /**
  88785. * Sets the local matrix to rest pose matrix
  88786. */
  88787. returnToRest(): void;
  88788. /**
  88789. * Gets the inverse of the absolute transform matrix.
  88790. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  88791. * @returns a matrix
  88792. */
  88793. getInvertedAbsoluteTransform(): Matrix;
  88794. /**
  88795. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  88796. * @returns a matrix
  88797. */
  88798. getAbsoluteTransform(): Matrix;
  88799. /**
  88800. * Links with the given transform node.
  88801. * The local matrix of this bone is copied from the transform node every frame.
  88802. * @param transformNode defines the transform node to link to
  88803. */
  88804. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  88805. /**
  88806. * Gets the node used to drive the bone's transformation
  88807. * @returns a transform node or null
  88808. */
  88809. getTransformNode(): Nullable<TransformNode>;
  88810. /** Gets or sets current position (in local space) */
  88811. get position(): Vector3;
  88812. set position(newPosition: Vector3);
  88813. /** Gets or sets current rotation (in local space) */
  88814. get rotation(): Vector3;
  88815. set rotation(newRotation: Vector3);
  88816. /** Gets or sets current rotation quaternion (in local space) */
  88817. get rotationQuaternion(): Quaternion;
  88818. set rotationQuaternion(newRotation: Quaternion);
  88819. /** Gets or sets current scaling (in local space) */
  88820. get scaling(): Vector3;
  88821. set scaling(newScaling: Vector3);
  88822. /**
  88823. * Gets the animation properties override
  88824. */
  88825. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  88826. private _decompose;
  88827. private _compose;
  88828. /**
  88829. * Update the base and local matrices
  88830. * @param matrix defines the new base or local matrix
  88831. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  88832. * @param updateLocalMatrix defines if the local matrix should be updated
  88833. */
  88834. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  88835. /** @hidden */
  88836. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  88837. /**
  88838. * Flag the bone as dirty (Forcing it to update everything)
  88839. */
  88840. markAsDirty(): void;
  88841. /** @hidden */
  88842. _markAsDirtyAndCompose(): void;
  88843. private _markAsDirtyAndDecompose;
  88844. /**
  88845. * Translate the bone in local or world space
  88846. * @param vec The amount to translate the bone
  88847. * @param space The space that the translation is in
  88848. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88849. */
  88850. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  88851. /**
  88852. * Set the postion of the bone in local or world space
  88853. * @param position The position to set the bone
  88854. * @param space The space that the position is in
  88855. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88856. */
  88857. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  88858. /**
  88859. * Set the absolute position of the bone (world space)
  88860. * @param position The position to set the bone
  88861. * @param mesh The mesh that this bone is attached to
  88862. */
  88863. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  88864. /**
  88865. * Scale the bone on the x, y and z axes (in local space)
  88866. * @param x The amount to scale the bone on the x axis
  88867. * @param y The amount to scale the bone on the y axis
  88868. * @param z The amount to scale the bone on the z axis
  88869. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  88870. */
  88871. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  88872. /**
  88873. * Set the bone scaling in local space
  88874. * @param scale defines the scaling vector
  88875. */
  88876. setScale(scale: Vector3): void;
  88877. /**
  88878. * Gets the current scaling in local space
  88879. * @returns the current scaling vector
  88880. */
  88881. getScale(): Vector3;
  88882. /**
  88883. * Gets the current scaling in local space and stores it in a target vector
  88884. * @param result defines the target vector
  88885. */
  88886. getScaleToRef(result: Vector3): void;
  88887. /**
  88888. * Set the yaw, pitch, and roll of the bone in local or world space
  88889. * @param yaw The rotation of the bone on the y axis
  88890. * @param pitch The rotation of the bone on the x axis
  88891. * @param roll The rotation of the bone on the z axis
  88892. * @param space The space that the axes of rotation are in
  88893. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88894. */
  88895. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  88896. /**
  88897. * Add a rotation to the bone on an axis in local or world space
  88898. * @param axis The axis to rotate the bone on
  88899. * @param amount The amount to rotate the bone
  88900. * @param space The space that the axis is in
  88901. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88902. */
  88903. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  88904. /**
  88905. * Set the rotation of the bone to a particular axis angle in local or world space
  88906. * @param axis The axis to rotate the bone on
  88907. * @param angle The angle that the bone should be rotated to
  88908. * @param space The space that the axis is in
  88909. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88910. */
  88911. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  88912. /**
  88913. * Set the euler rotation of the bone in local of world space
  88914. * @param rotation The euler rotation that the bone should be set to
  88915. * @param space The space that the rotation is in
  88916. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88917. */
  88918. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  88919. /**
  88920. * Set the quaternion rotation of the bone in local of world space
  88921. * @param quat The quaternion rotation that the bone should be set to
  88922. * @param space The space that the rotation is in
  88923. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88924. */
  88925. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  88926. /**
  88927. * Set the rotation matrix of the bone in local of world space
  88928. * @param rotMat The rotation matrix that the bone should be set to
  88929. * @param space The space that the rotation is in
  88930. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88931. */
  88932. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  88933. private _rotateWithMatrix;
  88934. private _getNegativeRotationToRef;
  88935. /**
  88936. * Get the position of the bone in local or world space
  88937. * @param space The space that the returned position is in
  88938. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88939. * @returns The position of the bone
  88940. */
  88941. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  88942. /**
  88943. * Copy the position of the bone to a vector3 in local or world space
  88944. * @param space The space that the returned position is in
  88945. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88946. * @param result The vector3 to copy the position to
  88947. */
  88948. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  88949. /**
  88950. * Get the absolute position of the bone (world space)
  88951. * @param mesh The mesh that this bone is attached to
  88952. * @returns The absolute position of the bone
  88953. */
  88954. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  88955. /**
  88956. * Copy the absolute position of the bone (world space) to the result param
  88957. * @param mesh The mesh that this bone is attached to
  88958. * @param result The vector3 to copy the absolute position to
  88959. */
  88960. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  88961. /**
  88962. * Compute the absolute transforms of this bone and its children
  88963. */
  88964. computeAbsoluteTransforms(): void;
  88965. /**
  88966. * Get the world direction from an axis that is in the local space of the bone
  88967. * @param localAxis The local direction that is used to compute the world direction
  88968. * @param mesh The mesh that this bone is attached to
  88969. * @returns The world direction
  88970. */
  88971. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  88972. /**
  88973. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  88974. * @param localAxis The local direction that is used to compute the world direction
  88975. * @param mesh The mesh that this bone is attached to
  88976. * @param result The vector3 that the world direction will be copied to
  88977. */
  88978. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  88979. /**
  88980. * Get the euler rotation of the bone in local or world space
  88981. * @param space The space that the rotation should be in
  88982. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88983. * @returns The euler rotation
  88984. */
  88985. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  88986. /**
  88987. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  88988. * @param space The space that the rotation should be in
  88989. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88990. * @param result The vector3 that the rotation should be copied to
  88991. */
  88992. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  88993. /**
  88994. * Get the quaternion rotation of the bone in either local or world space
  88995. * @param space The space that the rotation should be in
  88996. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88997. * @returns The quaternion rotation
  88998. */
  88999. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  89000. /**
  89001. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  89002. * @param space The space that the rotation should be in
  89003. * @param mesh The mesh that this bone is attached to. This is only used in world space
  89004. * @param result The quaternion that the rotation should be copied to
  89005. */
  89006. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  89007. /**
  89008. * Get the rotation matrix of the bone in local or world space
  89009. * @param space The space that the rotation should be in
  89010. * @param mesh The mesh that this bone is attached to. This is only used in world space
  89011. * @returns The rotation matrix
  89012. */
  89013. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  89014. /**
  89015. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  89016. * @param space The space that the rotation should be in
  89017. * @param mesh The mesh that this bone is attached to. This is only used in world space
  89018. * @param result The quaternion that the rotation should be copied to
  89019. */
  89020. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  89021. /**
  89022. * Get the world position of a point that is in the local space of the bone
  89023. * @param position The local position
  89024. * @param mesh The mesh that this bone is attached to
  89025. * @returns The world position
  89026. */
  89027. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  89028. /**
  89029. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  89030. * @param position The local position
  89031. * @param mesh The mesh that this bone is attached to
  89032. * @param result The vector3 that the world position should be copied to
  89033. */
  89034. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  89035. /**
  89036. * Get the local position of a point that is in world space
  89037. * @param position The world position
  89038. * @param mesh The mesh that this bone is attached to
  89039. * @returns The local position
  89040. */
  89041. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  89042. /**
  89043. * Get the local position of a point that is in world space and copy it to the result param
  89044. * @param position The world position
  89045. * @param mesh The mesh that this bone is attached to
  89046. * @param result The vector3 that the local position should be copied to
  89047. */
  89048. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  89049. }
  89050. }
  89051. declare module BABYLON {
  89052. /**
  89053. * Defines a runtime animation
  89054. */
  89055. export class RuntimeAnimation {
  89056. private _events;
  89057. /**
  89058. * The current frame of the runtime animation
  89059. */
  89060. private _currentFrame;
  89061. /**
  89062. * The animation used by the runtime animation
  89063. */
  89064. private _animation;
  89065. /**
  89066. * The target of the runtime animation
  89067. */
  89068. private _target;
  89069. /**
  89070. * The initiating animatable
  89071. */
  89072. private _host;
  89073. /**
  89074. * The original value of the runtime animation
  89075. */
  89076. private _originalValue;
  89077. /**
  89078. * The original blend value of the runtime animation
  89079. */
  89080. private _originalBlendValue;
  89081. /**
  89082. * The offsets cache of the runtime animation
  89083. */
  89084. private _offsetsCache;
  89085. /**
  89086. * The high limits cache of the runtime animation
  89087. */
  89088. private _highLimitsCache;
  89089. /**
  89090. * Specifies if the runtime animation has been stopped
  89091. */
  89092. private _stopped;
  89093. /**
  89094. * The blending factor of the runtime animation
  89095. */
  89096. private _blendingFactor;
  89097. /**
  89098. * The BabylonJS scene
  89099. */
  89100. private _scene;
  89101. /**
  89102. * The current value of the runtime animation
  89103. */
  89104. private _currentValue;
  89105. /** @hidden */
  89106. _animationState: _IAnimationState;
  89107. /**
  89108. * The active target of the runtime animation
  89109. */
  89110. private _activeTargets;
  89111. private _currentActiveTarget;
  89112. private _directTarget;
  89113. /**
  89114. * The target path of the runtime animation
  89115. */
  89116. private _targetPath;
  89117. /**
  89118. * The weight of the runtime animation
  89119. */
  89120. private _weight;
  89121. /**
  89122. * The ratio offset of the runtime animation
  89123. */
  89124. private _ratioOffset;
  89125. /**
  89126. * The previous delay of the runtime animation
  89127. */
  89128. private _previousDelay;
  89129. /**
  89130. * The previous ratio of the runtime animation
  89131. */
  89132. private _previousRatio;
  89133. private _enableBlending;
  89134. private _keys;
  89135. private _minFrame;
  89136. private _maxFrame;
  89137. private _minValue;
  89138. private _maxValue;
  89139. private _targetIsArray;
  89140. /**
  89141. * Gets the current frame of the runtime animation
  89142. */
  89143. get currentFrame(): number;
  89144. /**
  89145. * Gets the weight of the runtime animation
  89146. */
  89147. get weight(): number;
  89148. /**
  89149. * Gets the current value of the runtime animation
  89150. */
  89151. get currentValue(): any;
  89152. /**
  89153. * Gets the target path of the runtime animation
  89154. */
  89155. get targetPath(): string;
  89156. /**
  89157. * Gets the actual target of the runtime animation
  89158. */
  89159. get target(): any;
  89160. /**
  89161. * Gets the additive state of the runtime animation
  89162. */
  89163. get isAdditive(): boolean;
  89164. /** @hidden */
  89165. _onLoop: () => void;
  89166. /**
  89167. * Create a new RuntimeAnimation object
  89168. * @param target defines the target of the animation
  89169. * @param animation defines the source animation object
  89170. * @param scene defines the hosting scene
  89171. * @param host defines the initiating Animatable
  89172. */
  89173. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  89174. private _preparePath;
  89175. /**
  89176. * Gets the animation from the runtime animation
  89177. */
  89178. get animation(): Animation;
  89179. /**
  89180. * Resets the runtime animation to the beginning
  89181. * @param restoreOriginal defines whether to restore the target property to the original value
  89182. */
  89183. reset(restoreOriginal?: boolean): void;
  89184. /**
  89185. * Specifies if the runtime animation is stopped
  89186. * @returns Boolean specifying if the runtime animation is stopped
  89187. */
  89188. isStopped(): boolean;
  89189. /**
  89190. * Disposes of the runtime animation
  89191. */
  89192. dispose(): void;
  89193. /**
  89194. * Apply the interpolated value to the target
  89195. * @param currentValue defines the value computed by the animation
  89196. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  89197. */
  89198. setValue(currentValue: any, weight: number): void;
  89199. private _getOriginalValues;
  89200. private _setValue;
  89201. /**
  89202. * Gets the loop pmode of the runtime animation
  89203. * @returns Loop Mode
  89204. */
  89205. private _getCorrectLoopMode;
  89206. /**
  89207. * Move the current animation to a given frame
  89208. * @param frame defines the frame to move to
  89209. */
  89210. goToFrame(frame: number): void;
  89211. /**
  89212. * @hidden Internal use only
  89213. */
  89214. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  89215. /**
  89216. * Execute the current animation
  89217. * @param delay defines the delay to add to the current frame
  89218. * @param from defines the lower bound of the animation range
  89219. * @param to defines the upper bound of the animation range
  89220. * @param loop defines if the current animation must loop
  89221. * @param speedRatio defines the current speed ratio
  89222. * @param weight defines the weight of the animation (default is -1 so no weight)
  89223. * @param onLoop optional callback called when animation loops
  89224. * @returns a boolean indicating if the animation is running
  89225. */
  89226. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  89227. }
  89228. }
  89229. declare module BABYLON {
  89230. /**
  89231. * Class used to store an actual running animation
  89232. */
  89233. export class Animatable {
  89234. /** defines the target object */
  89235. target: any;
  89236. /** defines the starting frame number (default is 0) */
  89237. fromFrame: number;
  89238. /** defines the ending frame number (default is 100) */
  89239. toFrame: number;
  89240. /** defines if the animation must loop (default is false) */
  89241. loopAnimation: boolean;
  89242. /** defines a callback to call when animation ends if it is not looping */
  89243. onAnimationEnd?: (() => void) | null | undefined;
  89244. /** defines a callback to call when animation loops */
  89245. onAnimationLoop?: (() => void) | null | undefined;
  89246. /** defines whether the animation should be evaluated additively */
  89247. isAdditive: boolean;
  89248. private _localDelayOffset;
  89249. private _pausedDelay;
  89250. private _runtimeAnimations;
  89251. private _paused;
  89252. private _scene;
  89253. private _speedRatio;
  89254. private _weight;
  89255. private _syncRoot;
  89256. /**
  89257. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  89258. * This will only apply for non looping animation (default is true)
  89259. */
  89260. disposeOnEnd: boolean;
  89261. /**
  89262. * Gets a boolean indicating if the animation has started
  89263. */
  89264. animationStarted: boolean;
  89265. /**
  89266. * Observer raised when the animation ends
  89267. */
  89268. onAnimationEndObservable: Observable<Animatable>;
  89269. /**
  89270. * Observer raised when the animation loops
  89271. */
  89272. onAnimationLoopObservable: Observable<Animatable>;
  89273. /**
  89274. * Gets the root Animatable used to synchronize and normalize animations
  89275. */
  89276. get syncRoot(): Nullable<Animatable>;
  89277. /**
  89278. * Gets the current frame of the first RuntimeAnimation
  89279. * Used to synchronize Animatables
  89280. */
  89281. get masterFrame(): number;
  89282. /**
  89283. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  89284. */
  89285. get weight(): number;
  89286. set weight(value: number);
  89287. /**
  89288. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  89289. */
  89290. get speedRatio(): number;
  89291. set speedRatio(value: number);
  89292. /**
  89293. * Creates a new Animatable
  89294. * @param scene defines the hosting scene
  89295. * @param target defines the target object
  89296. * @param fromFrame defines the starting frame number (default is 0)
  89297. * @param toFrame defines the ending frame number (default is 100)
  89298. * @param loopAnimation defines if the animation must loop (default is false)
  89299. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  89300. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  89301. * @param animations defines a group of animation to add to the new Animatable
  89302. * @param onAnimationLoop defines a callback to call when animation loops
  89303. * @param isAdditive defines whether the animation should be evaluated additively
  89304. */
  89305. constructor(scene: Scene,
  89306. /** defines the target object */
  89307. target: any,
  89308. /** defines the starting frame number (default is 0) */
  89309. fromFrame?: number,
  89310. /** defines the ending frame number (default is 100) */
  89311. toFrame?: number,
  89312. /** defines if the animation must loop (default is false) */
  89313. loopAnimation?: boolean, speedRatio?: number,
  89314. /** defines a callback to call when animation ends if it is not looping */
  89315. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  89316. /** defines a callback to call when animation loops */
  89317. onAnimationLoop?: (() => void) | null | undefined,
  89318. /** defines whether the animation should be evaluated additively */
  89319. isAdditive?: boolean);
  89320. /**
  89321. * Synchronize and normalize current Animatable with a source Animatable
  89322. * This is useful when using animation weights and when animations are not of the same length
  89323. * @param root defines the root Animatable to synchronize with
  89324. * @returns the current Animatable
  89325. */
  89326. syncWith(root: Animatable): Animatable;
  89327. /**
  89328. * Gets the list of runtime animations
  89329. * @returns an array of RuntimeAnimation
  89330. */
  89331. getAnimations(): RuntimeAnimation[];
  89332. /**
  89333. * Adds more animations to the current animatable
  89334. * @param target defines the target of the animations
  89335. * @param animations defines the new animations to add
  89336. */
  89337. appendAnimations(target: any, animations: Animation[]): void;
  89338. /**
  89339. * Gets the source animation for a specific property
  89340. * @param property defines the propertyu to look for
  89341. * @returns null or the source animation for the given property
  89342. */
  89343. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  89344. /**
  89345. * Gets the runtime animation for a specific property
  89346. * @param property defines the propertyu to look for
  89347. * @returns null or the runtime animation for the given property
  89348. */
  89349. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  89350. /**
  89351. * Resets the animatable to its original state
  89352. */
  89353. reset(): void;
  89354. /**
  89355. * Allows the animatable to blend with current running animations
  89356. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  89357. * @param blendingSpeed defines the blending speed to use
  89358. */
  89359. enableBlending(blendingSpeed: number): void;
  89360. /**
  89361. * Disable animation blending
  89362. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  89363. */
  89364. disableBlending(): void;
  89365. /**
  89366. * Jump directly to a given frame
  89367. * @param frame defines the frame to jump to
  89368. */
  89369. goToFrame(frame: number): void;
  89370. /**
  89371. * Pause the animation
  89372. */
  89373. pause(): void;
  89374. /**
  89375. * Restart the animation
  89376. */
  89377. restart(): void;
  89378. private _raiseOnAnimationEnd;
  89379. /**
  89380. * Stop and delete the current animation
  89381. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  89382. * @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)
  89383. */
  89384. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  89385. /**
  89386. * Wait asynchronously for the animation to end
  89387. * @returns a promise which will be fullfilled when the animation ends
  89388. */
  89389. waitAsync(): Promise<Animatable>;
  89390. /** @hidden */
  89391. _animate(delay: number): boolean;
  89392. }
  89393. interface Scene {
  89394. /** @hidden */
  89395. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  89396. /** @hidden */
  89397. _processLateAnimationBindingsForMatrices(holder: {
  89398. totalWeight: number;
  89399. totalAdditiveWeight: number;
  89400. animations: RuntimeAnimation[];
  89401. additiveAnimations: RuntimeAnimation[];
  89402. originalValue: Matrix;
  89403. }): any;
  89404. /** @hidden */
  89405. _processLateAnimationBindingsForQuaternions(holder: {
  89406. totalWeight: number;
  89407. totalAdditiveWeight: number;
  89408. animations: RuntimeAnimation[];
  89409. additiveAnimations: RuntimeAnimation[];
  89410. originalValue: Quaternion;
  89411. }, refQuaternion: Quaternion): Quaternion;
  89412. /** @hidden */
  89413. _processLateAnimationBindings(): void;
  89414. /**
  89415. * Will start the animation sequence of a given target
  89416. * @param target defines the target
  89417. * @param from defines from which frame should animation start
  89418. * @param to defines until which frame should animation run.
  89419. * @param weight defines the weight to apply to the animation (1.0 by default)
  89420. * @param loop defines if the animation loops
  89421. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  89422. * @param onAnimationEnd defines the function to be executed when the animation ends
  89423. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  89424. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  89425. * @param onAnimationLoop defines the callback to call when an animation loops
  89426. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  89427. * @returns the animatable object created for this animation
  89428. */
  89429. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  89430. /**
  89431. * Will start the animation sequence of a given target
  89432. * @param target defines the target
  89433. * @param from defines from which frame should animation start
  89434. * @param to defines until which frame should animation run.
  89435. * @param loop defines if the animation loops
  89436. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  89437. * @param onAnimationEnd defines the function to be executed when the animation ends
  89438. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  89439. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  89440. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  89441. * @param onAnimationLoop defines the callback to call when an animation loops
  89442. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  89443. * @returns the animatable object created for this animation
  89444. */
  89445. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  89446. /**
  89447. * Will start the animation sequence of a given target and its hierarchy
  89448. * @param target defines the target
  89449. * @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.
  89450. * @param from defines from which frame should animation start
  89451. * @param to defines until which frame should animation run.
  89452. * @param loop defines if the animation loops
  89453. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  89454. * @param onAnimationEnd defines the function to be executed when the animation ends
  89455. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  89456. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  89457. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  89458. * @param onAnimationLoop defines the callback to call when an animation loops
  89459. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  89460. * @returns the list of created animatables
  89461. */
  89462. 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, isAdditive?: boolean): Animatable[];
  89463. /**
  89464. * Begin a new animation on a given node
  89465. * @param target defines the target where the animation will take place
  89466. * @param animations defines the list of animations to start
  89467. * @param from defines the initial value
  89468. * @param to defines the final value
  89469. * @param loop defines if you want animation to loop (off by default)
  89470. * @param speedRatio defines the speed ratio to apply to all animations
  89471. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  89472. * @param onAnimationLoop defines the callback to call when an animation loops
  89473. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  89474. * @returns the list of created animatables
  89475. */
  89476. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  89477. /**
  89478. * Begin a new animation on a given node and its hierarchy
  89479. * @param target defines the root node where the animation will take place
  89480. * @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.
  89481. * @param animations defines the list of animations to start
  89482. * @param from defines the initial value
  89483. * @param to defines the final value
  89484. * @param loop defines if you want animation to loop (off by default)
  89485. * @param speedRatio defines the speed ratio to apply to all animations
  89486. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  89487. * @param onAnimationLoop defines the callback to call when an animation loops
  89488. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  89489. * @returns the list of animatables created for all nodes
  89490. */
  89491. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  89492. /**
  89493. * Gets the animatable associated with a specific target
  89494. * @param target defines the target of the animatable
  89495. * @returns the required animatable if found
  89496. */
  89497. getAnimatableByTarget(target: any): Nullable<Animatable>;
  89498. /**
  89499. * Gets all animatables associated with a given target
  89500. * @param target defines the target to look animatables for
  89501. * @returns an array of Animatables
  89502. */
  89503. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  89504. /**
  89505. * Stops and removes all animations that have been applied to the scene
  89506. */
  89507. stopAllAnimations(): void;
  89508. /**
  89509. * Gets the current delta time used by animation engine
  89510. */
  89511. deltaTime: number;
  89512. }
  89513. interface Bone {
  89514. /**
  89515. * Copy an animation range from another bone
  89516. * @param source defines the source bone
  89517. * @param rangeName defines the range name to copy
  89518. * @param frameOffset defines the frame offset
  89519. * @param rescaleAsRequired defines if rescaling must be applied if required
  89520. * @param skelDimensionsRatio defines the scaling ratio
  89521. * @returns true if operation was successful
  89522. */
  89523. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  89524. }
  89525. }
  89526. declare module BABYLON {
  89527. /**
  89528. * Class used to handle skinning animations
  89529. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  89530. */
  89531. export class Skeleton implements IAnimatable {
  89532. /** defines the skeleton name */
  89533. name: string;
  89534. /** defines the skeleton Id */
  89535. id: string;
  89536. /**
  89537. * Defines the list of child bones
  89538. */
  89539. bones: Bone[];
  89540. /**
  89541. * Defines an estimate of the dimension of the skeleton at rest
  89542. */
  89543. dimensionsAtRest: Vector3;
  89544. /**
  89545. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  89546. */
  89547. needInitialSkinMatrix: boolean;
  89548. /**
  89549. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  89550. */
  89551. overrideMesh: Nullable<AbstractMesh>;
  89552. /**
  89553. * Gets the list of animations attached to this skeleton
  89554. */
  89555. animations: Array<Animation>;
  89556. private _scene;
  89557. private _isDirty;
  89558. private _transformMatrices;
  89559. private _transformMatrixTexture;
  89560. private _meshesWithPoseMatrix;
  89561. private _animatables;
  89562. private _identity;
  89563. private _synchronizedWithMesh;
  89564. private _ranges;
  89565. private _lastAbsoluteTransformsUpdateId;
  89566. private _canUseTextureForBones;
  89567. private _uniqueId;
  89568. /** @hidden */
  89569. _numBonesWithLinkedTransformNode: number;
  89570. /** @hidden */
  89571. _hasWaitingData: Nullable<boolean>;
  89572. /**
  89573. * Specifies if the skeleton should be serialized
  89574. */
  89575. doNotSerialize: boolean;
  89576. private _useTextureToStoreBoneMatrices;
  89577. /**
  89578. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  89579. * Please note that this option is not available if the hardware does not support it
  89580. */
  89581. get useTextureToStoreBoneMatrices(): boolean;
  89582. set useTextureToStoreBoneMatrices(value: boolean);
  89583. private _animationPropertiesOverride;
  89584. /**
  89585. * Gets or sets the animation properties override
  89586. */
  89587. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  89588. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  89589. /**
  89590. * List of inspectable custom properties (used by the Inspector)
  89591. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  89592. */
  89593. inspectableCustomProperties: IInspectable[];
  89594. /**
  89595. * An observable triggered before computing the skeleton's matrices
  89596. */
  89597. onBeforeComputeObservable: Observable<Skeleton>;
  89598. /**
  89599. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  89600. */
  89601. get isUsingTextureForMatrices(): boolean;
  89602. /**
  89603. * Gets the unique ID of this skeleton
  89604. */
  89605. get uniqueId(): number;
  89606. /**
  89607. * Creates a new skeleton
  89608. * @param name defines the skeleton name
  89609. * @param id defines the skeleton Id
  89610. * @param scene defines the hosting scene
  89611. */
  89612. constructor(
  89613. /** defines the skeleton name */
  89614. name: string,
  89615. /** defines the skeleton Id */
  89616. id: string, scene: Scene);
  89617. /**
  89618. * Gets the current object class name.
  89619. * @return the class name
  89620. */
  89621. getClassName(): string;
  89622. /**
  89623. * Returns an array containing the root bones
  89624. * @returns an array containing the root bones
  89625. */
  89626. getChildren(): Array<Bone>;
  89627. /**
  89628. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  89629. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  89630. * @returns a Float32Array containing matrices data
  89631. */
  89632. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  89633. /**
  89634. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  89635. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  89636. * @returns a raw texture containing the data
  89637. */
  89638. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  89639. /**
  89640. * Gets the current hosting scene
  89641. * @returns a scene object
  89642. */
  89643. getScene(): Scene;
  89644. /**
  89645. * Gets a string representing the current skeleton data
  89646. * @param fullDetails defines a boolean indicating if we want a verbose version
  89647. * @returns a string representing the current skeleton data
  89648. */
  89649. toString(fullDetails?: boolean): string;
  89650. /**
  89651. * Get bone's index searching by name
  89652. * @param name defines bone's name to search for
  89653. * @return the indice of the bone. Returns -1 if not found
  89654. */
  89655. getBoneIndexByName(name: string): number;
  89656. /**
  89657. * Creater a new animation range
  89658. * @param name defines the name of the range
  89659. * @param from defines the start key
  89660. * @param to defines the end key
  89661. */
  89662. createAnimationRange(name: string, from: number, to: number): void;
  89663. /**
  89664. * Delete a specific animation range
  89665. * @param name defines the name of the range
  89666. * @param deleteFrames defines if frames must be removed as well
  89667. */
  89668. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  89669. /**
  89670. * Gets a specific animation range
  89671. * @param name defines the name of the range to look for
  89672. * @returns the requested animation range or null if not found
  89673. */
  89674. getAnimationRange(name: string): Nullable<AnimationRange>;
  89675. /**
  89676. * Gets the list of all animation ranges defined on this skeleton
  89677. * @returns an array
  89678. */
  89679. getAnimationRanges(): Nullable<AnimationRange>[];
  89680. /**
  89681. * Copy animation range from a source skeleton.
  89682. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  89683. * @param source defines the source skeleton
  89684. * @param name defines the name of the range to copy
  89685. * @param rescaleAsRequired defines if rescaling must be applied if required
  89686. * @returns true if operation was successful
  89687. */
  89688. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  89689. /**
  89690. * Forces the skeleton to go to rest pose
  89691. */
  89692. returnToRest(): void;
  89693. private _getHighestAnimationFrame;
  89694. /**
  89695. * Begin a specific animation range
  89696. * @param name defines the name of the range to start
  89697. * @param loop defines if looping must be turned on (false by default)
  89698. * @param speedRatio defines the speed ratio to apply (1 by default)
  89699. * @param onAnimationEnd defines a callback which will be called when animation will end
  89700. * @returns a new animatable
  89701. */
  89702. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  89703. /**
  89704. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  89705. * @param skeleton defines the Skeleton containing the animation range to convert
  89706. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  89707. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  89708. * @returns the original skeleton
  89709. */
  89710. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  89711. /** @hidden */
  89712. _markAsDirty(): void;
  89713. /** @hidden */
  89714. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  89715. /** @hidden */
  89716. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  89717. private _computeTransformMatrices;
  89718. /**
  89719. * Build all resources required to render a skeleton
  89720. */
  89721. prepare(): void;
  89722. /**
  89723. * Gets the list of animatables currently running for this skeleton
  89724. * @returns an array of animatables
  89725. */
  89726. getAnimatables(): IAnimatable[];
  89727. /**
  89728. * Clone the current skeleton
  89729. * @param name defines the name of the new skeleton
  89730. * @param id defines the id of the new skeleton
  89731. * @returns the new skeleton
  89732. */
  89733. clone(name: string, id?: string): Skeleton;
  89734. /**
  89735. * Enable animation blending for this skeleton
  89736. * @param blendingSpeed defines the blending speed to apply
  89737. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  89738. */
  89739. enableBlending(blendingSpeed?: number): void;
  89740. /**
  89741. * Releases all resources associated with the current skeleton
  89742. */
  89743. dispose(): void;
  89744. /**
  89745. * Serialize the skeleton in a JSON object
  89746. * @returns a JSON object
  89747. */
  89748. serialize(): any;
  89749. /**
  89750. * Creates a new skeleton from serialized data
  89751. * @param parsedSkeleton defines the serialized data
  89752. * @param scene defines the hosting scene
  89753. * @returns a new skeleton
  89754. */
  89755. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  89756. /**
  89757. * Compute all node absolute transforms
  89758. * @param forceUpdate defines if computation must be done even if cache is up to date
  89759. */
  89760. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  89761. /**
  89762. * Gets the root pose matrix
  89763. * @returns a matrix
  89764. */
  89765. getPoseMatrix(): Nullable<Matrix>;
  89766. /**
  89767. * Sorts bones per internal index
  89768. */
  89769. sortBones(): void;
  89770. private _sortBones;
  89771. }
  89772. }
  89773. declare module BABYLON {
  89774. /**
  89775. * Creates an instance based on a source mesh.
  89776. */
  89777. export class InstancedMesh extends AbstractMesh {
  89778. private _sourceMesh;
  89779. private _currentLOD;
  89780. /** @hidden */
  89781. _indexInSourceMeshInstanceArray: number;
  89782. constructor(name: string, source: Mesh);
  89783. /**
  89784. * Returns the string "InstancedMesh".
  89785. */
  89786. getClassName(): string;
  89787. /** Gets the list of lights affecting that mesh */
  89788. get lightSources(): Light[];
  89789. _resyncLightSources(): void;
  89790. _resyncLightSource(light: Light): void;
  89791. _removeLightSource(light: Light, dispose: boolean): void;
  89792. /**
  89793. * If the source mesh receives shadows
  89794. */
  89795. get receiveShadows(): boolean;
  89796. /**
  89797. * The material of the source mesh
  89798. */
  89799. get material(): Nullable<Material>;
  89800. /**
  89801. * Visibility of the source mesh
  89802. */
  89803. get visibility(): number;
  89804. /**
  89805. * Skeleton of the source mesh
  89806. */
  89807. get skeleton(): Nullable<Skeleton>;
  89808. /**
  89809. * Rendering ground id of the source mesh
  89810. */
  89811. get renderingGroupId(): number;
  89812. set renderingGroupId(value: number);
  89813. /**
  89814. * Returns the total number of vertices (integer).
  89815. */
  89816. getTotalVertices(): number;
  89817. /**
  89818. * Returns a positive integer : the total number of indices in this mesh geometry.
  89819. * @returns the numner of indices or zero if the mesh has no geometry.
  89820. */
  89821. getTotalIndices(): number;
  89822. /**
  89823. * The source mesh of the instance
  89824. */
  89825. get sourceMesh(): Mesh;
  89826. /**
  89827. * Is this node ready to be used/rendered
  89828. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  89829. * @return {boolean} is it ready
  89830. */
  89831. isReady(completeCheck?: boolean): boolean;
  89832. /**
  89833. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89834. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  89835. * @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.
  89836. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  89837. */
  89838. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  89839. /**
  89840. * Sets the vertex data of the mesh geometry for the requested `kind`.
  89841. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  89842. * The `data` are either a numeric array either a Float32Array.
  89843. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  89844. * 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).
  89845. * Note that a new underlying VertexBuffer object is created each call.
  89846. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  89847. *
  89848. * Possible `kind` values :
  89849. * - VertexBuffer.PositionKind
  89850. * - VertexBuffer.UVKind
  89851. * - VertexBuffer.UV2Kind
  89852. * - VertexBuffer.UV3Kind
  89853. * - VertexBuffer.UV4Kind
  89854. * - VertexBuffer.UV5Kind
  89855. * - VertexBuffer.UV6Kind
  89856. * - VertexBuffer.ColorKind
  89857. * - VertexBuffer.MatricesIndicesKind
  89858. * - VertexBuffer.MatricesIndicesExtraKind
  89859. * - VertexBuffer.MatricesWeightsKind
  89860. * - VertexBuffer.MatricesWeightsExtraKind
  89861. *
  89862. * Returns the Mesh.
  89863. */
  89864. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89865. /**
  89866. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  89867. * If the mesh has no geometry, it is simply returned as it is.
  89868. * The `data` are either a numeric array either a Float32Array.
  89869. * No new underlying VertexBuffer object is created.
  89870. * 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.
  89871. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  89872. *
  89873. * Possible `kind` values :
  89874. * - VertexBuffer.PositionKind
  89875. * - VertexBuffer.UVKind
  89876. * - VertexBuffer.UV2Kind
  89877. * - VertexBuffer.UV3Kind
  89878. * - VertexBuffer.UV4Kind
  89879. * - VertexBuffer.UV5Kind
  89880. * - VertexBuffer.UV6Kind
  89881. * - VertexBuffer.ColorKind
  89882. * - VertexBuffer.MatricesIndicesKind
  89883. * - VertexBuffer.MatricesIndicesExtraKind
  89884. * - VertexBuffer.MatricesWeightsKind
  89885. * - VertexBuffer.MatricesWeightsExtraKind
  89886. *
  89887. * Returns the Mesh.
  89888. */
  89889. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  89890. /**
  89891. * Sets the mesh indices.
  89892. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  89893. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  89894. * This method creates a new index buffer each call.
  89895. * Returns the Mesh.
  89896. */
  89897. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  89898. /**
  89899. * Boolean : True if the mesh owns the requested kind of data.
  89900. */
  89901. isVerticesDataPresent(kind: string): boolean;
  89902. /**
  89903. * Returns an array of indices (IndicesArray).
  89904. */
  89905. getIndices(): Nullable<IndicesArray>;
  89906. get _positions(): Nullable<Vector3[]>;
  89907. /**
  89908. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89909. * This means the mesh underlying bounding box and sphere are recomputed.
  89910. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89911. * @returns the current mesh
  89912. */
  89913. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  89914. /** @hidden */
  89915. _preActivate(): InstancedMesh;
  89916. /** @hidden */
  89917. _activate(renderId: number, intermediateRendering: boolean): boolean;
  89918. /** @hidden */
  89919. _postActivate(): void;
  89920. getWorldMatrix(): Matrix;
  89921. get isAnInstance(): boolean;
  89922. /**
  89923. * Returns the current associated LOD AbstractMesh.
  89924. */
  89925. getLOD(camera: Camera): AbstractMesh;
  89926. /** @hidden */
  89927. _preActivateForIntermediateRendering(renderId: number): Mesh;
  89928. /** @hidden */
  89929. _syncSubMeshes(): InstancedMesh;
  89930. /** @hidden */
  89931. _generatePointsArray(): boolean;
  89932. /**
  89933. * Creates a new InstancedMesh from the current mesh.
  89934. * - name (string) : the cloned mesh name
  89935. * - newParent (optional Node) : the optional Node to parent the clone to.
  89936. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  89937. *
  89938. * Returns the clone.
  89939. */
  89940. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  89941. /**
  89942. * Disposes the InstancedMesh.
  89943. * Returns nothing.
  89944. */
  89945. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89946. }
  89947. interface Mesh {
  89948. /**
  89949. * Register a custom buffer that will be instanced
  89950. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  89951. * @param kind defines the buffer kind
  89952. * @param stride defines the stride in floats
  89953. */
  89954. registerInstancedBuffer(kind: string, stride: number): void;
  89955. /** @hidden */
  89956. _userInstancedBuffersStorage: {
  89957. data: {
  89958. [key: string]: Float32Array;
  89959. };
  89960. sizes: {
  89961. [key: string]: number;
  89962. };
  89963. vertexBuffers: {
  89964. [key: string]: Nullable<VertexBuffer>;
  89965. };
  89966. strides: {
  89967. [key: string]: number;
  89968. };
  89969. };
  89970. }
  89971. interface AbstractMesh {
  89972. /**
  89973. * Object used to store instanced buffers defined by user
  89974. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  89975. */
  89976. instancedBuffers: {
  89977. [key: string]: any;
  89978. };
  89979. }
  89980. }
  89981. declare module BABYLON {
  89982. /**
  89983. * Defines the options associated with the creation of a shader material.
  89984. */
  89985. export interface IShaderMaterialOptions {
  89986. /**
  89987. * Does the material work in alpha blend mode
  89988. */
  89989. needAlphaBlending: boolean;
  89990. /**
  89991. * Does the material work in alpha test mode
  89992. */
  89993. needAlphaTesting: boolean;
  89994. /**
  89995. * The list of attribute names used in the shader
  89996. */
  89997. attributes: string[];
  89998. /**
  89999. * The list of unifrom names used in the shader
  90000. */
  90001. uniforms: string[];
  90002. /**
  90003. * The list of UBO names used in the shader
  90004. */
  90005. uniformBuffers: string[];
  90006. /**
  90007. * The list of sampler names used in the shader
  90008. */
  90009. samplers: string[];
  90010. /**
  90011. * The list of defines used in the shader
  90012. */
  90013. defines: string[];
  90014. }
  90015. /**
  90016. * 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.
  90017. *
  90018. * This returned material effects how the mesh will look based on the code in the shaders.
  90019. *
  90020. * @see http://doc.babylonjs.com/how_to/shader_material
  90021. */
  90022. export class ShaderMaterial extends Material {
  90023. private _shaderPath;
  90024. private _options;
  90025. private _textures;
  90026. private _textureArrays;
  90027. private _floats;
  90028. private _ints;
  90029. private _floatsArrays;
  90030. private _colors3;
  90031. private _colors3Arrays;
  90032. private _colors4;
  90033. private _colors4Arrays;
  90034. private _vectors2;
  90035. private _vectors3;
  90036. private _vectors4;
  90037. private _matrices;
  90038. private _matrixArrays;
  90039. private _matrices3x3;
  90040. private _matrices2x2;
  90041. private _vectors2Arrays;
  90042. private _vectors3Arrays;
  90043. private _vectors4Arrays;
  90044. private _cachedWorldViewMatrix;
  90045. private _cachedWorldViewProjectionMatrix;
  90046. private _renderId;
  90047. private _multiview;
  90048. private _cachedDefines;
  90049. /**
  90050. * Instantiate a new shader material.
  90051. * 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.
  90052. * This returned material effects how the mesh will look based on the code in the shaders.
  90053. * @see http://doc.babylonjs.com/how_to/shader_material
  90054. * @param name Define the name of the material in the scene
  90055. * @param scene Define the scene the material belongs to
  90056. * @param shaderPath Defines the route to the shader code in one of three ways:
  90057. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  90058. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  90059. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  90060. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  90061. * @param options Define the options used to create the shader
  90062. */
  90063. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  90064. /**
  90065. * Gets the shader path used to define the shader code
  90066. * It can be modified to trigger a new compilation
  90067. */
  90068. get shaderPath(): any;
  90069. /**
  90070. * Sets the shader path used to define the shader code
  90071. * It can be modified to trigger a new compilation
  90072. */
  90073. set shaderPath(shaderPath: any);
  90074. /**
  90075. * Gets the options used to compile the shader.
  90076. * They can be modified to trigger a new compilation
  90077. */
  90078. get options(): IShaderMaterialOptions;
  90079. /**
  90080. * Gets the current class name of the material e.g. "ShaderMaterial"
  90081. * Mainly use in serialization.
  90082. * @returns the class name
  90083. */
  90084. getClassName(): string;
  90085. /**
  90086. * Specifies if the material will require alpha blending
  90087. * @returns a boolean specifying if alpha blending is needed
  90088. */
  90089. needAlphaBlending(): boolean;
  90090. /**
  90091. * Specifies if this material should be rendered in alpha test mode
  90092. * @returns a boolean specifying if an alpha test is needed.
  90093. */
  90094. needAlphaTesting(): boolean;
  90095. private _checkUniform;
  90096. /**
  90097. * Set a texture in the shader.
  90098. * @param name Define the name of the uniform samplers as defined in the shader
  90099. * @param texture Define the texture to bind to this sampler
  90100. * @return the material itself allowing "fluent" like uniform updates
  90101. */
  90102. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  90103. /**
  90104. * Set a texture array in the shader.
  90105. * @param name Define the name of the uniform sampler array as defined in the shader
  90106. * @param textures Define the list of textures to bind to this sampler
  90107. * @return the material itself allowing "fluent" like uniform updates
  90108. */
  90109. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  90110. /**
  90111. * Set a float in the shader.
  90112. * @param name Define the name of the uniform as defined in the shader
  90113. * @param value Define the value to give to the uniform
  90114. * @return the material itself allowing "fluent" like uniform updates
  90115. */
  90116. setFloat(name: string, value: number): ShaderMaterial;
  90117. /**
  90118. * Set a int in the shader.
  90119. * @param name Define the name of the uniform as defined in the shader
  90120. * @param value Define the value to give to the uniform
  90121. * @return the material itself allowing "fluent" like uniform updates
  90122. */
  90123. setInt(name: string, value: number): ShaderMaterial;
  90124. /**
  90125. * Set an array of floats in the shader.
  90126. * @param name Define the name of the uniform as defined in the shader
  90127. * @param value Define the value to give to the uniform
  90128. * @return the material itself allowing "fluent" like uniform updates
  90129. */
  90130. setFloats(name: string, value: number[]): ShaderMaterial;
  90131. /**
  90132. * Set a vec3 in the shader from a Color3.
  90133. * @param name Define the name of the uniform as defined in the shader
  90134. * @param value Define the value to give to the uniform
  90135. * @return the material itself allowing "fluent" like uniform updates
  90136. */
  90137. setColor3(name: string, value: Color3): ShaderMaterial;
  90138. /**
  90139. * Set a vec3 array in the shader from a Color3 array.
  90140. * @param name Define the name of the uniform as defined in the shader
  90141. * @param value Define the value to give to the uniform
  90142. * @return the material itself allowing "fluent" like uniform updates
  90143. */
  90144. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  90145. /**
  90146. * Set a vec4 in the shader from a Color4.
  90147. * @param name Define the name of the uniform as defined in the shader
  90148. * @param value Define the value to give to the uniform
  90149. * @return the material itself allowing "fluent" like uniform updates
  90150. */
  90151. setColor4(name: string, value: Color4): ShaderMaterial;
  90152. /**
  90153. * Set a vec4 array in the shader from a Color4 array.
  90154. * @param name Define the name of the uniform as defined in the shader
  90155. * @param value Define the value to give to the uniform
  90156. * @return the material itself allowing "fluent" like uniform updates
  90157. */
  90158. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  90159. /**
  90160. * Set a vec2 in the shader from a Vector2.
  90161. * @param name Define the name of the uniform as defined in the shader
  90162. * @param value Define the value to give to the uniform
  90163. * @return the material itself allowing "fluent" like uniform updates
  90164. */
  90165. setVector2(name: string, value: Vector2): ShaderMaterial;
  90166. /**
  90167. * Set a vec3 in the shader from a Vector3.
  90168. * @param name Define the name of the uniform as defined in the shader
  90169. * @param value Define the value to give to the uniform
  90170. * @return the material itself allowing "fluent" like uniform updates
  90171. */
  90172. setVector3(name: string, value: Vector3): ShaderMaterial;
  90173. /**
  90174. * Set a vec4 in the shader from a Vector4.
  90175. * @param name Define the name of the uniform as defined in the shader
  90176. * @param value Define the value to give to the uniform
  90177. * @return the material itself allowing "fluent" like uniform updates
  90178. */
  90179. setVector4(name: string, value: Vector4): ShaderMaterial;
  90180. /**
  90181. * Set a mat4 in the shader from a Matrix.
  90182. * @param name Define the name of the uniform as defined in the shader
  90183. * @param value Define the value to give to the uniform
  90184. * @return the material itself allowing "fluent" like uniform updates
  90185. */
  90186. setMatrix(name: string, value: Matrix): ShaderMaterial;
  90187. /**
  90188. * Set a float32Array in the shader from a matrix array.
  90189. * @param name Define the name of the uniform as defined in the shader
  90190. * @param value Define the value to give to the uniform
  90191. * @return the material itself allowing "fluent" like uniform updates
  90192. */
  90193. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  90194. /**
  90195. * Set a mat3 in the shader from a Float32Array.
  90196. * @param name Define the name of the uniform as defined in the shader
  90197. * @param value Define the value to give to the uniform
  90198. * @return the material itself allowing "fluent" like uniform updates
  90199. */
  90200. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  90201. /**
  90202. * Set a mat2 in the shader from a Float32Array.
  90203. * @param name Define the name of the uniform as defined in the shader
  90204. * @param value Define the value to give to the uniform
  90205. * @return the material itself allowing "fluent" like uniform updates
  90206. */
  90207. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  90208. /**
  90209. * Set a vec2 array in the shader from a number array.
  90210. * @param name Define the name of the uniform as defined in the shader
  90211. * @param value Define the value to give to the uniform
  90212. * @return the material itself allowing "fluent" like uniform updates
  90213. */
  90214. setArray2(name: string, value: number[]): ShaderMaterial;
  90215. /**
  90216. * Set a vec3 array in the shader from a number array.
  90217. * @param name Define the name of the uniform as defined in the shader
  90218. * @param value Define the value to give to the uniform
  90219. * @return the material itself allowing "fluent" like uniform updates
  90220. */
  90221. setArray3(name: string, value: number[]): ShaderMaterial;
  90222. /**
  90223. * Set a vec4 array in the shader from a number array.
  90224. * @param name Define the name of the uniform as defined in the shader
  90225. * @param value Define the value to give to the uniform
  90226. * @return the material itself allowing "fluent" like uniform updates
  90227. */
  90228. setArray4(name: string, value: number[]): ShaderMaterial;
  90229. private _checkCache;
  90230. /**
  90231. * Specifies that the submesh is ready to be used
  90232. * @param mesh defines the mesh to check
  90233. * @param subMesh defines which submesh to check
  90234. * @param useInstances specifies that instances should be used
  90235. * @returns a boolean indicating that the submesh is ready or not
  90236. */
  90237. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  90238. /**
  90239. * Checks if the material is ready to render the requested mesh
  90240. * @param mesh Define the mesh to render
  90241. * @param useInstances Define whether or not the material is used with instances
  90242. * @returns true if ready, otherwise false
  90243. */
  90244. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  90245. /**
  90246. * Binds the world matrix to the material
  90247. * @param world defines the world transformation matrix
  90248. * @param effectOverride - If provided, use this effect instead of internal effect
  90249. */
  90250. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  90251. /**
  90252. * Binds the submesh to this material by preparing the effect and shader to draw
  90253. * @param world defines the world transformation matrix
  90254. * @param mesh defines the mesh containing the submesh
  90255. * @param subMesh defines the submesh to bind the material to
  90256. */
  90257. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  90258. /**
  90259. * Binds the material to the mesh
  90260. * @param world defines the world transformation matrix
  90261. * @param mesh defines the mesh to bind the material to
  90262. * @param effectOverride - If provided, use this effect instead of internal effect
  90263. */
  90264. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  90265. protected _afterBind(mesh?: Mesh): void;
  90266. /**
  90267. * Gets the active textures from the material
  90268. * @returns an array of textures
  90269. */
  90270. getActiveTextures(): BaseTexture[];
  90271. /**
  90272. * Specifies if the material uses a texture
  90273. * @param texture defines the texture to check against the material
  90274. * @returns a boolean specifying if the material uses the texture
  90275. */
  90276. hasTexture(texture: BaseTexture): boolean;
  90277. /**
  90278. * Makes a duplicate of the material, and gives it a new name
  90279. * @param name defines the new name for the duplicated material
  90280. * @returns the cloned material
  90281. */
  90282. clone(name: string): ShaderMaterial;
  90283. /**
  90284. * Disposes the material
  90285. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  90286. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  90287. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  90288. */
  90289. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  90290. /**
  90291. * Serializes this material in a JSON representation
  90292. * @returns the serialized material object
  90293. */
  90294. serialize(): any;
  90295. /**
  90296. * Creates a shader material from parsed shader material data
  90297. * @param source defines the JSON represnetation of the material
  90298. * @param scene defines the hosting scene
  90299. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  90300. * @returns a new material
  90301. */
  90302. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  90303. }
  90304. }
  90305. declare module BABYLON {
  90306. /** @hidden */
  90307. export var colorPixelShader: {
  90308. name: string;
  90309. shader: string;
  90310. };
  90311. }
  90312. declare module BABYLON {
  90313. /** @hidden */
  90314. export var colorVertexShader: {
  90315. name: string;
  90316. shader: string;
  90317. };
  90318. }
  90319. declare module BABYLON {
  90320. /**
  90321. * Line mesh
  90322. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  90323. */
  90324. export class LinesMesh extends Mesh {
  90325. /**
  90326. * If vertex color should be applied to the mesh
  90327. */
  90328. readonly useVertexColor?: boolean | undefined;
  90329. /**
  90330. * If vertex alpha should be applied to the mesh
  90331. */
  90332. readonly useVertexAlpha?: boolean | undefined;
  90333. /**
  90334. * Color of the line (Default: White)
  90335. */
  90336. color: Color3;
  90337. /**
  90338. * Alpha of the line (Default: 1)
  90339. */
  90340. alpha: number;
  90341. /**
  90342. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  90343. * This margin is expressed in world space coordinates, so its value may vary.
  90344. * Default value is 0.1
  90345. */
  90346. intersectionThreshold: number;
  90347. private _colorShader;
  90348. private color4;
  90349. /**
  90350. * Creates a new LinesMesh
  90351. * @param name defines the name
  90352. * @param scene defines the hosting scene
  90353. * @param parent defines the parent mesh if any
  90354. * @param source defines the optional source LinesMesh used to clone data from
  90355. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  90356. * When false, achieved by calling a clone(), also passing False.
  90357. * This will make creation of children, recursive.
  90358. * @param useVertexColor defines if this LinesMesh supports vertex color
  90359. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  90360. */
  90361. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  90362. /**
  90363. * If vertex color should be applied to the mesh
  90364. */
  90365. useVertexColor?: boolean | undefined,
  90366. /**
  90367. * If vertex alpha should be applied to the mesh
  90368. */
  90369. useVertexAlpha?: boolean | undefined);
  90370. private _addClipPlaneDefine;
  90371. private _removeClipPlaneDefine;
  90372. isReady(): boolean;
  90373. /**
  90374. * Returns the string "LineMesh"
  90375. */
  90376. getClassName(): string;
  90377. /**
  90378. * @hidden
  90379. */
  90380. get material(): Material;
  90381. /**
  90382. * @hidden
  90383. */
  90384. set material(value: Material);
  90385. /**
  90386. * @hidden
  90387. */
  90388. get checkCollisions(): boolean;
  90389. /** @hidden */
  90390. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  90391. /** @hidden */
  90392. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  90393. /**
  90394. * Disposes of the line mesh
  90395. * @param doNotRecurse If children should be disposed
  90396. */
  90397. dispose(doNotRecurse?: boolean): void;
  90398. /**
  90399. * Returns a new LineMesh object cloned from the current one.
  90400. */
  90401. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  90402. /**
  90403. * Creates a new InstancedLinesMesh object from the mesh model.
  90404. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90405. * @param name defines the name of the new instance
  90406. * @returns a new InstancedLinesMesh
  90407. */
  90408. createInstance(name: string): InstancedLinesMesh;
  90409. }
  90410. /**
  90411. * Creates an instance based on a source LinesMesh
  90412. */
  90413. export class InstancedLinesMesh extends InstancedMesh {
  90414. /**
  90415. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  90416. * This margin is expressed in world space coordinates, so its value may vary.
  90417. * Initilized with the intersectionThreshold value of the source LinesMesh
  90418. */
  90419. intersectionThreshold: number;
  90420. constructor(name: string, source: LinesMesh);
  90421. /**
  90422. * Returns the string "InstancedLinesMesh".
  90423. */
  90424. getClassName(): string;
  90425. }
  90426. }
  90427. declare module BABYLON {
  90428. /** @hidden */
  90429. export var linePixelShader: {
  90430. name: string;
  90431. shader: string;
  90432. };
  90433. }
  90434. declare module BABYLON {
  90435. /** @hidden */
  90436. export var lineVertexShader: {
  90437. name: string;
  90438. shader: string;
  90439. };
  90440. }
  90441. declare module BABYLON {
  90442. interface AbstractMesh {
  90443. /**
  90444. * Gets the edgesRenderer associated with the mesh
  90445. */
  90446. edgesRenderer: Nullable<EdgesRenderer>;
  90447. }
  90448. interface LinesMesh {
  90449. /**
  90450. * Enables the edge rendering mode on the mesh.
  90451. * This mode makes the mesh edges visible
  90452. * @param epsilon defines the maximal distance between two angles to detect a face
  90453. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90454. * @returns the currentAbstractMesh
  90455. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90456. */
  90457. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  90458. }
  90459. interface InstancedLinesMesh {
  90460. /**
  90461. * Enables the edge rendering mode on the mesh.
  90462. * This mode makes the mesh edges visible
  90463. * @param epsilon defines the maximal distance between two angles to detect a face
  90464. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90465. * @returns the current InstancedLinesMesh
  90466. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90467. */
  90468. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  90469. }
  90470. /**
  90471. * Defines the minimum contract an Edges renderer should follow.
  90472. */
  90473. export interface IEdgesRenderer extends IDisposable {
  90474. /**
  90475. * Gets or sets a boolean indicating if the edgesRenderer is active
  90476. */
  90477. isEnabled: boolean;
  90478. /**
  90479. * Renders the edges of the attached mesh,
  90480. */
  90481. render(): void;
  90482. /**
  90483. * Checks wether or not the edges renderer is ready to render.
  90484. * @return true if ready, otherwise false.
  90485. */
  90486. isReady(): boolean;
  90487. }
  90488. /**
  90489. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  90490. */
  90491. export class EdgesRenderer implements IEdgesRenderer {
  90492. /**
  90493. * Define the size of the edges with an orthographic camera
  90494. */
  90495. edgesWidthScalerForOrthographic: number;
  90496. /**
  90497. * Define the size of the edges with a perspective camera
  90498. */
  90499. edgesWidthScalerForPerspective: number;
  90500. protected _source: AbstractMesh;
  90501. protected _linesPositions: number[];
  90502. protected _linesNormals: number[];
  90503. protected _linesIndices: number[];
  90504. protected _epsilon: number;
  90505. protected _indicesCount: number;
  90506. protected _lineShader: ShaderMaterial;
  90507. protected _ib: DataBuffer;
  90508. protected _buffers: {
  90509. [key: string]: Nullable<VertexBuffer>;
  90510. };
  90511. protected _checkVerticesInsteadOfIndices: boolean;
  90512. private _meshRebuildObserver;
  90513. private _meshDisposeObserver;
  90514. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  90515. isEnabled: boolean;
  90516. /**
  90517. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  90518. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  90519. * @param source Mesh used to create edges
  90520. * @param epsilon sum of angles in adjacency to check for edge
  90521. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  90522. * @param generateEdgesLines - should generate Lines or only prepare resources.
  90523. */
  90524. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  90525. protected _prepareRessources(): void;
  90526. /** @hidden */
  90527. _rebuild(): void;
  90528. /**
  90529. * Releases the required resources for the edges renderer
  90530. */
  90531. dispose(): void;
  90532. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  90533. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  90534. /**
  90535. * Checks if the pair of p0 and p1 is en edge
  90536. * @param faceIndex
  90537. * @param edge
  90538. * @param faceNormals
  90539. * @param p0
  90540. * @param p1
  90541. * @private
  90542. */
  90543. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  90544. /**
  90545. * push line into the position, normal and index buffer
  90546. * @protected
  90547. */
  90548. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  90549. /**
  90550. * Generates lines edges from adjacencjes
  90551. * @private
  90552. */
  90553. _generateEdgesLines(): void;
  90554. /**
  90555. * Checks wether or not the edges renderer is ready to render.
  90556. * @return true if ready, otherwise false.
  90557. */
  90558. isReady(): boolean;
  90559. /**
  90560. * Renders the edges of the attached mesh,
  90561. */
  90562. render(): void;
  90563. }
  90564. /**
  90565. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  90566. */
  90567. export class LineEdgesRenderer extends EdgesRenderer {
  90568. /**
  90569. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  90570. * @param source LineMesh used to generate edges
  90571. * @param epsilon not important (specified angle for edge detection)
  90572. * @param checkVerticesInsteadOfIndices not important for LineMesh
  90573. */
  90574. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  90575. /**
  90576. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  90577. */
  90578. _generateEdgesLines(): void;
  90579. }
  90580. }
  90581. declare module BABYLON {
  90582. /**
  90583. * This represents the object necessary to create a rendering group.
  90584. * This is exclusively used and created by the rendering manager.
  90585. * To modify the behavior, you use the available helpers in your scene or meshes.
  90586. * @hidden
  90587. */
  90588. export class RenderingGroup {
  90589. index: number;
  90590. private static _zeroVector;
  90591. private _scene;
  90592. private _opaqueSubMeshes;
  90593. private _transparentSubMeshes;
  90594. private _alphaTestSubMeshes;
  90595. private _depthOnlySubMeshes;
  90596. private _particleSystems;
  90597. private _spriteManagers;
  90598. private _opaqueSortCompareFn;
  90599. private _alphaTestSortCompareFn;
  90600. private _transparentSortCompareFn;
  90601. private _renderOpaque;
  90602. private _renderAlphaTest;
  90603. private _renderTransparent;
  90604. /** @hidden */
  90605. _edgesRenderers: SmartArray<IEdgesRenderer>;
  90606. onBeforeTransparentRendering: () => void;
  90607. /**
  90608. * Set the opaque sort comparison function.
  90609. * If null the sub meshes will be render in the order they were created
  90610. */
  90611. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90612. /**
  90613. * Set the alpha test sort comparison function.
  90614. * If null the sub meshes will be render in the order they were created
  90615. */
  90616. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90617. /**
  90618. * Set the transparent sort comparison function.
  90619. * If null the sub meshes will be render in the order they were created
  90620. */
  90621. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90622. /**
  90623. * Creates a new rendering group.
  90624. * @param index The rendering group index
  90625. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  90626. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  90627. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  90628. */
  90629. 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>);
  90630. /**
  90631. * Render all the sub meshes contained in the group.
  90632. * @param customRenderFunction Used to override the default render behaviour of the group.
  90633. * @returns true if rendered some submeshes.
  90634. */
  90635. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  90636. /**
  90637. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  90638. * @param subMeshes The submeshes to render
  90639. */
  90640. private renderOpaqueSorted;
  90641. /**
  90642. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  90643. * @param subMeshes The submeshes to render
  90644. */
  90645. private renderAlphaTestSorted;
  90646. /**
  90647. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  90648. * @param subMeshes The submeshes to render
  90649. */
  90650. private renderTransparentSorted;
  90651. /**
  90652. * Renders the submeshes in a specified order.
  90653. * @param subMeshes The submeshes to sort before render
  90654. * @param sortCompareFn The comparison function use to sort
  90655. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  90656. * @param transparent Specifies to activate blending if true
  90657. */
  90658. private static renderSorted;
  90659. /**
  90660. * Renders the submeshes in the order they were dispatched (no sort applied).
  90661. * @param subMeshes The submeshes to render
  90662. */
  90663. private static renderUnsorted;
  90664. /**
  90665. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90666. * are rendered back to front if in the same alpha index.
  90667. *
  90668. * @param a The first submesh
  90669. * @param b The second submesh
  90670. * @returns The result of the comparison
  90671. */
  90672. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  90673. /**
  90674. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90675. * are rendered back to front.
  90676. *
  90677. * @param a The first submesh
  90678. * @param b The second submesh
  90679. * @returns The result of the comparison
  90680. */
  90681. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  90682. /**
  90683. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90684. * are rendered front to back (prevent overdraw).
  90685. *
  90686. * @param a The first submesh
  90687. * @param b The second submesh
  90688. * @returns The result of the comparison
  90689. */
  90690. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  90691. /**
  90692. * Resets the different lists of submeshes to prepare a new frame.
  90693. */
  90694. prepare(): void;
  90695. dispose(): void;
  90696. /**
  90697. * Inserts the submesh in its correct queue depending on its material.
  90698. * @param subMesh The submesh to dispatch
  90699. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  90700. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  90701. */
  90702. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  90703. dispatchSprites(spriteManager: ISpriteManager): void;
  90704. dispatchParticles(particleSystem: IParticleSystem): void;
  90705. private _renderParticles;
  90706. private _renderSprites;
  90707. }
  90708. }
  90709. declare module BABYLON {
  90710. /**
  90711. * Interface describing the different options available in the rendering manager
  90712. * regarding Auto Clear between groups.
  90713. */
  90714. export interface IRenderingManagerAutoClearSetup {
  90715. /**
  90716. * Defines whether or not autoclear is enable.
  90717. */
  90718. autoClear: boolean;
  90719. /**
  90720. * Defines whether or not to autoclear the depth buffer.
  90721. */
  90722. depth: boolean;
  90723. /**
  90724. * Defines whether or not to autoclear the stencil buffer.
  90725. */
  90726. stencil: boolean;
  90727. }
  90728. /**
  90729. * This class is used by the onRenderingGroupObservable
  90730. */
  90731. export class RenderingGroupInfo {
  90732. /**
  90733. * The Scene that being rendered
  90734. */
  90735. scene: Scene;
  90736. /**
  90737. * The camera currently used for the rendering pass
  90738. */
  90739. camera: Nullable<Camera>;
  90740. /**
  90741. * The ID of the renderingGroup being processed
  90742. */
  90743. renderingGroupId: number;
  90744. }
  90745. /**
  90746. * This is the manager responsible of all the rendering for meshes sprites and particles.
  90747. * It is enable to manage the different groups as well as the different necessary sort functions.
  90748. * This should not be used directly aside of the few static configurations
  90749. */
  90750. export class RenderingManager {
  90751. /**
  90752. * The max id used for rendering groups (not included)
  90753. */
  90754. static MAX_RENDERINGGROUPS: number;
  90755. /**
  90756. * The min id used for rendering groups (included)
  90757. */
  90758. static MIN_RENDERINGGROUPS: number;
  90759. /**
  90760. * Used to globally prevent autoclearing scenes.
  90761. */
  90762. static AUTOCLEAR: boolean;
  90763. /**
  90764. * @hidden
  90765. */
  90766. _useSceneAutoClearSetup: boolean;
  90767. private _scene;
  90768. private _renderingGroups;
  90769. private _depthStencilBufferAlreadyCleaned;
  90770. private _autoClearDepthStencil;
  90771. private _customOpaqueSortCompareFn;
  90772. private _customAlphaTestSortCompareFn;
  90773. private _customTransparentSortCompareFn;
  90774. private _renderingGroupInfo;
  90775. /**
  90776. * Instantiates a new rendering group for a particular scene
  90777. * @param scene Defines the scene the groups belongs to
  90778. */
  90779. constructor(scene: Scene);
  90780. private _clearDepthStencilBuffer;
  90781. /**
  90782. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  90783. * @hidden
  90784. */
  90785. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  90786. /**
  90787. * Resets the different information of the group to prepare a new frame
  90788. * @hidden
  90789. */
  90790. reset(): void;
  90791. /**
  90792. * Dispose and release the group and its associated resources.
  90793. * @hidden
  90794. */
  90795. dispose(): void;
  90796. /**
  90797. * Clear the info related to rendering groups preventing retention points during dispose.
  90798. */
  90799. freeRenderingGroups(): void;
  90800. private _prepareRenderingGroup;
  90801. /**
  90802. * Add a sprite manager to the rendering manager in order to render it this frame.
  90803. * @param spriteManager Define the sprite manager to render
  90804. */
  90805. dispatchSprites(spriteManager: ISpriteManager): void;
  90806. /**
  90807. * Add a particle system to the rendering manager in order to render it this frame.
  90808. * @param particleSystem Define the particle system to render
  90809. */
  90810. dispatchParticles(particleSystem: IParticleSystem): void;
  90811. /**
  90812. * Add a submesh to the manager in order to render it this frame
  90813. * @param subMesh The submesh to dispatch
  90814. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  90815. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  90816. */
  90817. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  90818. /**
  90819. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  90820. * This allowed control for front to back rendering or reversly depending of the special needs.
  90821. *
  90822. * @param renderingGroupId The rendering group id corresponding to its index
  90823. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  90824. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  90825. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  90826. */
  90827. 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;
  90828. /**
  90829. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  90830. *
  90831. * @param renderingGroupId The rendering group id corresponding to its index
  90832. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  90833. * @param depth Automatically clears depth between groups if true and autoClear is true.
  90834. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  90835. */
  90836. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  90837. /**
  90838. * Gets the current auto clear configuration for one rendering group of the rendering
  90839. * manager.
  90840. * @param index the rendering group index to get the information for
  90841. * @returns The auto clear setup for the requested rendering group
  90842. */
  90843. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  90844. }
  90845. }
  90846. declare module BABYLON {
  90847. /**
  90848. * Defines the options associated with the creation of a custom shader for a shadow generator.
  90849. */
  90850. export interface ICustomShaderOptions {
  90851. /**
  90852. * Gets or sets the custom shader name to use
  90853. */
  90854. shaderName: string;
  90855. /**
  90856. * The list of attribute names used in the shader
  90857. */
  90858. attributes?: string[];
  90859. /**
  90860. * The list of unifrom names used in the shader
  90861. */
  90862. uniforms?: string[];
  90863. /**
  90864. * The list of sampler names used in the shader
  90865. */
  90866. samplers?: string[];
  90867. /**
  90868. * The list of defines used in the shader
  90869. */
  90870. defines?: string[];
  90871. }
  90872. /**
  90873. * Interface to implement to create a shadow generator compatible with BJS.
  90874. */
  90875. export interface IShadowGenerator {
  90876. /**
  90877. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  90878. * @returns The render target texture if present otherwise, null
  90879. */
  90880. getShadowMap(): Nullable<RenderTargetTexture>;
  90881. /**
  90882. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  90883. * @param subMesh The submesh we want to render in the shadow map
  90884. * @param useInstances Defines wether will draw in the map using instances
  90885. * @returns true if ready otherwise, false
  90886. */
  90887. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  90888. /**
  90889. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  90890. * @param defines Defines of the material we want to update
  90891. * @param lightIndex Index of the light in the enabled light list of the material
  90892. */
  90893. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  90894. /**
  90895. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  90896. * defined in the generator but impacting the effect).
  90897. * It implies the unifroms available on the materials are the standard BJS ones.
  90898. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  90899. * @param effect The effect we are binfing the information for
  90900. */
  90901. bindShadowLight(lightIndex: string, effect: Effect): void;
  90902. /**
  90903. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  90904. * (eq to shadow prjection matrix * light transform matrix)
  90905. * @returns The transform matrix used to create the shadow map
  90906. */
  90907. getTransformMatrix(): Matrix;
  90908. /**
  90909. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  90910. * Cube and 2D textures for instance.
  90911. */
  90912. recreateShadowMap(): void;
  90913. /**
  90914. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  90915. * @param onCompiled Callback triggered at the and of the effects compilation
  90916. * @param options Sets of optional options forcing the compilation with different modes
  90917. */
  90918. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  90919. useInstances: boolean;
  90920. }>): void;
  90921. /**
  90922. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  90923. * @param options Sets of optional options forcing the compilation with different modes
  90924. * @returns A promise that resolves when the compilation completes
  90925. */
  90926. forceCompilationAsync(options?: Partial<{
  90927. useInstances: boolean;
  90928. }>): Promise<void>;
  90929. /**
  90930. * Serializes the shadow generator setup to a json object.
  90931. * @returns The serialized JSON object
  90932. */
  90933. serialize(): any;
  90934. /**
  90935. * Disposes the Shadow map and related Textures and effects.
  90936. */
  90937. dispose(): void;
  90938. }
  90939. /**
  90940. * Default implementation IShadowGenerator.
  90941. * This is the main object responsible of generating shadows in the framework.
  90942. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  90943. */
  90944. export class ShadowGenerator implements IShadowGenerator {
  90945. /**
  90946. * Name of the shadow generator class
  90947. */
  90948. static CLASSNAME: string;
  90949. /**
  90950. * Shadow generator mode None: no filtering applied.
  90951. */
  90952. static readonly FILTER_NONE: number;
  90953. /**
  90954. * Shadow generator mode ESM: Exponential Shadow Mapping.
  90955. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  90956. */
  90957. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  90958. /**
  90959. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  90960. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  90961. */
  90962. static readonly FILTER_POISSONSAMPLING: number;
  90963. /**
  90964. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  90965. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  90966. */
  90967. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  90968. /**
  90969. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  90970. * edge artifacts on steep falloff.
  90971. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  90972. */
  90973. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  90974. /**
  90975. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  90976. * edge artifacts on steep falloff.
  90977. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  90978. */
  90979. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  90980. /**
  90981. * Shadow generator mode PCF: Percentage Closer Filtering
  90982. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  90983. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  90984. */
  90985. static readonly FILTER_PCF: number;
  90986. /**
  90987. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  90988. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  90989. * Contact Hardening
  90990. */
  90991. static readonly FILTER_PCSS: number;
  90992. /**
  90993. * Reserved for PCF and PCSS
  90994. * Highest Quality.
  90995. *
  90996. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  90997. *
  90998. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  90999. */
  91000. static readonly QUALITY_HIGH: number;
  91001. /**
  91002. * Reserved for PCF and PCSS
  91003. * Good tradeoff for quality/perf cross devices
  91004. *
  91005. * Execute PCF on a 3*3 kernel.
  91006. *
  91007. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  91008. */
  91009. static readonly QUALITY_MEDIUM: number;
  91010. /**
  91011. * Reserved for PCF and PCSS
  91012. * The lowest quality but the fastest.
  91013. *
  91014. * Execute PCF on a 1*1 kernel.
  91015. *
  91016. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  91017. */
  91018. static readonly QUALITY_LOW: number;
  91019. /** Gets or sets the custom shader name to use */
  91020. customShaderOptions: ICustomShaderOptions;
  91021. /**
  91022. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  91023. */
  91024. onBeforeShadowMapRenderObservable: Observable<Effect>;
  91025. /**
  91026. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  91027. */
  91028. onAfterShadowMapRenderObservable: Observable<Effect>;
  91029. /**
  91030. * Observable triggered before a mesh is rendered in the shadow map.
  91031. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  91032. */
  91033. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  91034. /**
  91035. * Observable triggered after a mesh is rendered in the shadow map.
  91036. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  91037. */
  91038. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  91039. protected _bias: number;
  91040. /**
  91041. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  91042. */
  91043. get bias(): number;
  91044. /**
  91045. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  91046. */
  91047. set bias(bias: number);
  91048. protected _normalBias: number;
  91049. /**
  91050. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  91051. */
  91052. get normalBias(): number;
  91053. /**
  91054. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  91055. */
  91056. set normalBias(normalBias: number);
  91057. protected _blurBoxOffset: number;
  91058. /**
  91059. * Gets the blur box offset: offset applied during the blur pass.
  91060. * Only useful if useKernelBlur = false
  91061. */
  91062. get blurBoxOffset(): number;
  91063. /**
  91064. * Sets the blur box offset: offset applied during the blur pass.
  91065. * Only useful if useKernelBlur = false
  91066. */
  91067. set blurBoxOffset(value: number);
  91068. protected _blurScale: number;
  91069. /**
  91070. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  91071. * 2 means half of the size.
  91072. */
  91073. get blurScale(): number;
  91074. /**
  91075. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  91076. * 2 means half of the size.
  91077. */
  91078. set blurScale(value: number);
  91079. protected _blurKernel: number;
  91080. /**
  91081. * Gets the blur kernel: kernel size of the blur pass.
  91082. * Only useful if useKernelBlur = true
  91083. */
  91084. get blurKernel(): number;
  91085. /**
  91086. * Sets the blur kernel: kernel size of the blur pass.
  91087. * Only useful if useKernelBlur = true
  91088. */
  91089. set blurKernel(value: number);
  91090. protected _useKernelBlur: boolean;
  91091. /**
  91092. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  91093. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  91094. */
  91095. get useKernelBlur(): boolean;
  91096. /**
  91097. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  91098. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  91099. */
  91100. set useKernelBlur(value: boolean);
  91101. protected _depthScale: number;
  91102. /**
  91103. * Gets the depth scale used in ESM mode.
  91104. */
  91105. get depthScale(): number;
  91106. /**
  91107. * Sets the depth scale used in ESM mode.
  91108. * This can override the scale stored on the light.
  91109. */
  91110. set depthScale(value: number);
  91111. protected _validateFilter(filter: number): number;
  91112. protected _filter: number;
  91113. /**
  91114. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  91115. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  91116. */
  91117. get filter(): number;
  91118. /**
  91119. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  91120. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  91121. */
  91122. set filter(value: number);
  91123. /**
  91124. * Gets if the current filter is set to Poisson Sampling.
  91125. */
  91126. get usePoissonSampling(): boolean;
  91127. /**
  91128. * Sets the current filter to Poisson Sampling.
  91129. */
  91130. set usePoissonSampling(value: boolean);
  91131. /**
  91132. * Gets if the current filter is set to ESM.
  91133. */
  91134. get useExponentialShadowMap(): boolean;
  91135. /**
  91136. * Sets the current filter is to ESM.
  91137. */
  91138. set useExponentialShadowMap(value: boolean);
  91139. /**
  91140. * Gets if the current filter is set to filtered ESM.
  91141. */
  91142. get useBlurExponentialShadowMap(): boolean;
  91143. /**
  91144. * Gets if the current filter is set to filtered ESM.
  91145. */
  91146. set useBlurExponentialShadowMap(value: boolean);
  91147. /**
  91148. * Gets if the current filter is set to "close ESM" (using the inverse of the
  91149. * exponential to prevent steep falloff artifacts).
  91150. */
  91151. get useCloseExponentialShadowMap(): boolean;
  91152. /**
  91153. * Sets the current filter to "close ESM" (using the inverse of the
  91154. * exponential to prevent steep falloff artifacts).
  91155. */
  91156. set useCloseExponentialShadowMap(value: boolean);
  91157. /**
  91158. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  91159. * exponential to prevent steep falloff artifacts).
  91160. */
  91161. get useBlurCloseExponentialShadowMap(): boolean;
  91162. /**
  91163. * Sets the current filter to filtered "close ESM" (using the inverse of the
  91164. * exponential to prevent steep falloff artifacts).
  91165. */
  91166. set useBlurCloseExponentialShadowMap(value: boolean);
  91167. /**
  91168. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  91169. */
  91170. get usePercentageCloserFiltering(): boolean;
  91171. /**
  91172. * Sets the current filter to "PCF" (percentage closer filtering).
  91173. */
  91174. set usePercentageCloserFiltering(value: boolean);
  91175. protected _filteringQuality: number;
  91176. /**
  91177. * Gets the PCF or PCSS Quality.
  91178. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  91179. */
  91180. get filteringQuality(): number;
  91181. /**
  91182. * Sets the PCF or PCSS Quality.
  91183. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  91184. */
  91185. set filteringQuality(filteringQuality: number);
  91186. /**
  91187. * Gets if the current filter is set to "PCSS" (contact hardening).
  91188. */
  91189. get useContactHardeningShadow(): boolean;
  91190. /**
  91191. * Sets the current filter to "PCSS" (contact hardening).
  91192. */
  91193. set useContactHardeningShadow(value: boolean);
  91194. protected _contactHardeningLightSizeUVRatio: number;
  91195. /**
  91196. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  91197. * Using a ratio helps keeping shape stability independently of the map size.
  91198. *
  91199. * It does not account for the light projection as it was having too much
  91200. * instability during the light setup or during light position changes.
  91201. *
  91202. * Only valid if useContactHardeningShadow is true.
  91203. */
  91204. get contactHardeningLightSizeUVRatio(): number;
  91205. /**
  91206. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  91207. * Using a ratio helps keeping shape stability independently of the map size.
  91208. *
  91209. * It does not account for the light projection as it was having too much
  91210. * instability during the light setup or during light position changes.
  91211. *
  91212. * Only valid if useContactHardeningShadow is true.
  91213. */
  91214. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  91215. protected _darkness: number;
  91216. /** Gets or sets the actual darkness of a shadow */
  91217. get darkness(): number;
  91218. set darkness(value: number);
  91219. /**
  91220. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  91221. * 0 means strongest and 1 would means no shadow.
  91222. * @returns the darkness.
  91223. */
  91224. getDarkness(): number;
  91225. /**
  91226. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  91227. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  91228. * @returns the shadow generator allowing fluent coding.
  91229. */
  91230. setDarkness(darkness: number): ShadowGenerator;
  91231. protected _transparencyShadow: boolean;
  91232. /** Gets or sets the ability to have transparent shadow */
  91233. get transparencyShadow(): boolean;
  91234. set transparencyShadow(value: boolean);
  91235. /**
  91236. * Sets the ability to have transparent shadow (boolean).
  91237. * @param transparent True if transparent else False
  91238. * @returns the shadow generator allowing fluent coding
  91239. */
  91240. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  91241. protected _shadowMap: Nullable<RenderTargetTexture>;
  91242. protected _shadowMap2: Nullable<RenderTargetTexture>;
  91243. /**
  91244. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  91245. * @returns The render target texture if present otherwise, null
  91246. */
  91247. getShadowMap(): Nullable<RenderTargetTexture>;
  91248. /**
  91249. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  91250. * @returns The render target texture if the shadow map is present otherwise, null
  91251. */
  91252. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  91253. /**
  91254. * Gets the class name of that object
  91255. * @returns "ShadowGenerator"
  91256. */
  91257. getClassName(): string;
  91258. /**
  91259. * Helper function to add a mesh and its descendants to the list of shadow casters.
  91260. * @param mesh Mesh to add
  91261. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  91262. * @returns the Shadow Generator itself
  91263. */
  91264. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  91265. /**
  91266. * Helper function to remove a mesh and its descendants from the list of shadow casters
  91267. * @param mesh Mesh to remove
  91268. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  91269. * @returns the Shadow Generator itself
  91270. */
  91271. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  91272. /**
  91273. * Controls the extent to which the shadows fade out at the edge of the frustum
  91274. */
  91275. frustumEdgeFalloff: number;
  91276. protected _light: IShadowLight;
  91277. /**
  91278. * Returns the associated light object.
  91279. * @returns the light generating the shadow
  91280. */
  91281. getLight(): IShadowLight;
  91282. /**
  91283. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  91284. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  91285. * It might on the other hand introduce peter panning.
  91286. */
  91287. forceBackFacesOnly: boolean;
  91288. protected _scene: Scene;
  91289. protected _lightDirection: Vector3;
  91290. protected _effect: Effect;
  91291. protected _viewMatrix: Matrix;
  91292. protected _projectionMatrix: Matrix;
  91293. protected _transformMatrix: Matrix;
  91294. protected _cachedPosition: Vector3;
  91295. protected _cachedDirection: Vector3;
  91296. protected _cachedDefines: string;
  91297. protected _currentRenderID: number;
  91298. protected _boxBlurPostprocess: Nullable<PostProcess>;
  91299. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  91300. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  91301. protected _blurPostProcesses: PostProcess[];
  91302. protected _mapSize: number;
  91303. protected _currentFaceIndex: number;
  91304. protected _currentFaceIndexCache: number;
  91305. protected _textureType: number;
  91306. protected _defaultTextureMatrix: Matrix;
  91307. protected _storedUniqueId: Nullable<number>;
  91308. /** @hidden */
  91309. static _SceneComponentInitialization: (scene: Scene) => void;
  91310. /**
  91311. * Creates a ShadowGenerator object.
  91312. * A ShadowGenerator is the required tool to use the shadows.
  91313. * Each light casting shadows needs to use its own ShadowGenerator.
  91314. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  91315. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  91316. * @param light The light object generating the shadows.
  91317. * @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.
  91318. */
  91319. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  91320. protected _initializeGenerator(): void;
  91321. protected _createTargetRenderTexture(): void;
  91322. protected _initializeShadowMap(): void;
  91323. protected _initializeBlurRTTAndPostProcesses(): void;
  91324. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  91325. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  91326. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  91327. protected _applyFilterValues(): void;
  91328. /**
  91329. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  91330. * @param onCompiled Callback triggered at the and of the effects compilation
  91331. * @param options Sets of optional options forcing the compilation with different modes
  91332. */
  91333. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  91334. useInstances: boolean;
  91335. }>): void;
  91336. /**
  91337. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  91338. * @param options Sets of optional options forcing the compilation with different modes
  91339. * @returns A promise that resolves when the compilation completes
  91340. */
  91341. forceCompilationAsync(options?: Partial<{
  91342. useInstances: boolean;
  91343. }>): Promise<void>;
  91344. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  91345. private _prepareShadowDefines;
  91346. /**
  91347. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  91348. * @param subMesh The submesh we want to render in the shadow map
  91349. * @param useInstances Defines wether will draw in the map using instances
  91350. * @returns true if ready otherwise, false
  91351. */
  91352. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  91353. /**
  91354. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  91355. * @param defines Defines of the material we want to update
  91356. * @param lightIndex Index of the light in the enabled light list of the material
  91357. */
  91358. prepareDefines(defines: any, lightIndex: number): void;
  91359. /**
  91360. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  91361. * defined in the generator but impacting the effect).
  91362. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  91363. * @param effect The effect we are binfing the information for
  91364. */
  91365. bindShadowLight(lightIndex: string, effect: Effect): void;
  91366. /**
  91367. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  91368. * (eq to shadow prjection matrix * light transform matrix)
  91369. * @returns The transform matrix used to create the shadow map
  91370. */
  91371. getTransformMatrix(): Matrix;
  91372. /**
  91373. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  91374. * Cube and 2D textures for instance.
  91375. */
  91376. recreateShadowMap(): void;
  91377. protected _disposeBlurPostProcesses(): void;
  91378. protected _disposeRTTandPostProcesses(): void;
  91379. /**
  91380. * Disposes the ShadowGenerator.
  91381. * Returns nothing.
  91382. */
  91383. dispose(): void;
  91384. /**
  91385. * Serializes the shadow generator setup to a json object.
  91386. * @returns The serialized JSON object
  91387. */
  91388. serialize(): any;
  91389. /**
  91390. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  91391. * @param parsedShadowGenerator The JSON object to parse
  91392. * @param scene The scene to create the shadow map for
  91393. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  91394. * @returns The parsed shadow generator
  91395. */
  91396. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  91397. }
  91398. }
  91399. declare module BABYLON {
  91400. /**
  91401. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  91402. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  91403. * 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.
  91404. */
  91405. export abstract class Light extends Node {
  91406. /**
  91407. * Falloff Default: light is falling off following the material specification:
  91408. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  91409. */
  91410. static readonly FALLOFF_DEFAULT: number;
  91411. /**
  91412. * Falloff Physical: light is falling off following the inverse squared distance law.
  91413. */
  91414. static readonly FALLOFF_PHYSICAL: number;
  91415. /**
  91416. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  91417. * to enhance interoperability with other engines.
  91418. */
  91419. static readonly FALLOFF_GLTF: number;
  91420. /**
  91421. * Falloff Standard: light is falling off like in the standard material
  91422. * to enhance interoperability with other materials.
  91423. */
  91424. static readonly FALLOFF_STANDARD: number;
  91425. /**
  91426. * If every light affecting the material is in this lightmapMode,
  91427. * material.lightmapTexture adds or multiplies
  91428. * (depends on material.useLightmapAsShadowmap)
  91429. * after every other light calculations.
  91430. */
  91431. static readonly LIGHTMAP_DEFAULT: number;
  91432. /**
  91433. * material.lightmapTexture as only diffuse lighting from this light
  91434. * adds only specular lighting from this light
  91435. * adds dynamic shadows
  91436. */
  91437. static readonly LIGHTMAP_SPECULAR: number;
  91438. /**
  91439. * material.lightmapTexture as only lighting
  91440. * no light calculation from this light
  91441. * only adds dynamic shadows from this light
  91442. */
  91443. static readonly LIGHTMAP_SHADOWSONLY: number;
  91444. /**
  91445. * Each light type uses the default quantity according to its type:
  91446. * point/spot lights use luminous intensity
  91447. * directional lights use illuminance
  91448. */
  91449. static readonly INTENSITYMODE_AUTOMATIC: number;
  91450. /**
  91451. * lumen (lm)
  91452. */
  91453. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  91454. /**
  91455. * candela (lm/sr)
  91456. */
  91457. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  91458. /**
  91459. * lux (lm/m^2)
  91460. */
  91461. static readonly INTENSITYMODE_ILLUMINANCE: number;
  91462. /**
  91463. * nit (cd/m^2)
  91464. */
  91465. static readonly INTENSITYMODE_LUMINANCE: number;
  91466. /**
  91467. * Light type const id of the point light.
  91468. */
  91469. static readonly LIGHTTYPEID_POINTLIGHT: number;
  91470. /**
  91471. * Light type const id of the directional light.
  91472. */
  91473. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  91474. /**
  91475. * Light type const id of the spot light.
  91476. */
  91477. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  91478. /**
  91479. * Light type const id of the hemispheric light.
  91480. */
  91481. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  91482. /**
  91483. * Diffuse gives the basic color to an object.
  91484. */
  91485. diffuse: Color3;
  91486. /**
  91487. * Specular produces a highlight color on an object.
  91488. * Note: This is note affecting PBR materials.
  91489. */
  91490. specular: Color3;
  91491. /**
  91492. * Defines the falloff type for this light. This lets overrriding how punctual light are
  91493. * falling off base on range or angle.
  91494. * This can be set to any values in Light.FALLOFF_x.
  91495. *
  91496. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  91497. * other types of materials.
  91498. */
  91499. falloffType: number;
  91500. /**
  91501. * Strength of the light.
  91502. * Note: By default it is define in the framework own unit.
  91503. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  91504. */
  91505. intensity: number;
  91506. private _range;
  91507. protected _inverseSquaredRange: number;
  91508. /**
  91509. * Defines how far from the source the light is impacting in scene units.
  91510. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  91511. */
  91512. get range(): number;
  91513. /**
  91514. * Defines how far from the source the light is impacting in scene units.
  91515. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  91516. */
  91517. set range(value: number);
  91518. /**
  91519. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  91520. * of light.
  91521. */
  91522. private _photometricScale;
  91523. private _intensityMode;
  91524. /**
  91525. * Gets the photometric scale used to interpret the intensity.
  91526. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  91527. */
  91528. get intensityMode(): number;
  91529. /**
  91530. * Sets the photometric scale used to interpret the intensity.
  91531. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  91532. */
  91533. set intensityMode(value: number);
  91534. private _radius;
  91535. /**
  91536. * Gets the light radius used by PBR Materials to simulate soft area lights.
  91537. */
  91538. get radius(): number;
  91539. /**
  91540. * sets the light radius used by PBR Materials to simulate soft area lights.
  91541. */
  91542. set radius(value: number);
  91543. private _renderPriority;
  91544. /**
  91545. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  91546. * exceeding the number allowed of the materials.
  91547. */
  91548. renderPriority: number;
  91549. private _shadowEnabled;
  91550. /**
  91551. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  91552. * the current shadow generator.
  91553. */
  91554. get shadowEnabled(): boolean;
  91555. /**
  91556. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  91557. * the current shadow generator.
  91558. */
  91559. set shadowEnabled(value: boolean);
  91560. private _includedOnlyMeshes;
  91561. /**
  91562. * Gets the only meshes impacted by this light.
  91563. */
  91564. get includedOnlyMeshes(): AbstractMesh[];
  91565. /**
  91566. * Sets the only meshes impacted by this light.
  91567. */
  91568. set includedOnlyMeshes(value: AbstractMesh[]);
  91569. private _excludedMeshes;
  91570. /**
  91571. * Gets the meshes not impacted by this light.
  91572. */
  91573. get excludedMeshes(): AbstractMesh[];
  91574. /**
  91575. * Sets the meshes not impacted by this light.
  91576. */
  91577. set excludedMeshes(value: AbstractMesh[]);
  91578. private _excludeWithLayerMask;
  91579. /**
  91580. * Gets the layer id use to find what meshes are not impacted by the light.
  91581. * Inactive if 0
  91582. */
  91583. get excludeWithLayerMask(): number;
  91584. /**
  91585. * Sets the layer id use to find what meshes are not impacted by the light.
  91586. * Inactive if 0
  91587. */
  91588. set excludeWithLayerMask(value: number);
  91589. private _includeOnlyWithLayerMask;
  91590. /**
  91591. * Gets the layer id use to find what meshes are impacted by the light.
  91592. * Inactive if 0
  91593. */
  91594. get includeOnlyWithLayerMask(): number;
  91595. /**
  91596. * Sets the layer id use to find what meshes are impacted by the light.
  91597. * Inactive if 0
  91598. */
  91599. set includeOnlyWithLayerMask(value: number);
  91600. private _lightmapMode;
  91601. /**
  91602. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  91603. */
  91604. get lightmapMode(): number;
  91605. /**
  91606. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  91607. */
  91608. set lightmapMode(value: number);
  91609. /**
  91610. * Shadow generator associted to the light.
  91611. * @hidden Internal use only.
  91612. */
  91613. _shadowGenerator: Nullable<IShadowGenerator>;
  91614. /**
  91615. * @hidden Internal use only.
  91616. */
  91617. _excludedMeshesIds: string[];
  91618. /**
  91619. * @hidden Internal use only.
  91620. */
  91621. _includedOnlyMeshesIds: string[];
  91622. /**
  91623. * The current light unifom buffer.
  91624. * @hidden Internal use only.
  91625. */
  91626. _uniformBuffer: UniformBuffer;
  91627. /** @hidden */
  91628. _renderId: number;
  91629. /**
  91630. * Creates a Light object in the scene.
  91631. * Documentation : https://doc.babylonjs.com/babylon101/lights
  91632. * @param name The firendly name of the light
  91633. * @param scene The scene the light belongs too
  91634. */
  91635. constructor(name: string, scene: Scene);
  91636. protected abstract _buildUniformLayout(): void;
  91637. /**
  91638. * Sets the passed Effect "effect" with the Light information.
  91639. * @param effect The effect to update
  91640. * @param lightIndex The index of the light in the effect to update
  91641. * @returns The light
  91642. */
  91643. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  91644. /**
  91645. * Sets the passed Effect "effect" with the Light textures.
  91646. * @param effect The effect to update
  91647. * @param lightIndex The index of the light in the effect to update
  91648. * @returns The light
  91649. */
  91650. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  91651. /**
  91652. * Binds the lights information from the scene to the effect for the given mesh.
  91653. * @param lightIndex Light index
  91654. * @param scene The scene where the light belongs to
  91655. * @param effect The effect we are binding the data to
  91656. * @param useSpecular Defines if specular is supported
  91657. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  91658. */
  91659. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  91660. /**
  91661. * Sets the passed Effect "effect" with the Light information.
  91662. * @param effect The effect to update
  91663. * @param lightDataUniformName The uniform used to store light data (position or direction)
  91664. * @returns The light
  91665. */
  91666. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  91667. /**
  91668. * Returns the string "Light".
  91669. * @returns the class name
  91670. */
  91671. getClassName(): string;
  91672. /** @hidden */
  91673. readonly _isLight: boolean;
  91674. /**
  91675. * Converts the light information to a readable string for debug purpose.
  91676. * @param fullDetails Supports for multiple levels of logging within scene loading
  91677. * @returns the human readable light info
  91678. */
  91679. toString(fullDetails?: boolean): string;
  91680. /** @hidden */
  91681. protected _syncParentEnabledState(): void;
  91682. /**
  91683. * Set the enabled state of this node.
  91684. * @param value - the new enabled state
  91685. */
  91686. setEnabled(value: boolean): void;
  91687. /**
  91688. * Returns the Light associated shadow generator if any.
  91689. * @return the associated shadow generator.
  91690. */
  91691. getShadowGenerator(): Nullable<IShadowGenerator>;
  91692. /**
  91693. * Returns a Vector3, the absolute light position in the World.
  91694. * @returns the world space position of the light
  91695. */
  91696. getAbsolutePosition(): Vector3;
  91697. /**
  91698. * Specifies if the light will affect the passed mesh.
  91699. * @param mesh The mesh to test against the light
  91700. * @return true the mesh is affected otherwise, false.
  91701. */
  91702. canAffectMesh(mesh: AbstractMesh): boolean;
  91703. /**
  91704. * Sort function to order lights for rendering.
  91705. * @param a First Light object to compare to second.
  91706. * @param b Second Light object to compare first.
  91707. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  91708. */
  91709. static CompareLightsPriority(a: Light, b: Light): number;
  91710. /**
  91711. * Releases resources associated with this node.
  91712. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91713. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91714. */
  91715. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91716. /**
  91717. * Returns the light type ID (integer).
  91718. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  91719. */
  91720. getTypeID(): number;
  91721. /**
  91722. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  91723. * @returns the scaled intensity in intensity mode unit
  91724. */
  91725. getScaledIntensity(): number;
  91726. /**
  91727. * Returns a new Light object, named "name", from the current one.
  91728. * @param name The name of the cloned light
  91729. * @returns the new created light
  91730. */
  91731. clone(name: string): Nullable<Light>;
  91732. /**
  91733. * Serializes the current light into a Serialization object.
  91734. * @returns the serialized object.
  91735. */
  91736. serialize(): any;
  91737. /**
  91738. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  91739. * This new light is named "name" and added to the passed scene.
  91740. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  91741. * @param name The friendly name of the light
  91742. * @param scene The scene the new light will belong to
  91743. * @returns the constructor function
  91744. */
  91745. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  91746. /**
  91747. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  91748. * @param parsedLight The JSON representation of the light
  91749. * @param scene The scene to create the parsed light in
  91750. * @returns the created light after parsing
  91751. */
  91752. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  91753. private _hookArrayForExcluded;
  91754. private _hookArrayForIncludedOnly;
  91755. private _resyncMeshes;
  91756. /**
  91757. * Forces the meshes to update their light related information in their rendering used effects
  91758. * @hidden Internal Use Only
  91759. */
  91760. _markMeshesAsLightDirty(): void;
  91761. /**
  91762. * Recomputes the cached photometric scale if needed.
  91763. */
  91764. private _computePhotometricScale;
  91765. /**
  91766. * Returns the Photometric Scale according to the light type and intensity mode.
  91767. */
  91768. private _getPhotometricScale;
  91769. /**
  91770. * Reorder the light in the scene according to their defined priority.
  91771. * @hidden Internal Use Only
  91772. */
  91773. _reorderLightsInScene(): void;
  91774. /**
  91775. * Prepares the list of defines specific to the light type.
  91776. * @param defines the list of defines
  91777. * @param lightIndex defines the index of the light for the effect
  91778. */
  91779. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  91780. }
  91781. }
  91782. declare module BABYLON {
  91783. /**
  91784. * Interface used to define Action
  91785. */
  91786. export interface IAction {
  91787. /**
  91788. * Trigger for the action
  91789. */
  91790. trigger: number;
  91791. /** Options of the trigger */
  91792. triggerOptions: any;
  91793. /**
  91794. * Gets the trigger parameters
  91795. * @returns the trigger parameters
  91796. */
  91797. getTriggerParameter(): any;
  91798. /**
  91799. * Internal only - executes current action event
  91800. * @hidden
  91801. */
  91802. _executeCurrent(evt?: ActionEvent): void;
  91803. /**
  91804. * Serialize placeholder for child classes
  91805. * @param parent of child
  91806. * @returns the serialized object
  91807. */
  91808. serialize(parent: any): any;
  91809. /**
  91810. * Internal only
  91811. * @hidden
  91812. */
  91813. _prepare(): void;
  91814. /**
  91815. * Internal only - manager for action
  91816. * @hidden
  91817. */
  91818. _actionManager: AbstractActionManager;
  91819. /**
  91820. * Adds action to chain of actions, may be a DoNothingAction
  91821. * @param action defines the next action to execute
  91822. * @returns The action passed in
  91823. * @see https://www.babylonjs-playground.com/#1T30HR#0
  91824. */
  91825. then(action: IAction): IAction;
  91826. }
  91827. /**
  91828. * The action to be carried out following a trigger
  91829. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  91830. */
  91831. export class Action implements IAction {
  91832. /** the trigger, with or without parameters, for the action */
  91833. triggerOptions: any;
  91834. /**
  91835. * Trigger for the action
  91836. */
  91837. trigger: number;
  91838. /**
  91839. * Internal only - manager for action
  91840. * @hidden
  91841. */
  91842. _actionManager: ActionManager;
  91843. private _nextActiveAction;
  91844. private _child;
  91845. private _condition?;
  91846. private _triggerParameter;
  91847. /**
  91848. * An event triggered prior to action being executed.
  91849. */
  91850. onBeforeExecuteObservable: Observable<Action>;
  91851. /**
  91852. * Creates a new Action
  91853. * @param triggerOptions the trigger, with or without parameters, for the action
  91854. * @param condition an optional determinant of action
  91855. */
  91856. constructor(
  91857. /** the trigger, with or without parameters, for the action */
  91858. triggerOptions: any, condition?: Condition);
  91859. /**
  91860. * Internal only
  91861. * @hidden
  91862. */
  91863. _prepare(): void;
  91864. /**
  91865. * Gets the trigger parameters
  91866. * @returns the trigger parameters
  91867. */
  91868. getTriggerParameter(): any;
  91869. /**
  91870. * Internal only - executes current action event
  91871. * @hidden
  91872. */
  91873. _executeCurrent(evt?: ActionEvent): void;
  91874. /**
  91875. * Execute placeholder for child classes
  91876. * @param evt optional action event
  91877. */
  91878. execute(evt?: ActionEvent): void;
  91879. /**
  91880. * Skips to next active action
  91881. */
  91882. skipToNextActiveAction(): void;
  91883. /**
  91884. * Adds action to chain of actions, may be a DoNothingAction
  91885. * @param action defines the next action to execute
  91886. * @returns The action passed in
  91887. * @see https://www.babylonjs-playground.com/#1T30HR#0
  91888. */
  91889. then(action: Action): Action;
  91890. /**
  91891. * Internal only
  91892. * @hidden
  91893. */
  91894. _getProperty(propertyPath: string): string;
  91895. /**
  91896. * Internal only
  91897. * @hidden
  91898. */
  91899. _getEffectiveTarget(target: any, propertyPath: string): any;
  91900. /**
  91901. * Serialize placeholder for child classes
  91902. * @param parent of child
  91903. * @returns the serialized object
  91904. */
  91905. serialize(parent: any): any;
  91906. /**
  91907. * Internal only called by serialize
  91908. * @hidden
  91909. */
  91910. protected _serialize(serializedAction: any, parent?: any): any;
  91911. /**
  91912. * Internal only
  91913. * @hidden
  91914. */
  91915. static _SerializeValueAsString: (value: any) => string;
  91916. /**
  91917. * Internal only
  91918. * @hidden
  91919. */
  91920. static _GetTargetProperty: (target: Node | Scene) => {
  91921. name: string;
  91922. targetType: string;
  91923. value: string;
  91924. };
  91925. }
  91926. }
  91927. declare module BABYLON {
  91928. /**
  91929. * A Condition applied to an Action
  91930. */
  91931. export class Condition {
  91932. /**
  91933. * Internal only - manager for action
  91934. * @hidden
  91935. */
  91936. _actionManager: ActionManager;
  91937. /**
  91938. * Internal only
  91939. * @hidden
  91940. */
  91941. _evaluationId: number;
  91942. /**
  91943. * Internal only
  91944. * @hidden
  91945. */
  91946. _currentResult: boolean;
  91947. /**
  91948. * Creates a new Condition
  91949. * @param actionManager the manager of the action the condition is applied to
  91950. */
  91951. constructor(actionManager: ActionManager);
  91952. /**
  91953. * Check if the current condition is valid
  91954. * @returns a boolean
  91955. */
  91956. isValid(): boolean;
  91957. /**
  91958. * Internal only
  91959. * @hidden
  91960. */
  91961. _getProperty(propertyPath: string): string;
  91962. /**
  91963. * Internal only
  91964. * @hidden
  91965. */
  91966. _getEffectiveTarget(target: any, propertyPath: string): any;
  91967. /**
  91968. * Serialize placeholder for child classes
  91969. * @returns the serialized object
  91970. */
  91971. serialize(): any;
  91972. /**
  91973. * Internal only
  91974. * @hidden
  91975. */
  91976. protected _serialize(serializedCondition: any): any;
  91977. }
  91978. /**
  91979. * Defines specific conditional operators as extensions of Condition
  91980. */
  91981. export class ValueCondition extends Condition {
  91982. /** path to specify the property of the target the conditional operator uses */
  91983. propertyPath: string;
  91984. /** the value compared by the conditional operator against the current value of the property */
  91985. value: any;
  91986. /** the conditional operator, default ValueCondition.IsEqual */
  91987. operator: number;
  91988. /**
  91989. * Internal only
  91990. * @hidden
  91991. */
  91992. private static _IsEqual;
  91993. /**
  91994. * Internal only
  91995. * @hidden
  91996. */
  91997. private static _IsDifferent;
  91998. /**
  91999. * Internal only
  92000. * @hidden
  92001. */
  92002. private static _IsGreater;
  92003. /**
  92004. * Internal only
  92005. * @hidden
  92006. */
  92007. private static _IsLesser;
  92008. /**
  92009. * returns the number for IsEqual
  92010. */
  92011. static get IsEqual(): number;
  92012. /**
  92013. * Returns the number for IsDifferent
  92014. */
  92015. static get IsDifferent(): number;
  92016. /**
  92017. * Returns the number for IsGreater
  92018. */
  92019. static get IsGreater(): number;
  92020. /**
  92021. * Returns the number for IsLesser
  92022. */
  92023. static get IsLesser(): number;
  92024. /**
  92025. * Internal only The action manager for the condition
  92026. * @hidden
  92027. */
  92028. _actionManager: ActionManager;
  92029. /**
  92030. * Internal only
  92031. * @hidden
  92032. */
  92033. private _target;
  92034. /**
  92035. * Internal only
  92036. * @hidden
  92037. */
  92038. private _effectiveTarget;
  92039. /**
  92040. * Internal only
  92041. * @hidden
  92042. */
  92043. private _property;
  92044. /**
  92045. * Creates a new ValueCondition
  92046. * @param actionManager manager for the action the condition applies to
  92047. * @param target for the action
  92048. * @param propertyPath path to specify the property of the target the conditional operator uses
  92049. * @param value the value compared by the conditional operator against the current value of the property
  92050. * @param operator the conditional operator, default ValueCondition.IsEqual
  92051. */
  92052. constructor(actionManager: ActionManager, target: any,
  92053. /** path to specify the property of the target the conditional operator uses */
  92054. propertyPath: string,
  92055. /** the value compared by the conditional operator against the current value of the property */
  92056. value: any,
  92057. /** the conditional operator, default ValueCondition.IsEqual */
  92058. operator?: number);
  92059. /**
  92060. * Compares the given value with the property value for the specified conditional operator
  92061. * @returns the result of the comparison
  92062. */
  92063. isValid(): boolean;
  92064. /**
  92065. * Serialize the ValueCondition into a JSON compatible object
  92066. * @returns serialization object
  92067. */
  92068. serialize(): any;
  92069. /**
  92070. * Gets the name of the conditional operator for the ValueCondition
  92071. * @param operator the conditional operator
  92072. * @returns the name
  92073. */
  92074. static GetOperatorName(operator: number): string;
  92075. }
  92076. /**
  92077. * Defines a predicate condition as an extension of Condition
  92078. */
  92079. export class PredicateCondition extends Condition {
  92080. /** defines the predicate function used to validate the condition */
  92081. predicate: () => boolean;
  92082. /**
  92083. * Internal only - manager for action
  92084. * @hidden
  92085. */
  92086. _actionManager: ActionManager;
  92087. /**
  92088. * Creates a new PredicateCondition
  92089. * @param actionManager manager for the action the condition applies to
  92090. * @param predicate defines the predicate function used to validate the condition
  92091. */
  92092. constructor(actionManager: ActionManager,
  92093. /** defines the predicate function used to validate the condition */
  92094. predicate: () => boolean);
  92095. /**
  92096. * @returns the validity of the predicate condition
  92097. */
  92098. isValid(): boolean;
  92099. }
  92100. /**
  92101. * Defines a state condition as an extension of Condition
  92102. */
  92103. export class StateCondition extends Condition {
  92104. /** Value to compare with target state */
  92105. value: string;
  92106. /**
  92107. * Internal only - manager for action
  92108. * @hidden
  92109. */
  92110. _actionManager: ActionManager;
  92111. /**
  92112. * Internal only
  92113. * @hidden
  92114. */
  92115. private _target;
  92116. /**
  92117. * Creates a new StateCondition
  92118. * @param actionManager manager for the action the condition applies to
  92119. * @param target of the condition
  92120. * @param value to compare with target state
  92121. */
  92122. constructor(actionManager: ActionManager, target: any,
  92123. /** Value to compare with target state */
  92124. value: string);
  92125. /**
  92126. * Gets a boolean indicating if the current condition is met
  92127. * @returns the validity of the state
  92128. */
  92129. isValid(): boolean;
  92130. /**
  92131. * Serialize the StateCondition into a JSON compatible object
  92132. * @returns serialization object
  92133. */
  92134. serialize(): any;
  92135. }
  92136. }
  92137. declare module BABYLON {
  92138. /**
  92139. * This defines an action responsible to toggle a boolean once triggered.
  92140. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92141. */
  92142. export class SwitchBooleanAction extends Action {
  92143. /**
  92144. * The path to the boolean property in the target object
  92145. */
  92146. propertyPath: string;
  92147. private _target;
  92148. private _effectiveTarget;
  92149. private _property;
  92150. /**
  92151. * Instantiate the action
  92152. * @param triggerOptions defines the trigger options
  92153. * @param target defines the object containing the boolean
  92154. * @param propertyPath defines the path to the boolean property in the target object
  92155. * @param condition defines the trigger related conditions
  92156. */
  92157. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  92158. /** @hidden */
  92159. _prepare(): void;
  92160. /**
  92161. * Execute the action toggle the boolean value.
  92162. */
  92163. execute(): void;
  92164. /**
  92165. * Serializes the actions and its related information.
  92166. * @param parent defines the object to serialize in
  92167. * @returns the serialized object
  92168. */
  92169. serialize(parent: any): any;
  92170. }
  92171. /**
  92172. * This defines an action responsible to set a the state field of the target
  92173. * to a desired value once triggered.
  92174. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92175. */
  92176. export class SetStateAction extends Action {
  92177. /**
  92178. * The value to store in the state field.
  92179. */
  92180. value: string;
  92181. private _target;
  92182. /**
  92183. * Instantiate the action
  92184. * @param triggerOptions defines the trigger options
  92185. * @param target defines the object containing the state property
  92186. * @param value defines the value to store in the state field
  92187. * @param condition defines the trigger related conditions
  92188. */
  92189. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  92190. /**
  92191. * Execute the action and store the value on the target state property.
  92192. */
  92193. execute(): void;
  92194. /**
  92195. * Serializes the actions and its related information.
  92196. * @param parent defines the object to serialize in
  92197. * @returns the serialized object
  92198. */
  92199. serialize(parent: any): any;
  92200. }
  92201. /**
  92202. * This defines an action responsible to set a property of the target
  92203. * to a desired value once triggered.
  92204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92205. */
  92206. export class SetValueAction extends Action {
  92207. /**
  92208. * The path of the property to set in the target.
  92209. */
  92210. propertyPath: string;
  92211. /**
  92212. * The value to set in the property
  92213. */
  92214. value: any;
  92215. private _target;
  92216. private _effectiveTarget;
  92217. private _property;
  92218. /**
  92219. * Instantiate the action
  92220. * @param triggerOptions defines the trigger options
  92221. * @param target defines the object containing the property
  92222. * @param propertyPath defines the path of the property to set in the target
  92223. * @param value defines the value to set in the property
  92224. * @param condition defines the trigger related conditions
  92225. */
  92226. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  92227. /** @hidden */
  92228. _prepare(): void;
  92229. /**
  92230. * Execute the action and set the targetted property to the desired value.
  92231. */
  92232. execute(): void;
  92233. /**
  92234. * Serializes the actions and its related information.
  92235. * @param parent defines the object to serialize in
  92236. * @returns the serialized object
  92237. */
  92238. serialize(parent: any): any;
  92239. }
  92240. /**
  92241. * This defines an action responsible to increment the target value
  92242. * to a desired value once triggered.
  92243. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92244. */
  92245. export class IncrementValueAction extends Action {
  92246. /**
  92247. * The path of the property to increment in the target.
  92248. */
  92249. propertyPath: string;
  92250. /**
  92251. * The value we should increment the property by.
  92252. */
  92253. value: any;
  92254. private _target;
  92255. private _effectiveTarget;
  92256. private _property;
  92257. /**
  92258. * Instantiate the action
  92259. * @param triggerOptions defines the trigger options
  92260. * @param target defines the object containing the property
  92261. * @param propertyPath defines the path of the property to increment in the target
  92262. * @param value defines the value value we should increment the property by
  92263. * @param condition defines the trigger related conditions
  92264. */
  92265. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  92266. /** @hidden */
  92267. _prepare(): void;
  92268. /**
  92269. * Execute the action and increment the target of the value amount.
  92270. */
  92271. execute(): void;
  92272. /**
  92273. * Serializes the actions and its related information.
  92274. * @param parent defines the object to serialize in
  92275. * @returns the serialized object
  92276. */
  92277. serialize(parent: any): any;
  92278. }
  92279. /**
  92280. * This defines an action responsible to start an animation once triggered.
  92281. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92282. */
  92283. export class PlayAnimationAction extends Action {
  92284. /**
  92285. * Where the animation should start (animation frame)
  92286. */
  92287. from: number;
  92288. /**
  92289. * Where the animation should stop (animation frame)
  92290. */
  92291. to: number;
  92292. /**
  92293. * Define if the animation should loop or stop after the first play.
  92294. */
  92295. loop?: boolean;
  92296. private _target;
  92297. /**
  92298. * Instantiate the action
  92299. * @param triggerOptions defines the trigger options
  92300. * @param target defines the target animation or animation name
  92301. * @param from defines from where the animation should start (animation frame)
  92302. * @param end defines where the animation should stop (animation frame)
  92303. * @param loop defines if the animation should loop or stop after the first play
  92304. * @param condition defines the trigger related conditions
  92305. */
  92306. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  92307. /** @hidden */
  92308. _prepare(): void;
  92309. /**
  92310. * Execute the action and play the animation.
  92311. */
  92312. execute(): void;
  92313. /**
  92314. * Serializes the actions and its related information.
  92315. * @param parent defines the object to serialize in
  92316. * @returns the serialized object
  92317. */
  92318. serialize(parent: any): any;
  92319. }
  92320. /**
  92321. * This defines an action responsible to stop an animation once triggered.
  92322. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92323. */
  92324. export class StopAnimationAction extends Action {
  92325. private _target;
  92326. /**
  92327. * Instantiate the action
  92328. * @param triggerOptions defines the trigger options
  92329. * @param target defines the target animation or animation name
  92330. * @param condition defines the trigger related conditions
  92331. */
  92332. constructor(triggerOptions: any, target: any, condition?: Condition);
  92333. /** @hidden */
  92334. _prepare(): void;
  92335. /**
  92336. * Execute the action and stop the animation.
  92337. */
  92338. execute(): void;
  92339. /**
  92340. * Serializes the actions and its related information.
  92341. * @param parent defines the object to serialize in
  92342. * @returns the serialized object
  92343. */
  92344. serialize(parent: any): any;
  92345. }
  92346. /**
  92347. * This defines an action responsible that does nothing once triggered.
  92348. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92349. */
  92350. export class DoNothingAction extends Action {
  92351. /**
  92352. * Instantiate the action
  92353. * @param triggerOptions defines the trigger options
  92354. * @param condition defines the trigger related conditions
  92355. */
  92356. constructor(triggerOptions?: any, condition?: Condition);
  92357. /**
  92358. * Execute the action and do nothing.
  92359. */
  92360. execute(): void;
  92361. /**
  92362. * Serializes the actions and its related information.
  92363. * @param parent defines the object to serialize in
  92364. * @returns the serialized object
  92365. */
  92366. serialize(parent: any): any;
  92367. }
  92368. /**
  92369. * This defines an action responsible to trigger several actions once triggered.
  92370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92371. */
  92372. export class CombineAction extends Action {
  92373. /**
  92374. * The list of aggregated animations to run.
  92375. */
  92376. children: Action[];
  92377. /**
  92378. * Instantiate the action
  92379. * @param triggerOptions defines the trigger options
  92380. * @param children defines the list of aggregated animations to run
  92381. * @param condition defines the trigger related conditions
  92382. */
  92383. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  92384. /** @hidden */
  92385. _prepare(): void;
  92386. /**
  92387. * Execute the action and executes all the aggregated actions.
  92388. */
  92389. execute(evt: ActionEvent): void;
  92390. /**
  92391. * Serializes the actions and its related information.
  92392. * @param parent defines the object to serialize in
  92393. * @returns the serialized object
  92394. */
  92395. serialize(parent: any): any;
  92396. }
  92397. /**
  92398. * This defines an action responsible to run code (external event) once triggered.
  92399. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92400. */
  92401. export class ExecuteCodeAction extends Action {
  92402. /**
  92403. * The callback function to run.
  92404. */
  92405. func: (evt: ActionEvent) => void;
  92406. /**
  92407. * Instantiate the action
  92408. * @param triggerOptions defines the trigger options
  92409. * @param func defines the callback function to run
  92410. * @param condition defines the trigger related conditions
  92411. */
  92412. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  92413. /**
  92414. * Execute the action and run the attached code.
  92415. */
  92416. execute(evt: ActionEvent): void;
  92417. }
  92418. /**
  92419. * This defines an action responsible to set the parent property of the target once triggered.
  92420. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92421. */
  92422. export class SetParentAction extends Action {
  92423. private _parent;
  92424. private _target;
  92425. /**
  92426. * Instantiate the action
  92427. * @param triggerOptions defines the trigger options
  92428. * @param target defines the target containing the parent property
  92429. * @param parent defines from where the animation should start (animation frame)
  92430. * @param condition defines the trigger related conditions
  92431. */
  92432. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  92433. /** @hidden */
  92434. _prepare(): void;
  92435. /**
  92436. * Execute the action and set the parent property.
  92437. */
  92438. execute(): void;
  92439. /**
  92440. * Serializes the actions and its related information.
  92441. * @param parent defines the object to serialize in
  92442. * @returns the serialized object
  92443. */
  92444. serialize(parent: any): any;
  92445. }
  92446. }
  92447. declare module BABYLON {
  92448. /**
  92449. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  92450. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  92451. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92452. */
  92453. export class ActionManager extends AbstractActionManager {
  92454. /**
  92455. * Nothing
  92456. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92457. */
  92458. static readonly NothingTrigger: number;
  92459. /**
  92460. * On pick
  92461. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92462. */
  92463. static readonly OnPickTrigger: number;
  92464. /**
  92465. * On left pick
  92466. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92467. */
  92468. static readonly OnLeftPickTrigger: number;
  92469. /**
  92470. * On right pick
  92471. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92472. */
  92473. static readonly OnRightPickTrigger: number;
  92474. /**
  92475. * On center pick
  92476. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92477. */
  92478. static readonly OnCenterPickTrigger: number;
  92479. /**
  92480. * On pick down
  92481. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92482. */
  92483. static readonly OnPickDownTrigger: number;
  92484. /**
  92485. * On double pick
  92486. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92487. */
  92488. static readonly OnDoublePickTrigger: number;
  92489. /**
  92490. * On pick up
  92491. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92492. */
  92493. static readonly OnPickUpTrigger: number;
  92494. /**
  92495. * On pick out.
  92496. * This trigger will only be raised if you also declared a OnPickDown
  92497. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92498. */
  92499. static readonly OnPickOutTrigger: number;
  92500. /**
  92501. * On long press
  92502. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92503. */
  92504. static readonly OnLongPressTrigger: number;
  92505. /**
  92506. * On pointer over
  92507. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92508. */
  92509. static readonly OnPointerOverTrigger: number;
  92510. /**
  92511. * On pointer out
  92512. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92513. */
  92514. static readonly OnPointerOutTrigger: number;
  92515. /**
  92516. * On every frame
  92517. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92518. */
  92519. static readonly OnEveryFrameTrigger: number;
  92520. /**
  92521. * On intersection enter
  92522. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92523. */
  92524. static readonly OnIntersectionEnterTrigger: number;
  92525. /**
  92526. * On intersection exit
  92527. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92528. */
  92529. static readonly OnIntersectionExitTrigger: number;
  92530. /**
  92531. * On key down
  92532. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92533. */
  92534. static readonly OnKeyDownTrigger: number;
  92535. /**
  92536. * On key up
  92537. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92538. */
  92539. static readonly OnKeyUpTrigger: number;
  92540. private _scene;
  92541. /**
  92542. * Creates a new action manager
  92543. * @param scene defines the hosting scene
  92544. */
  92545. constructor(scene: Scene);
  92546. /**
  92547. * Releases all associated resources
  92548. */
  92549. dispose(): void;
  92550. /**
  92551. * Gets hosting scene
  92552. * @returns the hosting scene
  92553. */
  92554. getScene(): Scene;
  92555. /**
  92556. * Does this action manager handles actions of any of the given triggers
  92557. * @param triggers defines the triggers to be tested
  92558. * @return a boolean indicating whether one (or more) of the triggers is handled
  92559. */
  92560. hasSpecificTriggers(triggers: number[]): boolean;
  92561. /**
  92562. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  92563. * speed.
  92564. * @param triggerA defines the trigger to be tested
  92565. * @param triggerB defines the trigger to be tested
  92566. * @return a boolean indicating whether one (or more) of the triggers is handled
  92567. */
  92568. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  92569. /**
  92570. * Does this action manager handles actions of a given trigger
  92571. * @param trigger defines the trigger to be tested
  92572. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  92573. * @return whether the trigger is handled
  92574. */
  92575. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  92576. /**
  92577. * Does this action manager has pointer triggers
  92578. */
  92579. get hasPointerTriggers(): boolean;
  92580. /**
  92581. * Does this action manager has pick triggers
  92582. */
  92583. get hasPickTriggers(): boolean;
  92584. /**
  92585. * Registers an action to this action manager
  92586. * @param action defines the action to be registered
  92587. * @return the action amended (prepared) after registration
  92588. */
  92589. registerAction(action: IAction): Nullable<IAction>;
  92590. /**
  92591. * Unregisters an action to this action manager
  92592. * @param action defines the action to be unregistered
  92593. * @return a boolean indicating whether the action has been unregistered
  92594. */
  92595. unregisterAction(action: IAction): Boolean;
  92596. /**
  92597. * Process a specific trigger
  92598. * @param trigger defines the trigger to process
  92599. * @param evt defines the event details to be processed
  92600. */
  92601. processTrigger(trigger: number, evt?: IActionEvent): void;
  92602. /** @hidden */
  92603. _getEffectiveTarget(target: any, propertyPath: string): any;
  92604. /** @hidden */
  92605. _getProperty(propertyPath: string): string;
  92606. /**
  92607. * Serialize this manager to a JSON object
  92608. * @param name defines the property name to store this manager
  92609. * @returns a JSON representation of this manager
  92610. */
  92611. serialize(name: string): any;
  92612. /**
  92613. * Creates a new ActionManager from a JSON data
  92614. * @param parsedActions defines the JSON data to read from
  92615. * @param object defines the hosting mesh
  92616. * @param scene defines the hosting scene
  92617. */
  92618. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  92619. /**
  92620. * Get a trigger name by index
  92621. * @param trigger defines the trigger index
  92622. * @returns a trigger name
  92623. */
  92624. static GetTriggerName(trigger: number): string;
  92625. }
  92626. }
  92627. declare module BABYLON {
  92628. /**
  92629. * Class used to represent a sprite
  92630. * @see http://doc.babylonjs.com/babylon101/sprites
  92631. */
  92632. export class Sprite {
  92633. /** defines the name */
  92634. name: string;
  92635. /** Gets or sets the current world position */
  92636. position: Vector3;
  92637. /** Gets or sets the main color */
  92638. color: Color4;
  92639. /** Gets or sets the width */
  92640. width: number;
  92641. /** Gets or sets the height */
  92642. height: number;
  92643. /** Gets or sets rotation angle */
  92644. angle: number;
  92645. /** Gets or sets the cell index in the sprite sheet */
  92646. cellIndex: number;
  92647. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  92648. cellRef: string;
  92649. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  92650. invertU: number;
  92651. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  92652. invertV: number;
  92653. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  92654. disposeWhenFinishedAnimating: boolean;
  92655. /** Gets the list of attached animations */
  92656. animations: Animation[];
  92657. /** Gets or sets a boolean indicating if the sprite can be picked */
  92658. isPickable: boolean;
  92659. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  92660. useAlphaForPicking: boolean;
  92661. /** @hidden */
  92662. _xOffset: number;
  92663. /** @hidden */
  92664. _yOffset: number;
  92665. /** @hidden */
  92666. _xSize: number;
  92667. /** @hidden */
  92668. _ySize: number;
  92669. /**
  92670. * Gets or sets the associated action manager
  92671. */
  92672. actionManager: Nullable<ActionManager>;
  92673. private _animationStarted;
  92674. private _loopAnimation;
  92675. private _fromIndex;
  92676. private _toIndex;
  92677. private _delay;
  92678. private _direction;
  92679. private _manager;
  92680. private _time;
  92681. private _onAnimationEnd;
  92682. /**
  92683. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  92684. */
  92685. isVisible: boolean;
  92686. /**
  92687. * Gets or sets the sprite size
  92688. */
  92689. get size(): number;
  92690. set size(value: number);
  92691. /**
  92692. * Creates a new Sprite
  92693. * @param name defines the name
  92694. * @param manager defines the manager
  92695. */
  92696. constructor(
  92697. /** defines the name */
  92698. name: string, manager: ISpriteManager);
  92699. /**
  92700. * Starts an animation
  92701. * @param from defines the initial key
  92702. * @param to defines the end key
  92703. * @param loop defines if the animation must loop
  92704. * @param delay defines the start delay (in ms)
  92705. * @param onAnimationEnd defines a callback to call when animation ends
  92706. */
  92707. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  92708. /** Stops current animation (if any) */
  92709. stopAnimation(): void;
  92710. /** @hidden */
  92711. _animate(deltaTime: number): void;
  92712. /** Release associated resources */
  92713. dispose(): void;
  92714. }
  92715. }
  92716. declare module BABYLON {
  92717. /**
  92718. * Information about the result of picking within a scene
  92719. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  92720. */
  92721. export class PickingInfo {
  92722. /** @hidden */
  92723. _pickingUnavailable: boolean;
  92724. /**
  92725. * If the pick collided with an object
  92726. */
  92727. hit: boolean;
  92728. /**
  92729. * Distance away where the pick collided
  92730. */
  92731. distance: number;
  92732. /**
  92733. * The location of pick collision
  92734. */
  92735. pickedPoint: Nullable<Vector3>;
  92736. /**
  92737. * The mesh corresponding the the pick collision
  92738. */
  92739. pickedMesh: Nullable<AbstractMesh>;
  92740. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  92741. bu: number;
  92742. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  92743. bv: number;
  92744. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  92745. faceId: number;
  92746. /** Id of the the submesh that was picked */
  92747. subMeshId: number;
  92748. /** If a sprite was picked, this will be the sprite the pick collided with */
  92749. pickedSprite: Nullable<Sprite>;
  92750. /**
  92751. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  92752. */
  92753. originMesh: Nullable<AbstractMesh>;
  92754. /**
  92755. * The ray that was used to perform the picking.
  92756. */
  92757. ray: Nullable<Ray>;
  92758. /**
  92759. * Gets the normal correspodning to the face the pick collided with
  92760. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  92761. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  92762. * @returns The normal correspodning to the face the pick collided with
  92763. */
  92764. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  92765. /**
  92766. * Gets the texture coordinates of where the pick occured
  92767. * @returns the vector containing the coordnates of the texture
  92768. */
  92769. getTextureCoordinates(): Nullable<Vector2>;
  92770. }
  92771. }
  92772. declare module BABYLON {
  92773. /**
  92774. * Gather the list of pointer event types as constants.
  92775. */
  92776. export class PointerEventTypes {
  92777. /**
  92778. * 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.
  92779. */
  92780. static readonly POINTERDOWN: number;
  92781. /**
  92782. * The pointerup event is fired when a pointer is no longer active.
  92783. */
  92784. static readonly POINTERUP: number;
  92785. /**
  92786. * The pointermove event is fired when a pointer changes coordinates.
  92787. */
  92788. static readonly POINTERMOVE: number;
  92789. /**
  92790. * The pointerwheel event is fired when a mouse wheel has been rotated.
  92791. */
  92792. static readonly POINTERWHEEL: number;
  92793. /**
  92794. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  92795. */
  92796. static readonly POINTERPICK: number;
  92797. /**
  92798. * The pointertap event is fired when a the object has been touched and released without drag.
  92799. */
  92800. static readonly POINTERTAP: number;
  92801. /**
  92802. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  92803. */
  92804. static readonly POINTERDOUBLETAP: number;
  92805. }
  92806. /**
  92807. * Base class of pointer info types.
  92808. */
  92809. export class PointerInfoBase {
  92810. /**
  92811. * Defines the type of event (PointerEventTypes)
  92812. */
  92813. type: number;
  92814. /**
  92815. * Defines the related dom event
  92816. */
  92817. event: PointerEvent | MouseWheelEvent;
  92818. /**
  92819. * Instantiates the base class of pointers info.
  92820. * @param type Defines the type of event (PointerEventTypes)
  92821. * @param event Defines the related dom event
  92822. */
  92823. constructor(
  92824. /**
  92825. * Defines the type of event (PointerEventTypes)
  92826. */
  92827. type: number,
  92828. /**
  92829. * Defines the related dom event
  92830. */
  92831. event: PointerEvent | MouseWheelEvent);
  92832. }
  92833. /**
  92834. * This class is used to store pointer related info for the onPrePointerObservable event.
  92835. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  92836. */
  92837. export class PointerInfoPre extends PointerInfoBase {
  92838. /**
  92839. * Ray from a pointer if availible (eg. 6dof controller)
  92840. */
  92841. ray: Nullable<Ray>;
  92842. /**
  92843. * Defines the local position of the pointer on the canvas.
  92844. */
  92845. localPosition: Vector2;
  92846. /**
  92847. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  92848. */
  92849. skipOnPointerObservable: boolean;
  92850. /**
  92851. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  92852. * @param type Defines the type of event (PointerEventTypes)
  92853. * @param event Defines the related dom event
  92854. * @param localX Defines the local x coordinates of the pointer when the event occured
  92855. * @param localY Defines the local y coordinates of the pointer when the event occured
  92856. */
  92857. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  92858. }
  92859. /**
  92860. * This type contains all the data related to a pointer event in Babylon.js.
  92861. * 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.
  92862. */
  92863. export class PointerInfo extends PointerInfoBase {
  92864. /**
  92865. * Defines the picking info associated to the info (if any)\
  92866. */
  92867. pickInfo: Nullable<PickingInfo>;
  92868. /**
  92869. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  92870. * @param type Defines the type of event (PointerEventTypes)
  92871. * @param event Defines the related dom event
  92872. * @param pickInfo Defines the picking info associated to the info (if any)\
  92873. */
  92874. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  92875. /**
  92876. * Defines the picking info associated to the info (if any)\
  92877. */
  92878. pickInfo: Nullable<PickingInfo>);
  92879. }
  92880. /**
  92881. * Data relating to a touch event on the screen.
  92882. */
  92883. export interface PointerTouch {
  92884. /**
  92885. * X coordinate of touch.
  92886. */
  92887. x: number;
  92888. /**
  92889. * Y coordinate of touch.
  92890. */
  92891. y: number;
  92892. /**
  92893. * Id of touch. Unique for each finger.
  92894. */
  92895. pointerId: number;
  92896. /**
  92897. * Event type passed from DOM.
  92898. */
  92899. type: any;
  92900. }
  92901. }
  92902. declare module BABYLON {
  92903. /**
  92904. * Manage the mouse inputs to control the movement of a free camera.
  92905. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92906. */
  92907. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  92908. /**
  92909. * Define if touch is enabled in the mouse input
  92910. */
  92911. touchEnabled: boolean;
  92912. /**
  92913. * Defines the camera the input is attached to.
  92914. */
  92915. camera: FreeCamera;
  92916. /**
  92917. * Defines the buttons associated with the input to handle camera move.
  92918. */
  92919. buttons: number[];
  92920. /**
  92921. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  92922. */
  92923. angularSensibility: number;
  92924. private _pointerInput;
  92925. private _onMouseMove;
  92926. private _observer;
  92927. private previousPosition;
  92928. /**
  92929. * Observable for when a pointer move event occurs containing the move offset
  92930. */
  92931. onPointerMovedObservable: Observable<{
  92932. offsetX: number;
  92933. offsetY: number;
  92934. }>;
  92935. /**
  92936. * @hidden
  92937. * If the camera should be rotated automatically based on pointer movement
  92938. */
  92939. _allowCameraRotation: boolean;
  92940. /**
  92941. * Manage the mouse inputs to control the movement of a free camera.
  92942. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92943. * @param touchEnabled Defines if touch is enabled or not
  92944. */
  92945. constructor(
  92946. /**
  92947. * Define if touch is enabled in the mouse input
  92948. */
  92949. touchEnabled?: boolean);
  92950. /**
  92951. * Attach the input controls to a specific dom element to get the input from.
  92952. * @param element Defines the element the controls should be listened from
  92953. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92954. */
  92955. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92956. /**
  92957. * Called on JS contextmenu event.
  92958. * Override this method to provide functionality.
  92959. */
  92960. protected onContextMenu(evt: PointerEvent): void;
  92961. /**
  92962. * Detach the current controls from the specified dom element.
  92963. * @param element Defines the element to stop listening the inputs from
  92964. */
  92965. detachControl(element: Nullable<HTMLElement>): void;
  92966. /**
  92967. * Gets the class name of the current intput.
  92968. * @returns the class name
  92969. */
  92970. getClassName(): string;
  92971. /**
  92972. * Get the friendly name associated with the input class.
  92973. * @returns the input friendly name
  92974. */
  92975. getSimpleName(): string;
  92976. }
  92977. }
  92978. declare module BABYLON {
  92979. /**
  92980. * Manage the touch inputs to control the movement of a free camera.
  92981. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92982. */
  92983. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  92984. /**
  92985. * Defines the camera the input is attached to.
  92986. */
  92987. camera: FreeCamera;
  92988. /**
  92989. * Defines the touch sensibility for rotation.
  92990. * The higher the faster.
  92991. */
  92992. touchAngularSensibility: number;
  92993. /**
  92994. * Defines the touch sensibility for move.
  92995. * The higher the faster.
  92996. */
  92997. touchMoveSensibility: number;
  92998. private _offsetX;
  92999. private _offsetY;
  93000. private _pointerPressed;
  93001. private _pointerInput;
  93002. private _observer;
  93003. private _onLostFocus;
  93004. /**
  93005. * Attach the input controls to a specific dom element to get the input from.
  93006. * @param element Defines the element the controls should be listened from
  93007. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93008. */
  93009. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93010. /**
  93011. * Detach the current controls from the specified dom element.
  93012. * @param element Defines the element to stop listening the inputs from
  93013. */
  93014. detachControl(element: Nullable<HTMLElement>): void;
  93015. /**
  93016. * Update the current camera state depending on the inputs that have been used this frame.
  93017. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93018. */
  93019. checkInputs(): void;
  93020. /**
  93021. * Gets the class name of the current intput.
  93022. * @returns the class name
  93023. */
  93024. getClassName(): string;
  93025. /**
  93026. * Get the friendly name associated with the input class.
  93027. * @returns the input friendly name
  93028. */
  93029. getSimpleName(): string;
  93030. }
  93031. }
  93032. declare module BABYLON {
  93033. /**
  93034. * Default Inputs manager for the FreeCamera.
  93035. * It groups all the default supported inputs for ease of use.
  93036. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93037. */
  93038. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  93039. /**
  93040. * @hidden
  93041. */
  93042. _mouseInput: Nullable<FreeCameraMouseInput>;
  93043. /**
  93044. * Instantiates a new FreeCameraInputsManager.
  93045. * @param camera Defines the camera the inputs belong to
  93046. */
  93047. constructor(camera: FreeCamera);
  93048. /**
  93049. * Add keyboard input support to the input manager.
  93050. * @returns the current input manager
  93051. */
  93052. addKeyboard(): FreeCameraInputsManager;
  93053. /**
  93054. * Add mouse input support to the input manager.
  93055. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  93056. * @returns the current input manager
  93057. */
  93058. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  93059. /**
  93060. * Removes the mouse input support from the manager
  93061. * @returns the current input manager
  93062. */
  93063. removeMouse(): FreeCameraInputsManager;
  93064. /**
  93065. * Add touch input support to the input manager.
  93066. * @returns the current input manager
  93067. */
  93068. addTouch(): FreeCameraInputsManager;
  93069. /**
  93070. * Remove all attached input methods from a camera
  93071. */
  93072. clear(): void;
  93073. }
  93074. }
  93075. declare module BABYLON {
  93076. /**
  93077. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  93078. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  93079. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93080. */
  93081. export class FreeCamera extends TargetCamera {
  93082. /**
  93083. * Define the collision ellipsoid of the camera.
  93084. * This is helpful to simulate a camera body like the player body around the camera
  93085. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  93086. */
  93087. ellipsoid: Vector3;
  93088. /**
  93089. * Define an offset for the position of the ellipsoid around the camera.
  93090. * This can be helpful to determine the center of the body near the gravity center of the body
  93091. * instead of its head.
  93092. */
  93093. ellipsoidOffset: Vector3;
  93094. /**
  93095. * Enable or disable collisions of the camera with the rest of the scene objects.
  93096. */
  93097. checkCollisions: boolean;
  93098. /**
  93099. * Enable or disable gravity on the camera.
  93100. */
  93101. applyGravity: boolean;
  93102. /**
  93103. * Define the input manager associated to the camera.
  93104. */
  93105. inputs: FreeCameraInputsManager;
  93106. /**
  93107. * Gets the input sensibility for a mouse input. (default is 2000.0)
  93108. * Higher values reduce sensitivity.
  93109. */
  93110. get angularSensibility(): number;
  93111. /**
  93112. * Sets the input sensibility for a mouse input. (default is 2000.0)
  93113. * Higher values reduce sensitivity.
  93114. */
  93115. set angularSensibility(value: number);
  93116. /**
  93117. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  93118. */
  93119. get keysUp(): number[];
  93120. set keysUp(value: number[]);
  93121. /**
  93122. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  93123. */
  93124. get keysUpward(): number[];
  93125. set keysUpward(value: number[]);
  93126. /**
  93127. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  93128. */
  93129. get keysDown(): number[];
  93130. set keysDown(value: number[]);
  93131. /**
  93132. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  93133. */
  93134. get keysDownward(): number[];
  93135. set keysDownward(value: number[]);
  93136. /**
  93137. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  93138. */
  93139. get keysLeft(): number[];
  93140. set keysLeft(value: number[]);
  93141. /**
  93142. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  93143. */
  93144. get keysRight(): number[];
  93145. set keysRight(value: number[]);
  93146. /**
  93147. * Event raised when the camera collide with a mesh in the scene.
  93148. */
  93149. onCollide: (collidedMesh: AbstractMesh) => void;
  93150. private _collider;
  93151. private _needMoveForGravity;
  93152. private _oldPosition;
  93153. private _diffPosition;
  93154. private _newPosition;
  93155. /** @hidden */
  93156. _localDirection: Vector3;
  93157. /** @hidden */
  93158. _transformedDirection: Vector3;
  93159. /**
  93160. * Instantiates a Free Camera.
  93161. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  93162. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  93163. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93164. * @param name Define the name of the camera in the scene
  93165. * @param position Define the start position of the camera in the scene
  93166. * @param scene Define the scene the camera belongs to
  93167. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  93168. */
  93169. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93170. /**
  93171. * Attached controls to the current camera.
  93172. * @param element Defines the element the controls should be listened from
  93173. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93174. */
  93175. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93176. /**
  93177. * Detach the current controls from the camera.
  93178. * The camera will stop reacting to inputs.
  93179. * @param element Defines the element to stop listening the inputs from
  93180. */
  93181. detachControl(element: HTMLElement): void;
  93182. private _collisionMask;
  93183. /**
  93184. * Define a collision mask to limit the list of object the camera can collide with
  93185. */
  93186. get collisionMask(): number;
  93187. set collisionMask(mask: number);
  93188. /** @hidden */
  93189. _collideWithWorld(displacement: Vector3): void;
  93190. private _onCollisionPositionChange;
  93191. /** @hidden */
  93192. _checkInputs(): void;
  93193. /** @hidden */
  93194. _decideIfNeedsToMove(): boolean;
  93195. /** @hidden */
  93196. _updatePosition(): void;
  93197. /**
  93198. * Destroy the camera and release the current resources hold by it.
  93199. */
  93200. dispose(): void;
  93201. /**
  93202. * Gets the current object class name.
  93203. * @return the class name
  93204. */
  93205. getClassName(): string;
  93206. }
  93207. }
  93208. declare module BABYLON {
  93209. /**
  93210. * Represents a gamepad control stick position
  93211. */
  93212. export class StickValues {
  93213. /**
  93214. * The x component of the control stick
  93215. */
  93216. x: number;
  93217. /**
  93218. * The y component of the control stick
  93219. */
  93220. y: number;
  93221. /**
  93222. * Initializes the gamepad x and y control stick values
  93223. * @param x The x component of the gamepad control stick value
  93224. * @param y The y component of the gamepad control stick value
  93225. */
  93226. constructor(
  93227. /**
  93228. * The x component of the control stick
  93229. */
  93230. x: number,
  93231. /**
  93232. * The y component of the control stick
  93233. */
  93234. y: number);
  93235. }
  93236. /**
  93237. * An interface which manages callbacks for gamepad button changes
  93238. */
  93239. export interface GamepadButtonChanges {
  93240. /**
  93241. * Called when a gamepad has been changed
  93242. */
  93243. changed: boolean;
  93244. /**
  93245. * Called when a gamepad press event has been triggered
  93246. */
  93247. pressChanged: boolean;
  93248. /**
  93249. * Called when a touch event has been triggered
  93250. */
  93251. touchChanged: boolean;
  93252. /**
  93253. * Called when a value has changed
  93254. */
  93255. valueChanged: boolean;
  93256. }
  93257. /**
  93258. * Represents a gamepad
  93259. */
  93260. export class Gamepad {
  93261. /**
  93262. * The id of the gamepad
  93263. */
  93264. id: string;
  93265. /**
  93266. * The index of the gamepad
  93267. */
  93268. index: number;
  93269. /**
  93270. * The browser gamepad
  93271. */
  93272. browserGamepad: any;
  93273. /**
  93274. * Specifies what type of gamepad this represents
  93275. */
  93276. type: number;
  93277. private _leftStick;
  93278. private _rightStick;
  93279. /** @hidden */
  93280. _isConnected: boolean;
  93281. private _leftStickAxisX;
  93282. private _leftStickAxisY;
  93283. private _rightStickAxisX;
  93284. private _rightStickAxisY;
  93285. /**
  93286. * Triggered when the left control stick has been changed
  93287. */
  93288. private _onleftstickchanged;
  93289. /**
  93290. * Triggered when the right control stick has been changed
  93291. */
  93292. private _onrightstickchanged;
  93293. /**
  93294. * Represents a gamepad controller
  93295. */
  93296. static GAMEPAD: number;
  93297. /**
  93298. * Represents a generic controller
  93299. */
  93300. static GENERIC: number;
  93301. /**
  93302. * Represents an XBox controller
  93303. */
  93304. static XBOX: number;
  93305. /**
  93306. * Represents a pose-enabled controller
  93307. */
  93308. static POSE_ENABLED: number;
  93309. /**
  93310. * Represents an Dual Shock controller
  93311. */
  93312. static DUALSHOCK: number;
  93313. /**
  93314. * Specifies whether the left control stick should be Y-inverted
  93315. */
  93316. protected _invertLeftStickY: boolean;
  93317. /**
  93318. * Specifies if the gamepad has been connected
  93319. */
  93320. get isConnected(): boolean;
  93321. /**
  93322. * Initializes the gamepad
  93323. * @param id The id of the gamepad
  93324. * @param index The index of the gamepad
  93325. * @param browserGamepad The browser gamepad
  93326. * @param leftStickX The x component of the left joystick
  93327. * @param leftStickY The y component of the left joystick
  93328. * @param rightStickX The x component of the right joystick
  93329. * @param rightStickY The y component of the right joystick
  93330. */
  93331. constructor(
  93332. /**
  93333. * The id of the gamepad
  93334. */
  93335. id: string,
  93336. /**
  93337. * The index of the gamepad
  93338. */
  93339. index: number,
  93340. /**
  93341. * The browser gamepad
  93342. */
  93343. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  93344. /**
  93345. * Callback triggered when the left joystick has changed
  93346. * @param callback
  93347. */
  93348. onleftstickchanged(callback: (values: StickValues) => void): void;
  93349. /**
  93350. * Callback triggered when the right joystick has changed
  93351. * @param callback
  93352. */
  93353. onrightstickchanged(callback: (values: StickValues) => void): void;
  93354. /**
  93355. * Gets the left joystick
  93356. */
  93357. get leftStick(): StickValues;
  93358. /**
  93359. * Sets the left joystick values
  93360. */
  93361. set leftStick(newValues: StickValues);
  93362. /**
  93363. * Gets the right joystick
  93364. */
  93365. get rightStick(): StickValues;
  93366. /**
  93367. * Sets the right joystick value
  93368. */
  93369. set rightStick(newValues: StickValues);
  93370. /**
  93371. * Updates the gamepad joystick positions
  93372. */
  93373. update(): void;
  93374. /**
  93375. * Disposes the gamepad
  93376. */
  93377. dispose(): void;
  93378. }
  93379. /**
  93380. * Represents a generic gamepad
  93381. */
  93382. export class GenericPad extends Gamepad {
  93383. private _buttons;
  93384. private _onbuttondown;
  93385. private _onbuttonup;
  93386. /**
  93387. * Observable triggered when a button has been pressed
  93388. */
  93389. onButtonDownObservable: Observable<number>;
  93390. /**
  93391. * Observable triggered when a button has been released
  93392. */
  93393. onButtonUpObservable: Observable<number>;
  93394. /**
  93395. * Callback triggered when a button has been pressed
  93396. * @param callback Called when a button has been pressed
  93397. */
  93398. onbuttondown(callback: (buttonPressed: number) => void): void;
  93399. /**
  93400. * Callback triggered when a button has been released
  93401. * @param callback Called when a button has been released
  93402. */
  93403. onbuttonup(callback: (buttonReleased: number) => void): void;
  93404. /**
  93405. * Initializes the generic gamepad
  93406. * @param id The id of the generic gamepad
  93407. * @param index The index of the generic gamepad
  93408. * @param browserGamepad The browser gamepad
  93409. */
  93410. constructor(id: string, index: number, browserGamepad: any);
  93411. private _setButtonValue;
  93412. /**
  93413. * Updates the generic gamepad
  93414. */
  93415. update(): void;
  93416. /**
  93417. * Disposes the generic gamepad
  93418. */
  93419. dispose(): void;
  93420. }
  93421. }
  93422. declare module BABYLON {
  93423. /**
  93424. * Defines the types of pose enabled controllers that are supported
  93425. */
  93426. export enum PoseEnabledControllerType {
  93427. /**
  93428. * HTC Vive
  93429. */
  93430. VIVE = 0,
  93431. /**
  93432. * Oculus Rift
  93433. */
  93434. OCULUS = 1,
  93435. /**
  93436. * Windows mixed reality
  93437. */
  93438. WINDOWS = 2,
  93439. /**
  93440. * Samsung gear VR
  93441. */
  93442. GEAR_VR = 3,
  93443. /**
  93444. * Google Daydream
  93445. */
  93446. DAYDREAM = 4,
  93447. /**
  93448. * Generic
  93449. */
  93450. GENERIC = 5
  93451. }
  93452. /**
  93453. * Defines the MutableGamepadButton interface for the state of a gamepad button
  93454. */
  93455. export interface MutableGamepadButton {
  93456. /**
  93457. * Value of the button/trigger
  93458. */
  93459. value: number;
  93460. /**
  93461. * If the button/trigger is currently touched
  93462. */
  93463. touched: boolean;
  93464. /**
  93465. * If the button/trigger is currently pressed
  93466. */
  93467. pressed: boolean;
  93468. }
  93469. /**
  93470. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  93471. * @hidden
  93472. */
  93473. export interface ExtendedGamepadButton extends GamepadButton {
  93474. /**
  93475. * If the button/trigger is currently pressed
  93476. */
  93477. readonly pressed: boolean;
  93478. /**
  93479. * If the button/trigger is currently touched
  93480. */
  93481. readonly touched: boolean;
  93482. /**
  93483. * Value of the button/trigger
  93484. */
  93485. readonly value: number;
  93486. }
  93487. /** @hidden */
  93488. export interface _GamePadFactory {
  93489. /**
  93490. * Returns whether or not the current gamepad can be created for this type of controller.
  93491. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  93492. * @returns true if it can be created, otherwise false
  93493. */
  93494. canCreate(gamepadInfo: any): boolean;
  93495. /**
  93496. * Creates a new instance of the Gamepad.
  93497. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  93498. * @returns the new gamepad instance
  93499. */
  93500. create(gamepadInfo: any): Gamepad;
  93501. }
  93502. /**
  93503. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  93504. */
  93505. export class PoseEnabledControllerHelper {
  93506. /** @hidden */
  93507. static _ControllerFactories: _GamePadFactory[];
  93508. /** @hidden */
  93509. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  93510. /**
  93511. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  93512. * @param vrGamepad the gamepad to initialized
  93513. * @returns a vr controller of the type the gamepad identified as
  93514. */
  93515. static InitiateController(vrGamepad: any): Gamepad;
  93516. }
  93517. /**
  93518. * Defines the PoseEnabledController object that contains state of a vr capable controller
  93519. */
  93520. export class PoseEnabledController extends Gamepad implements PoseControlled {
  93521. /**
  93522. * If the controller is used in a webXR session
  93523. */
  93524. isXR: boolean;
  93525. private _deviceRoomPosition;
  93526. private _deviceRoomRotationQuaternion;
  93527. /**
  93528. * The device position in babylon space
  93529. */
  93530. devicePosition: Vector3;
  93531. /**
  93532. * The device rotation in babylon space
  93533. */
  93534. deviceRotationQuaternion: Quaternion;
  93535. /**
  93536. * The scale factor of the device in babylon space
  93537. */
  93538. deviceScaleFactor: number;
  93539. /**
  93540. * (Likely devicePosition should be used instead) The device position in its room space
  93541. */
  93542. position: Vector3;
  93543. /**
  93544. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  93545. */
  93546. rotationQuaternion: Quaternion;
  93547. /**
  93548. * The type of controller (Eg. Windows mixed reality)
  93549. */
  93550. controllerType: PoseEnabledControllerType;
  93551. protected _calculatedPosition: Vector3;
  93552. private _calculatedRotation;
  93553. /**
  93554. * The raw pose from the device
  93555. */
  93556. rawPose: DevicePose;
  93557. private _trackPosition;
  93558. private _maxRotationDistFromHeadset;
  93559. private _draggedRoomRotation;
  93560. /**
  93561. * @hidden
  93562. */
  93563. _disableTrackPosition(fixedPosition: Vector3): void;
  93564. /**
  93565. * Internal, the mesh attached to the controller
  93566. * @hidden
  93567. */
  93568. _mesh: Nullable<AbstractMesh>;
  93569. private _poseControlledCamera;
  93570. private _leftHandSystemQuaternion;
  93571. /**
  93572. * Internal, matrix used to convert room space to babylon space
  93573. * @hidden
  93574. */
  93575. _deviceToWorld: Matrix;
  93576. /**
  93577. * Node to be used when casting a ray from the controller
  93578. * @hidden
  93579. */
  93580. _pointingPoseNode: Nullable<TransformNode>;
  93581. /**
  93582. * Name of the child mesh that can be used to cast a ray from the controller
  93583. */
  93584. static readonly POINTING_POSE: string;
  93585. /**
  93586. * Creates a new PoseEnabledController from a gamepad
  93587. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  93588. */
  93589. constructor(browserGamepad: any);
  93590. private _workingMatrix;
  93591. /**
  93592. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  93593. */
  93594. update(): void;
  93595. /**
  93596. * Updates only the pose device and mesh without doing any button event checking
  93597. */
  93598. protected _updatePoseAndMesh(): void;
  93599. /**
  93600. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  93601. * @param poseData raw pose fromthe device
  93602. */
  93603. updateFromDevice(poseData: DevicePose): void;
  93604. /**
  93605. * @hidden
  93606. */
  93607. _meshAttachedObservable: Observable<AbstractMesh>;
  93608. /**
  93609. * Attaches a mesh to the controller
  93610. * @param mesh the mesh to be attached
  93611. */
  93612. attachToMesh(mesh: AbstractMesh): void;
  93613. /**
  93614. * Attaches the controllers mesh to a camera
  93615. * @param camera the camera the mesh should be attached to
  93616. */
  93617. attachToPoseControlledCamera(camera: TargetCamera): void;
  93618. /**
  93619. * Disposes of the controller
  93620. */
  93621. dispose(): void;
  93622. /**
  93623. * The mesh that is attached to the controller
  93624. */
  93625. get mesh(): Nullable<AbstractMesh>;
  93626. /**
  93627. * Gets the ray of the controller in the direction the controller is pointing
  93628. * @param length the length the resulting ray should be
  93629. * @returns a ray in the direction the controller is pointing
  93630. */
  93631. getForwardRay(length?: number): Ray;
  93632. }
  93633. }
  93634. declare module BABYLON {
  93635. /**
  93636. * Defines the WebVRController object that represents controllers tracked in 3D space
  93637. */
  93638. export abstract class WebVRController extends PoseEnabledController {
  93639. /**
  93640. * Internal, the default controller model for the controller
  93641. */
  93642. protected _defaultModel: Nullable<AbstractMesh>;
  93643. /**
  93644. * Fired when the trigger state has changed
  93645. */
  93646. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  93647. /**
  93648. * Fired when the main button state has changed
  93649. */
  93650. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  93651. /**
  93652. * Fired when the secondary button state has changed
  93653. */
  93654. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  93655. /**
  93656. * Fired when the pad state has changed
  93657. */
  93658. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  93659. /**
  93660. * Fired when controllers stick values have changed
  93661. */
  93662. onPadValuesChangedObservable: Observable<StickValues>;
  93663. /**
  93664. * Array of button availible on the controller
  93665. */
  93666. protected _buttons: Array<MutableGamepadButton>;
  93667. private _onButtonStateChange;
  93668. /**
  93669. * Fired when a controller button's state has changed
  93670. * @param callback the callback containing the button that was modified
  93671. */
  93672. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  93673. /**
  93674. * X and Y axis corresponding to the controllers joystick
  93675. */
  93676. pad: StickValues;
  93677. /**
  93678. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  93679. */
  93680. hand: string;
  93681. /**
  93682. * The default controller model for the controller
  93683. */
  93684. get defaultModel(): Nullable<AbstractMesh>;
  93685. /**
  93686. * Creates a new WebVRController from a gamepad
  93687. * @param vrGamepad the gamepad that the WebVRController should be created from
  93688. */
  93689. constructor(vrGamepad: any);
  93690. /**
  93691. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  93692. */
  93693. update(): void;
  93694. /**
  93695. * Function to be called when a button is modified
  93696. */
  93697. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  93698. /**
  93699. * Loads a mesh and attaches it to the controller
  93700. * @param scene the scene the mesh should be added to
  93701. * @param meshLoaded callback for when the mesh has been loaded
  93702. */
  93703. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  93704. private _setButtonValue;
  93705. private _changes;
  93706. private _checkChanges;
  93707. /**
  93708. * Disposes of th webVRCOntroller
  93709. */
  93710. dispose(): void;
  93711. }
  93712. }
  93713. declare module BABYLON {
  93714. /**
  93715. * The HemisphericLight simulates the ambient environment light,
  93716. * so the passed direction is the light reflection direction, not the incoming direction.
  93717. */
  93718. export class HemisphericLight extends Light {
  93719. /**
  93720. * The groundColor is the light in the opposite direction to the one specified during creation.
  93721. * 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.
  93722. */
  93723. groundColor: Color3;
  93724. /**
  93725. * The light reflection direction, not the incoming direction.
  93726. */
  93727. direction: Vector3;
  93728. /**
  93729. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  93730. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  93731. * The HemisphericLight can't cast shadows.
  93732. * Documentation : https://doc.babylonjs.com/babylon101/lights
  93733. * @param name The friendly name of the light
  93734. * @param direction The direction of the light reflection
  93735. * @param scene The scene the light belongs to
  93736. */
  93737. constructor(name: string, direction: Vector3, scene: Scene);
  93738. protected _buildUniformLayout(): void;
  93739. /**
  93740. * Returns the string "HemisphericLight".
  93741. * @return The class name
  93742. */
  93743. getClassName(): string;
  93744. /**
  93745. * Sets the HemisphericLight direction towards the passed target (Vector3).
  93746. * Returns the updated direction.
  93747. * @param target The target the direction should point to
  93748. * @return The computed direction
  93749. */
  93750. setDirectionToTarget(target: Vector3): Vector3;
  93751. /**
  93752. * Returns the shadow generator associated to the light.
  93753. * @returns Always null for hemispheric lights because it does not support shadows.
  93754. */
  93755. getShadowGenerator(): Nullable<IShadowGenerator>;
  93756. /**
  93757. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  93758. * @param effect The effect to update
  93759. * @param lightIndex The index of the light in the effect to update
  93760. * @returns The hemispheric light
  93761. */
  93762. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  93763. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  93764. /**
  93765. * Computes the world matrix of the node
  93766. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93767. * @param useWasUpdatedFlag defines a reserved property
  93768. * @returns the world matrix
  93769. */
  93770. computeWorldMatrix(): Matrix;
  93771. /**
  93772. * Returns the integer 3.
  93773. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  93774. */
  93775. getTypeID(): number;
  93776. /**
  93777. * Prepares the list of defines specific to the light type.
  93778. * @param defines the list of defines
  93779. * @param lightIndex defines the index of the light for the effect
  93780. */
  93781. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  93782. }
  93783. }
  93784. declare module BABYLON {
  93785. /** @hidden */
  93786. export var vrMultiviewToSingleviewPixelShader: {
  93787. name: string;
  93788. shader: string;
  93789. };
  93790. }
  93791. declare module BABYLON {
  93792. /**
  93793. * Renders to multiple views with a single draw call
  93794. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  93795. */
  93796. export class MultiviewRenderTarget extends RenderTargetTexture {
  93797. /**
  93798. * Creates a multiview render target
  93799. * @param scene scene used with the render target
  93800. * @param size the size of the render target (used for each view)
  93801. */
  93802. constructor(scene: Scene, size?: number | {
  93803. width: number;
  93804. height: number;
  93805. } | {
  93806. ratio: number;
  93807. });
  93808. /**
  93809. * @hidden
  93810. * @param faceIndex the face index, if its a cube texture
  93811. */
  93812. _bindFrameBuffer(faceIndex?: number): void;
  93813. /**
  93814. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  93815. * @returns the view count
  93816. */
  93817. getViewCount(): number;
  93818. }
  93819. }
  93820. declare module BABYLON {
  93821. /**
  93822. * Represents a camera frustum
  93823. */
  93824. export class Frustum {
  93825. /**
  93826. * Gets the planes representing the frustum
  93827. * @param transform matrix to be applied to the returned planes
  93828. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  93829. */
  93830. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  93831. /**
  93832. * Gets the near frustum plane transformed by the transform matrix
  93833. * @param transform transformation matrix to be applied to the resulting frustum plane
  93834. * @param frustumPlane the resuling frustum plane
  93835. */
  93836. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93837. /**
  93838. * Gets the far frustum plane transformed by the transform matrix
  93839. * @param transform transformation matrix to be applied to the resulting frustum plane
  93840. * @param frustumPlane the resuling frustum plane
  93841. */
  93842. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93843. /**
  93844. * Gets the left frustum plane transformed by the transform matrix
  93845. * @param transform transformation matrix to be applied to the resulting frustum plane
  93846. * @param frustumPlane the resuling frustum plane
  93847. */
  93848. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93849. /**
  93850. * Gets the right frustum plane transformed by the transform matrix
  93851. * @param transform transformation matrix to be applied to the resulting frustum plane
  93852. * @param frustumPlane the resuling frustum plane
  93853. */
  93854. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93855. /**
  93856. * Gets the top frustum plane transformed by the transform matrix
  93857. * @param transform transformation matrix to be applied to the resulting frustum plane
  93858. * @param frustumPlane the resuling frustum plane
  93859. */
  93860. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93861. /**
  93862. * Gets the bottom frustum plane transformed by the transform matrix
  93863. * @param transform transformation matrix to be applied to the resulting frustum plane
  93864. * @param frustumPlane the resuling frustum plane
  93865. */
  93866. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93867. /**
  93868. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  93869. * @param transform transformation matrix to be applied to the resulting frustum planes
  93870. * @param frustumPlanes the resuling frustum planes
  93871. */
  93872. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  93873. }
  93874. }
  93875. declare module BABYLON {
  93876. interface Engine {
  93877. /**
  93878. * Creates a new multiview render target
  93879. * @param width defines the width of the texture
  93880. * @param height defines the height of the texture
  93881. * @returns the created multiview texture
  93882. */
  93883. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  93884. /**
  93885. * Binds a multiview framebuffer to be drawn to
  93886. * @param multiviewTexture texture to bind
  93887. */
  93888. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  93889. }
  93890. interface Camera {
  93891. /**
  93892. * @hidden
  93893. * 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)
  93894. */
  93895. _useMultiviewToSingleView: boolean;
  93896. /**
  93897. * @hidden
  93898. * 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)
  93899. */
  93900. _multiviewTexture: Nullable<RenderTargetTexture>;
  93901. /**
  93902. * @hidden
  93903. * ensures the multiview texture of the camera exists and has the specified width/height
  93904. * @param width height to set on the multiview texture
  93905. * @param height width to set on the multiview texture
  93906. */
  93907. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  93908. }
  93909. interface Scene {
  93910. /** @hidden */
  93911. _transformMatrixR: Matrix;
  93912. /** @hidden */
  93913. _multiviewSceneUbo: Nullable<UniformBuffer>;
  93914. /** @hidden */
  93915. _createMultiviewUbo(): void;
  93916. /** @hidden */
  93917. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  93918. /** @hidden */
  93919. _renderMultiviewToSingleView(camera: Camera): void;
  93920. }
  93921. }
  93922. declare module BABYLON {
  93923. /**
  93924. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  93925. * This will not be used for webXR as it supports displaying texture arrays directly
  93926. */
  93927. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  93928. /**
  93929. * Initializes a VRMultiviewToSingleview
  93930. * @param name name of the post process
  93931. * @param camera camera to be applied to
  93932. * @param scaleFactor scaling factor to the size of the output texture
  93933. */
  93934. constructor(name: string, camera: Camera, scaleFactor: number);
  93935. }
  93936. }
  93937. declare module BABYLON {
  93938. /**
  93939. * Interface used to define additional presentation attributes
  93940. */
  93941. export interface IVRPresentationAttributes {
  93942. /**
  93943. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  93944. */
  93945. highRefreshRate: boolean;
  93946. /**
  93947. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  93948. */
  93949. foveationLevel: number;
  93950. }
  93951. interface Engine {
  93952. /** @hidden */
  93953. _vrDisplay: any;
  93954. /** @hidden */
  93955. _vrSupported: boolean;
  93956. /** @hidden */
  93957. _oldSize: Size;
  93958. /** @hidden */
  93959. _oldHardwareScaleFactor: number;
  93960. /** @hidden */
  93961. _vrExclusivePointerMode: boolean;
  93962. /** @hidden */
  93963. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  93964. /** @hidden */
  93965. _onVRDisplayPointerRestricted: () => void;
  93966. /** @hidden */
  93967. _onVRDisplayPointerUnrestricted: () => void;
  93968. /** @hidden */
  93969. _onVrDisplayConnect: Nullable<(display: any) => void>;
  93970. /** @hidden */
  93971. _onVrDisplayDisconnect: Nullable<() => void>;
  93972. /** @hidden */
  93973. _onVrDisplayPresentChange: Nullable<() => void>;
  93974. /**
  93975. * Observable signaled when VR display mode changes
  93976. */
  93977. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  93978. /**
  93979. * Observable signaled when VR request present is complete
  93980. */
  93981. onVRRequestPresentComplete: Observable<boolean>;
  93982. /**
  93983. * Observable signaled when VR request present starts
  93984. */
  93985. onVRRequestPresentStart: Observable<Engine>;
  93986. /**
  93987. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  93988. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  93989. */
  93990. isInVRExclusivePointerMode: boolean;
  93991. /**
  93992. * Gets a boolean indicating if a webVR device was detected
  93993. * @returns true if a webVR device was detected
  93994. */
  93995. isVRDevicePresent(): boolean;
  93996. /**
  93997. * Gets the current webVR device
  93998. * @returns the current webVR device (or null)
  93999. */
  94000. getVRDevice(): any;
  94001. /**
  94002. * Initializes a webVR display and starts listening to display change events
  94003. * The onVRDisplayChangedObservable will be notified upon these changes
  94004. * @returns A promise containing a VRDisplay and if vr is supported
  94005. */
  94006. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  94007. /** @hidden */
  94008. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  94009. /**
  94010. * Gets or sets the presentation attributes used to configure VR rendering
  94011. */
  94012. vrPresentationAttributes?: IVRPresentationAttributes;
  94013. /**
  94014. * Call this function to switch to webVR mode
  94015. * Will do nothing if webVR is not supported or if there is no webVR device
  94016. * @param options the webvr options provided to the camera. mainly used for multiview
  94017. * @see http://doc.babylonjs.com/how_to/webvr_camera
  94018. */
  94019. enableVR(options: WebVROptions): void;
  94020. /** @hidden */
  94021. _onVRFullScreenTriggered(): void;
  94022. }
  94023. }
  94024. declare module BABYLON {
  94025. /**
  94026. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  94027. * IMPORTANT!! The data is right-hand data.
  94028. * @export
  94029. * @interface DevicePose
  94030. */
  94031. export interface DevicePose {
  94032. /**
  94033. * The position of the device, values in array are [x,y,z].
  94034. */
  94035. readonly position: Nullable<Float32Array>;
  94036. /**
  94037. * The linearVelocity of the device, values in array are [x,y,z].
  94038. */
  94039. readonly linearVelocity: Nullable<Float32Array>;
  94040. /**
  94041. * The linearAcceleration of the device, values in array are [x,y,z].
  94042. */
  94043. readonly linearAcceleration: Nullable<Float32Array>;
  94044. /**
  94045. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  94046. */
  94047. readonly orientation: Nullable<Float32Array>;
  94048. /**
  94049. * The angularVelocity of the device, values in array are [x,y,z].
  94050. */
  94051. readonly angularVelocity: Nullable<Float32Array>;
  94052. /**
  94053. * The angularAcceleration of the device, values in array are [x,y,z].
  94054. */
  94055. readonly angularAcceleration: Nullable<Float32Array>;
  94056. }
  94057. /**
  94058. * Interface representing a pose controlled object in Babylon.
  94059. * A pose controlled object has both regular pose values as well as pose values
  94060. * from an external device such as a VR head mounted display
  94061. */
  94062. export interface PoseControlled {
  94063. /**
  94064. * The position of the object in babylon space.
  94065. */
  94066. position: Vector3;
  94067. /**
  94068. * The rotation quaternion of the object in babylon space.
  94069. */
  94070. rotationQuaternion: Quaternion;
  94071. /**
  94072. * The position of the device in babylon space.
  94073. */
  94074. devicePosition?: Vector3;
  94075. /**
  94076. * The rotation quaternion of the device in babylon space.
  94077. */
  94078. deviceRotationQuaternion: Quaternion;
  94079. /**
  94080. * The raw pose coming from the device.
  94081. */
  94082. rawPose: Nullable<DevicePose>;
  94083. /**
  94084. * The scale of the device to be used when translating from device space to babylon space.
  94085. */
  94086. deviceScaleFactor: number;
  94087. /**
  94088. * Updates the poseControlled values based on the input device pose.
  94089. * @param poseData the pose data to update the object with
  94090. */
  94091. updateFromDevice(poseData: DevicePose): void;
  94092. }
  94093. /**
  94094. * Set of options to customize the webVRCamera
  94095. */
  94096. export interface WebVROptions {
  94097. /**
  94098. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  94099. */
  94100. trackPosition?: boolean;
  94101. /**
  94102. * Sets the scale of the vrDevice in babylon space. (default: 1)
  94103. */
  94104. positionScale?: number;
  94105. /**
  94106. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  94107. */
  94108. displayName?: string;
  94109. /**
  94110. * Should the native controller meshes be initialized. (default: true)
  94111. */
  94112. controllerMeshes?: boolean;
  94113. /**
  94114. * Creating a default HemiLight only on controllers. (default: true)
  94115. */
  94116. defaultLightingOnControllers?: boolean;
  94117. /**
  94118. * If you don't want to use the default VR button of the helper. (default: false)
  94119. */
  94120. useCustomVRButton?: boolean;
  94121. /**
  94122. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  94123. */
  94124. customVRButton?: HTMLButtonElement;
  94125. /**
  94126. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  94127. */
  94128. rayLength?: number;
  94129. /**
  94130. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  94131. */
  94132. defaultHeight?: number;
  94133. /**
  94134. * If multiview should be used if availible (default: false)
  94135. */
  94136. useMultiview?: boolean;
  94137. }
  94138. /**
  94139. * This represents a WebVR camera.
  94140. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  94141. * @example http://doc.babylonjs.com/how_to/webvr_camera
  94142. */
  94143. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  94144. private webVROptions;
  94145. /**
  94146. * @hidden
  94147. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  94148. */
  94149. _vrDevice: any;
  94150. /**
  94151. * The rawPose of the vrDevice.
  94152. */
  94153. rawPose: Nullable<DevicePose>;
  94154. private _onVREnabled;
  94155. private _specsVersion;
  94156. private _attached;
  94157. private _frameData;
  94158. protected _descendants: Array<Node>;
  94159. private _deviceRoomPosition;
  94160. /** @hidden */
  94161. _deviceRoomRotationQuaternion: Quaternion;
  94162. private _standingMatrix;
  94163. /**
  94164. * Represents device position in babylon space.
  94165. */
  94166. devicePosition: Vector3;
  94167. /**
  94168. * Represents device rotation in babylon space.
  94169. */
  94170. deviceRotationQuaternion: Quaternion;
  94171. /**
  94172. * The scale of the device to be used when translating from device space to babylon space.
  94173. */
  94174. deviceScaleFactor: number;
  94175. private _deviceToWorld;
  94176. private _worldToDevice;
  94177. /**
  94178. * References to the webVR controllers for the vrDevice.
  94179. */
  94180. controllers: Array<WebVRController>;
  94181. /**
  94182. * Emits an event when a controller is attached.
  94183. */
  94184. onControllersAttachedObservable: Observable<WebVRController[]>;
  94185. /**
  94186. * Emits an event when a controller's mesh has been loaded;
  94187. */
  94188. onControllerMeshLoadedObservable: Observable<WebVRController>;
  94189. /**
  94190. * Emits an event when the HMD's pose has been updated.
  94191. */
  94192. onPoseUpdatedFromDeviceObservable: Observable<any>;
  94193. private _poseSet;
  94194. /**
  94195. * If the rig cameras be used as parent instead of this camera.
  94196. */
  94197. rigParenting: boolean;
  94198. private _lightOnControllers;
  94199. private _defaultHeight?;
  94200. /**
  94201. * Instantiates a WebVRFreeCamera.
  94202. * @param name The name of the WebVRFreeCamera
  94203. * @param position The starting anchor position for the camera
  94204. * @param scene The scene the camera belongs to
  94205. * @param webVROptions a set of customizable options for the webVRCamera
  94206. */
  94207. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  94208. /**
  94209. * Gets the device distance from the ground in meters.
  94210. * @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.
  94211. */
  94212. deviceDistanceToRoomGround(): number;
  94213. /**
  94214. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  94215. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  94216. */
  94217. useStandingMatrix(callback?: (bool: boolean) => void): void;
  94218. /**
  94219. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  94220. * @returns A promise with a boolean set to if the standing matrix is supported.
  94221. */
  94222. useStandingMatrixAsync(): Promise<boolean>;
  94223. /**
  94224. * Disposes the camera
  94225. */
  94226. dispose(): void;
  94227. /**
  94228. * Gets a vrController by name.
  94229. * @param name The name of the controller to retreive
  94230. * @returns the controller matching the name specified or null if not found
  94231. */
  94232. getControllerByName(name: string): Nullable<WebVRController>;
  94233. private _leftController;
  94234. /**
  94235. * The controller corresponding to the users left hand.
  94236. */
  94237. get leftController(): Nullable<WebVRController>;
  94238. private _rightController;
  94239. /**
  94240. * The controller corresponding to the users right hand.
  94241. */
  94242. get rightController(): Nullable<WebVRController>;
  94243. /**
  94244. * Casts a ray forward from the vrCamera's gaze.
  94245. * @param length Length of the ray (default: 100)
  94246. * @returns the ray corresponding to the gaze
  94247. */
  94248. getForwardRay(length?: number): Ray;
  94249. /**
  94250. * @hidden
  94251. * Updates the camera based on device's frame data
  94252. */
  94253. _checkInputs(): void;
  94254. /**
  94255. * Updates the poseControlled values based on the input device pose.
  94256. * @param poseData Pose coming from the device
  94257. */
  94258. updateFromDevice(poseData: DevicePose): void;
  94259. private _htmlElementAttached;
  94260. private _detachIfAttached;
  94261. /**
  94262. * WebVR's attach control will start broadcasting frames to the device.
  94263. * Note that in certain browsers (chrome for example) this function must be called
  94264. * within a user-interaction callback. Example:
  94265. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  94266. *
  94267. * @param element html element to attach the vrDevice to
  94268. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  94269. */
  94270. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94271. /**
  94272. * Detaches the camera from the html element and disables VR
  94273. *
  94274. * @param element html element to detach from
  94275. */
  94276. detachControl(element: HTMLElement): void;
  94277. /**
  94278. * @returns the name of this class
  94279. */
  94280. getClassName(): string;
  94281. /**
  94282. * Calls resetPose on the vrDisplay
  94283. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  94284. */
  94285. resetToCurrentRotation(): void;
  94286. /**
  94287. * @hidden
  94288. * Updates the rig cameras (left and right eye)
  94289. */
  94290. _updateRigCameras(): void;
  94291. private _workingVector;
  94292. private _oneVector;
  94293. private _workingMatrix;
  94294. private updateCacheCalled;
  94295. private _correctPositionIfNotTrackPosition;
  94296. /**
  94297. * @hidden
  94298. * Updates the cached values of the camera
  94299. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  94300. */
  94301. _updateCache(ignoreParentClass?: boolean): void;
  94302. /**
  94303. * @hidden
  94304. * Get current device position in babylon world
  94305. */
  94306. _computeDevicePosition(): void;
  94307. /**
  94308. * Updates the current device position and rotation in the babylon world
  94309. */
  94310. update(): void;
  94311. /**
  94312. * @hidden
  94313. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  94314. * @returns an identity matrix
  94315. */
  94316. _getViewMatrix(): Matrix;
  94317. private _tmpMatrix;
  94318. /**
  94319. * This function is called by the two RIG cameras.
  94320. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  94321. * @hidden
  94322. */
  94323. _getWebVRViewMatrix(): Matrix;
  94324. /** @hidden */
  94325. _getWebVRProjectionMatrix(): Matrix;
  94326. private _onGamepadConnectedObserver;
  94327. private _onGamepadDisconnectedObserver;
  94328. private _updateCacheWhenTrackingDisabledObserver;
  94329. /**
  94330. * Initializes the controllers and their meshes
  94331. */
  94332. initControllers(): void;
  94333. }
  94334. }
  94335. declare module BABYLON {
  94336. /**
  94337. * Size options for a post process
  94338. */
  94339. export type PostProcessOptions = {
  94340. width: number;
  94341. height: number;
  94342. };
  94343. /**
  94344. * PostProcess can be used to apply a shader to a texture after it has been rendered
  94345. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  94346. */
  94347. export class PostProcess {
  94348. /** Name of the PostProcess. */
  94349. name: string;
  94350. /**
  94351. * Gets or sets the unique id of the post process
  94352. */
  94353. uniqueId: number;
  94354. /**
  94355. * Width of the texture to apply the post process on
  94356. */
  94357. width: number;
  94358. /**
  94359. * Height of the texture to apply the post process on
  94360. */
  94361. height: number;
  94362. /**
  94363. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  94364. * @hidden
  94365. */
  94366. _outputTexture: Nullable<InternalTexture>;
  94367. /**
  94368. * Sampling mode used by the shader
  94369. * See https://doc.babylonjs.com/classes/3.1/texture
  94370. */
  94371. renderTargetSamplingMode: number;
  94372. /**
  94373. * Clear color to use when screen clearing
  94374. */
  94375. clearColor: Color4;
  94376. /**
  94377. * If the buffer needs to be cleared before applying the post process. (default: true)
  94378. * Should be set to false if shader will overwrite all previous pixels.
  94379. */
  94380. autoClear: boolean;
  94381. /**
  94382. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  94383. */
  94384. alphaMode: number;
  94385. /**
  94386. * Sets the setAlphaBlendConstants of the babylon engine
  94387. */
  94388. alphaConstants: Color4;
  94389. /**
  94390. * Animations to be used for the post processing
  94391. */
  94392. animations: Animation[];
  94393. /**
  94394. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  94395. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  94396. */
  94397. enablePixelPerfectMode: boolean;
  94398. /**
  94399. * Force the postprocess to be applied without taking in account viewport
  94400. */
  94401. forceFullscreenViewport: boolean;
  94402. /**
  94403. * List of inspectable custom properties (used by the Inspector)
  94404. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94405. */
  94406. inspectableCustomProperties: IInspectable[];
  94407. /**
  94408. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  94409. *
  94410. * | Value | Type | Description |
  94411. * | ----- | ----------------------------------- | ----------- |
  94412. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  94413. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  94414. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  94415. *
  94416. */
  94417. scaleMode: number;
  94418. /**
  94419. * Force textures to be a power of two (default: false)
  94420. */
  94421. alwaysForcePOT: boolean;
  94422. private _samples;
  94423. /**
  94424. * Number of sample textures (default: 1)
  94425. */
  94426. get samples(): number;
  94427. set samples(n: number);
  94428. /**
  94429. * Modify the scale of the post process to be the same as the viewport (default: false)
  94430. */
  94431. adaptScaleToCurrentViewport: boolean;
  94432. private _camera;
  94433. private _scene;
  94434. private _engine;
  94435. private _options;
  94436. private _reusable;
  94437. private _textureType;
  94438. private _textureFormat;
  94439. /**
  94440. * Smart array of input and output textures for the post process.
  94441. * @hidden
  94442. */
  94443. _textures: SmartArray<InternalTexture>;
  94444. /**
  94445. * The index in _textures that corresponds to the output texture.
  94446. * @hidden
  94447. */
  94448. _currentRenderTextureInd: number;
  94449. private _effect;
  94450. private _samplers;
  94451. private _fragmentUrl;
  94452. private _vertexUrl;
  94453. private _parameters;
  94454. private _scaleRatio;
  94455. protected _indexParameters: any;
  94456. private _shareOutputWithPostProcess;
  94457. private _texelSize;
  94458. private _forcedOutputTexture;
  94459. /**
  94460. * Returns the fragment url or shader name used in the post process.
  94461. * @returns the fragment url or name in the shader store.
  94462. */
  94463. getEffectName(): string;
  94464. /**
  94465. * An event triggered when the postprocess is activated.
  94466. */
  94467. onActivateObservable: Observable<Camera>;
  94468. private _onActivateObserver;
  94469. /**
  94470. * A function that is added to the onActivateObservable
  94471. */
  94472. set onActivate(callback: Nullable<(camera: Camera) => void>);
  94473. /**
  94474. * An event triggered when the postprocess changes its size.
  94475. */
  94476. onSizeChangedObservable: Observable<PostProcess>;
  94477. private _onSizeChangedObserver;
  94478. /**
  94479. * A function that is added to the onSizeChangedObservable
  94480. */
  94481. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  94482. /**
  94483. * An event triggered when the postprocess applies its effect.
  94484. */
  94485. onApplyObservable: Observable<Effect>;
  94486. private _onApplyObserver;
  94487. /**
  94488. * A function that is added to the onApplyObservable
  94489. */
  94490. set onApply(callback: (effect: Effect) => void);
  94491. /**
  94492. * An event triggered before rendering the postprocess
  94493. */
  94494. onBeforeRenderObservable: Observable<Effect>;
  94495. private _onBeforeRenderObserver;
  94496. /**
  94497. * A function that is added to the onBeforeRenderObservable
  94498. */
  94499. set onBeforeRender(callback: (effect: Effect) => void);
  94500. /**
  94501. * An event triggered after rendering the postprocess
  94502. */
  94503. onAfterRenderObservable: Observable<Effect>;
  94504. private _onAfterRenderObserver;
  94505. /**
  94506. * A function that is added to the onAfterRenderObservable
  94507. */
  94508. set onAfterRender(callback: (efect: Effect) => void);
  94509. /**
  94510. * 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
  94511. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  94512. */
  94513. get inputTexture(): InternalTexture;
  94514. set inputTexture(value: InternalTexture);
  94515. /**
  94516. * Gets the camera which post process is applied to.
  94517. * @returns The camera the post process is applied to.
  94518. */
  94519. getCamera(): Camera;
  94520. /**
  94521. * Gets the texel size of the postprocess.
  94522. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  94523. */
  94524. get texelSize(): Vector2;
  94525. /**
  94526. * Creates a new instance PostProcess
  94527. * @param name The name of the PostProcess.
  94528. * @param fragmentUrl The url of the fragment shader to be used.
  94529. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  94530. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  94531. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  94532. * @param camera The camera to apply the render pass to.
  94533. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94534. * @param engine The engine which the post process will be applied. (default: current engine)
  94535. * @param reusable If the post process can be reused on the same frame. (default: false)
  94536. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  94537. * @param textureType Type of textures used when performing the post process. (default: 0)
  94538. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  94539. * @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
  94540. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  94541. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  94542. */
  94543. constructor(
  94544. /** Name of the PostProcess. */
  94545. 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, textureFormat?: number);
  94546. /**
  94547. * Gets a string idenfifying the name of the class
  94548. * @returns "PostProcess" string
  94549. */
  94550. getClassName(): string;
  94551. /**
  94552. * Gets the engine which this post process belongs to.
  94553. * @returns The engine the post process was enabled with.
  94554. */
  94555. getEngine(): Engine;
  94556. /**
  94557. * The effect that is created when initializing the post process.
  94558. * @returns The created effect corresponding the the postprocess.
  94559. */
  94560. getEffect(): Effect;
  94561. /**
  94562. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  94563. * @param postProcess The post process to share the output with.
  94564. * @returns This post process.
  94565. */
  94566. shareOutputWith(postProcess: PostProcess): PostProcess;
  94567. /**
  94568. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  94569. * This should be called if the post process that shares output with this post process is disabled/disposed.
  94570. */
  94571. useOwnOutput(): void;
  94572. /**
  94573. * Updates the effect with the current post process compile time values and recompiles the shader.
  94574. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  94575. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  94576. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  94577. * @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
  94578. * @param onCompiled Called when the shader has been compiled.
  94579. * @param onError Called if there is an error when compiling a shader.
  94580. */
  94581. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  94582. /**
  94583. * The post process is reusable if it can be used multiple times within one frame.
  94584. * @returns If the post process is reusable
  94585. */
  94586. isReusable(): boolean;
  94587. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  94588. markTextureDirty(): void;
  94589. /**
  94590. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  94591. * 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.
  94592. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  94593. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  94594. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  94595. * @returns The target texture that was bound to be written to.
  94596. */
  94597. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  94598. /**
  94599. * If the post process is supported.
  94600. */
  94601. get isSupported(): boolean;
  94602. /**
  94603. * The aspect ratio of the output texture.
  94604. */
  94605. get aspectRatio(): number;
  94606. /**
  94607. * Get a value indicating if the post-process is ready to be used
  94608. * @returns true if the post-process is ready (shader is compiled)
  94609. */
  94610. isReady(): boolean;
  94611. /**
  94612. * Binds all textures and uniforms to the shader, this will be run on every pass.
  94613. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  94614. */
  94615. apply(): Nullable<Effect>;
  94616. private _disposeTextures;
  94617. /**
  94618. * Disposes the post process.
  94619. * @param camera The camera to dispose the post process on.
  94620. */
  94621. dispose(camera?: Camera): void;
  94622. }
  94623. }
  94624. declare module BABYLON {
  94625. /** @hidden */
  94626. export var kernelBlurVaryingDeclaration: {
  94627. name: string;
  94628. shader: string;
  94629. };
  94630. }
  94631. declare module BABYLON {
  94632. /** @hidden */
  94633. export var kernelBlurFragment: {
  94634. name: string;
  94635. shader: string;
  94636. };
  94637. }
  94638. declare module BABYLON {
  94639. /** @hidden */
  94640. export var kernelBlurFragment2: {
  94641. name: string;
  94642. shader: string;
  94643. };
  94644. }
  94645. declare module BABYLON {
  94646. /** @hidden */
  94647. export var kernelBlurPixelShader: {
  94648. name: string;
  94649. shader: string;
  94650. };
  94651. }
  94652. declare module BABYLON {
  94653. /** @hidden */
  94654. export var kernelBlurVertex: {
  94655. name: string;
  94656. shader: string;
  94657. };
  94658. }
  94659. declare module BABYLON {
  94660. /** @hidden */
  94661. export var kernelBlurVertexShader: {
  94662. name: string;
  94663. shader: string;
  94664. };
  94665. }
  94666. declare module BABYLON {
  94667. /**
  94668. * The Blur Post Process which blurs an image based on a kernel and direction.
  94669. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  94670. */
  94671. export class BlurPostProcess extends PostProcess {
  94672. /** The direction in which to blur the image. */
  94673. direction: Vector2;
  94674. private blockCompilation;
  94675. protected _kernel: number;
  94676. protected _idealKernel: number;
  94677. protected _packedFloat: boolean;
  94678. private _staticDefines;
  94679. /**
  94680. * Sets the length in pixels of the blur sample region
  94681. */
  94682. set kernel(v: number);
  94683. /**
  94684. * Gets the length in pixels of the blur sample region
  94685. */
  94686. get kernel(): number;
  94687. /**
  94688. * Sets wether or not the blur needs to unpack/repack floats
  94689. */
  94690. set packedFloat(v: boolean);
  94691. /**
  94692. * Gets wether or not the blur is unpacking/repacking floats
  94693. */
  94694. get packedFloat(): boolean;
  94695. /**
  94696. * Creates a new instance BlurPostProcess
  94697. * @param name The name of the effect.
  94698. * @param direction The direction in which to blur the image.
  94699. * @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.
  94700. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  94701. * @param camera The camera to apply the render pass to.
  94702. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94703. * @param engine The engine which the post process will be applied. (default: current engine)
  94704. * @param reusable If the post process can be reused on the same frame. (default: false)
  94705. * @param textureType Type of textures used when performing the post process. (default: 0)
  94706. * @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)
  94707. */
  94708. constructor(name: string,
  94709. /** The direction in which to blur the image. */
  94710. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  94711. /**
  94712. * Updates the effect with the current post process compile time values and recompiles the shader.
  94713. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  94714. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  94715. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  94716. * @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
  94717. * @param onCompiled Called when the shader has been compiled.
  94718. * @param onError Called if there is an error when compiling a shader.
  94719. */
  94720. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  94721. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  94722. /**
  94723. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  94724. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  94725. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  94726. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  94727. * The gaps between physical kernels are compensated for in the weighting of the samples
  94728. * @param idealKernel Ideal blur kernel.
  94729. * @return Nearest best kernel.
  94730. */
  94731. protected _nearestBestKernel(idealKernel: number): number;
  94732. /**
  94733. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  94734. * @param x The point on the Gaussian distribution to sample.
  94735. * @return the value of the Gaussian function at x.
  94736. */
  94737. protected _gaussianWeight(x: number): number;
  94738. /**
  94739. * Generates a string that can be used as a floating point number in GLSL.
  94740. * @param x Value to print.
  94741. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  94742. * @return GLSL float string.
  94743. */
  94744. protected _glslFloat(x: number, decimalFigures?: number): string;
  94745. }
  94746. }
  94747. declare module BABYLON {
  94748. /**
  94749. * Mirror texture can be used to simulate the view from a mirror in a scene.
  94750. * It will dynamically be rendered every frame to adapt to the camera point of view.
  94751. * You can then easily use it as a reflectionTexture on a flat surface.
  94752. * In case the surface is not a plane, please consider relying on reflection probes.
  94753. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  94754. */
  94755. export class MirrorTexture extends RenderTargetTexture {
  94756. private scene;
  94757. /**
  94758. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  94759. * 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.
  94760. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  94761. */
  94762. mirrorPlane: Plane;
  94763. /**
  94764. * Define the blur ratio used to blur the reflection if needed.
  94765. */
  94766. set blurRatio(value: number);
  94767. get blurRatio(): number;
  94768. /**
  94769. * Define the adaptive blur kernel used to blur the reflection if needed.
  94770. * This will autocompute the closest best match for the `blurKernel`
  94771. */
  94772. set adaptiveBlurKernel(value: number);
  94773. /**
  94774. * Define the blur kernel used to blur the reflection if needed.
  94775. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  94776. */
  94777. set blurKernel(value: number);
  94778. /**
  94779. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  94780. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  94781. */
  94782. set blurKernelX(value: number);
  94783. get blurKernelX(): number;
  94784. /**
  94785. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  94786. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  94787. */
  94788. set blurKernelY(value: number);
  94789. get blurKernelY(): number;
  94790. private _autoComputeBlurKernel;
  94791. protected _onRatioRescale(): void;
  94792. private _updateGammaSpace;
  94793. private _imageProcessingConfigChangeObserver;
  94794. private _transformMatrix;
  94795. private _mirrorMatrix;
  94796. private _savedViewMatrix;
  94797. private _blurX;
  94798. private _blurY;
  94799. private _adaptiveBlurKernel;
  94800. private _blurKernelX;
  94801. private _blurKernelY;
  94802. private _blurRatio;
  94803. /**
  94804. * Instantiates a Mirror Texture.
  94805. * Mirror texture can be used to simulate the view from a mirror in a scene.
  94806. * It will dynamically be rendered every frame to adapt to the camera point of view.
  94807. * You can then easily use it as a reflectionTexture on a flat surface.
  94808. * In case the surface is not a plane, please consider relying on reflection probes.
  94809. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  94810. * @param name
  94811. * @param size
  94812. * @param scene
  94813. * @param generateMipMaps
  94814. * @param type
  94815. * @param samplingMode
  94816. * @param generateDepthBuffer
  94817. */
  94818. constructor(name: string, size: number | {
  94819. width: number;
  94820. height: number;
  94821. } | {
  94822. ratio: number;
  94823. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  94824. private _preparePostProcesses;
  94825. /**
  94826. * Clone the mirror texture.
  94827. * @returns the cloned texture
  94828. */
  94829. clone(): MirrorTexture;
  94830. /**
  94831. * Serialize the texture to a JSON representation you could use in Parse later on
  94832. * @returns the serialized JSON representation
  94833. */
  94834. serialize(): any;
  94835. /**
  94836. * Dispose the texture and release its associated resources.
  94837. */
  94838. dispose(): void;
  94839. }
  94840. }
  94841. declare module BABYLON {
  94842. /**
  94843. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  94844. * @see http://doc.babylonjs.com/babylon101/materials#texture
  94845. */
  94846. export class Texture extends BaseTexture {
  94847. /**
  94848. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  94849. */
  94850. static SerializeBuffers: boolean;
  94851. /** @hidden */
  94852. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  94853. /** @hidden */
  94854. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  94855. /** @hidden */
  94856. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  94857. /** nearest is mag = nearest and min = nearest and mip = linear */
  94858. static readonly NEAREST_SAMPLINGMODE: number;
  94859. /** nearest is mag = nearest and min = nearest and mip = linear */
  94860. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  94861. /** Bilinear is mag = linear and min = linear and mip = nearest */
  94862. static readonly BILINEAR_SAMPLINGMODE: number;
  94863. /** Bilinear is mag = linear and min = linear and mip = nearest */
  94864. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  94865. /** Trilinear is mag = linear and min = linear and mip = linear */
  94866. static readonly TRILINEAR_SAMPLINGMODE: number;
  94867. /** Trilinear is mag = linear and min = linear and mip = linear */
  94868. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  94869. /** mag = nearest and min = nearest and mip = nearest */
  94870. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  94871. /** mag = nearest and min = linear and mip = nearest */
  94872. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  94873. /** mag = nearest and min = linear and mip = linear */
  94874. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  94875. /** mag = nearest and min = linear and mip = none */
  94876. static readonly NEAREST_LINEAR: number;
  94877. /** mag = nearest and min = nearest and mip = none */
  94878. static readonly NEAREST_NEAREST: number;
  94879. /** mag = linear and min = nearest and mip = nearest */
  94880. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  94881. /** mag = linear and min = nearest and mip = linear */
  94882. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  94883. /** mag = linear and min = linear and mip = none */
  94884. static readonly LINEAR_LINEAR: number;
  94885. /** mag = linear and min = nearest and mip = none */
  94886. static readonly LINEAR_NEAREST: number;
  94887. /** Explicit coordinates mode */
  94888. static readonly EXPLICIT_MODE: number;
  94889. /** Spherical coordinates mode */
  94890. static readonly SPHERICAL_MODE: number;
  94891. /** Planar coordinates mode */
  94892. static readonly PLANAR_MODE: number;
  94893. /** Cubic coordinates mode */
  94894. static readonly CUBIC_MODE: number;
  94895. /** Projection coordinates mode */
  94896. static readonly PROJECTION_MODE: number;
  94897. /** Inverse Cubic coordinates mode */
  94898. static readonly SKYBOX_MODE: number;
  94899. /** Inverse Cubic coordinates mode */
  94900. static readonly INVCUBIC_MODE: number;
  94901. /** Equirectangular coordinates mode */
  94902. static readonly EQUIRECTANGULAR_MODE: number;
  94903. /** Equirectangular Fixed coordinates mode */
  94904. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  94905. /** Equirectangular Fixed Mirrored coordinates mode */
  94906. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  94907. /** Texture is not repeating outside of 0..1 UVs */
  94908. static readonly CLAMP_ADDRESSMODE: number;
  94909. /** Texture is repeating outside of 0..1 UVs */
  94910. static readonly WRAP_ADDRESSMODE: number;
  94911. /** Texture is repeating and mirrored */
  94912. static readonly MIRROR_ADDRESSMODE: number;
  94913. /**
  94914. * 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
  94915. */
  94916. static UseSerializedUrlIfAny: boolean;
  94917. /**
  94918. * Define the url of the texture.
  94919. */
  94920. url: Nullable<string>;
  94921. /**
  94922. * Define an offset on the texture to offset the u coordinates of the UVs
  94923. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  94924. */
  94925. uOffset: number;
  94926. /**
  94927. * Define an offset on the texture to offset the v coordinates of the UVs
  94928. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  94929. */
  94930. vOffset: number;
  94931. /**
  94932. * Define an offset on the texture to scale the u coordinates of the UVs
  94933. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  94934. */
  94935. uScale: number;
  94936. /**
  94937. * Define an offset on the texture to scale the v coordinates of the UVs
  94938. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  94939. */
  94940. vScale: number;
  94941. /**
  94942. * Define an offset on the texture to rotate around the u coordinates of the UVs
  94943. * @see http://doc.babylonjs.com/how_to/more_materials
  94944. */
  94945. uAng: number;
  94946. /**
  94947. * Define an offset on the texture to rotate around the v coordinates of the UVs
  94948. * @see http://doc.babylonjs.com/how_to/more_materials
  94949. */
  94950. vAng: number;
  94951. /**
  94952. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  94953. * @see http://doc.babylonjs.com/how_to/more_materials
  94954. */
  94955. wAng: number;
  94956. /**
  94957. * Defines the center of rotation (U)
  94958. */
  94959. uRotationCenter: number;
  94960. /**
  94961. * Defines the center of rotation (V)
  94962. */
  94963. vRotationCenter: number;
  94964. /**
  94965. * Defines the center of rotation (W)
  94966. */
  94967. wRotationCenter: number;
  94968. /**
  94969. * Are mip maps generated for this texture or not.
  94970. */
  94971. get noMipmap(): boolean;
  94972. /**
  94973. * List of inspectable custom properties (used by the Inspector)
  94974. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94975. */
  94976. inspectableCustomProperties: Nullable<IInspectable[]>;
  94977. private _noMipmap;
  94978. /** @hidden */
  94979. _invertY: boolean;
  94980. private _rowGenerationMatrix;
  94981. private _cachedTextureMatrix;
  94982. private _projectionModeMatrix;
  94983. private _t0;
  94984. private _t1;
  94985. private _t2;
  94986. private _cachedUOffset;
  94987. private _cachedVOffset;
  94988. private _cachedUScale;
  94989. private _cachedVScale;
  94990. private _cachedUAng;
  94991. private _cachedVAng;
  94992. private _cachedWAng;
  94993. private _cachedProjectionMatrixId;
  94994. private _cachedCoordinatesMode;
  94995. /** @hidden */
  94996. protected _initialSamplingMode: number;
  94997. /** @hidden */
  94998. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  94999. private _deleteBuffer;
  95000. protected _format: Nullable<number>;
  95001. private _delayedOnLoad;
  95002. private _delayedOnError;
  95003. private _mimeType?;
  95004. /**
  95005. * Observable triggered once the texture has been loaded.
  95006. */
  95007. onLoadObservable: Observable<Texture>;
  95008. protected _isBlocking: boolean;
  95009. /**
  95010. * Is the texture preventing material to render while loading.
  95011. * If false, a default texture will be used instead of the loading one during the preparation step.
  95012. */
  95013. set isBlocking(value: boolean);
  95014. get isBlocking(): boolean;
  95015. /**
  95016. * Get the current sampling mode associated with the texture.
  95017. */
  95018. get samplingMode(): number;
  95019. /**
  95020. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  95021. */
  95022. get invertY(): boolean;
  95023. /**
  95024. * Instantiates a new texture.
  95025. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  95026. * @see http://doc.babylonjs.com/babylon101/materials#texture
  95027. * @param url defines the url of the picture to load as a texture
  95028. * @param scene defines the scene or engine the texture will belong to
  95029. * @param noMipmap defines if the texture will require mip maps or not
  95030. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  95031. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  95032. * @param onLoad defines a callback triggered when the texture has been loaded
  95033. * @param onError defines a callback triggered when an error occurred during the loading session
  95034. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  95035. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  95036. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  95037. * @param mimeType defines an optional mime type information
  95038. */
  95039. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  95040. /**
  95041. * Update the url (and optional buffer) of this texture if url was null during construction.
  95042. * @param url the url of the texture
  95043. * @param buffer the buffer of the texture (defaults to null)
  95044. * @param onLoad callback called when the texture is loaded (defaults to null)
  95045. */
  95046. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  95047. /**
  95048. * Finish the loading sequence of a texture flagged as delayed load.
  95049. * @hidden
  95050. */
  95051. delayLoad(): void;
  95052. private _prepareRowForTextureGeneration;
  95053. /**
  95054. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  95055. * @returns the transform matrix of the texture.
  95056. */
  95057. getTextureMatrix(uBase?: number): Matrix;
  95058. /**
  95059. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  95060. * @returns The reflection texture transform
  95061. */
  95062. getReflectionTextureMatrix(): Matrix;
  95063. /**
  95064. * Clones the texture.
  95065. * @returns the cloned texture
  95066. */
  95067. clone(): Texture;
  95068. /**
  95069. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  95070. * @returns The JSON representation of the texture
  95071. */
  95072. serialize(): any;
  95073. /**
  95074. * Get the current class name of the texture useful for serialization or dynamic coding.
  95075. * @returns "Texture"
  95076. */
  95077. getClassName(): string;
  95078. /**
  95079. * Dispose the texture and release its associated resources.
  95080. */
  95081. dispose(): void;
  95082. /**
  95083. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  95084. * @param parsedTexture Define the JSON representation of the texture
  95085. * @param scene Define the scene the parsed texture should be instantiated in
  95086. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  95087. * @returns The parsed texture if successful
  95088. */
  95089. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  95090. /**
  95091. * Creates a texture from its base 64 representation.
  95092. * @param data Define the base64 payload without the data: prefix
  95093. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  95094. * @param scene Define the scene the texture should belong to
  95095. * @param noMipmap Forces the texture to not create mip map information if true
  95096. * @param invertY define if the texture needs to be inverted on the y axis during loading
  95097. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  95098. * @param onLoad define a callback triggered when the texture has been loaded
  95099. * @param onError define a callback triggered when an error occurred during the loading session
  95100. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  95101. * @returns the created texture
  95102. */
  95103. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  95104. /**
  95105. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  95106. * @param data Define the base64 payload without the data: prefix
  95107. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  95108. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  95109. * @param scene Define the scene the texture should belong to
  95110. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  95111. * @param noMipmap Forces the texture to not create mip map information if true
  95112. * @param invertY define if the texture needs to be inverted on the y axis during loading
  95113. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  95114. * @param onLoad define a callback triggered when the texture has been loaded
  95115. * @param onError define a callback triggered when an error occurred during the loading session
  95116. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  95117. * @returns the created texture
  95118. */
  95119. 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;
  95120. }
  95121. }
  95122. declare module BABYLON {
  95123. /**
  95124. * PostProcessManager is used to manage one or more post processes or post process pipelines
  95125. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  95126. */
  95127. export class PostProcessManager {
  95128. private _scene;
  95129. private _indexBuffer;
  95130. private _vertexBuffers;
  95131. /**
  95132. * Creates a new instance PostProcess
  95133. * @param scene The scene that the post process is associated with.
  95134. */
  95135. constructor(scene: Scene);
  95136. private _prepareBuffers;
  95137. private _buildIndexBuffer;
  95138. /**
  95139. * Rebuilds the vertex buffers of the manager.
  95140. * @hidden
  95141. */
  95142. _rebuild(): void;
  95143. /**
  95144. * Prepares a frame to be run through a post process.
  95145. * @param sourceTexture The input texture to the post procesess. (default: null)
  95146. * @param postProcesses An array of post processes to be run. (default: null)
  95147. * @returns True if the post processes were able to be run.
  95148. * @hidden
  95149. */
  95150. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  95151. /**
  95152. * Manually render a set of post processes to a texture.
  95153. * @param postProcesses An array of post processes to be run.
  95154. * @param targetTexture The target texture to render to.
  95155. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  95156. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  95157. * @param lodLevel defines which lod of the texture to render to
  95158. */
  95159. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  95160. /**
  95161. * Finalize the result of the output of the postprocesses.
  95162. * @param doNotPresent If true the result will not be displayed to the screen.
  95163. * @param targetTexture The target texture to render to.
  95164. * @param faceIndex The index of the face to bind the target texture to.
  95165. * @param postProcesses The array of post processes to render.
  95166. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  95167. * @hidden
  95168. */
  95169. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  95170. /**
  95171. * Disposes of the post process manager.
  95172. */
  95173. dispose(): void;
  95174. }
  95175. }
  95176. declare module BABYLON {
  95177. /**
  95178. * This Helps creating a texture that will be created from a camera in your scene.
  95179. * It is basically a dynamic texture that could be used to create special effects for instance.
  95180. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  95181. */
  95182. export class RenderTargetTexture extends Texture {
  95183. isCube: boolean;
  95184. /**
  95185. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  95186. */
  95187. static readonly REFRESHRATE_RENDER_ONCE: number;
  95188. /**
  95189. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  95190. */
  95191. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  95192. /**
  95193. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  95194. * the central point of your effect and can save a lot of performances.
  95195. */
  95196. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  95197. /**
  95198. * Use this predicate to dynamically define the list of mesh you want to render.
  95199. * If set, the renderList property will be overwritten.
  95200. */
  95201. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  95202. private _renderList;
  95203. /**
  95204. * Use this list to define the list of mesh you want to render.
  95205. */
  95206. get renderList(): Nullable<Array<AbstractMesh>>;
  95207. set renderList(value: Nullable<Array<AbstractMesh>>);
  95208. /**
  95209. * Use this function to overload the renderList array at rendering time.
  95210. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  95211. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  95212. * the cube (if the RTT is a cube, else layerOrFace=0).
  95213. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  95214. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  95215. * hold dummy elements!
  95216. */
  95217. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  95218. private _hookArray;
  95219. /**
  95220. * Define if particles should be rendered in your texture.
  95221. */
  95222. renderParticles: boolean;
  95223. /**
  95224. * Define if sprites should be rendered in your texture.
  95225. */
  95226. renderSprites: boolean;
  95227. /**
  95228. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  95229. */
  95230. coordinatesMode: number;
  95231. /**
  95232. * Define the camera used to render the texture.
  95233. */
  95234. activeCamera: Nullable<Camera>;
  95235. /**
  95236. * Override the mesh isReady function with your own one.
  95237. */
  95238. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  95239. /**
  95240. * Override the render function of the texture with your own one.
  95241. */
  95242. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  95243. /**
  95244. * Define if camera post processes should be use while rendering the texture.
  95245. */
  95246. useCameraPostProcesses: boolean;
  95247. /**
  95248. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  95249. */
  95250. ignoreCameraViewport: boolean;
  95251. private _postProcessManager;
  95252. private _postProcesses;
  95253. private _resizeObserver;
  95254. /**
  95255. * An event triggered when the texture is unbind.
  95256. */
  95257. onBeforeBindObservable: Observable<RenderTargetTexture>;
  95258. /**
  95259. * An event triggered when the texture is unbind.
  95260. */
  95261. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  95262. private _onAfterUnbindObserver;
  95263. /**
  95264. * Set a after unbind callback in the texture.
  95265. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  95266. */
  95267. set onAfterUnbind(callback: () => void);
  95268. /**
  95269. * An event triggered before rendering the texture
  95270. */
  95271. onBeforeRenderObservable: Observable<number>;
  95272. private _onBeforeRenderObserver;
  95273. /**
  95274. * Set a before render callback in the texture.
  95275. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  95276. */
  95277. set onBeforeRender(callback: (faceIndex: number) => void);
  95278. /**
  95279. * An event triggered after rendering the texture
  95280. */
  95281. onAfterRenderObservable: Observable<number>;
  95282. private _onAfterRenderObserver;
  95283. /**
  95284. * Set a after render callback in the texture.
  95285. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  95286. */
  95287. set onAfterRender(callback: (faceIndex: number) => void);
  95288. /**
  95289. * An event triggered after the texture clear
  95290. */
  95291. onClearObservable: Observable<Engine>;
  95292. private _onClearObserver;
  95293. /**
  95294. * Set a clear callback in the texture.
  95295. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  95296. */
  95297. set onClear(callback: (Engine: Engine) => void);
  95298. /**
  95299. * An event triggered when the texture is resized.
  95300. */
  95301. onResizeObservable: Observable<RenderTargetTexture>;
  95302. /**
  95303. * Define the clear color of the Render Target if it should be different from the scene.
  95304. */
  95305. clearColor: Color4;
  95306. protected _size: number | {
  95307. width: number;
  95308. height: number;
  95309. layers?: number;
  95310. };
  95311. protected _initialSizeParameter: number | {
  95312. width: number;
  95313. height: number;
  95314. } | {
  95315. ratio: number;
  95316. };
  95317. protected _sizeRatio: Nullable<number>;
  95318. /** @hidden */
  95319. _generateMipMaps: boolean;
  95320. protected _renderingManager: RenderingManager;
  95321. /** @hidden */
  95322. _waitingRenderList: string[];
  95323. protected _doNotChangeAspectRatio: boolean;
  95324. protected _currentRefreshId: number;
  95325. protected _refreshRate: number;
  95326. protected _textureMatrix: Matrix;
  95327. protected _samples: number;
  95328. protected _renderTargetOptions: RenderTargetCreationOptions;
  95329. /**
  95330. * Gets render target creation options that were used.
  95331. */
  95332. get renderTargetOptions(): RenderTargetCreationOptions;
  95333. protected _engine: Engine;
  95334. protected _onRatioRescale(): void;
  95335. /**
  95336. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  95337. * It must define where the camera used to render the texture is set
  95338. */
  95339. boundingBoxPosition: Vector3;
  95340. private _boundingBoxSize;
  95341. /**
  95342. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  95343. * When defined, the cubemap will switch to local mode
  95344. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  95345. * @example https://www.babylonjs-playground.com/#RNASML
  95346. */
  95347. set boundingBoxSize(value: Vector3);
  95348. get boundingBoxSize(): Vector3;
  95349. /**
  95350. * In case the RTT has been created with a depth texture, get the associated
  95351. * depth texture.
  95352. * Otherwise, return null.
  95353. */
  95354. get depthStencilTexture(): Nullable<InternalTexture>;
  95355. /**
  95356. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  95357. * or used a shadow, depth texture...
  95358. * @param name The friendly name of the texture
  95359. * @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)
  95360. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  95361. * @param generateMipMaps True if mip maps need to be generated after render.
  95362. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  95363. * @param type The type of the buffer in the RTT (int, half float, float...)
  95364. * @param isCube True if a cube texture needs to be created
  95365. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  95366. * @param generateDepthBuffer True to generate a depth buffer
  95367. * @param generateStencilBuffer True to generate a stencil buffer
  95368. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  95369. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  95370. * @param delayAllocation if the texture allocation should be delayed (default: false)
  95371. */
  95372. constructor(name: string, size: number | {
  95373. width: number;
  95374. height: number;
  95375. layers?: number;
  95376. } | {
  95377. ratio: number;
  95378. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  95379. /**
  95380. * Creates a depth stencil texture.
  95381. * This is only available in WebGL 2 or with the depth texture extension available.
  95382. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  95383. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  95384. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  95385. */
  95386. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  95387. private _processSizeParameter;
  95388. /**
  95389. * Define the number of samples to use in case of MSAA.
  95390. * It defaults to one meaning no MSAA has been enabled.
  95391. */
  95392. get samples(): number;
  95393. set samples(value: number);
  95394. /**
  95395. * Resets the refresh counter of the texture and start bak from scratch.
  95396. * Could be useful to regenerate the texture if it is setup to render only once.
  95397. */
  95398. resetRefreshCounter(): void;
  95399. /**
  95400. * Define the refresh rate of the texture or the rendering frequency.
  95401. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  95402. */
  95403. get refreshRate(): number;
  95404. set refreshRate(value: number);
  95405. /**
  95406. * Adds a post process to the render target rendering passes.
  95407. * @param postProcess define the post process to add
  95408. */
  95409. addPostProcess(postProcess: PostProcess): void;
  95410. /**
  95411. * Clear all the post processes attached to the render target
  95412. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  95413. */
  95414. clearPostProcesses(dispose?: boolean): void;
  95415. /**
  95416. * Remove one of the post process from the list of attached post processes to the texture
  95417. * @param postProcess define the post process to remove from the list
  95418. */
  95419. removePostProcess(postProcess: PostProcess): void;
  95420. /** @hidden */
  95421. _shouldRender(): boolean;
  95422. /**
  95423. * Gets the actual render size of the texture.
  95424. * @returns the width of the render size
  95425. */
  95426. getRenderSize(): number;
  95427. /**
  95428. * Gets the actual render width of the texture.
  95429. * @returns the width of the render size
  95430. */
  95431. getRenderWidth(): number;
  95432. /**
  95433. * Gets the actual render height of the texture.
  95434. * @returns the height of the render size
  95435. */
  95436. getRenderHeight(): number;
  95437. /**
  95438. * Gets the actual number of layers of the texture.
  95439. * @returns the number of layers
  95440. */
  95441. getRenderLayers(): number;
  95442. /**
  95443. * Get if the texture can be rescaled or not.
  95444. */
  95445. get canRescale(): boolean;
  95446. /**
  95447. * Resize the texture using a ratio.
  95448. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  95449. */
  95450. scale(ratio: number): void;
  95451. /**
  95452. * Get the texture reflection matrix used to rotate/transform the reflection.
  95453. * @returns the reflection matrix
  95454. */
  95455. getReflectionTextureMatrix(): Matrix;
  95456. /**
  95457. * Resize the texture to a new desired size.
  95458. * Be carrefull as it will recreate all the data in the new texture.
  95459. * @param size Define the new size. It can be:
  95460. * - a number for squared texture,
  95461. * - an object containing { width: number, height: number }
  95462. * - or an object containing a ratio { ratio: number }
  95463. */
  95464. resize(size: number | {
  95465. width: number;
  95466. height: number;
  95467. } | {
  95468. ratio: number;
  95469. }): void;
  95470. private _defaultRenderListPrepared;
  95471. /**
  95472. * Renders all the objects from the render list into the texture.
  95473. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  95474. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  95475. */
  95476. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  95477. private _bestReflectionRenderTargetDimension;
  95478. private _prepareRenderingManager;
  95479. /**
  95480. * @hidden
  95481. * @param faceIndex face index to bind to if this is a cubetexture
  95482. * @param layer defines the index of the texture to bind in the array
  95483. */
  95484. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  95485. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  95486. private renderToTarget;
  95487. /**
  95488. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  95489. * This allowed control for front to back rendering or reversly depending of the special needs.
  95490. *
  95491. * @param renderingGroupId The rendering group id corresponding to its index
  95492. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  95493. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  95494. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  95495. */
  95496. 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;
  95497. /**
  95498. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  95499. *
  95500. * @param renderingGroupId The rendering group id corresponding to its index
  95501. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  95502. */
  95503. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  95504. /**
  95505. * Clones the texture.
  95506. * @returns the cloned texture
  95507. */
  95508. clone(): RenderTargetTexture;
  95509. /**
  95510. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  95511. * @returns The JSON representation of the texture
  95512. */
  95513. serialize(): any;
  95514. /**
  95515. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  95516. */
  95517. disposeFramebufferObjects(): void;
  95518. /**
  95519. * Dispose the texture and release its associated resources.
  95520. */
  95521. dispose(): void;
  95522. /** @hidden */
  95523. _rebuild(): void;
  95524. /**
  95525. * Clear the info related to rendering groups preventing retention point in material dispose.
  95526. */
  95527. freeRenderingGroups(): void;
  95528. /**
  95529. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  95530. * @returns the view count
  95531. */
  95532. getViewCount(): number;
  95533. }
  95534. }
  95535. declare module BABYLON {
  95536. /**
  95537. * Class used to manipulate GUIDs
  95538. */
  95539. export class GUID {
  95540. /**
  95541. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95542. * Be aware Math.random() could cause collisions, but:
  95543. * "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"
  95544. * @returns a pseudo random id
  95545. */
  95546. static RandomId(): string;
  95547. }
  95548. }
  95549. declare module BABYLON {
  95550. /**
  95551. * Options to be used when creating a shadow depth material
  95552. */
  95553. export interface IIOptionShadowDepthMaterial {
  95554. /** Variables in the vertex shader code that need to have their names remapped.
  95555. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  95556. * "var_name" should be either: worldPos or vNormalW
  95557. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  95558. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  95559. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  95560. */
  95561. remappedVariables?: string[];
  95562. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  95563. standalone?: boolean;
  95564. }
  95565. /**
  95566. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  95567. */
  95568. export class ShadowDepthWrapper {
  95569. private _scene;
  95570. private _options?;
  95571. private _baseMaterial;
  95572. private _onEffectCreatedObserver;
  95573. private _subMeshToEffect;
  95574. private _subMeshToDepthEffect;
  95575. private _meshes;
  95576. /** @hidden */
  95577. _matriceNames: any;
  95578. /** Gets the standalone status of the wrapper */
  95579. get standalone(): boolean;
  95580. /** Gets the base material the wrapper is built upon */
  95581. get baseMaterial(): Material;
  95582. /**
  95583. * Instantiate a new shadow depth wrapper.
  95584. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  95585. * generate the shadow depth map. For more information, please refer to the documentation:
  95586. * https://doc.babylonjs.com/babylon101/shadows
  95587. * @param baseMaterial Material to wrap
  95588. * @param scene Define the scene the material belongs to
  95589. * @param options Options used to create the wrapper
  95590. */
  95591. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  95592. /**
  95593. * Gets the effect to use to generate the depth map
  95594. * @param subMesh subMesh to get the effect for
  95595. * @param shadowGenerator shadow generator to get the effect for
  95596. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  95597. */
  95598. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  95599. /**
  95600. * Specifies that the submesh is ready to be used for depth rendering
  95601. * @param subMesh submesh to check
  95602. * @param defines the list of defines to take into account when checking the effect
  95603. * @param shadowGenerator combined with subMesh, it defines the effect to check
  95604. * @param useInstances specifies that instances should be used
  95605. * @returns a boolean indicating that the submesh is ready or not
  95606. */
  95607. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  95608. /**
  95609. * Disposes the resources
  95610. */
  95611. dispose(): void;
  95612. private _makeEffect;
  95613. }
  95614. }
  95615. declare module BABYLON {
  95616. /**
  95617. * Options for compiling materials.
  95618. */
  95619. export interface IMaterialCompilationOptions {
  95620. /**
  95621. * Defines whether clip planes are enabled.
  95622. */
  95623. clipPlane: boolean;
  95624. /**
  95625. * Defines whether instances are enabled.
  95626. */
  95627. useInstances: boolean;
  95628. }
  95629. /**
  95630. * Base class for the main features of a material in Babylon.js
  95631. */
  95632. export class Material implements IAnimatable {
  95633. /**
  95634. * Returns the triangle fill mode
  95635. */
  95636. static readonly TriangleFillMode: number;
  95637. /**
  95638. * Returns the wireframe mode
  95639. */
  95640. static readonly WireFrameFillMode: number;
  95641. /**
  95642. * Returns the point fill mode
  95643. */
  95644. static readonly PointFillMode: number;
  95645. /**
  95646. * Returns the point list draw mode
  95647. */
  95648. static readonly PointListDrawMode: number;
  95649. /**
  95650. * Returns the line list draw mode
  95651. */
  95652. static readonly LineListDrawMode: number;
  95653. /**
  95654. * Returns the line loop draw mode
  95655. */
  95656. static readonly LineLoopDrawMode: number;
  95657. /**
  95658. * Returns the line strip draw mode
  95659. */
  95660. static readonly LineStripDrawMode: number;
  95661. /**
  95662. * Returns the triangle strip draw mode
  95663. */
  95664. static readonly TriangleStripDrawMode: number;
  95665. /**
  95666. * Returns the triangle fan draw mode
  95667. */
  95668. static readonly TriangleFanDrawMode: number;
  95669. /**
  95670. * Stores the clock-wise side orientation
  95671. */
  95672. static readonly ClockWiseSideOrientation: number;
  95673. /**
  95674. * Stores the counter clock-wise side orientation
  95675. */
  95676. static readonly CounterClockWiseSideOrientation: number;
  95677. /**
  95678. * The dirty texture flag value
  95679. */
  95680. static readonly TextureDirtyFlag: number;
  95681. /**
  95682. * The dirty light flag value
  95683. */
  95684. static readonly LightDirtyFlag: number;
  95685. /**
  95686. * The dirty fresnel flag value
  95687. */
  95688. static readonly FresnelDirtyFlag: number;
  95689. /**
  95690. * The dirty attribute flag value
  95691. */
  95692. static readonly AttributesDirtyFlag: number;
  95693. /**
  95694. * The dirty misc flag value
  95695. */
  95696. static readonly MiscDirtyFlag: number;
  95697. /**
  95698. * The all dirty flag value
  95699. */
  95700. static readonly AllDirtyFlag: number;
  95701. /**
  95702. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  95703. */
  95704. static readonly MATERIAL_OPAQUE: number;
  95705. /**
  95706. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  95707. */
  95708. static readonly MATERIAL_ALPHATEST: number;
  95709. /**
  95710. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  95711. */
  95712. static readonly MATERIAL_ALPHABLEND: number;
  95713. /**
  95714. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  95715. * They are also discarded below the alpha cutoff threshold to improve performances.
  95716. */
  95717. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  95718. /**
  95719. * Custom callback helping to override the default shader used in the material.
  95720. */
  95721. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  95722. /**
  95723. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  95724. */
  95725. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  95726. /**
  95727. * The ID of the material
  95728. */
  95729. id: string;
  95730. /**
  95731. * Gets or sets the unique id of the material
  95732. */
  95733. uniqueId: number;
  95734. /**
  95735. * The name of the material
  95736. */
  95737. name: string;
  95738. /**
  95739. * Gets or sets user defined metadata
  95740. */
  95741. metadata: any;
  95742. /**
  95743. * For internal use only. Please do not use.
  95744. */
  95745. reservedDataStore: any;
  95746. /**
  95747. * Specifies if the ready state should be checked on each call
  95748. */
  95749. checkReadyOnEveryCall: boolean;
  95750. /**
  95751. * Specifies if the ready state should be checked once
  95752. */
  95753. checkReadyOnlyOnce: boolean;
  95754. /**
  95755. * The state of the material
  95756. */
  95757. state: string;
  95758. /**
  95759. * The alpha value of the material
  95760. */
  95761. protected _alpha: number;
  95762. /**
  95763. * List of inspectable custom properties (used by the Inspector)
  95764. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95765. */
  95766. inspectableCustomProperties: IInspectable[];
  95767. /**
  95768. * Sets the alpha value of the material
  95769. */
  95770. set alpha(value: number);
  95771. /**
  95772. * Gets the alpha value of the material
  95773. */
  95774. get alpha(): number;
  95775. /**
  95776. * Specifies if back face culling is enabled
  95777. */
  95778. protected _backFaceCulling: boolean;
  95779. /**
  95780. * Sets the back-face culling state
  95781. */
  95782. set backFaceCulling(value: boolean);
  95783. /**
  95784. * Gets the back-face culling state
  95785. */
  95786. get backFaceCulling(): boolean;
  95787. /**
  95788. * Stores the value for side orientation
  95789. */
  95790. sideOrientation: number;
  95791. /**
  95792. * Callback triggered when the material is compiled
  95793. */
  95794. onCompiled: Nullable<(effect: Effect) => void>;
  95795. /**
  95796. * Callback triggered when an error occurs
  95797. */
  95798. onError: Nullable<(effect: Effect, errors: string) => void>;
  95799. /**
  95800. * Callback triggered to get the render target textures
  95801. */
  95802. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  95803. /**
  95804. * Gets a boolean indicating that current material needs to register RTT
  95805. */
  95806. get hasRenderTargetTextures(): boolean;
  95807. /**
  95808. * Specifies if the material should be serialized
  95809. */
  95810. doNotSerialize: boolean;
  95811. /**
  95812. * @hidden
  95813. */
  95814. _storeEffectOnSubMeshes: boolean;
  95815. /**
  95816. * Stores the animations for the material
  95817. */
  95818. animations: Nullable<Array<Animation>>;
  95819. /**
  95820. * An event triggered when the material is disposed
  95821. */
  95822. onDisposeObservable: Observable<Material>;
  95823. /**
  95824. * An observer which watches for dispose events
  95825. */
  95826. private _onDisposeObserver;
  95827. private _onUnBindObservable;
  95828. /**
  95829. * Called during a dispose event
  95830. */
  95831. set onDispose(callback: () => void);
  95832. private _onBindObservable;
  95833. /**
  95834. * An event triggered when the material is bound
  95835. */
  95836. get onBindObservable(): Observable<AbstractMesh>;
  95837. /**
  95838. * An observer which watches for bind events
  95839. */
  95840. private _onBindObserver;
  95841. /**
  95842. * Called during a bind event
  95843. */
  95844. set onBind(callback: (Mesh: AbstractMesh) => void);
  95845. /**
  95846. * An event triggered when the material is unbound
  95847. */
  95848. get onUnBindObservable(): Observable<Material>;
  95849. protected _onEffectCreatedObservable: Nullable<Observable<{
  95850. effect: Effect;
  95851. subMesh: Nullable<SubMesh>;
  95852. }>>;
  95853. /**
  95854. * An event triggered when the effect is (re)created
  95855. */
  95856. get onEffectCreatedObservable(): Observable<{
  95857. effect: Effect;
  95858. subMesh: Nullable<SubMesh>;
  95859. }>;
  95860. /**
  95861. * Stores the value of the alpha mode
  95862. */
  95863. private _alphaMode;
  95864. /**
  95865. * Sets the value of the alpha mode.
  95866. *
  95867. * | Value | Type | Description |
  95868. * | --- | --- | --- |
  95869. * | 0 | ALPHA_DISABLE | |
  95870. * | 1 | ALPHA_ADD | |
  95871. * | 2 | ALPHA_COMBINE | |
  95872. * | 3 | ALPHA_SUBTRACT | |
  95873. * | 4 | ALPHA_MULTIPLY | |
  95874. * | 5 | ALPHA_MAXIMIZED | |
  95875. * | 6 | ALPHA_ONEONE | |
  95876. * | 7 | ALPHA_PREMULTIPLIED | |
  95877. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  95878. * | 9 | ALPHA_INTERPOLATE | |
  95879. * | 10 | ALPHA_SCREENMODE | |
  95880. *
  95881. */
  95882. set alphaMode(value: number);
  95883. /**
  95884. * Gets the value of the alpha mode
  95885. */
  95886. get alphaMode(): number;
  95887. /**
  95888. * Stores the state of the need depth pre-pass value
  95889. */
  95890. private _needDepthPrePass;
  95891. /**
  95892. * Sets the need depth pre-pass value
  95893. */
  95894. set needDepthPrePass(value: boolean);
  95895. /**
  95896. * Gets the depth pre-pass value
  95897. */
  95898. get needDepthPrePass(): boolean;
  95899. /**
  95900. * Specifies if depth writing should be disabled
  95901. */
  95902. disableDepthWrite: boolean;
  95903. /**
  95904. * Specifies if color writing should be disabled
  95905. */
  95906. disableColorWrite: boolean;
  95907. /**
  95908. * Specifies if depth writing should be forced
  95909. */
  95910. forceDepthWrite: boolean;
  95911. /**
  95912. * Specifies the depth function that should be used. 0 means the default engine function
  95913. */
  95914. depthFunction: number;
  95915. /**
  95916. * Specifies if there should be a separate pass for culling
  95917. */
  95918. separateCullingPass: boolean;
  95919. /**
  95920. * Stores the state specifing if fog should be enabled
  95921. */
  95922. private _fogEnabled;
  95923. /**
  95924. * Sets the state for enabling fog
  95925. */
  95926. set fogEnabled(value: boolean);
  95927. /**
  95928. * Gets the value of the fog enabled state
  95929. */
  95930. get fogEnabled(): boolean;
  95931. /**
  95932. * Stores the size of points
  95933. */
  95934. pointSize: number;
  95935. /**
  95936. * Stores the z offset value
  95937. */
  95938. zOffset: number;
  95939. /**
  95940. * Gets a value specifying if wireframe mode is enabled
  95941. */
  95942. get wireframe(): boolean;
  95943. /**
  95944. * Sets the state of wireframe mode
  95945. */
  95946. set wireframe(value: boolean);
  95947. /**
  95948. * Gets the value specifying if point clouds are enabled
  95949. */
  95950. get pointsCloud(): boolean;
  95951. /**
  95952. * Sets the state of point cloud mode
  95953. */
  95954. set pointsCloud(value: boolean);
  95955. /**
  95956. * Gets the material fill mode
  95957. */
  95958. get fillMode(): number;
  95959. /**
  95960. * Sets the material fill mode
  95961. */
  95962. set fillMode(value: number);
  95963. /**
  95964. * @hidden
  95965. * Stores the effects for the material
  95966. */
  95967. _effect: Nullable<Effect>;
  95968. /**
  95969. * Specifies if uniform buffers should be used
  95970. */
  95971. private _useUBO;
  95972. /**
  95973. * Stores a reference to the scene
  95974. */
  95975. private _scene;
  95976. /**
  95977. * Stores the fill mode state
  95978. */
  95979. private _fillMode;
  95980. /**
  95981. * Specifies if the depth write state should be cached
  95982. */
  95983. private _cachedDepthWriteState;
  95984. /**
  95985. * Specifies if the color write state should be cached
  95986. */
  95987. private _cachedColorWriteState;
  95988. /**
  95989. * Specifies if the depth function state should be cached
  95990. */
  95991. private _cachedDepthFunctionState;
  95992. /**
  95993. * Stores the uniform buffer
  95994. */
  95995. protected _uniformBuffer: UniformBuffer;
  95996. /** @hidden */
  95997. _indexInSceneMaterialArray: number;
  95998. /** @hidden */
  95999. meshMap: Nullable<{
  96000. [id: string]: AbstractMesh | undefined;
  96001. }>;
  96002. /**
  96003. * Creates a material instance
  96004. * @param name defines the name of the material
  96005. * @param scene defines the scene to reference
  96006. * @param doNotAdd specifies if the material should be added to the scene
  96007. */
  96008. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  96009. /**
  96010. * Returns a string representation of the current material
  96011. * @param fullDetails defines a boolean indicating which levels of logging is desired
  96012. * @returns a string with material information
  96013. */
  96014. toString(fullDetails?: boolean): string;
  96015. /**
  96016. * Gets the class name of the material
  96017. * @returns a string with the class name of the material
  96018. */
  96019. getClassName(): string;
  96020. /**
  96021. * Specifies if updates for the material been locked
  96022. */
  96023. get isFrozen(): boolean;
  96024. /**
  96025. * Locks updates for the material
  96026. */
  96027. freeze(): void;
  96028. /**
  96029. * Unlocks updates for the material
  96030. */
  96031. unfreeze(): void;
  96032. /**
  96033. * Specifies if the material is ready to be used
  96034. * @param mesh defines the mesh to check
  96035. * @param useInstances specifies if instances should be used
  96036. * @returns a boolean indicating if the material is ready to be used
  96037. */
  96038. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  96039. /**
  96040. * Specifies that the submesh is ready to be used
  96041. * @param mesh defines the mesh to check
  96042. * @param subMesh defines which submesh to check
  96043. * @param useInstances specifies that instances should be used
  96044. * @returns a boolean indicating that the submesh is ready or not
  96045. */
  96046. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  96047. /**
  96048. * Returns the material effect
  96049. * @returns the effect associated with the material
  96050. */
  96051. getEffect(): Nullable<Effect>;
  96052. /**
  96053. * Returns the current scene
  96054. * @returns a Scene
  96055. */
  96056. getScene(): Scene;
  96057. /**
  96058. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  96059. */
  96060. protected _forceAlphaTest: boolean;
  96061. /**
  96062. * The transparency mode of the material.
  96063. */
  96064. protected _transparencyMode: Nullable<number>;
  96065. /**
  96066. * Gets the current transparency mode.
  96067. */
  96068. get transparencyMode(): Nullable<number>;
  96069. /**
  96070. * Sets the transparency mode of the material.
  96071. *
  96072. * | Value | Type | Description |
  96073. * | ----- | ----------------------------------- | ----------- |
  96074. * | 0 | OPAQUE | |
  96075. * | 1 | ALPHATEST | |
  96076. * | 2 | ALPHABLEND | |
  96077. * | 3 | ALPHATESTANDBLEND | |
  96078. *
  96079. */
  96080. set transparencyMode(value: Nullable<number>);
  96081. /**
  96082. * Returns true if alpha blending should be disabled.
  96083. */
  96084. protected get _disableAlphaBlending(): boolean;
  96085. /**
  96086. * Specifies whether or not this material should be rendered in alpha blend mode.
  96087. * @returns a boolean specifying if alpha blending is needed
  96088. */
  96089. needAlphaBlending(): boolean;
  96090. /**
  96091. * Specifies if the mesh will require alpha blending
  96092. * @param mesh defines the mesh to check
  96093. * @returns a boolean specifying if alpha blending is needed for the mesh
  96094. */
  96095. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  96096. /**
  96097. * Specifies whether or not this material should be rendered in alpha test mode.
  96098. * @returns a boolean specifying if an alpha test is needed.
  96099. */
  96100. needAlphaTesting(): boolean;
  96101. /**
  96102. * Specifies if material alpha testing should be turned on for the mesh
  96103. * @param mesh defines the mesh to check
  96104. */
  96105. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  96106. /**
  96107. * Gets the texture used for the alpha test
  96108. * @returns the texture to use for alpha testing
  96109. */
  96110. getAlphaTestTexture(): Nullable<BaseTexture>;
  96111. /**
  96112. * Marks the material to indicate that it needs to be re-calculated
  96113. */
  96114. markDirty(): void;
  96115. /** @hidden */
  96116. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  96117. /**
  96118. * Binds the material to the mesh
  96119. * @param world defines the world transformation matrix
  96120. * @param mesh defines the mesh to bind the material to
  96121. */
  96122. bind(world: Matrix, mesh?: Mesh): void;
  96123. /**
  96124. * Binds the submesh to the material
  96125. * @param world defines the world transformation matrix
  96126. * @param mesh defines the mesh containing the submesh
  96127. * @param subMesh defines the submesh to bind the material to
  96128. */
  96129. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  96130. /**
  96131. * Binds the world matrix to the material
  96132. * @param world defines the world transformation matrix
  96133. */
  96134. bindOnlyWorldMatrix(world: Matrix): void;
  96135. /**
  96136. * Binds the scene's uniform buffer to the effect.
  96137. * @param effect defines the effect to bind to the scene uniform buffer
  96138. * @param sceneUbo defines the uniform buffer storing scene data
  96139. */
  96140. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  96141. /**
  96142. * Binds the view matrix to the effect
  96143. * @param effect defines the effect to bind the view matrix to
  96144. */
  96145. bindView(effect: Effect): void;
  96146. /**
  96147. * Binds the view projection matrix to the effect
  96148. * @param effect defines the effect to bind the view projection matrix to
  96149. */
  96150. bindViewProjection(effect: Effect): void;
  96151. /**
  96152. * Processes to execute after binding the material to a mesh
  96153. * @param mesh defines the rendered mesh
  96154. */
  96155. protected _afterBind(mesh?: Mesh): void;
  96156. /**
  96157. * Unbinds the material from the mesh
  96158. */
  96159. unbind(): void;
  96160. /**
  96161. * Gets the active textures from the material
  96162. * @returns an array of textures
  96163. */
  96164. getActiveTextures(): BaseTexture[];
  96165. /**
  96166. * Specifies if the material uses a texture
  96167. * @param texture defines the texture to check against the material
  96168. * @returns a boolean specifying if the material uses the texture
  96169. */
  96170. hasTexture(texture: BaseTexture): boolean;
  96171. /**
  96172. * Makes a duplicate of the material, and gives it a new name
  96173. * @param name defines the new name for the duplicated material
  96174. * @returns the cloned material
  96175. */
  96176. clone(name: string): Nullable<Material>;
  96177. /**
  96178. * Gets the meshes bound to the material
  96179. * @returns an array of meshes bound to the material
  96180. */
  96181. getBindedMeshes(): AbstractMesh[];
  96182. /**
  96183. * Force shader compilation
  96184. * @param mesh defines the mesh associated with this material
  96185. * @param onCompiled defines a function to execute once the material is compiled
  96186. * @param options defines the options to configure the compilation
  96187. * @param onError defines a function to execute if the material fails compiling
  96188. */
  96189. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  96190. /**
  96191. * Force shader compilation
  96192. * @param mesh defines the mesh that will use this material
  96193. * @param options defines additional options for compiling the shaders
  96194. * @returns a promise that resolves when the compilation completes
  96195. */
  96196. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  96197. private static readonly _AllDirtyCallBack;
  96198. private static readonly _ImageProcessingDirtyCallBack;
  96199. private static readonly _TextureDirtyCallBack;
  96200. private static readonly _FresnelDirtyCallBack;
  96201. private static readonly _MiscDirtyCallBack;
  96202. private static readonly _LightsDirtyCallBack;
  96203. private static readonly _AttributeDirtyCallBack;
  96204. private static _FresnelAndMiscDirtyCallBack;
  96205. private static _TextureAndMiscDirtyCallBack;
  96206. private static readonly _DirtyCallbackArray;
  96207. private static readonly _RunDirtyCallBacks;
  96208. /**
  96209. * Marks a define in the material to indicate that it needs to be re-computed
  96210. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  96211. */
  96212. markAsDirty(flag: number): void;
  96213. /**
  96214. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  96215. * @param func defines a function which checks material defines against the submeshes
  96216. */
  96217. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  96218. /**
  96219. * Indicates that we need to re-calculated for all submeshes
  96220. */
  96221. protected _markAllSubMeshesAsAllDirty(): void;
  96222. /**
  96223. * Indicates that image processing needs to be re-calculated for all submeshes
  96224. */
  96225. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  96226. /**
  96227. * Indicates that textures need to be re-calculated for all submeshes
  96228. */
  96229. protected _markAllSubMeshesAsTexturesDirty(): void;
  96230. /**
  96231. * Indicates that fresnel needs to be re-calculated for all submeshes
  96232. */
  96233. protected _markAllSubMeshesAsFresnelDirty(): void;
  96234. /**
  96235. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  96236. */
  96237. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  96238. /**
  96239. * Indicates that lights need to be re-calculated for all submeshes
  96240. */
  96241. protected _markAllSubMeshesAsLightsDirty(): void;
  96242. /**
  96243. * Indicates that attributes need to be re-calculated for all submeshes
  96244. */
  96245. protected _markAllSubMeshesAsAttributesDirty(): void;
  96246. /**
  96247. * Indicates that misc needs to be re-calculated for all submeshes
  96248. */
  96249. protected _markAllSubMeshesAsMiscDirty(): void;
  96250. /**
  96251. * Indicates that textures and misc need to be re-calculated for all submeshes
  96252. */
  96253. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  96254. /**
  96255. * Disposes the material
  96256. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  96257. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  96258. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  96259. */
  96260. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  96261. /** @hidden */
  96262. private releaseVertexArrayObject;
  96263. /**
  96264. * Serializes this material
  96265. * @returns the serialized material object
  96266. */
  96267. serialize(): any;
  96268. /**
  96269. * Creates a material from parsed material data
  96270. * @param parsedMaterial defines parsed material data
  96271. * @param scene defines the hosting scene
  96272. * @param rootUrl defines the root URL to use to load textures
  96273. * @returns a new material
  96274. */
  96275. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  96276. }
  96277. }
  96278. declare module BABYLON {
  96279. /**
  96280. * A multi-material is used to apply different materials to different parts of the same object without the need of
  96281. * separate meshes. This can be use to improve performances.
  96282. * @see http://doc.babylonjs.com/how_to/multi_materials
  96283. */
  96284. export class MultiMaterial extends Material {
  96285. private _subMaterials;
  96286. /**
  96287. * Gets or Sets the list of Materials used within the multi material.
  96288. * They need to be ordered according to the submeshes order in the associated mesh
  96289. */
  96290. get subMaterials(): Nullable<Material>[];
  96291. set subMaterials(value: Nullable<Material>[]);
  96292. /**
  96293. * Function used to align with Node.getChildren()
  96294. * @returns the list of Materials used within the multi material
  96295. */
  96296. getChildren(): Nullable<Material>[];
  96297. /**
  96298. * Instantiates a new Multi Material
  96299. * A multi-material is used to apply different materials to different parts of the same object without the need of
  96300. * separate meshes. This can be use to improve performances.
  96301. * @see http://doc.babylonjs.com/how_to/multi_materials
  96302. * @param name Define the name in the scene
  96303. * @param scene Define the scene the material belongs to
  96304. */
  96305. constructor(name: string, scene: Scene);
  96306. private _hookArray;
  96307. /**
  96308. * Get one of the submaterial by its index in the submaterials array
  96309. * @param index The index to look the sub material at
  96310. * @returns The Material if the index has been defined
  96311. */
  96312. getSubMaterial(index: number): Nullable<Material>;
  96313. /**
  96314. * Get the list of active textures for the whole sub materials list.
  96315. * @returns All the textures that will be used during the rendering
  96316. */
  96317. getActiveTextures(): BaseTexture[];
  96318. /**
  96319. * Gets the current class name of the material e.g. "MultiMaterial"
  96320. * Mainly use in serialization.
  96321. * @returns the class name
  96322. */
  96323. getClassName(): string;
  96324. /**
  96325. * Checks if the material is ready to render the requested sub mesh
  96326. * @param mesh Define the mesh the submesh belongs to
  96327. * @param subMesh Define the sub mesh to look readyness for
  96328. * @param useInstances Define whether or not the material is used with instances
  96329. * @returns true if ready, otherwise false
  96330. */
  96331. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  96332. /**
  96333. * Clones the current material and its related sub materials
  96334. * @param name Define the name of the newly cloned material
  96335. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  96336. * @returns the cloned material
  96337. */
  96338. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  96339. /**
  96340. * Serializes the materials into a JSON representation.
  96341. * @returns the JSON representation
  96342. */
  96343. serialize(): any;
  96344. /**
  96345. * Dispose the material and release its associated resources
  96346. * @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)
  96347. * @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)
  96348. * @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)
  96349. */
  96350. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  96351. /**
  96352. * Creates a MultiMaterial from parsed MultiMaterial data.
  96353. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  96354. * @param scene defines the hosting scene
  96355. * @returns a new MultiMaterial
  96356. */
  96357. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  96358. }
  96359. }
  96360. declare module BABYLON {
  96361. /**
  96362. * Base class for submeshes
  96363. */
  96364. export class BaseSubMesh {
  96365. /** @hidden */
  96366. _materialDefines: Nullable<MaterialDefines>;
  96367. /** @hidden */
  96368. _materialEffect: Nullable<Effect>;
  96369. /** @hidden */
  96370. _effectOverride: Nullable<Effect>;
  96371. /**
  96372. * Gets material defines used by the effect associated to the sub mesh
  96373. */
  96374. get materialDefines(): Nullable<MaterialDefines>;
  96375. /**
  96376. * Sets material defines used by the effect associated to the sub mesh
  96377. */
  96378. set materialDefines(defines: Nullable<MaterialDefines>);
  96379. /**
  96380. * Gets associated effect
  96381. */
  96382. get effect(): Nullable<Effect>;
  96383. /**
  96384. * Sets associated effect (effect used to render this submesh)
  96385. * @param effect defines the effect to associate with
  96386. * @param defines defines the set of defines used to compile this effect
  96387. */
  96388. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  96389. }
  96390. /**
  96391. * Defines a subdivision inside a mesh
  96392. */
  96393. export class SubMesh extends BaseSubMesh implements ICullable {
  96394. /** the material index to use */
  96395. materialIndex: number;
  96396. /** vertex index start */
  96397. verticesStart: number;
  96398. /** vertices count */
  96399. verticesCount: number;
  96400. /** index start */
  96401. indexStart: number;
  96402. /** indices count */
  96403. indexCount: number;
  96404. /** @hidden */
  96405. _linesIndexCount: number;
  96406. private _mesh;
  96407. private _renderingMesh;
  96408. private _boundingInfo;
  96409. private _linesIndexBuffer;
  96410. /** @hidden */
  96411. _lastColliderWorldVertices: Nullable<Vector3[]>;
  96412. /** @hidden */
  96413. _trianglePlanes: Plane[];
  96414. /** @hidden */
  96415. _lastColliderTransformMatrix: Nullable<Matrix>;
  96416. /** @hidden */
  96417. _renderId: number;
  96418. /** @hidden */
  96419. _alphaIndex: number;
  96420. /** @hidden */
  96421. _distanceToCamera: number;
  96422. /** @hidden */
  96423. _id: number;
  96424. private _currentMaterial;
  96425. /**
  96426. * Add a new submesh to a mesh
  96427. * @param materialIndex defines the material index to use
  96428. * @param verticesStart defines vertex index start
  96429. * @param verticesCount defines vertices count
  96430. * @param indexStart defines index start
  96431. * @param indexCount defines indices count
  96432. * @param mesh defines the parent mesh
  96433. * @param renderingMesh defines an optional rendering mesh
  96434. * @param createBoundingBox defines if bounding box should be created for this submesh
  96435. * @returns the new submesh
  96436. */
  96437. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  96438. /**
  96439. * Creates a new submesh
  96440. * @param materialIndex defines the material index to use
  96441. * @param verticesStart defines vertex index start
  96442. * @param verticesCount defines vertices count
  96443. * @param indexStart defines index start
  96444. * @param indexCount defines indices count
  96445. * @param mesh defines the parent mesh
  96446. * @param renderingMesh defines an optional rendering mesh
  96447. * @param createBoundingBox defines if bounding box should be created for this submesh
  96448. */
  96449. constructor(
  96450. /** the material index to use */
  96451. materialIndex: number,
  96452. /** vertex index start */
  96453. verticesStart: number,
  96454. /** vertices count */
  96455. verticesCount: number,
  96456. /** index start */
  96457. indexStart: number,
  96458. /** indices count */
  96459. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  96460. /**
  96461. * Returns true if this submesh covers the entire parent mesh
  96462. * @ignorenaming
  96463. */
  96464. get IsGlobal(): boolean;
  96465. /**
  96466. * Returns the submesh BoudingInfo object
  96467. * @returns current bounding info (or mesh's one if the submesh is global)
  96468. */
  96469. getBoundingInfo(): BoundingInfo;
  96470. /**
  96471. * Sets the submesh BoundingInfo
  96472. * @param boundingInfo defines the new bounding info to use
  96473. * @returns the SubMesh
  96474. */
  96475. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  96476. /**
  96477. * Returns the mesh of the current submesh
  96478. * @return the parent mesh
  96479. */
  96480. getMesh(): AbstractMesh;
  96481. /**
  96482. * Returns the rendering mesh of the submesh
  96483. * @returns the rendering mesh (could be different from parent mesh)
  96484. */
  96485. getRenderingMesh(): Mesh;
  96486. /**
  96487. * Returns the submesh material
  96488. * @returns null or the current material
  96489. */
  96490. getMaterial(): Nullable<Material>;
  96491. /**
  96492. * Sets a new updated BoundingInfo object to the submesh
  96493. * @param data defines an optional position array to use to determine the bounding info
  96494. * @returns the SubMesh
  96495. */
  96496. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  96497. /** @hidden */
  96498. _checkCollision(collider: Collider): boolean;
  96499. /**
  96500. * Updates the submesh BoundingInfo
  96501. * @param world defines the world matrix to use to update the bounding info
  96502. * @returns the submesh
  96503. */
  96504. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  96505. /**
  96506. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  96507. * @param frustumPlanes defines the frustum planes
  96508. * @returns true if the submesh is intersecting with the frustum
  96509. */
  96510. isInFrustum(frustumPlanes: Plane[]): boolean;
  96511. /**
  96512. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  96513. * @param frustumPlanes defines the frustum planes
  96514. * @returns true if the submesh is inside the frustum
  96515. */
  96516. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  96517. /**
  96518. * Renders the submesh
  96519. * @param enableAlphaMode defines if alpha needs to be used
  96520. * @returns the submesh
  96521. */
  96522. render(enableAlphaMode: boolean): SubMesh;
  96523. /**
  96524. * @hidden
  96525. */
  96526. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  96527. /**
  96528. * Checks if the submesh intersects with a ray
  96529. * @param ray defines the ray to test
  96530. * @returns true is the passed ray intersects the submesh bounding box
  96531. */
  96532. canIntersects(ray: Ray): boolean;
  96533. /**
  96534. * Intersects current submesh with a ray
  96535. * @param ray defines the ray to test
  96536. * @param positions defines mesh's positions array
  96537. * @param indices defines mesh's indices array
  96538. * @param fastCheck defines if the first intersection will be used (and not the closest)
  96539. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96540. * @returns intersection info or null if no intersection
  96541. */
  96542. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  96543. /** @hidden */
  96544. private _intersectLines;
  96545. /** @hidden */
  96546. private _intersectUnIndexedLines;
  96547. /** @hidden */
  96548. private _intersectTriangles;
  96549. /** @hidden */
  96550. private _intersectUnIndexedTriangles;
  96551. /** @hidden */
  96552. _rebuild(): void;
  96553. /**
  96554. * Creates a new submesh from the passed mesh
  96555. * @param newMesh defines the new hosting mesh
  96556. * @param newRenderingMesh defines an optional rendering mesh
  96557. * @returns the new submesh
  96558. */
  96559. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  96560. /**
  96561. * Release associated resources
  96562. */
  96563. dispose(): void;
  96564. /**
  96565. * Gets the class name
  96566. * @returns the string "SubMesh".
  96567. */
  96568. getClassName(): string;
  96569. /**
  96570. * Creates a new submesh from indices data
  96571. * @param materialIndex the index of the main mesh material
  96572. * @param startIndex the index where to start the copy in the mesh indices array
  96573. * @param indexCount the number of indices to copy then from the startIndex
  96574. * @param mesh the main mesh to create the submesh from
  96575. * @param renderingMesh the optional rendering mesh
  96576. * @returns a new submesh
  96577. */
  96578. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  96579. }
  96580. }
  96581. declare module BABYLON {
  96582. /**
  96583. * Class used to represent data loading progression
  96584. */
  96585. export class SceneLoaderFlags {
  96586. private static _ForceFullSceneLoadingForIncremental;
  96587. private static _ShowLoadingScreen;
  96588. private static _CleanBoneMatrixWeights;
  96589. private static _loggingLevel;
  96590. /**
  96591. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  96592. */
  96593. static get ForceFullSceneLoadingForIncremental(): boolean;
  96594. static set ForceFullSceneLoadingForIncremental(value: boolean);
  96595. /**
  96596. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  96597. */
  96598. static get ShowLoadingScreen(): boolean;
  96599. static set ShowLoadingScreen(value: boolean);
  96600. /**
  96601. * Defines the current logging level (while loading the scene)
  96602. * @ignorenaming
  96603. */
  96604. static get loggingLevel(): number;
  96605. static set loggingLevel(value: number);
  96606. /**
  96607. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  96608. */
  96609. static get CleanBoneMatrixWeights(): boolean;
  96610. static set CleanBoneMatrixWeights(value: boolean);
  96611. }
  96612. }
  96613. declare module BABYLON {
  96614. /**
  96615. * Class used to store geometry data (vertex buffers + index buffer)
  96616. */
  96617. export class Geometry implements IGetSetVerticesData {
  96618. /**
  96619. * Gets or sets the ID of the geometry
  96620. */
  96621. id: string;
  96622. /**
  96623. * Gets or sets the unique ID of the geometry
  96624. */
  96625. uniqueId: number;
  96626. /**
  96627. * Gets the delay loading state of the geometry (none by default which means not delayed)
  96628. */
  96629. delayLoadState: number;
  96630. /**
  96631. * Gets the file containing the data to load when running in delay load state
  96632. */
  96633. delayLoadingFile: Nullable<string>;
  96634. /**
  96635. * Callback called when the geometry is updated
  96636. */
  96637. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  96638. private _scene;
  96639. private _engine;
  96640. private _meshes;
  96641. private _totalVertices;
  96642. /** @hidden */
  96643. _indices: IndicesArray;
  96644. /** @hidden */
  96645. _vertexBuffers: {
  96646. [key: string]: VertexBuffer;
  96647. };
  96648. private _isDisposed;
  96649. private _extend;
  96650. private _boundingBias;
  96651. /** @hidden */
  96652. _delayInfo: Array<string>;
  96653. private _indexBuffer;
  96654. private _indexBufferIsUpdatable;
  96655. /** @hidden */
  96656. _boundingInfo: Nullable<BoundingInfo>;
  96657. /** @hidden */
  96658. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  96659. /** @hidden */
  96660. _softwareSkinningFrameId: number;
  96661. private _vertexArrayObjects;
  96662. private _updatable;
  96663. /** @hidden */
  96664. _positions: Nullable<Vector3[]>;
  96665. /**
  96666. * 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
  96667. */
  96668. get boundingBias(): Vector2;
  96669. /**
  96670. * 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
  96671. */
  96672. set boundingBias(value: Vector2);
  96673. /**
  96674. * Static function used to attach a new empty geometry to a mesh
  96675. * @param mesh defines the mesh to attach the geometry to
  96676. * @returns the new Geometry
  96677. */
  96678. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  96679. /** Get the list of meshes using this geometry */
  96680. get meshes(): Mesh[];
  96681. /**
  96682. * Creates a new geometry
  96683. * @param id defines the unique ID
  96684. * @param scene defines the hosting scene
  96685. * @param vertexData defines the VertexData used to get geometry data
  96686. * @param updatable defines if geometry must be updatable (false by default)
  96687. * @param mesh defines the mesh that will be associated with the geometry
  96688. */
  96689. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  96690. /**
  96691. * Gets the current extend of the geometry
  96692. */
  96693. get extend(): {
  96694. minimum: Vector3;
  96695. maximum: Vector3;
  96696. };
  96697. /**
  96698. * Gets the hosting scene
  96699. * @returns the hosting Scene
  96700. */
  96701. getScene(): Scene;
  96702. /**
  96703. * Gets the hosting engine
  96704. * @returns the hosting Engine
  96705. */
  96706. getEngine(): Engine;
  96707. /**
  96708. * Defines if the geometry is ready to use
  96709. * @returns true if the geometry is ready to be used
  96710. */
  96711. isReady(): boolean;
  96712. /**
  96713. * Gets a value indicating that the geometry should not be serialized
  96714. */
  96715. get doNotSerialize(): boolean;
  96716. /** @hidden */
  96717. _rebuild(): void;
  96718. /**
  96719. * Affects all geometry data in one call
  96720. * @param vertexData defines the geometry data
  96721. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  96722. */
  96723. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  96724. /**
  96725. * Set specific vertex data
  96726. * @param kind defines the data kind (Position, normal, etc...)
  96727. * @param data defines the vertex data to use
  96728. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  96729. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  96730. */
  96731. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  96732. /**
  96733. * Removes a specific vertex data
  96734. * @param kind defines the data kind (Position, normal, etc...)
  96735. */
  96736. removeVerticesData(kind: string): void;
  96737. /**
  96738. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  96739. * @param buffer defines the vertex buffer to use
  96740. * @param totalVertices defines the total number of vertices for position kind (could be null)
  96741. */
  96742. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  96743. /**
  96744. * Update a specific vertex buffer
  96745. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  96746. * It will do nothing if the buffer is not updatable
  96747. * @param kind defines the data kind (Position, normal, etc...)
  96748. * @param data defines the data to use
  96749. * @param offset defines the offset in the target buffer where to store the data
  96750. * @param useBytes set to true if the offset is in bytes
  96751. */
  96752. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  96753. /**
  96754. * Update a specific vertex buffer
  96755. * This function will create a new buffer if the current one is not updatable
  96756. * @param kind defines the data kind (Position, normal, etc...)
  96757. * @param data defines the data to use
  96758. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  96759. */
  96760. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  96761. private _updateBoundingInfo;
  96762. /** @hidden */
  96763. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  96764. /**
  96765. * Gets total number of vertices
  96766. * @returns the total number of vertices
  96767. */
  96768. getTotalVertices(): number;
  96769. /**
  96770. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  96771. * @param kind defines the data kind (Position, normal, etc...)
  96772. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  96773. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96774. * @returns a float array containing vertex data
  96775. */
  96776. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  96777. /**
  96778. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  96779. * @param kind defines the data kind (Position, normal, etc...)
  96780. * @returns true if the vertex buffer with the specified kind is updatable
  96781. */
  96782. isVertexBufferUpdatable(kind: string): boolean;
  96783. /**
  96784. * Gets a specific vertex buffer
  96785. * @param kind defines the data kind (Position, normal, etc...)
  96786. * @returns a VertexBuffer
  96787. */
  96788. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  96789. /**
  96790. * Returns all vertex buffers
  96791. * @return an object holding all vertex buffers indexed by kind
  96792. */
  96793. getVertexBuffers(): Nullable<{
  96794. [key: string]: VertexBuffer;
  96795. }>;
  96796. /**
  96797. * Gets a boolean indicating if specific vertex buffer is present
  96798. * @param kind defines the data kind (Position, normal, etc...)
  96799. * @returns true if data is present
  96800. */
  96801. isVerticesDataPresent(kind: string): boolean;
  96802. /**
  96803. * Gets a list of all attached data kinds (Position, normal, etc...)
  96804. * @returns a list of string containing all kinds
  96805. */
  96806. getVerticesDataKinds(): string[];
  96807. /**
  96808. * Update index buffer
  96809. * @param indices defines the indices to store in the index buffer
  96810. * @param offset defines the offset in the target buffer where to store the data
  96811. * @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)
  96812. */
  96813. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  96814. /**
  96815. * Creates a new index buffer
  96816. * @param indices defines the indices to store in the index buffer
  96817. * @param totalVertices defines the total number of vertices (could be null)
  96818. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  96819. */
  96820. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  96821. /**
  96822. * Return the total number of indices
  96823. * @returns the total number of indices
  96824. */
  96825. getTotalIndices(): number;
  96826. /**
  96827. * Gets the index buffer array
  96828. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  96829. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96830. * @returns the index buffer array
  96831. */
  96832. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  96833. /**
  96834. * Gets the index buffer
  96835. * @return the index buffer
  96836. */
  96837. getIndexBuffer(): Nullable<DataBuffer>;
  96838. /** @hidden */
  96839. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  96840. /**
  96841. * Release the associated resources for a specific mesh
  96842. * @param mesh defines the source mesh
  96843. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  96844. */
  96845. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  96846. /**
  96847. * Apply current geometry to a given mesh
  96848. * @param mesh defines the mesh to apply geometry to
  96849. */
  96850. applyToMesh(mesh: Mesh): void;
  96851. private _updateExtend;
  96852. private _applyToMesh;
  96853. private notifyUpdate;
  96854. /**
  96855. * Load the geometry if it was flagged as delay loaded
  96856. * @param scene defines the hosting scene
  96857. * @param onLoaded defines a callback called when the geometry is loaded
  96858. */
  96859. load(scene: Scene, onLoaded?: () => void): void;
  96860. private _queueLoad;
  96861. /**
  96862. * Invert the geometry to move from a right handed system to a left handed one.
  96863. */
  96864. toLeftHanded(): void;
  96865. /** @hidden */
  96866. _resetPointsArrayCache(): void;
  96867. /** @hidden */
  96868. _generatePointsArray(): boolean;
  96869. /**
  96870. * Gets a value indicating if the geometry is disposed
  96871. * @returns true if the geometry was disposed
  96872. */
  96873. isDisposed(): boolean;
  96874. private _disposeVertexArrayObjects;
  96875. /**
  96876. * Free all associated resources
  96877. */
  96878. dispose(): void;
  96879. /**
  96880. * Clone the current geometry into a new geometry
  96881. * @param id defines the unique ID of the new geometry
  96882. * @returns a new geometry object
  96883. */
  96884. copy(id: string): Geometry;
  96885. /**
  96886. * Serialize the current geometry info (and not the vertices data) into a JSON object
  96887. * @return a JSON representation of the current geometry data (without the vertices data)
  96888. */
  96889. serialize(): any;
  96890. private toNumberArray;
  96891. /**
  96892. * Serialize all vertices data into a JSON oject
  96893. * @returns a JSON representation of the current geometry data
  96894. */
  96895. serializeVerticeData(): any;
  96896. /**
  96897. * Extracts a clone of a mesh geometry
  96898. * @param mesh defines the source mesh
  96899. * @param id defines the unique ID of the new geometry object
  96900. * @returns the new geometry object
  96901. */
  96902. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  96903. /**
  96904. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  96905. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  96906. * Be aware Math.random() could cause collisions, but:
  96907. * "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"
  96908. * @returns a string containing a new GUID
  96909. */
  96910. static RandomId(): string;
  96911. /** @hidden */
  96912. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  96913. private static _CleanMatricesWeights;
  96914. /**
  96915. * Create a new geometry from persisted data (Using .babylon file format)
  96916. * @param parsedVertexData defines the persisted data
  96917. * @param scene defines the hosting scene
  96918. * @param rootUrl defines the root url to use to load assets (like delayed data)
  96919. * @returns the new geometry object
  96920. */
  96921. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  96922. }
  96923. }
  96924. declare module BABYLON {
  96925. /**
  96926. * Define an interface for all classes that will get and set the data on vertices
  96927. */
  96928. export interface IGetSetVerticesData {
  96929. /**
  96930. * Gets a boolean indicating if specific vertex data is present
  96931. * @param kind defines the vertex data kind to use
  96932. * @returns true is data kind is present
  96933. */
  96934. isVerticesDataPresent(kind: string): boolean;
  96935. /**
  96936. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  96937. * @param kind defines the data kind (Position, normal, etc...)
  96938. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  96939. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96940. * @returns a float array containing vertex data
  96941. */
  96942. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  96943. /**
  96944. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  96945. * @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.
  96946. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96947. * @returns the indices array or an empty array if the mesh has no geometry
  96948. */
  96949. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  96950. /**
  96951. * Set specific vertex data
  96952. * @param kind defines the data kind (Position, normal, etc...)
  96953. * @param data defines the vertex data to use
  96954. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  96955. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  96956. */
  96957. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  96958. /**
  96959. * Update a specific associated vertex buffer
  96960. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  96961. * - VertexBuffer.PositionKind
  96962. * - VertexBuffer.UVKind
  96963. * - VertexBuffer.UV2Kind
  96964. * - VertexBuffer.UV3Kind
  96965. * - VertexBuffer.UV4Kind
  96966. * - VertexBuffer.UV5Kind
  96967. * - VertexBuffer.UV6Kind
  96968. * - VertexBuffer.ColorKind
  96969. * - VertexBuffer.MatricesIndicesKind
  96970. * - VertexBuffer.MatricesIndicesExtraKind
  96971. * - VertexBuffer.MatricesWeightsKind
  96972. * - VertexBuffer.MatricesWeightsExtraKind
  96973. * @param data defines the data source
  96974. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  96975. * @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)
  96976. */
  96977. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  96978. /**
  96979. * Creates a new index buffer
  96980. * @param indices defines the indices to store in the index buffer
  96981. * @param totalVertices defines the total number of vertices (could be null)
  96982. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  96983. */
  96984. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  96985. }
  96986. /**
  96987. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  96988. */
  96989. export class VertexData {
  96990. /**
  96991. * Mesh side orientation : usually the external or front surface
  96992. */
  96993. static readonly FRONTSIDE: number;
  96994. /**
  96995. * Mesh side orientation : usually the internal or back surface
  96996. */
  96997. static readonly BACKSIDE: number;
  96998. /**
  96999. * Mesh side orientation : both internal and external or front and back surfaces
  97000. */
  97001. static readonly DOUBLESIDE: number;
  97002. /**
  97003. * Mesh side orientation : by default, `FRONTSIDE`
  97004. */
  97005. static readonly DEFAULTSIDE: number;
  97006. /**
  97007. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  97008. */
  97009. positions: Nullable<FloatArray>;
  97010. /**
  97011. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  97012. */
  97013. normals: Nullable<FloatArray>;
  97014. /**
  97015. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  97016. */
  97017. tangents: Nullable<FloatArray>;
  97018. /**
  97019. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  97020. */
  97021. uvs: Nullable<FloatArray>;
  97022. /**
  97023. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  97024. */
  97025. uvs2: Nullable<FloatArray>;
  97026. /**
  97027. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  97028. */
  97029. uvs3: Nullable<FloatArray>;
  97030. /**
  97031. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  97032. */
  97033. uvs4: Nullable<FloatArray>;
  97034. /**
  97035. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  97036. */
  97037. uvs5: Nullable<FloatArray>;
  97038. /**
  97039. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  97040. */
  97041. uvs6: Nullable<FloatArray>;
  97042. /**
  97043. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  97044. */
  97045. colors: Nullable<FloatArray>;
  97046. /**
  97047. * 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).
  97048. */
  97049. matricesIndices: Nullable<FloatArray>;
  97050. /**
  97051. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  97052. */
  97053. matricesWeights: Nullable<FloatArray>;
  97054. /**
  97055. * An array extending the number of possible indices
  97056. */
  97057. matricesIndicesExtra: Nullable<FloatArray>;
  97058. /**
  97059. * An array extending the number of possible weights when the number of indices is extended
  97060. */
  97061. matricesWeightsExtra: Nullable<FloatArray>;
  97062. /**
  97063. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  97064. */
  97065. indices: Nullable<IndicesArray>;
  97066. /**
  97067. * Uses the passed data array to set the set the values for the specified kind of data
  97068. * @param data a linear array of floating numbers
  97069. * @param kind the type of data that is being set, eg positions, colors etc
  97070. */
  97071. set(data: FloatArray, kind: string): void;
  97072. /**
  97073. * Associates the vertexData to the passed Mesh.
  97074. * Sets it as updatable or not (default `false`)
  97075. * @param mesh the mesh the vertexData is applied to
  97076. * @param updatable when used and having the value true allows new data to update the vertexData
  97077. * @returns the VertexData
  97078. */
  97079. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  97080. /**
  97081. * Associates the vertexData to the passed Geometry.
  97082. * Sets it as updatable or not (default `false`)
  97083. * @param geometry the geometry the vertexData is applied to
  97084. * @param updatable when used and having the value true allows new data to update the vertexData
  97085. * @returns VertexData
  97086. */
  97087. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  97088. /**
  97089. * Updates the associated mesh
  97090. * @param mesh the mesh to be updated
  97091. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  97092. * @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
  97093. * @returns VertexData
  97094. */
  97095. updateMesh(mesh: Mesh): VertexData;
  97096. /**
  97097. * Updates the associated geometry
  97098. * @param geometry the geometry to be updated
  97099. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  97100. * @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
  97101. * @returns VertexData.
  97102. */
  97103. updateGeometry(geometry: Geometry): VertexData;
  97104. private _applyTo;
  97105. private _update;
  97106. /**
  97107. * Transforms each position and each normal of the vertexData according to the passed Matrix
  97108. * @param matrix the transforming matrix
  97109. * @returns the VertexData
  97110. */
  97111. transform(matrix: Matrix): VertexData;
  97112. /**
  97113. * Merges the passed VertexData into the current one
  97114. * @param other the VertexData to be merged into the current one
  97115. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  97116. * @returns the modified VertexData
  97117. */
  97118. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  97119. private _mergeElement;
  97120. private _validate;
  97121. /**
  97122. * Serializes the VertexData
  97123. * @returns a serialized object
  97124. */
  97125. serialize(): any;
  97126. /**
  97127. * Extracts the vertexData from a mesh
  97128. * @param mesh the mesh from which to extract the VertexData
  97129. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  97130. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  97131. * @returns the object VertexData associated to the passed mesh
  97132. */
  97133. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  97134. /**
  97135. * Extracts the vertexData from the geometry
  97136. * @param geometry the geometry from which to extract the VertexData
  97137. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  97138. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  97139. * @returns the object VertexData associated to the passed mesh
  97140. */
  97141. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  97142. private static _ExtractFrom;
  97143. /**
  97144. * Creates the VertexData for a Ribbon
  97145. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  97146. * * pathArray array of paths, each of which an array of successive Vector3
  97147. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  97148. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  97149. * * 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
  97150. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97151. * * 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)
  97152. * * 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)
  97153. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  97154. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  97155. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  97156. * @returns the VertexData of the ribbon
  97157. */
  97158. static CreateRibbon(options: {
  97159. pathArray: Vector3[][];
  97160. closeArray?: boolean;
  97161. closePath?: boolean;
  97162. offset?: number;
  97163. sideOrientation?: number;
  97164. frontUVs?: Vector4;
  97165. backUVs?: Vector4;
  97166. invertUV?: boolean;
  97167. uvs?: Vector2[];
  97168. colors?: Color4[];
  97169. }): VertexData;
  97170. /**
  97171. * Creates the VertexData for a box
  97172. * @param options an object used to set the following optional parameters for the box, required but can be empty
  97173. * * size sets the width, height and depth of the box to the value of size, optional default 1
  97174. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  97175. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  97176. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  97177. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  97178. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  97179. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97180. * * 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)
  97181. * * 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)
  97182. * @returns the VertexData of the box
  97183. */
  97184. static CreateBox(options: {
  97185. size?: number;
  97186. width?: number;
  97187. height?: number;
  97188. depth?: number;
  97189. faceUV?: Vector4[];
  97190. faceColors?: Color4[];
  97191. sideOrientation?: number;
  97192. frontUVs?: Vector4;
  97193. backUVs?: Vector4;
  97194. }): VertexData;
  97195. /**
  97196. * Creates the VertexData for a tiled box
  97197. * @param options an object used to set the following optional parameters for the box, required but can be empty
  97198. * * faceTiles sets the pattern, tile size and number of tiles for a face
  97199. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  97200. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  97201. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97202. * @returns the VertexData of the box
  97203. */
  97204. static CreateTiledBox(options: {
  97205. pattern?: number;
  97206. width?: number;
  97207. height?: number;
  97208. depth?: number;
  97209. tileSize?: number;
  97210. tileWidth?: number;
  97211. tileHeight?: number;
  97212. alignHorizontal?: number;
  97213. alignVertical?: number;
  97214. faceUV?: Vector4[];
  97215. faceColors?: Color4[];
  97216. sideOrientation?: number;
  97217. }): VertexData;
  97218. /**
  97219. * Creates the VertexData for a tiled plane
  97220. * @param options an object used to set the following optional parameters for the box, required but can be empty
  97221. * * pattern a limited pattern arrangement depending on the number
  97222. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  97223. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  97224. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  97225. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97226. * * 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)
  97227. * * 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)
  97228. * @returns the VertexData of the tiled plane
  97229. */
  97230. static CreateTiledPlane(options: {
  97231. pattern?: number;
  97232. tileSize?: number;
  97233. tileWidth?: number;
  97234. tileHeight?: number;
  97235. size?: number;
  97236. width?: number;
  97237. height?: number;
  97238. alignHorizontal?: number;
  97239. alignVertical?: number;
  97240. sideOrientation?: number;
  97241. frontUVs?: Vector4;
  97242. backUVs?: Vector4;
  97243. }): VertexData;
  97244. /**
  97245. * Creates the VertexData for an ellipsoid, defaults to a sphere
  97246. * @param options an object used to set the following optional parameters for the box, required but can be empty
  97247. * * segments sets the number of horizontal strips optional, default 32
  97248. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  97249. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  97250. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  97251. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  97252. * * 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
  97253. * * 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
  97254. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97255. * * 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)
  97256. * * 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)
  97257. * @returns the VertexData of the ellipsoid
  97258. */
  97259. static CreateSphere(options: {
  97260. segments?: number;
  97261. diameter?: number;
  97262. diameterX?: number;
  97263. diameterY?: number;
  97264. diameterZ?: number;
  97265. arc?: number;
  97266. slice?: number;
  97267. sideOrientation?: number;
  97268. frontUVs?: Vector4;
  97269. backUVs?: Vector4;
  97270. }): VertexData;
  97271. /**
  97272. * Creates the VertexData for a cylinder, cone or prism
  97273. * @param options an object used to set the following optional parameters for the box, required but can be empty
  97274. * * height sets the height (y direction) of the cylinder, optional, default 2
  97275. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  97276. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  97277. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  97278. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  97279. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  97280. * * 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
  97281. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  97282. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  97283. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  97284. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  97285. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97286. * * 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)
  97287. * * 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)
  97288. * @returns the VertexData of the cylinder, cone or prism
  97289. */
  97290. static CreateCylinder(options: {
  97291. height?: number;
  97292. diameterTop?: number;
  97293. diameterBottom?: number;
  97294. diameter?: number;
  97295. tessellation?: number;
  97296. subdivisions?: number;
  97297. arc?: number;
  97298. faceColors?: Color4[];
  97299. faceUV?: Vector4[];
  97300. hasRings?: boolean;
  97301. enclose?: boolean;
  97302. sideOrientation?: number;
  97303. frontUVs?: Vector4;
  97304. backUVs?: Vector4;
  97305. }): VertexData;
  97306. /**
  97307. * Creates the VertexData for a torus
  97308. * @param options an object used to set the following optional parameters for the box, required but can be empty
  97309. * * diameter the diameter of the torus, optional default 1
  97310. * * thickness the diameter of the tube forming the torus, optional default 0.5
  97311. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  97312. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97313. * * 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)
  97314. * * 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)
  97315. * @returns the VertexData of the torus
  97316. */
  97317. static CreateTorus(options: {
  97318. diameter?: number;
  97319. thickness?: number;
  97320. tessellation?: number;
  97321. sideOrientation?: number;
  97322. frontUVs?: Vector4;
  97323. backUVs?: Vector4;
  97324. }): VertexData;
  97325. /**
  97326. * Creates the VertexData of the LineSystem
  97327. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  97328. * - lines an array of lines, each line being an array of successive Vector3
  97329. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  97330. * @returns the VertexData of the LineSystem
  97331. */
  97332. static CreateLineSystem(options: {
  97333. lines: Vector3[][];
  97334. colors?: Nullable<Color4[][]>;
  97335. }): VertexData;
  97336. /**
  97337. * Create the VertexData for a DashedLines
  97338. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  97339. * - points an array successive Vector3
  97340. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  97341. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  97342. * - dashNb the intended total number of dashes, optional, default 200
  97343. * @returns the VertexData for the DashedLines
  97344. */
  97345. static CreateDashedLines(options: {
  97346. points: Vector3[];
  97347. dashSize?: number;
  97348. gapSize?: number;
  97349. dashNb?: number;
  97350. }): VertexData;
  97351. /**
  97352. * Creates the VertexData for a Ground
  97353. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  97354. * - width the width (x direction) of the ground, optional, default 1
  97355. * - height the height (z direction) of the ground, optional, default 1
  97356. * - subdivisions the number of subdivisions per side, optional, default 1
  97357. * @returns the VertexData of the Ground
  97358. */
  97359. static CreateGround(options: {
  97360. width?: number;
  97361. height?: number;
  97362. subdivisions?: number;
  97363. subdivisionsX?: number;
  97364. subdivisionsY?: number;
  97365. }): VertexData;
  97366. /**
  97367. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  97368. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  97369. * * xmin the ground minimum X coordinate, optional, default -1
  97370. * * zmin the ground minimum Z coordinate, optional, default -1
  97371. * * xmax the ground maximum X coordinate, optional, default 1
  97372. * * zmax the ground maximum Z coordinate, optional, default 1
  97373. * * 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}
  97374. * * 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}
  97375. * @returns the VertexData of the TiledGround
  97376. */
  97377. static CreateTiledGround(options: {
  97378. xmin: number;
  97379. zmin: number;
  97380. xmax: number;
  97381. zmax: number;
  97382. subdivisions?: {
  97383. w: number;
  97384. h: number;
  97385. };
  97386. precision?: {
  97387. w: number;
  97388. h: number;
  97389. };
  97390. }): VertexData;
  97391. /**
  97392. * Creates the VertexData of the Ground designed from a heightmap
  97393. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  97394. * * width the width (x direction) of the ground
  97395. * * height the height (z direction) of the ground
  97396. * * subdivisions the number of subdivisions per side
  97397. * * minHeight the minimum altitude on the ground, optional, default 0
  97398. * * maxHeight the maximum altitude on the ground, optional default 1
  97399. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  97400. * * buffer the array holding the image color data
  97401. * * bufferWidth the width of image
  97402. * * bufferHeight the height of image
  97403. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  97404. * @returns the VertexData of the Ground designed from a heightmap
  97405. */
  97406. static CreateGroundFromHeightMap(options: {
  97407. width: number;
  97408. height: number;
  97409. subdivisions: number;
  97410. minHeight: number;
  97411. maxHeight: number;
  97412. colorFilter: Color3;
  97413. buffer: Uint8Array;
  97414. bufferWidth: number;
  97415. bufferHeight: number;
  97416. alphaFilter: number;
  97417. }): VertexData;
  97418. /**
  97419. * Creates the VertexData for a Plane
  97420. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  97421. * * size sets the width and height of the plane to the value of size, optional default 1
  97422. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  97423. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  97424. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97425. * * 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)
  97426. * * 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)
  97427. * @returns the VertexData of the box
  97428. */
  97429. static CreatePlane(options: {
  97430. size?: number;
  97431. width?: number;
  97432. height?: number;
  97433. sideOrientation?: number;
  97434. frontUVs?: Vector4;
  97435. backUVs?: Vector4;
  97436. }): VertexData;
  97437. /**
  97438. * Creates the VertexData of the Disc or regular Polygon
  97439. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  97440. * * radius the radius of the disc, optional default 0.5
  97441. * * tessellation the number of polygon sides, optional, default 64
  97442. * * 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
  97443. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97444. * * 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)
  97445. * * 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)
  97446. * @returns the VertexData of the box
  97447. */
  97448. static CreateDisc(options: {
  97449. radius?: number;
  97450. tessellation?: number;
  97451. arc?: number;
  97452. sideOrientation?: number;
  97453. frontUVs?: Vector4;
  97454. backUVs?: Vector4;
  97455. }): VertexData;
  97456. /**
  97457. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  97458. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  97459. * @param polygon a mesh built from polygonTriangulation.build()
  97460. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97461. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  97462. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  97463. * @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)
  97464. * @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)
  97465. * @returns the VertexData of the Polygon
  97466. */
  97467. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  97468. /**
  97469. * Creates the VertexData of the IcoSphere
  97470. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  97471. * * radius the radius of the IcoSphere, optional default 1
  97472. * * radiusX allows stretching in the x direction, optional, default radius
  97473. * * radiusY allows stretching in the y direction, optional, default radius
  97474. * * radiusZ allows stretching in the z direction, optional, default radius
  97475. * * flat when true creates a flat shaded mesh, optional, default true
  97476. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  97477. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97478. * * 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)
  97479. * * 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)
  97480. * @returns the VertexData of the IcoSphere
  97481. */
  97482. static CreateIcoSphere(options: {
  97483. radius?: number;
  97484. radiusX?: number;
  97485. radiusY?: number;
  97486. radiusZ?: number;
  97487. flat?: boolean;
  97488. subdivisions?: number;
  97489. sideOrientation?: number;
  97490. frontUVs?: Vector4;
  97491. backUVs?: Vector4;
  97492. }): VertexData;
  97493. /**
  97494. * Creates the VertexData for a Polyhedron
  97495. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  97496. * * type provided types are:
  97497. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  97498. * * 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)
  97499. * * size the size of the IcoSphere, optional default 1
  97500. * * sizeX allows stretching in the x direction, optional, default size
  97501. * * sizeY allows stretching in the y direction, optional, default size
  97502. * * sizeZ allows stretching in the z direction, optional, default size
  97503. * * 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
  97504. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  97505. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  97506. * * flat when true creates a flat shaded mesh, optional, default true
  97507. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  97508. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97509. * * 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)
  97510. * * 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)
  97511. * @returns the VertexData of the Polyhedron
  97512. */
  97513. static CreatePolyhedron(options: {
  97514. type?: number;
  97515. size?: number;
  97516. sizeX?: number;
  97517. sizeY?: number;
  97518. sizeZ?: number;
  97519. custom?: any;
  97520. faceUV?: Vector4[];
  97521. faceColors?: Color4[];
  97522. flat?: boolean;
  97523. sideOrientation?: number;
  97524. frontUVs?: Vector4;
  97525. backUVs?: Vector4;
  97526. }): VertexData;
  97527. /**
  97528. * Creates the VertexData for a TorusKnot
  97529. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  97530. * * radius the radius of the torus knot, optional, default 2
  97531. * * tube the thickness of the tube, optional, default 0.5
  97532. * * radialSegments the number of sides on each tube segments, optional, default 32
  97533. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  97534. * * p the number of windings around the z axis, optional, default 2
  97535. * * q the number of windings around the x axis, optional, default 3
  97536. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97537. * * 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)
  97538. * * 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)
  97539. * @returns the VertexData of the Torus Knot
  97540. */
  97541. static CreateTorusKnot(options: {
  97542. radius?: number;
  97543. tube?: number;
  97544. radialSegments?: number;
  97545. tubularSegments?: number;
  97546. p?: number;
  97547. q?: number;
  97548. sideOrientation?: number;
  97549. frontUVs?: Vector4;
  97550. backUVs?: Vector4;
  97551. }): VertexData;
  97552. /**
  97553. * Compute normals for given positions and indices
  97554. * @param positions an array of vertex positions, [...., x, y, z, ......]
  97555. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  97556. * @param normals an array of vertex normals, [...., x, y, z, ......]
  97557. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  97558. * * facetNormals : optional array of facet normals (vector3)
  97559. * * facetPositions : optional array of facet positions (vector3)
  97560. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  97561. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  97562. * * bInfo : optional bounding info, required for facetPartitioning computation
  97563. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  97564. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  97565. * * useRightHandedSystem: optional boolean to for right handed system computation
  97566. * * depthSort : optional boolean to enable the facet depth sort computation
  97567. * * distanceTo : optional Vector3 to compute the facet depth from this location
  97568. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  97569. */
  97570. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  97571. facetNormals?: any;
  97572. facetPositions?: any;
  97573. facetPartitioning?: any;
  97574. ratio?: number;
  97575. bInfo?: any;
  97576. bbSize?: Vector3;
  97577. subDiv?: any;
  97578. useRightHandedSystem?: boolean;
  97579. depthSort?: boolean;
  97580. distanceTo?: Vector3;
  97581. depthSortedFacets?: any;
  97582. }): void;
  97583. /** @hidden */
  97584. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  97585. /**
  97586. * Applies VertexData created from the imported parameters to the geometry
  97587. * @param parsedVertexData the parsed data from an imported file
  97588. * @param geometry the geometry to apply the VertexData to
  97589. */
  97590. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  97591. }
  97592. }
  97593. declare module BABYLON {
  97594. /**
  97595. * Defines a target to use with MorphTargetManager
  97596. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97597. */
  97598. export class MorphTarget implements IAnimatable {
  97599. /** defines the name of the target */
  97600. name: string;
  97601. /**
  97602. * Gets or sets the list of animations
  97603. */
  97604. animations: Animation[];
  97605. private _scene;
  97606. private _positions;
  97607. private _normals;
  97608. private _tangents;
  97609. private _uvs;
  97610. private _influence;
  97611. private _uniqueId;
  97612. /**
  97613. * Observable raised when the influence changes
  97614. */
  97615. onInfluenceChanged: Observable<boolean>;
  97616. /** @hidden */
  97617. _onDataLayoutChanged: Observable<void>;
  97618. /**
  97619. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  97620. */
  97621. get influence(): number;
  97622. set influence(influence: number);
  97623. /**
  97624. * Gets or sets the id of the morph Target
  97625. */
  97626. id: string;
  97627. private _animationPropertiesOverride;
  97628. /**
  97629. * Gets or sets the animation properties override
  97630. */
  97631. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  97632. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  97633. /**
  97634. * Creates a new MorphTarget
  97635. * @param name defines the name of the target
  97636. * @param influence defines the influence to use
  97637. * @param scene defines the scene the morphtarget belongs to
  97638. */
  97639. constructor(
  97640. /** defines the name of the target */
  97641. name: string, influence?: number, scene?: Nullable<Scene>);
  97642. /**
  97643. * Gets the unique ID of this manager
  97644. */
  97645. get uniqueId(): number;
  97646. /**
  97647. * Gets a boolean defining if the target contains position data
  97648. */
  97649. get hasPositions(): boolean;
  97650. /**
  97651. * Gets a boolean defining if the target contains normal data
  97652. */
  97653. get hasNormals(): boolean;
  97654. /**
  97655. * Gets a boolean defining if the target contains tangent data
  97656. */
  97657. get hasTangents(): boolean;
  97658. /**
  97659. * Gets a boolean defining if the target contains texture coordinates data
  97660. */
  97661. get hasUVs(): boolean;
  97662. /**
  97663. * Affects position data to this target
  97664. * @param data defines the position data to use
  97665. */
  97666. setPositions(data: Nullable<FloatArray>): void;
  97667. /**
  97668. * Gets the position data stored in this target
  97669. * @returns a FloatArray containing the position data (or null if not present)
  97670. */
  97671. getPositions(): Nullable<FloatArray>;
  97672. /**
  97673. * Affects normal data to this target
  97674. * @param data defines the normal data to use
  97675. */
  97676. setNormals(data: Nullable<FloatArray>): void;
  97677. /**
  97678. * Gets the normal data stored in this target
  97679. * @returns a FloatArray containing the normal data (or null if not present)
  97680. */
  97681. getNormals(): Nullable<FloatArray>;
  97682. /**
  97683. * Affects tangent data to this target
  97684. * @param data defines the tangent data to use
  97685. */
  97686. setTangents(data: Nullable<FloatArray>): void;
  97687. /**
  97688. * Gets the tangent data stored in this target
  97689. * @returns a FloatArray containing the tangent data (or null if not present)
  97690. */
  97691. getTangents(): Nullable<FloatArray>;
  97692. /**
  97693. * Affects texture coordinates data to this target
  97694. * @param data defines the texture coordinates data to use
  97695. */
  97696. setUVs(data: Nullable<FloatArray>): void;
  97697. /**
  97698. * Gets the texture coordinates data stored in this target
  97699. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  97700. */
  97701. getUVs(): Nullable<FloatArray>;
  97702. /**
  97703. * Clone the current target
  97704. * @returns a new MorphTarget
  97705. */
  97706. clone(): MorphTarget;
  97707. /**
  97708. * Serializes the current target into a Serialization object
  97709. * @returns the serialized object
  97710. */
  97711. serialize(): any;
  97712. /**
  97713. * Returns the string "MorphTarget"
  97714. * @returns "MorphTarget"
  97715. */
  97716. getClassName(): string;
  97717. /**
  97718. * Creates a new target from serialized data
  97719. * @param serializationObject defines the serialized data to use
  97720. * @returns a new MorphTarget
  97721. */
  97722. static Parse(serializationObject: any): MorphTarget;
  97723. /**
  97724. * Creates a MorphTarget from mesh data
  97725. * @param mesh defines the source mesh
  97726. * @param name defines the name to use for the new target
  97727. * @param influence defines the influence to attach to the target
  97728. * @returns a new MorphTarget
  97729. */
  97730. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  97731. }
  97732. }
  97733. declare module BABYLON {
  97734. /**
  97735. * This class is used to deform meshes using morphing between different targets
  97736. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97737. */
  97738. export class MorphTargetManager {
  97739. private _targets;
  97740. private _targetInfluenceChangedObservers;
  97741. private _targetDataLayoutChangedObservers;
  97742. private _activeTargets;
  97743. private _scene;
  97744. private _influences;
  97745. private _supportsNormals;
  97746. private _supportsTangents;
  97747. private _supportsUVs;
  97748. private _vertexCount;
  97749. private _uniqueId;
  97750. private _tempInfluences;
  97751. /**
  97752. * Gets or sets a boolean indicating if normals must be morphed
  97753. */
  97754. enableNormalMorphing: boolean;
  97755. /**
  97756. * Gets or sets a boolean indicating if tangents must be morphed
  97757. */
  97758. enableTangentMorphing: boolean;
  97759. /**
  97760. * Gets or sets a boolean indicating if UV must be morphed
  97761. */
  97762. enableUVMorphing: boolean;
  97763. /**
  97764. * Creates a new MorphTargetManager
  97765. * @param scene defines the current scene
  97766. */
  97767. constructor(scene?: Nullable<Scene>);
  97768. /**
  97769. * Gets the unique ID of this manager
  97770. */
  97771. get uniqueId(): number;
  97772. /**
  97773. * Gets the number of vertices handled by this manager
  97774. */
  97775. get vertexCount(): number;
  97776. /**
  97777. * Gets a boolean indicating if this manager supports morphing of normals
  97778. */
  97779. get supportsNormals(): boolean;
  97780. /**
  97781. * Gets a boolean indicating if this manager supports morphing of tangents
  97782. */
  97783. get supportsTangents(): boolean;
  97784. /**
  97785. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  97786. */
  97787. get supportsUVs(): boolean;
  97788. /**
  97789. * Gets the number of targets stored in this manager
  97790. */
  97791. get numTargets(): number;
  97792. /**
  97793. * Gets the number of influencers (ie. the number of targets with influences > 0)
  97794. */
  97795. get numInfluencers(): number;
  97796. /**
  97797. * Gets the list of influences (one per target)
  97798. */
  97799. get influences(): Float32Array;
  97800. /**
  97801. * Gets the active target at specified index. An active target is a target with an influence > 0
  97802. * @param index defines the index to check
  97803. * @returns the requested target
  97804. */
  97805. getActiveTarget(index: number): MorphTarget;
  97806. /**
  97807. * Gets the target at specified index
  97808. * @param index defines the index to check
  97809. * @returns the requested target
  97810. */
  97811. getTarget(index: number): MorphTarget;
  97812. /**
  97813. * Add a new target to this manager
  97814. * @param target defines the target to add
  97815. */
  97816. addTarget(target: MorphTarget): void;
  97817. /**
  97818. * Removes a target from the manager
  97819. * @param target defines the target to remove
  97820. */
  97821. removeTarget(target: MorphTarget): void;
  97822. /**
  97823. * Clone the current manager
  97824. * @returns a new MorphTargetManager
  97825. */
  97826. clone(): MorphTargetManager;
  97827. /**
  97828. * Serializes the current manager into a Serialization object
  97829. * @returns the serialized object
  97830. */
  97831. serialize(): any;
  97832. private _syncActiveTargets;
  97833. /**
  97834. * Syncrhonize the targets with all the meshes using this morph target manager
  97835. */
  97836. synchronize(): void;
  97837. /**
  97838. * Creates a new MorphTargetManager from serialized data
  97839. * @param serializationObject defines the serialized data
  97840. * @param scene defines the hosting scene
  97841. * @returns the new MorphTargetManager
  97842. */
  97843. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  97844. }
  97845. }
  97846. declare module BABYLON {
  97847. /**
  97848. * Class used to represent a specific level of detail of a mesh
  97849. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  97850. */
  97851. export class MeshLODLevel {
  97852. /** Defines the distance where this level should start being displayed */
  97853. distance: number;
  97854. /** Defines the mesh to use to render this level */
  97855. mesh: Nullable<Mesh>;
  97856. /**
  97857. * Creates a new LOD level
  97858. * @param distance defines the distance where this level should star being displayed
  97859. * @param mesh defines the mesh to use to render this level
  97860. */
  97861. constructor(
  97862. /** Defines the distance where this level should start being displayed */
  97863. distance: number,
  97864. /** Defines the mesh to use to render this level */
  97865. mesh: Nullable<Mesh>);
  97866. }
  97867. }
  97868. declare module BABYLON {
  97869. /**
  97870. * Mesh representing the gorund
  97871. */
  97872. export class GroundMesh extends Mesh {
  97873. /** If octree should be generated */
  97874. generateOctree: boolean;
  97875. private _heightQuads;
  97876. /** @hidden */
  97877. _subdivisionsX: number;
  97878. /** @hidden */
  97879. _subdivisionsY: number;
  97880. /** @hidden */
  97881. _width: number;
  97882. /** @hidden */
  97883. _height: number;
  97884. /** @hidden */
  97885. _minX: number;
  97886. /** @hidden */
  97887. _maxX: number;
  97888. /** @hidden */
  97889. _minZ: number;
  97890. /** @hidden */
  97891. _maxZ: number;
  97892. constructor(name: string, scene: Scene);
  97893. /**
  97894. * "GroundMesh"
  97895. * @returns "GroundMesh"
  97896. */
  97897. getClassName(): string;
  97898. /**
  97899. * The minimum of x and y subdivisions
  97900. */
  97901. get subdivisions(): number;
  97902. /**
  97903. * X subdivisions
  97904. */
  97905. get subdivisionsX(): number;
  97906. /**
  97907. * Y subdivisions
  97908. */
  97909. get subdivisionsY(): number;
  97910. /**
  97911. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  97912. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  97913. * @param chunksCount the number of subdivisions for x and y
  97914. * @param octreeBlocksSize (Default: 32)
  97915. */
  97916. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  97917. /**
  97918. * Returns a height (y) value in the Worl system :
  97919. * the ground altitude at the coordinates (x, z) expressed in the World system.
  97920. * @param x x coordinate
  97921. * @param z z coordinate
  97922. * @returns the ground y position if (x, z) are outside the ground surface.
  97923. */
  97924. getHeightAtCoordinates(x: number, z: number): number;
  97925. /**
  97926. * Returns a normalized vector (Vector3) orthogonal to the ground
  97927. * at the ground coordinates (x, z) expressed in the World system.
  97928. * @param x x coordinate
  97929. * @param z z coordinate
  97930. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  97931. */
  97932. getNormalAtCoordinates(x: number, z: number): Vector3;
  97933. /**
  97934. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  97935. * at the ground coordinates (x, z) expressed in the World system.
  97936. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  97937. * @param x x coordinate
  97938. * @param z z coordinate
  97939. * @param ref vector to store the result
  97940. * @returns the GroundMesh.
  97941. */
  97942. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  97943. /**
  97944. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  97945. * if the ground has been updated.
  97946. * This can be used in the render loop.
  97947. * @returns the GroundMesh.
  97948. */
  97949. updateCoordinateHeights(): GroundMesh;
  97950. private _getFacetAt;
  97951. private _initHeightQuads;
  97952. private _computeHeightQuads;
  97953. /**
  97954. * Serializes this ground mesh
  97955. * @param serializationObject object to write serialization to
  97956. */
  97957. serialize(serializationObject: any): void;
  97958. /**
  97959. * Parses a serialized ground mesh
  97960. * @param parsedMesh the serialized mesh
  97961. * @param scene the scene to create the ground mesh in
  97962. * @returns the created ground mesh
  97963. */
  97964. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  97965. }
  97966. }
  97967. declare module BABYLON {
  97968. /**
  97969. * Interface for Physics-Joint data
  97970. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97971. */
  97972. export interface PhysicsJointData {
  97973. /**
  97974. * The main pivot of the joint
  97975. */
  97976. mainPivot?: Vector3;
  97977. /**
  97978. * The connected pivot of the joint
  97979. */
  97980. connectedPivot?: Vector3;
  97981. /**
  97982. * The main axis of the joint
  97983. */
  97984. mainAxis?: Vector3;
  97985. /**
  97986. * The connected axis of the joint
  97987. */
  97988. connectedAxis?: Vector3;
  97989. /**
  97990. * The collision of the joint
  97991. */
  97992. collision?: boolean;
  97993. /**
  97994. * Native Oimo/Cannon/Energy data
  97995. */
  97996. nativeParams?: any;
  97997. }
  97998. /**
  97999. * This is a holder class for the physics joint created by the physics plugin
  98000. * It holds a set of functions to control the underlying joint
  98001. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  98002. */
  98003. export class PhysicsJoint {
  98004. /**
  98005. * The type of the physics joint
  98006. */
  98007. type: number;
  98008. /**
  98009. * The data for the physics joint
  98010. */
  98011. jointData: PhysicsJointData;
  98012. private _physicsJoint;
  98013. protected _physicsPlugin: IPhysicsEnginePlugin;
  98014. /**
  98015. * Initializes the physics joint
  98016. * @param type The type of the physics joint
  98017. * @param jointData The data for the physics joint
  98018. */
  98019. constructor(
  98020. /**
  98021. * The type of the physics joint
  98022. */
  98023. type: number,
  98024. /**
  98025. * The data for the physics joint
  98026. */
  98027. jointData: PhysicsJointData);
  98028. /**
  98029. * Gets the physics joint
  98030. */
  98031. get physicsJoint(): any;
  98032. /**
  98033. * Sets the physics joint
  98034. */
  98035. set physicsJoint(newJoint: any);
  98036. /**
  98037. * Sets the physics plugin
  98038. */
  98039. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  98040. /**
  98041. * Execute a function that is physics-plugin specific.
  98042. * @param {Function} func the function that will be executed.
  98043. * It accepts two parameters: the physics world and the physics joint
  98044. */
  98045. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  98046. /**
  98047. * Distance-Joint type
  98048. */
  98049. static DistanceJoint: number;
  98050. /**
  98051. * Hinge-Joint type
  98052. */
  98053. static HingeJoint: number;
  98054. /**
  98055. * Ball-and-Socket joint type
  98056. */
  98057. static BallAndSocketJoint: number;
  98058. /**
  98059. * Wheel-Joint type
  98060. */
  98061. static WheelJoint: number;
  98062. /**
  98063. * Slider-Joint type
  98064. */
  98065. static SliderJoint: number;
  98066. /**
  98067. * Prismatic-Joint type
  98068. */
  98069. static PrismaticJoint: number;
  98070. /**
  98071. * Universal-Joint type
  98072. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  98073. */
  98074. static UniversalJoint: number;
  98075. /**
  98076. * Hinge-Joint 2 type
  98077. */
  98078. static Hinge2Joint: number;
  98079. /**
  98080. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  98081. */
  98082. static PointToPointJoint: number;
  98083. /**
  98084. * Spring-Joint type
  98085. */
  98086. static SpringJoint: number;
  98087. /**
  98088. * Lock-Joint type
  98089. */
  98090. static LockJoint: number;
  98091. }
  98092. /**
  98093. * A class representing a physics distance joint
  98094. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  98095. */
  98096. export class DistanceJoint extends PhysicsJoint {
  98097. /**
  98098. *
  98099. * @param jointData The data for the Distance-Joint
  98100. */
  98101. constructor(jointData: DistanceJointData);
  98102. /**
  98103. * Update the predefined distance.
  98104. * @param maxDistance The maximum preferred distance
  98105. * @param minDistance The minimum preferred distance
  98106. */
  98107. updateDistance(maxDistance: number, minDistance?: number): void;
  98108. }
  98109. /**
  98110. * Represents a Motor-Enabled Joint
  98111. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  98112. */
  98113. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  98114. /**
  98115. * Initializes the Motor-Enabled Joint
  98116. * @param type The type of the joint
  98117. * @param jointData The physica joint data for the joint
  98118. */
  98119. constructor(type: number, jointData: PhysicsJointData);
  98120. /**
  98121. * Set the motor values.
  98122. * Attention, this function is plugin specific. Engines won't react 100% the same.
  98123. * @param force the force to apply
  98124. * @param maxForce max force for this motor.
  98125. */
  98126. setMotor(force?: number, maxForce?: number): void;
  98127. /**
  98128. * Set the motor's limits.
  98129. * Attention, this function is plugin specific. Engines won't react 100% the same.
  98130. * @param upperLimit The upper limit of the motor
  98131. * @param lowerLimit The lower limit of the motor
  98132. */
  98133. setLimit(upperLimit: number, lowerLimit?: number): void;
  98134. }
  98135. /**
  98136. * This class represents a single physics Hinge-Joint
  98137. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  98138. */
  98139. export class HingeJoint extends MotorEnabledJoint {
  98140. /**
  98141. * Initializes the Hinge-Joint
  98142. * @param jointData The joint data for the Hinge-Joint
  98143. */
  98144. constructor(jointData: PhysicsJointData);
  98145. /**
  98146. * Set the motor values.
  98147. * Attention, this function is plugin specific. Engines won't react 100% the same.
  98148. * @param {number} force the force to apply
  98149. * @param {number} maxForce max force for this motor.
  98150. */
  98151. setMotor(force?: number, maxForce?: number): void;
  98152. /**
  98153. * Set the motor's limits.
  98154. * Attention, this function is plugin specific. Engines won't react 100% the same.
  98155. * @param upperLimit The upper limit of the motor
  98156. * @param lowerLimit The lower limit of the motor
  98157. */
  98158. setLimit(upperLimit: number, lowerLimit?: number): void;
  98159. }
  98160. /**
  98161. * This class represents a dual hinge physics joint (same as wheel joint)
  98162. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  98163. */
  98164. export class Hinge2Joint extends MotorEnabledJoint {
  98165. /**
  98166. * Initializes the Hinge2-Joint
  98167. * @param jointData The joint data for the Hinge2-Joint
  98168. */
  98169. constructor(jointData: PhysicsJointData);
  98170. /**
  98171. * Set the motor values.
  98172. * Attention, this function is plugin specific. Engines won't react 100% the same.
  98173. * @param {number} targetSpeed the speed the motor is to reach
  98174. * @param {number} maxForce max force for this motor.
  98175. * @param {motorIndex} the motor's index, 0 or 1.
  98176. */
  98177. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  98178. /**
  98179. * Set the motor limits.
  98180. * Attention, this function is plugin specific. Engines won't react 100% the same.
  98181. * @param {number} upperLimit the upper limit
  98182. * @param {number} lowerLimit lower limit
  98183. * @param {motorIndex} the motor's index, 0 or 1.
  98184. */
  98185. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  98186. }
  98187. /**
  98188. * Interface for a motor enabled joint
  98189. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  98190. */
  98191. export interface IMotorEnabledJoint {
  98192. /**
  98193. * Physics joint
  98194. */
  98195. physicsJoint: any;
  98196. /**
  98197. * Sets the motor of the motor-enabled joint
  98198. * @param force The force of the motor
  98199. * @param maxForce The maximum force of the motor
  98200. * @param motorIndex The index of the motor
  98201. */
  98202. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  98203. /**
  98204. * Sets the limit of the motor
  98205. * @param upperLimit The upper limit of the motor
  98206. * @param lowerLimit The lower limit of the motor
  98207. * @param motorIndex The index of the motor
  98208. */
  98209. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  98210. }
  98211. /**
  98212. * Joint data for a Distance-Joint
  98213. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  98214. */
  98215. export interface DistanceJointData extends PhysicsJointData {
  98216. /**
  98217. * Max distance the 2 joint objects can be apart
  98218. */
  98219. maxDistance: number;
  98220. }
  98221. /**
  98222. * Joint data from a spring joint
  98223. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  98224. */
  98225. export interface SpringJointData extends PhysicsJointData {
  98226. /**
  98227. * Length of the spring
  98228. */
  98229. length: number;
  98230. /**
  98231. * Stiffness of the spring
  98232. */
  98233. stiffness: number;
  98234. /**
  98235. * Damping of the spring
  98236. */
  98237. damping: number;
  98238. /** this callback will be called when applying the force to the impostors. */
  98239. forceApplicationCallback: () => void;
  98240. }
  98241. }
  98242. declare module BABYLON {
  98243. /**
  98244. * Holds the data for the raycast result
  98245. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  98246. */
  98247. export class PhysicsRaycastResult {
  98248. private _hasHit;
  98249. private _hitDistance;
  98250. private _hitNormalWorld;
  98251. private _hitPointWorld;
  98252. private _rayFromWorld;
  98253. private _rayToWorld;
  98254. /**
  98255. * Gets if there was a hit
  98256. */
  98257. get hasHit(): boolean;
  98258. /**
  98259. * Gets the distance from the hit
  98260. */
  98261. get hitDistance(): number;
  98262. /**
  98263. * Gets the hit normal/direction in the world
  98264. */
  98265. get hitNormalWorld(): Vector3;
  98266. /**
  98267. * Gets the hit point in the world
  98268. */
  98269. get hitPointWorld(): Vector3;
  98270. /**
  98271. * Gets the ray "start point" of the ray in the world
  98272. */
  98273. get rayFromWorld(): Vector3;
  98274. /**
  98275. * Gets the ray "end point" of the ray in the world
  98276. */
  98277. get rayToWorld(): Vector3;
  98278. /**
  98279. * Sets the hit data (normal & point in world space)
  98280. * @param hitNormalWorld defines the normal in world space
  98281. * @param hitPointWorld defines the point in world space
  98282. */
  98283. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  98284. /**
  98285. * Sets the distance from the start point to the hit point
  98286. * @param distance
  98287. */
  98288. setHitDistance(distance: number): void;
  98289. /**
  98290. * Calculates the distance manually
  98291. */
  98292. calculateHitDistance(): void;
  98293. /**
  98294. * Resets all the values to default
  98295. * @param from The from point on world space
  98296. * @param to The to point on world space
  98297. */
  98298. reset(from?: Vector3, to?: Vector3): void;
  98299. }
  98300. /**
  98301. * Interface for the size containing width and height
  98302. */
  98303. interface IXYZ {
  98304. /**
  98305. * X
  98306. */
  98307. x: number;
  98308. /**
  98309. * Y
  98310. */
  98311. y: number;
  98312. /**
  98313. * Z
  98314. */
  98315. z: number;
  98316. }
  98317. }
  98318. declare module BABYLON {
  98319. /**
  98320. * Interface used to describe a physics joint
  98321. */
  98322. export interface PhysicsImpostorJoint {
  98323. /** Defines the main impostor to which the joint is linked */
  98324. mainImpostor: PhysicsImpostor;
  98325. /** Defines the impostor that is connected to the main impostor using this joint */
  98326. connectedImpostor: PhysicsImpostor;
  98327. /** Defines the joint itself */
  98328. joint: PhysicsJoint;
  98329. }
  98330. /** @hidden */
  98331. export interface IPhysicsEnginePlugin {
  98332. world: any;
  98333. name: string;
  98334. setGravity(gravity: Vector3): void;
  98335. setTimeStep(timeStep: number): void;
  98336. getTimeStep(): number;
  98337. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  98338. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  98339. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  98340. generatePhysicsBody(impostor: PhysicsImpostor): void;
  98341. removePhysicsBody(impostor: PhysicsImpostor): void;
  98342. generateJoint(joint: PhysicsImpostorJoint): void;
  98343. removeJoint(joint: PhysicsImpostorJoint): void;
  98344. isSupported(): boolean;
  98345. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  98346. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  98347. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  98348. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  98349. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  98350. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  98351. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  98352. getBodyMass(impostor: PhysicsImpostor): number;
  98353. getBodyFriction(impostor: PhysicsImpostor): number;
  98354. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  98355. getBodyRestitution(impostor: PhysicsImpostor): number;
  98356. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  98357. getBodyPressure?(impostor: PhysicsImpostor): number;
  98358. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  98359. getBodyStiffness?(impostor: PhysicsImpostor): number;
  98360. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  98361. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  98362. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  98363. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  98364. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  98365. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  98366. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  98367. sleepBody(impostor: PhysicsImpostor): void;
  98368. wakeUpBody(impostor: PhysicsImpostor): void;
  98369. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  98370. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  98371. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  98372. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  98373. getRadius(impostor: PhysicsImpostor): number;
  98374. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  98375. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  98376. dispose(): void;
  98377. }
  98378. /**
  98379. * Interface used to define a physics engine
  98380. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  98381. */
  98382. export interface IPhysicsEngine {
  98383. /**
  98384. * Gets the gravity vector used by the simulation
  98385. */
  98386. gravity: Vector3;
  98387. /**
  98388. * Sets the gravity vector used by the simulation
  98389. * @param gravity defines the gravity vector to use
  98390. */
  98391. setGravity(gravity: Vector3): void;
  98392. /**
  98393. * Set the time step of the physics engine.
  98394. * Default is 1/60.
  98395. * To slow it down, enter 1/600 for example.
  98396. * To speed it up, 1/30
  98397. * @param newTimeStep the new timestep to apply to this world.
  98398. */
  98399. setTimeStep(newTimeStep: number): void;
  98400. /**
  98401. * Get the time step of the physics engine.
  98402. * @returns the current time step
  98403. */
  98404. getTimeStep(): number;
  98405. /**
  98406. * Set the sub time step of the physics engine.
  98407. * Default is 0 meaning there is no sub steps
  98408. * To increase physics resolution precision, set a small value (like 1 ms)
  98409. * @param subTimeStep defines the new sub timestep used for physics resolution.
  98410. */
  98411. setSubTimeStep(subTimeStep: number): void;
  98412. /**
  98413. * Get the sub time step of the physics engine.
  98414. * @returns the current sub time step
  98415. */
  98416. getSubTimeStep(): number;
  98417. /**
  98418. * Release all resources
  98419. */
  98420. dispose(): void;
  98421. /**
  98422. * Gets the name of the current physics plugin
  98423. * @returns the name of the plugin
  98424. */
  98425. getPhysicsPluginName(): string;
  98426. /**
  98427. * Adding a new impostor for the impostor tracking.
  98428. * This will be done by the impostor itself.
  98429. * @param impostor the impostor to add
  98430. */
  98431. addImpostor(impostor: PhysicsImpostor): void;
  98432. /**
  98433. * Remove an impostor from the engine.
  98434. * This impostor and its mesh will not longer be updated by the physics engine.
  98435. * @param impostor the impostor to remove
  98436. */
  98437. removeImpostor(impostor: PhysicsImpostor): void;
  98438. /**
  98439. * Add a joint to the physics engine
  98440. * @param mainImpostor defines the main impostor to which the joint is added.
  98441. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  98442. * @param joint defines the joint that will connect both impostors.
  98443. */
  98444. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  98445. /**
  98446. * Removes a joint from the simulation
  98447. * @param mainImpostor defines the impostor used with the joint
  98448. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  98449. * @param joint defines the joint to remove
  98450. */
  98451. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  98452. /**
  98453. * Gets the current plugin used to run the simulation
  98454. * @returns current plugin
  98455. */
  98456. getPhysicsPlugin(): IPhysicsEnginePlugin;
  98457. /**
  98458. * Gets the list of physic impostors
  98459. * @returns an array of PhysicsImpostor
  98460. */
  98461. getImpostors(): Array<PhysicsImpostor>;
  98462. /**
  98463. * Gets the impostor for a physics enabled object
  98464. * @param object defines the object impersonated by the impostor
  98465. * @returns the PhysicsImpostor or null if not found
  98466. */
  98467. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  98468. /**
  98469. * Gets the impostor for a physics body object
  98470. * @param body defines physics body used by the impostor
  98471. * @returns the PhysicsImpostor or null if not found
  98472. */
  98473. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  98474. /**
  98475. * Does a raycast in the physics world
  98476. * @param from when should the ray start?
  98477. * @param to when should the ray end?
  98478. * @returns PhysicsRaycastResult
  98479. */
  98480. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  98481. /**
  98482. * Called by the scene. No need to call it.
  98483. * @param delta defines the timespam between frames
  98484. */
  98485. _step(delta: number): void;
  98486. }
  98487. }
  98488. declare module BABYLON {
  98489. /**
  98490. * The interface for the physics imposter parameters
  98491. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  98492. */
  98493. export interface PhysicsImpostorParameters {
  98494. /**
  98495. * The mass of the physics imposter
  98496. */
  98497. mass: number;
  98498. /**
  98499. * The friction of the physics imposter
  98500. */
  98501. friction?: number;
  98502. /**
  98503. * The coefficient of restitution of the physics imposter
  98504. */
  98505. restitution?: number;
  98506. /**
  98507. * The native options of the physics imposter
  98508. */
  98509. nativeOptions?: any;
  98510. /**
  98511. * Specifies if the parent should be ignored
  98512. */
  98513. ignoreParent?: boolean;
  98514. /**
  98515. * Specifies if bi-directional transformations should be disabled
  98516. */
  98517. disableBidirectionalTransformation?: boolean;
  98518. /**
  98519. * The pressure inside the physics imposter, soft object only
  98520. */
  98521. pressure?: number;
  98522. /**
  98523. * The stiffness the physics imposter, soft object only
  98524. */
  98525. stiffness?: number;
  98526. /**
  98527. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  98528. */
  98529. velocityIterations?: number;
  98530. /**
  98531. * The number of iterations used in maintaining consistent vertex positions, soft object only
  98532. */
  98533. positionIterations?: number;
  98534. /**
  98535. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  98536. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  98537. * Add to fix multiple points
  98538. */
  98539. fixedPoints?: number;
  98540. /**
  98541. * The collision margin around a soft object
  98542. */
  98543. margin?: number;
  98544. /**
  98545. * The collision margin around a soft object
  98546. */
  98547. damping?: number;
  98548. /**
  98549. * The path for a rope based on an extrusion
  98550. */
  98551. path?: any;
  98552. /**
  98553. * The shape of an extrusion used for a rope based on an extrusion
  98554. */
  98555. shape?: any;
  98556. }
  98557. /**
  98558. * Interface for a physics-enabled object
  98559. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  98560. */
  98561. export interface IPhysicsEnabledObject {
  98562. /**
  98563. * The position of the physics-enabled object
  98564. */
  98565. position: Vector3;
  98566. /**
  98567. * The rotation of the physics-enabled object
  98568. */
  98569. rotationQuaternion: Nullable<Quaternion>;
  98570. /**
  98571. * The scale of the physics-enabled object
  98572. */
  98573. scaling: Vector3;
  98574. /**
  98575. * The rotation of the physics-enabled object
  98576. */
  98577. rotation?: Vector3;
  98578. /**
  98579. * The parent of the physics-enabled object
  98580. */
  98581. parent?: any;
  98582. /**
  98583. * The bounding info of the physics-enabled object
  98584. * @returns The bounding info of the physics-enabled object
  98585. */
  98586. getBoundingInfo(): BoundingInfo;
  98587. /**
  98588. * Computes the world matrix
  98589. * @param force Specifies if the world matrix should be computed by force
  98590. * @returns A world matrix
  98591. */
  98592. computeWorldMatrix(force: boolean): Matrix;
  98593. /**
  98594. * Gets the world matrix
  98595. * @returns A world matrix
  98596. */
  98597. getWorldMatrix?(): Matrix;
  98598. /**
  98599. * Gets the child meshes
  98600. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  98601. * @returns An array of abstract meshes
  98602. */
  98603. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  98604. /**
  98605. * Gets the vertex data
  98606. * @param kind The type of vertex data
  98607. * @returns A nullable array of numbers, or a float32 array
  98608. */
  98609. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  98610. /**
  98611. * Gets the indices from the mesh
  98612. * @returns A nullable array of index arrays
  98613. */
  98614. getIndices?(): Nullable<IndicesArray>;
  98615. /**
  98616. * Gets the scene from the mesh
  98617. * @returns the indices array or null
  98618. */
  98619. getScene?(): Scene;
  98620. /**
  98621. * Gets the absolute position from the mesh
  98622. * @returns the absolute position
  98623. */
  98624. getAbsolutePosition(): Vector3;
  98625. /**
  98626. * Gets the absolute pivot point from the mesh
  98627. * @returns the absolute pivot point
  98628. */
  98629. getAbsolutePivotPoint(): Vector3;
  98630. /**
  98631. * Rotates the mesh
  98632. * @param axis The axis of rotation
  98633. * @param amount The amount of rotation
  98634. * @param space The space of the rotation
  98635. * @returns The rotation transform node
  98636. */
  98637. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  98638. /**
  98639. * Translates the mesh
  98640. * @param axis The axis of translation
  98641. * @param distance The distance of translation
  98642. * @param space The space of the translation
  98643. * @returns The transform node
  98644. */
  98645. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  98646. /**
  98647. * Sets the absolute position of the mesh
  98648. * @param absolutePosition The absolute position of the mesh
  98649. * @returns The transform node
  98650. */
  98651. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  98652. /**
  98653. * Gets the class name of the mesh
  98654. * @returns The class name
  98655. */
  98656. getClassName(): string;
  98657. }
  98658. /**
  98659. * Represents a physics imposter
  98660. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  98661. */
  98662. export class PhysicsImpostor {
  98663. /**
  98664. * The physics-enabled object used as the physics imposter
  98665. */
  98666. object: IPhysicsEnabledObject;
  98667. /**
  98668. * The type of the physics imposter
  98669. */
  98670. type: number;
  98671. private _options;
  98672. private _scene?;
  98673. /**
  98674. * The default object size of the imposter
  98675. */
  98676. static DEFAULT_OBJECT_SIZE: Vector3;
  98677. /**
  98678. * The identity quaternion of the imposter
  98679. */
  98680. static IDENTITY_QUATERNION: Quaternion;
  98681. /** @hidden */
  98682. _pluginData: any;
  98683. private _physicsEngine;
  98684. private _physicsBody;
  98685. private _bodyUpdateRequired;
  98686. private _onBeforePhysicsStepCallbacks;
  98687. private _onAfterPhysicsStepCallbacks;
  98688. /** @hidden */
  98689. _onPhysicsCollideCallbacks: Array<{
  98690. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  98691. otherImpostors: Array<PhysicsImpostor>;
  98692. }>;
  98693. private _deltaPosition;
  98694. private _deltaRotation;
  98695. private _deltaRotationConjugated;
  98696. /** @hidden */
  98697. _isFromLine: boolean;
  98698. private _parent;
  98699. private _isDisposed;
  98700. private static _tmpVecs;
  98701. private static _tmpQuat;
  98702. /**
  98703. * Specifies if the physics imposter is disposed
  98704. */
  98705. get isDisposed(): boolean;
  98706. /**
  98707. * Gets the mass of the physics imposter
  98708. */
  98709. get mass(): number;
  98710. set mass(value: number);
  98711. /**
  98712. * Gets the coefficient of friction
  98713. */
  98714. get friction(): number;
  98715. /**
  98716. * Sets the coefficient of friction
  98717. */
  98718. set friction(value: number);
  98719. /**
  98720. * Gets the coefficient of restitution
  98721. */
  98722. get restitution(): number;
  98723. /**
  98724. * Sets the coefficient of restitution
  98725. */
  98726. set restitution(value: number);
  98727. /**
  98728. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  98729. */
  98730. get pressure(): number;
  98731. /**
  98732. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  98733. */
  98734. set pressure(value: number);
  98735. /**
  98736. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  98737. */
  98738. get stiffness(): number;
  98739. /**
  98740. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  98741. */
  98742. set stiffness(value: number);
  98743. /**
  98744. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  98745. */
  98746. get velocityIterations(): number;
  98747. /**
  98748. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  98749. */
  98750. set velocityIterations(value: number);
  98751. /**
  98752. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  98753. */
  98754. get positionIterations(): number;
  98755. /**
  98756. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  98757. */
  98758. set positionIterations(value: number);
  98759. /**
  98760. * The unique id of the physics imposter
  98761. * set by the physics engine when adding this impostor to the array
  98762. */
  98763. uniqueId: number;
  98764. /**
  98765. * @hidden
  98766. */
  98767. soft: boolean;
  98768. /**
  98769. * @hidden
  98770. */
  98771. segments: number;
  98772. private _joints;
  98773. /**
  98774. * Initializes the physics imposter
  98775. * @param object The physics-enabled object used as the physics imposter
  98776. * @param type The type of the physics imposter
  98777. * @param _options The options for the physics imposter
  98778. * @param _scene The Babylon scene
  98779. */
  98780. constructor(
  98781. /**
  98782. * The physics-enabled object used as the physics imposter
  98783. */
  98784. object: IPhysicsEnabledObject,
  98785. /**
  98786. * The type of the physics imposter
  98787. */
  98788. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  98789. /**
  98790. * This function will completly initialize this impostor.
  98791. * It will create a new body - but only if this mesh has no parent.
  98792. * If it has, this impostor will not be used other than to define the impostor
  98793. * of the child mesh.
  98794. * @hidden
  98795. */
  98796. _init(): void;
  98797. private _getPhysicsParent;
  98798. /**
  98799. * Should a new body be generated.
  98800. * @returns boolean specifying if body initialization is required
  98801. */
  98802. isBodyInitRequired(): boolean;
  98803. /**
  98804. * Sets the updated scaling
  98805. * @param updated Specifies if the scaling is updated
  98806. */
  98807. setScalingUpdated(): void;
  98808. /**
  98809. * Force a regeneration of this or the parent's impostor's body.
  98810. * Use under cautious - This will remove all joints already implemented.
  98811. */
  98812. forceUpdate(): void;
  98813. /**
  98814. * Gets the body that holds this impostor. Either its own, or its parent.
  98815. */
  98816. get physicsBody(): any;
  98817. /**
  98818. * Get the parent of the physics imposter
  98819. * @returns Physics imposter or null
  98820. */
  98821. get parent(): Nullable<PhysicsImpostor>;
  98822. /**
  98823. * Sets the parent of the physics imposter
  98824. */
  98825. set parent(value: Nullable<PhysicsImpostor>);
  98826. /**
  98827. * Set the physics body. Used mainly by the physics engine/plugin
  98828. */
  98829. set physicsBody(physicsBody: any);
  98830. /**
  98831. * Resets the update flags
  98832. */
  98833. resetUpdateFlags(): void;
  98834. /**
  98835. * Gets the object extend size
  98836. * @returns the object extend size
  98837. */
  98838. getObjectExtendSize(): Vector3;
  98839. /**
  98840. * Gets the object center
  98841. * @returns The object center
  98842. */
  98843. getObjectCenter(): Vector3;
  98844. /**
  98845. * Get a specific parameter from the options parameters
  98846. * @param paramName The object parameter name
  98847. * @returns The object parameter
  98848. */
  98849. getParam(paramName: string): any;
  98850. /**
  98851. * Sets a specific parameter in the options given to the physics plugin
  98852. * @param paramName The parameter name
  98853. * @param value The value of the parameter
  98854. */
  98855. setParam(paramName: string, value: number): void;
  98856. /**
  98857. * Specifically change the body's mass option. Won't recreate the physics body object
  98858. * @param mass The mass of the physics imposter
  98859. */
  98860. setMass(mass: number): void;
  98861. /**
  98862. * Gets the linear velocity
  98863. * @returns linear velocity or null
  98864. */
  98865. getLinearVelocity(): Nullable<Vector3>;
  98866. /**
  98867. * Sets the linear velocity
  98868. * @param velocity linear velocity or null
  98869. */
  98870. setLinearVelocity(velocity: Nullable<Vector3>): void;
  98871. /**
  98872. * Gets the angular velocity
  98873. * @returns angular velocity or null
  98874. */
  98875. getAngularVelocity(): Nullable<Vector3>;
  98876. /**
  98877. * Sets the angular velocity
  98878. * @param velocity The velocity or null
  98879. */
  98880. setAngularVelocity(velocity: Nullable<Vector3>): void;
  98881. /**
  98882. * Execute a function with the physics plugin native code
  98883. * Provide a function the will have two variables - the world object and the physics body object
  98884. * @param func The function to execute with the physics plugin native code
  98885. */
  98886. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  98887. /**
  98888. * Register a function that will be executed before the physics world is stepping forward
  98889. * @param func The function to execute before the physics world is stepped forward
  98890. */
  98891. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  98892. /**
  98893. * Unregister a function that will be executed before the physics world is stepping forward
  98894. * @param func The function to execute before the physics world is stepped forward
  98895. */
  98896. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  98897. /**
  98898. * Register a function that will be executed after the physics step
  98899. * @param func The function to execute after physics step
  98900. */
  98901. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  98902. /**
  98903. * Unregisters a function that will be executed after the physics step
  98904. * @param func The function to execute after physics step
  98905. */
  98906. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  98907. /**
  98908. * register a function that will be executed when this impostor collides against a different body
  98909. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  98910. * @param func Callback that is executed on collision
  98911. */
  98912. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  98913. /**
  98914. * Unregisters the physics imposter on contact
  98915. * @param collideAgainst The physics object to collide against
  98916. * @param func Callback to execute on collision
  98917. */
  98918. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  98919. private _tmpQuat;
  98920. private _tmpQuat2;
  98921. /**
  98922. * Get the parent rotation
  98923. * @returns The parent rotation
  98924. */
  98925. getParentsRotation(): Quaternion;
  98926. /**
  98927. * this function is executed by the physics engine.
  98928. */
  98929. beforeStep: () => void;
  98930. /**
  98931. * this function is executed by the physics engine
  98932. */
  98933. afterStep: () => void;
  98934. /**
  98935. * Legacy collision detection event support
  98936. */
  98937. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  98938. /**
  98939. * event and body object due to cannon's event-based architecture.
  98940. */
  98941. onCollide: (e: {
  98942. body: any;
  98943. }) => void;
  98944. /**
  98945. * Apply a force
  98946. * @param force The force to apply
  98947. * @param contactPoint The contact point for the force
  98948. * @returns The physics imposter
  98949. */
  98950. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  98951. /**
  98952. * Apply an impulse
  98953. * @param force The impulse force
  98954. * @param contactPoint The contact point for the impulse force
  98955. * @returns The physics imposter
  98956. */
  98957. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  98958. /**
  98959. * A help function to create a joint
  98960. * @param otherImpostor A physics imposter used to create a joint
  98961. * @param jointType The type of joint
  98962. * @param jointData The data for the joint
  98963. * @returns The physics imposter
  98964. */
  98965. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  98966. /**
  98967. * Add a joint to this impostor with a different impostor
  98968. * @param otherImpostor A physics imposter used to add a joint
  98969. * @param joint The joint to add
  98970. * @returns The physics imposter
  98971. */
  98972. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  98973. /**
  98974. * Add an anchor to a cloth impostor
  98975. * @param otherImpostor rigid impostor to anchor to
  98976. * @param width ratio across width from 0 to 1
  98977. * @param height ratio up height from 0 to 1
  98978. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  98979. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  98980. * @returns impostor the soft imposter
  98981. */
  98982. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  98983. /**
  98984. * Add a hook to a rope impostor
  98985. * @param otherImpostor rigid impostor to anchor to
  98986. * @param length ratio across rope from 0 to 1
  98987. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  98988. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  98989. * @returns impostor the rope imposter
  98990. */
  98991. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  98992. /**
  98993. * Will keep this body still, in a sleep mode.
  98994. * @returns the physics imposter
  98995. */
  98996. sleep(): PhysicsImpostor;
  98997. /**
  98998. * Wake the body up.
  98999. * @returns The physics imposter
  99000. */
  99001. wakeUp(): PhysicsImpostor;
  99002. /**
  99003. * Clones the physics imposter
  99004. * @param newObject The physics imposter clones to this physics-enabled object
  99005. * @returns A nullable physics imposter
  99006. */
  99007. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  99008. /**
  99009. * Disposes the physics imposter
  99010. */
  99011. dispose(): void;
  99012. /**
  99013. * Sets the delta position
  99014. * @param position The delta position amount
  99015. */
  99016. setDeltaPosition(position: Vector3): void;
  99017. /**
  99018. * Sets the delta rotation
  99019. * @param rotation The delta rotation amount
  99020. */
  99021. setDeltaRotation(rotation: Quaternion): void;
  99022. /**
  99023. * Gets the box size of the physics imposter and stores the result in the input parameter
  99024. * @param result Stores the box size
  99025. * @returns The physics imposter
  99026. */
  99027. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  99028. /**
  99029. * Gets the radius of the physics imposter
  99030. * @returns Radius of the physics imposter
  99031. */
  99032. getRadius(): number;
  99033. /**
  99034. * Sync a bone with this impostor
  99035. * @param bone The bone to sync to the impostor.
  99036. * @param boneMesh The mesh that the bone is influencing.
  99037. * @param jointPivot The pivot of the joint / bone in local space.
  99038. * @param distToJoint Optional distance from the impostor to the joint.
  99039. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  99040. */
  99041. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  99042. /**
  99043. * Sync impostor to a bone
  99044. * @param bone The bone that the impostor will be synced to.
  99045. * @param boneMesh The mesh that the bone is influencing.
  99046. * @param jointPivot The pivot of the joint / bone in local space.
  99047. * @param distToJoint Optional distance from the impostor to the joint.
  99048. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  99049. * @param boneAxis Optional vector3 axis the bone is aligned with
  99050. */
  99051. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  99052. /**
  99053. * No-Imposter type
  99054. */
  99055. static NoImpostor: number;
  99056. /**
  99057. * Sphere-Imposter type
  99058. */
  99059. static SphereImpostor: number;
  99060. /**
  99061. * Box-Imposter type
  99062. */
  99063. static BoxImpostor: number;
  99064. /**
  99065. * Plane-Imposter type
  99066. */
  99067. static PlaneImpostor: number;
  99068. /**
  99069. * Mesh-imposter type
  99070. */
  99071. static MeshImpostor: number;
  99072. /**
  99073. * Capsule-Impostor type (Ammo.js plugin only)
  99074. */
  99075. static CapsuleImpostor: number;
  99076. /**
  99077. * Cylinder-Imposter type
  99078. */
  99079. static CylinderImpostor: number;
  99080. /**
  99081. * Particle-Imposter type
  99082. */
  99083. static ParticleImpostor: number;
  99084. /**
  99085. * Heightmap-Imposter type
  99086. */
  99087. static HeightmapImpostor: number;
  99088. /**
  99089. * ConvexHull-Impostor type (Ammo.js plugin only)
  99090. */
  99091. static ConvexHullImpostor: number;
  99092. /**
  99093. * Custom-Imposter type (Ammo.js plugin only)
  99094. */
  99095. static CustomImpostor: number;
  99096. /**
  99097. * Rope-Imposter type
  99098. */
  99099. static RopeImpostor: number;
  99100. /**
  99101. * Cloth-Imposter type
  99102. */
  99103. static ClothImpostor: number;
  99104. /**
  99105. * Softbody-Imposter type
  99106. */
  99107. static SoftbodyImpostor: number;
  99108. }
  99109. }
  99110. declare module BABYLON {
  99111. /**
  99112. * @hidden
  99113. **/
  99114. export class _CreationDataStorage {
  99115. closePath?: boolean;
  99116. closeArray?: boolean;
  99117. idx: number[];
  99118. dashSize: number;
  99119. gapSize: number;
  99120. path3D: Path3D;
  99121. pathArray: Vector3[][];
  99122. arc: number;
  99123. radius: number;
  99124. cap: number;
  99125. tessellation: number;
  99126. }
  99127. /**
  99128. * @hidden
  99129. **/
  99130. class _InstanceDataStorage {
  99131. visibleInstances: any;
  99132. batchCache: _InstancesBatch;
  99133. instancesBufferSize: number;
  99134. instancesBuffer: Nullable<Buffer>;
  99135. instancesData: Float32Array;
  99136. overridenInstanceCount: number;
  99137. isFrozen: boolean;
  99138. previousBatch: Nullable<_InstancesBatch>;
  99139. hardwareInstancedRendering: boolean;
  99140. sideOrientation: number;
  99141. manualUpdate: boolean;
  99142. }
  99143. /**
  99144. * @hidden
  99145. **/
  99146. export class _InstancesBatch {
  99147. mustReturn: boolean;
  99148. visibleInstances: Nullable<InstancedMesh[]>[];
  99149. renderSelf: boolean[];
  99150. hardwareInstancedRendering: boolean[];
  99151. }
  99152. /**
  99153. * Class used to represent renderable models
  99154. */
  99155. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  99156. /**
  99157. * Mesh side orientation : usually the external or front surface
  99158. */
  99159. static readonly FRONTSIDE: number;
  99160. /**
  99161. * Mesh side orientation : usually the internal or back surface
  99162. */
  99163. static readonly BACKSIDE: number;
  99164. /**
  99165. * Mesh side orientation : both internal and external or front and back surfaces
  99166. */
  99167. static readonly DOUBLESIDE: number;
  99168. /**
  99169. * Mesh side orientation : by default, `FRONTSIDE`
  99170. */
  99171. static readonly DEFAULTSIDE: number;
  99172. /**
  99173. * Mesh cap setting : no cap
  99174. */
  99175. static readonly NO_CAP: number;
  99176. /**
  99177. * Mesh cap setting : one cap at the beginning of the mesh
  99178. */
  99179. static readonly CAP_START: number;
  99180. /**
  99181. * Mesh cap setting : one cap at the end of the mesh
  99182. */
  99183. static readonly CAP_END: number;
  99184. /**
  99185. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  99186. */
  99187. static readonly CAP_ALL: number;
  99188. /**
  99189. * Mesh pattern setting : no flip or rotate
  99190. */
  99191. static readonly NO_FLIP: number;
  99192. /**
  99193. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  99194. */
  99195. static readonly FLIP_TILE: number;
  99196. /**
  99197. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  99198. */
  99199. static readonly ROTATE_TILE: number;
  99200. /**
  99201. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  99202. */
  99203. static readonly FLIP_ROW: number;
  99204. /**
  99205. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  99206. */
  99207. static readonly ROTATE_ROW: number;
  99208. /**
  99209. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  99210. */
  99211. static readonly FLIP_N_ROTATE_TILE: number;
  99212. /**
  99213. * Mesh pattern setting : rotate pattern and rotate
  99214. */
  99215. static readonly FLIP_N_ROTATE_ROW: number;
  99216. /**
  99217. * Mesh tile positioning : part tiles same on left/right or top/bottom
  99218. */
  99219. static readonly CENTER: number;
  99220. /**
  99221. * Mesh tile positioning : part tiles on left
  99222. */
  99223. static readonly LEFT: number;
  99224. /**
  99225. * Mesh tile positioning : part tiles on right
  99226. */
  99227. static readonly RIGHT: number;
  99228. /**
  99229. * Mesh tile positioning : part tiles on top
  99230. */
  99231. static readonly TOP: number;
  99232. /**
  99233. * Mesh tile positioning : part tiles on bottom
  99234. */
  99235. static readonly BOTTOM: number;
  99236. /**
  99237. * Gets the default side orientation.
  99238. * @param orientation the orientation to value to attempt to get
  99239. * @returns the default orientation
  99240. * @hidden
  99241. */
  99242. static _GetDefaultSideOrientation(orientation?: number): number;
  99243. private _internalMeshDataInfo;
  99244. /**
  99245. * An event triggered before rendering the mesh
  99246. */
  99247. get onBeforeRenderObservable(): Observable<Mesh>;
  99248. /**
  99249. * An event triggered before binding the mesh
  99250. */
  99251. get onBeforeBindObservable(): Observable<Mesh>;
  99252. /**
  99253. * An event triggered after rendering the mesh
  99254. */
  99255. get onAfterRenderObservable(): Observable<Mesh>;
  99256. /**
  99257. * An event triggered before drawing the mesh
  99258. */
  99259. get onBeforeDrawObservable(): Observable<Mesh>;
  99260. private _onBeforeDrawObserver;
  99261. /**
  99262. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  99263. */
  99264. set onBeforeDraw(callback: () => void);
  99265. get hasInstances(): boolean;
  99266. /**
  99267. * Gets the delay loading state of the mesh (when delay loading is turned on)
  99268. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  99269. */
  99270. delayLoadState: number;
  99271. /**
  99272. * Gets the list of instances created from this mesh
  99273. * it is not supposed to be modified manually.
  99274. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  99275. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  99276. */
  99277. instances: InstancedMesh[];
  99278. /**
  99279. * Gets the file containing delay loading data for this mesh
  99280. */
  99281. delayLoadingFile: string;
  99282. /** @hidden */
  99283. _binaryInfo: any;
  99284. /**
  99285. * User defined function used to change how LOD level selection is done
  99286. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  99287. */
  99288. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  99289. /**
  99290. * Gets or sets the morph target manager
  99291. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  99292. */
  99293. get morphTargetManager(): Nullable<MorphTargetManager>;
  99294. set morphTargetManager(value: Nullable<MorphTargetManager>);
  99295. /** @hidden */
  99296. _creationDataStorage: Nullable<_CreationDataStorage>;
  99297. /** @hidden */
  99298. _geometry: Nullable<Geometry>;
  99299. /** @hidden */
  99300. _delayInfo: Array<string>;
  99301. /** @hidden */
  99302. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  99303. /** @hidden */
  99304. _instanceDataStorage: _InstanceDataStorage;
  99305. private _effectiveMaterial;
  99306. /** @hidden */
  99307. _shouldGenerateFlatShading: boolean;
  99308. /** @hidden */
  99309. _originalBuilderSideOrientation: number;
  99310. /**
  99311. * Use this property to change the original side orientation defined at construction time
  99312. */
  99313. overrideMaterialSideOrientation: Nullable<number>;
  99314. /**
  99315. * Gets the source mesh (the one used to clone this one from)
  99316. */
  99317. get source(): Nullable<Mesh>;
  99318. /**
  99319. * Gets or sets a boolean indicating that this mesh does not use index buffer
  99320. */
  99321. get isUnIndexed(): boolean;
  99322. set isUnIndexed(value: boolean);
  99323. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  99324. get worldMatrixInstancedBuffer(): Float32Array;
  99325. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  99326. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  99327. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  99328. /**
  99329. * @constructor
  99330. * @param name The value used by scene.getMeshByName() to do a lookup.
  99331. * @param scene The scene to add this mesh to.
  99332. * @param parent The parent of this mesh, if it has one
  99333. * @param source An optional Mesh from which geometry is shared, cloned.
  99334. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  99335. * When false, achieved by calling a clone(), also passing False.
  99336. * This will make creation of children, recursive.
  99337. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  99338. */
  99339. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  99340. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  99341. doNotInstantiate: boolean;
  99342. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  99343. /**
  99344. * Gets the class name
  99345. * @returns the string "Mesh".
  99346. */
  99347. getClassName(): string;
  99348. /** @hidden */
  99349. get _isMesh(): boolean;
  99350. /**
  99351. * Returns a description of this mesh
  99352. * @param fullDetails define if full details about this mesh must be used
  99353. * @returns a descriptive string representing this mesh
  99354. */
  99355. toString(fullDetails?: boolean): string;
  99356. /** @hidden */
  99357. _unBindEffect(): void;
  99358. /**
  99359. * Gets a boolean indicating if this mesh has LOD
  99360. */
  99361. get hasLODLevels(): boolean;
  99362. /**
  99363. * Gets the list of MeshLODLevel associated with the current mesh
  99364. * @returns an array of MeshLODLevel
  99365. */
  99366. getLODLevels(): MeshLODLevel[];
  99367. private _sortLODLevels;
  99368. /**
  99369. * Add a mesh as LOD level triggered at the given distance.
  99370. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  99371. * @param distance The distance from the center of the object to show this level
  99372. * @param mesh The mesh to be added as LOD level (can be null)
  99373. * @return This mesh (for chaining)
  99374. */
  99375. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  99376. /**
  99377. * Returns the LOD level mesh at the passed distance or null if not found.
  99378. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  99379. * @param distance The distance from the center of the object to show this level
  99380. * @returns a Mesh or `null`
  99381. */
  99382. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  99383. /**
  99384. * Remove a mesh from the LOD array
  99385. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  99386. * @param mesh defines the mesh to be removed
  99387. * @return This mesh (for chaining)
  99388. */
  99389. removeLODLevel(mesh: Mesh): Mesh;
  99390. /**
  99391. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  99392. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  99393. * @param camera defines the camera to use to compute distance
  99394. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  99395. * @return This mesh (for chaining)
  99396. */
  99397. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  99398. /**
  99399. * Gets the mesh internal Geometry object
  99400. */
  99401. get geometry(): Nullable<Geometry>;
  99402. /**
  99403. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  99404. * @returns the total number of vertices
  99405. */
  99406. getTotalVertices(): number;
  99407. /**
  99408. * Returns the content of an associated vertex buffer
  99409. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  99410. * - VertexBuffer.PositionKind
  99411. * - VertexBuffer.UVKind
  99412. * - VertexBuffer.UV2Kind
  99413. * - VertexBuffer.UV3Kind
  99414. * - VertexBuffer.UV4Kind
  99415. * - VertexBuffer.UV5Kind
  99416. * - VertexBuffer.UV6Kind
  99417. * - VertexBuffer.ColorKind
  99418. * - VertexBuffer.MatricesIndicesKind
  99419. * - VertexBuffer.MatricesIndicesExtraKind
  99420. * - VertexBuffer.MatricesWeightsKind
  99421. * - VertexBuffer.MatricesWeightsExtraKind
  99422. * @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
  99423. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  99424. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  99425. */
  99426. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  99427. /**
  99428. * Returns the mesh VertexBuffer object from the requested `kind`
  99429. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  99430. * - VertexBuffer.PositionKind
  99431. * - VertexBuffer.NormalKind
  99432. * - VertexBuffer.UVKind
  99433. * - VertexBuffer.UV2Kind
  99434. * - VertexBuffer.UV3Kind
  99435. * - VertexBuffer.UV4Kind
  99436. * - VertexBuffer.UV5Kind
  99437. * - VertexBuffer.UV6Kind
  99438. * - VertexBuffer.ColorKind
  99439. * - VertexBuffer.MatricesIndicesKind
  99440. * - VertexBuffer.MatricesIndicesExtraKind
  99441. * - VertexBuffer.MatricesWeightsKind
  99442. * - VertexBuffer.MatricesWeightsExtraKind
  99443. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  99444. */
  99445. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  99446. /**
  99447. * Tests if a specific vertex buffer is associated with this mesh
  99448. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  99449. * - VertexBuffer.PositionKind
  99450. * - VertexBuffer.NormalKind
  99451. * - VertexBuffer.UVKind
  99452. * - VertexBuffer.UV2Kind
  99453. * - VertexBuffer.UV3Kind
  99454. * - VertexBuffer.UV4Kind
  99455. * - VertexBuffer.UV5Kind
  99456. * - VertexBuffer.UV6Kind
  99457. * - VertexBuffer.ColorKind
  99458. * - VertexBuffer.MatricesIndicesKind
  99459. * - VertexBuffer.MatricesIndicesExtraKind
  99460. * - VertexBuffer.MatricesWeightsKind
  99461. * - VertexBuffer.MatricesWeightsExtraKind
  99462. * @returns a boolean
  99463. */
  99464. isVerticesDataPresent(kind: string): boolean;
  99465. /**
  99466. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  99467. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  99468. * - VertexBuffer.PositionKind
  99469. * - VertexBuffer.UVKind
  99470. * - VertexBuffer.UV2Kind
  99471. * - VertexBuffer.UV3Kind
  99472. * - VertexBuffer.UV4Kind
  99473. * - VertexBuffer.UV5Kind
  99474. * - VertexBuffer.UV6Kind
  99475. * - VertexBuffer.ColorKind
  99476. * - VertexBuffer.MatricesIndicesKind
  99477. * - VertexBuffer.MatricesIndicesExtraKind
  99478. * - VertexBuffer.MatricesWeightsKind
  99479. * - VertexBuffer.MatricesWeightsExtraKind
  99480. * @returns a boolean
  99481. */
  99482. isVertexBufferUpdatable(kind: string): boolean;
  99483. /**
  99484. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  99485. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  99486. * - VertexBuffer.PositionKind
  99487. * - VertexBuffer.NormalKind
  99488. * - VertexBuffer.UVKind
  99489. * - VertexBuffer.UV2Kind
  99490. * - VertexBuffer.UV3Kind
  99491. * - VertexBuffer.UV4Kind
  99492. * - VertexBuffer.UV5Kind
  99493. * - VertexBuffer.UV6Kind
  99494. * - VertexBuffer.ColorKind
  99495. * - VertexBuffer.MatricesIndicesKind
  99496. * - VertexBuffer.MatricesIndicesExtraKind
  99497. * - VertexBuffer.MatricesWeightsKind
  99498. * - VertexBuffer.MatricesWeightsExtraKind
  99499. * @returns an array of strings
  99500. */
  99501. getVerticesDataKinds(): string[];
  99502. /**
  99503. * Returns a positive integer : the total number of indices in this mesh geometry.
  99504. * @returns the numner of indices or zero if the mesh has no geometry.
  99505. */
  99506. getTotalIndices(): number;
  99507. /**
  99508. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  99509. * @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.
  99510. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  99511. * @returns the indices array or an empty array if the mesh has no geometry
  99512. */
  99513. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  99514. get isBlocked(): boolean;
  99515. /**
  99516. * Determine if the current mesh is ready to be rendered
  99517. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  99518. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  99519. * @returns true if all associated assets are ready (material, textures, shaders)
  99520. */
  99521. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  99522. /**
  99523. * 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.
  99524. */
  99525. get areNormalsFrozen(): boolean;
  99526. /**
  99527. * 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.
  99528. * @returns the current mesh
  99529. */
  99530. freezeNormals(): Mesh;
  99531. /**
  99532. * 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
  99533. * @returns the current mesh
  99534. */
  99535. unfreezeNormals(): Mesh;
  99536. /**
  99537. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  99538. */
  99539. set overridenInstanceCount(count: number);
  99540. /** @hidden */
  99541. _preActivate(): Mesh;
  99542. /** @hidden */
  99543. _preActivateForIntermediateRendering(renderId: number): Mesh;
  99544. /** @hidden */
  99545. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  99546. /**
  99547. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  99548. * This means the mesh underlying bounding box and sphere are recomputed.
  99549. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  99550. * @returns the current mesh
  99551. */
  99552. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  99553. /** @hidden */
  99554. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  99555. /**
  99556. * This function will subdivide the mesh into multiple submeshes
  99557. * @param count defines the expected number of submeshes
  99558. */
  99559. subdivide(count: number): void;
  99560. /**
  99561. * Copy a FloatArray into a specific associated vertex buffer
  99562. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  99563. * - VertexBuffer.PositionKind
  99564. * - VertexBuffer.UVKind
  99565. * - VertexBuffer.UV2Kind
  99566. * - VertexBuffer.UV3Kind
  99567. * - VertexBuffer.UV4Kind
  99568. * - VertexBuffer.UV5Kind
  99569. * - VertexBuffer.UV6Kind
  99570. * - VertexBuffer.ColorKind
  99571. * - VertexBuffer.MatricesIndicesKind
  99572. * - VertexBuffer.MatricesIndicesExtraKind
  99573. * - VertexBuffer.MatricesWeightsKind
  99574. * - VertexBuffer.MatricesWeightsExtraKind
  99575. * @param data defines the data source
  99576. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  99577. * @param stride defines the data stride size (can be null)
  99578. * @returns the current mesh
  99579. */
  99580. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  99581. /**
  99582. * Delete a vertex buffer associated with this mesh
  99583. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  99584. * - VertexBuffer.PositionKind
  99585. * - VertexBuffer.UVKind
  99586. * - VertexBuffer.UV2Kind
  99587. * - VertexBuffer.UV3Kind
  99588. * - VertexBuffer.UV4Kind
  99589. * - VertexBuffer.UV5Kind
  99590. * - VertexBuffer.UV6Kind
  99591. * - VertexBuffer.ColorKind
  99592. * - VertexBuffer.MatricesIndicesKind
  99593. * - VertexBuffer.MatricesIndicesExtraKind
  99594. * - VertexBuffer.MatricesWeightsKind
  99595. * - VertexBuffer.MatricesWeightsExtraKind
  99596. */
  99597. removeVerticesData(kind: string): void;
  99598. /**
  99599. * Flags an associated vertex buffer as updatable
  99600. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  99601. * - VertexBuffer.PositionKind
  99602. * - VertexBuffer.UVKind
  99603. * - VertexBuffer.UV2Kind
  99604. * - VertexBuffer.UV3Kind
  99605. * - VertexBuffer.UV4Kind
  99606. * - VertexBuffer.UV5Kind
  99607. * - VertexBuffer.UV6Kind
  99608. * - VertexBuffer.ColorKind
  99609. * - VertexBuffer.MatricesIndicesKind
  99610. * - VertexBuffer.MatricesIndicesExtraKind
  99611. * - VertexBuffer.MatricesWeightsKind
  99612. * - VertexBuffer.MatricesWeightsExtraKind
  99613. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  99614. */
  99615. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  99616. /**
  99617. * Sets the mesh global Vertex Buffer
  99618. * @param buffer defines the buffer to use
  99619. * @returns the current mesh
  99620. */
  99621. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  99622. /**
  99623. * Update a specific associated vertex buffer
  99624. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  99625. * - VertexBuffer.PositionKind
  99626. * - VertexBuffer.UVKind
  99627. * - VertexBuffer.UV2Kind
  99628. * - VertexBuffer.UV3Kind
  99629. * - VertexBuffer.UV4Kind
  99630. * - VertexBuffer.UV5Kind
  99631. * - VertexBuffer.UV6Kind
  99632. * - VertexBuffer.ColorKind
  99633. * - VertexBuffer.MatricesIndicesKind
  99634. * - VertexBuffer.MatricesIndicesExtraKind
  99635. * - VertexBuffer.MatricesWeightsKind
  99636. * - VertexBuffer.MatricesWeightsExtraKind
  99637. * @param data defines the data source
  99638. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  99639. * @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)
  99640. * @returns the current mesh
  99641. */
  99642. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  99643. /**
  99644. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  99645. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  99646. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  99647. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  99648. * @returns the current mesh
  99649. */
  99650. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  99651. /**
  99652. * Creates a un-shared specific occurence of the geometry for the mesh.
  99653. * @returns the current mesh
  99654. */
  99655. makeGeometryUnique(): Mesh;
  99656. /**
  99657. * Set the index buffer of this mesh
  99658. * @param indices defines the source data
  99659. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  99660. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  99661. * @returns the current mesh
  99662. */
  99663. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  99664. /**
  99665. * Update the current index buffer
  99666. * @param indices defines the source data
  99667. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  99668. * @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)
  99669. * @returns the current mesh
  99670. */
  99671. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  99672. /**
  99673. * Invert the geometry to move from a right handed system to a left handed one.
  99674. * @returns the current mesh
  99675. */
  99676. toLeftHanded(): Mesh;
  99677. /** @hidden */
  99678. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  99679. /** @hidden */
  99680. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  99681. /**
  99682. * Registers for this mesh a javascript function called just before the rendering process
  99683. * @param func defines the function to call before rendering this mesh
  99684. * @returns the current mesh
  99685. */
  99686. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  99687. /**
  99688. * Disposes a previously registered javascript function called before the rendering
  99689. * @param func defines the function to remove
  99690. * @returns the current mesh
  99691. */
  99692. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  99693. /**
  99694. * Registers for this mesh a javascript function called just after the rendering is complete
  99695. * @param func defines the function to call after rendering this mesh
  99696. * @returns the current mesh
  99697. */
  99698. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  99699. /**
  99700. * Disposes a previously registered javascript function called after the rendering.
  99701. * @param func defines the function to remove
  99702. * @returns the current mesh
  99703. */
  99704. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  99705. /** @hidden */
  99706. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  99707. /** @hidden */
  99708. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  99709. /** @hidden */
  99710. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  99711. /** @hidden */
  99712. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  99713. /** @hidden */
  99714. _rebuild(): void;
  99715. /** @hidden */
  99716. _freeze(): void;
  99717. /** @hidden */
  99718. _unFreeze(): void;
  99719. /**
  99720. * 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
  99721. * @param subMesh defines the subMesh to render
  99722. * @param enableAlphaMode defines if alpha mode can be changed
  99723. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  99724. * @returns the current mesh
  99725. */
  99726. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  99727. private _onBeforeDraw;
  99728. /**
  99729. * Renormalize the mesh and patch it up if there are no weights
  99730. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  99731. * However in the case of zero weights then we set just a single influence to 1.
  99732. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  99733. */
  99734. cleanMatrixWeights(): void;
  99735. private normalizeSkinFourWeights;
  99736. private normalizeSkinWeightsAndExtra;
  99737. /**
  99738. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  99739. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  99740. * the user know there was an issue with importing the mesh
  99741. * @returns a validation object with skinned, valid and report string
  99742. */
  99743. validateSkinning(): {
  99744. skinned: boolean;
  99745. valid: boolean;
  99746. report: string;
  99747. };
  99748. /** @hidden */
  99749. _checkDelayState(): Mesh;
  99750. private _queueLoad;
  99751. /**
  99752. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  99753. * A mesh is in the frustum if its bounding box intersects the frustum
  99754. * @param frustumPlanes defines the frustum to test
  99755. * @returns true if the mesh is in the frustum planes
  99756. */
  99757. isInFrustum(frustumPlanes: Plane[]): boolean;
  99758. /**
  99759. * Sets the mesh material by the material or multiMaterial `id` property
  99760. * @param id is a string identifying the material or the multiMaterial
  99761. * @returns the current mesh
  99762. */
  99763. setMaterialByID(id: string): Mesh;
  99764. /**
  99765. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  99766. * @returns an array of IAnimatable
  99767. */
  99768. getAnimatables(): IAnimatable[];
  99769. /**
  99770. * Modifies the mesh geometry according to the passed transformation matrix.
  99771. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  99772. * The mesh normals are modified using the same transformation.
  99773. * Note that, under the hood, this method sets a new VertexBuffer each call.
  99774. * @param transform defines the transform matrix to use
  99775. * @see http://doc.babylonjs.com/resources/baking_transformations
  99776. * @returns the current mesh
  99777. */
  99778. bakeTransformIntoVertices(transform: Matrix): Mesh;
  99779. /**
  99780. * Modifies the mesh geometry according to its own current World Matrix.
  99781. * The mesh World Matrix is then reset.
  99782. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  99783. * Note that, under the hood, this method sets a new VertexBuffer each call.
  99784. * @see http://doc.babylonjs.com/resources/baking_transformations
  99785. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  99786. * @returns the current mesh
  99787. */
  99788. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  99789. /** @hidden */
  99790. get _positions(): Nullable<Vector3[]>;
  99791. /** @hidden */
  99792. _resetPointsArrayCache(): Mesh;
  99793. /** @hidden */
  99794. _generatePointsArray(): boolean;
  99795. /**
  99796. * Returns a new Mesh object generated from the current mesh properties.
  99797. * This method must not get confused with createInstance()
  99798. * @param name is a string, the name given to the new mesh
  99799. * @param newParent can be any Node object (default `null`)
  99800. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  99801. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  99802. * @returns a new mesh
  99803. */
  99804. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  99805. /**
  99806. * Releases resources associated with this mesh.
  99807. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99808. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99809. */
  99810. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99811. /** @hidden */
  99812. _disposeInstanceSpecificData(): void;
  99813. /**
  99814. * Modifies the mesh geometry according to a displacement map.
  99815. * 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.
  99816. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  99817. * @param url is a string, the URL from the image file is to be downloaded.
  99818. * @param minHeight is the lower limit of the displacement.
  99819. * @param maxHeight is the upper limit of the displacement.
  99820. * @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.
  99821. * @param uvOffset is an optional vector2 used to offset UV.
  99822. * @param uvScale is an optional vector2 used to scale UV.
  99823. * @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.
  99824. * @returns the Mesh.
  99825. */
  99826. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  99827. /**
  99828. * Modifies the mesh geometry according to a displacementMap buffer.
  99829. * 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.
  99830. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  99831. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  99832. * @param heightMapWidth is the width of the buffer image.
  99833. * @param heightMapHeight is the height of the buffer image.
  99834. * @param minHeight is the lower limit of the displacement.
  99835. * @param maxHeight is the upper limit of the displacement.
  99836. * @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.
  99837. * @param uvOffset is an optional vector2 used to offset UV.
  99838. * @param uvScale is an optional vector2 used to scale UV.
  99839. * @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.
  99840. * @returns the Mesh.
  99841. */
  99842. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  99843. /**
  99844. * Modify the mesh to get a flat shading rendering.
  99845. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  99846. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  99847. * @returns current mesh
  99848. */
  99849. convertToFlatShadedMesh(): Mesh;
  99850. /**
  99851. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  99852. * In other words, more vertices, no more indices and a single bigger VBO.
  99853. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  99854. * @returns current mesh
  99855. */
  99856. convertToUnIndexedMesh(): Mesh;
  99857. /**
  99858. * Inverses facet orientations.
  99859. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  99860. * @param flipNormals will also inverts the normals
  99861. * @returns current mesh
  99862. */
  99863. flipFaces(flipNormals?: boolean): Mesh;
  99864. /**
  99865. * Increase the number of facets and hence vertices in a mesh
  99866. * Vertex normals are interpolated from existing vertex normals
  99867. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  99868. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  99869. */
  99870. increaseVertices(numberPerEdge: number): void;
  99871. /**
  99872. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  99873. * This will undo any application of covertToFlatShadedMesh
  99874. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  99875. */
  99876. forceSharedVertices(): void;
  99877. /** @hidden */
  99878. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  99879. /** @hidden */
  99880. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  99881. /**
  99882. * Creates a new InstancedMesh object from the mesh model.
  99883. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  99884. * @param name defines the name of the new instance
  99885. * @returns a new InstancedMesh
  99886. */
  99887. createInstance(name: string): InstancedMesh;
  99888. /**
  99889. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  99890. * After this call, all the mesh instances have the same submeshes than the current mesh.
  99891. * @returns the current mesh
  99892. */
  99893. synchronizeInstances(): Mesh;
  99894. /**
  99895. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  99896. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  99897. * This should be used together with the simplification to avoid disappearing triangles.
  99898. * @param successCallback an optional success callback to be called after the optimization finished.
  99899. * @returns the current mesh
  99900. */
  99901. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  99902. /**
  99903. * Serialize current mesh
  99904. * @param serializationObject defines the object which will receive the serialization data
  99905. */
  99906. serialize(serializationObject: any): void;
  99907. /** @hidden */
  99908. _syncGeometryWithMorphTargetManager(): void;
  99909. /** @hidden */
  99910. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  99911. /**
  99912. * Returns a new Mesh object parsed from the source provided.
  99913. * @param parsedMesh is the source
  99914. * @param scene defines the hosting scene
  99915. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  99916. * @returns a new Mesh
  99917. */
  99918. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  99919. /**
  99920. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  99921. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  99922. * @param name defines the name of the mesh to create
  99923. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  99924. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  99925. * @param closePath creates a seam between the first and the last points of each path of the path array
  99926. * @param offset is taken in account only if the `pathArray` is containing a single path
  99927. * @param scene defines the hosting scene
  99928. * @param updatable defines if the mesh must be flagged as updatable
  99929. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99930. * @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)
  99931. * @returns a new Mesh
  99932. */
  99933. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  99934. /**
  99935. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  99936. * @param name defines the name of the mesh to create
  99937. * @param radius sets the radius size (float) of the polygon (default 0.5)
  99938. * @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
  99939. * @param scene defines the hosting scene
  99940. * @param updatable defines if the mesh must be flagged as updatable
  99941. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99942. * @returns a new Mesh
  99943. */
  99944. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  99945. /**
  99946. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  99947. * @param name defines the name of the mesh to create
  99948. * @param size sets the size (float) of each box side (default 1)
  99949. * @param scene defines the hosting scene
  99950. * @param updatable defines if the mesh must be flagged as updatable
  99951. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99952. * @returns a new Mesh
  99953. */
  99954. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  99955. /**
  99956. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  99957. * @param name defines the name of the mesh to create
  99958. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  99959. * @param diameter sets the diameter size (float) of the sphere (default 1)
  99960. * @param scene defines the hosting scene
  99961. * @param updatable defines if the mesh must be flagged as updatable
  99962. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99963. * @returns a new Mesh
  99964. */
  99965. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99966. /**
  99967. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  99968. * @param name defines the name of the mesh to create
  99969. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  99970. * @param diameter sets the diameter size (float) of the sphere (default 1)
  99971. * @param scene defines the hosting scene
  99972. * @returns a new Mesh
  99973. */
  99974. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  99975. /**
  99976. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  99977. * @param name defines the name of the mesh to create
  99978. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  99979. * @param diameterTop set the top cap diameter (floats, default 1)
  99980. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  99981. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  99982. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  99983. * @param scene defines the hosting scene
  99984. * @param updatable defines if the mesh must be flagged as updatable
  99985. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99986. * @returns a new Mesh
  99987. */
  99988. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  99989. /**
  99990. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  99991. * @param name defines the name of the mesh to create
  99992. * @param diameter sets the diameter size (float) of the torus (default 1)
  99993. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  99994. * @param tessellation sets the number of torus sides (postive integer, default 16)
  99995. * @param scene defines the hosting scene
  99996. * @param updatable defines if the mesh must be flagged as updatable
  99997. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99998. * @returns a new Mesh
  99999. */
  100000. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  100001. /**
  100002. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  100003. * @param name defines the name of the mesh to create
  100004. * @param radius sets the global radius size (float) of the torus knot (default 2)
  100005. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  100006. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  100007. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  100008. * @param p the number of windings on X axis (positive integers, default 2)
  100009. * @param q the number of windings on Y axis (positive integers, default 3)
  100010. * @param scene defines the hosting scene
  100011. * @param updatable defines if the mesh must be flagged as updatable
  100012. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  100013. * @returns a new Mesh
  100014. */
  100015. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  100016. /**
  100017. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  100018. * @param name defines the name of the mesh to create
  100019. * @param points is an array successive Vector3
  100020. * @param scene defines the hosting scene
  100021. * @param updatable defines if the mesh must be flagged as updatable
  100022. * @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).
  100023. * @returns a new Mesh
  100024. */
  100025. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  100026. /**
  100027. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  100028. * @param name defines the name of the mesh to create
  100029. * @param points is an array successive Vector3
  100030. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  100031. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  100032. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  100033. * @param scene defines the hosting scene
  100034. * @param updatable defines if the mesh must be flagged as updatable
  100035. * @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)
  100036. * @returns a new Mesh
  100037. */
  100038. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  100039. /**
  100040. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  100041. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  100042. * 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.
  100043. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  100044. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  100045. * Remember you can only change the shape positions, not their number when updating a polygon.
  100046. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  100047. * @param name defines the name of the mesh to create
  100048. * @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
  100049. * @param scene defines the hosting scene
  100050. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  100051. * @param updatable defines if the mesh must be flagged as updatable
  100052. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  100053. * @param earcutInjection can be used to inject your own earcut reference
  100054. * @returns a new Mesh
  100055. */
  100056. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  100057. /**
  100058. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  100059. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  100060. * @param name defines the name of the mesh to create
  100061. * @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
  100062. * @param depth defines the height of extrusion
  100063. * @param scene defines the hosting scene
  100064. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  100065. * @param updatable defines if the mesh must be flagged as updatable
  100066. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  100067. * @param earcutInjection can be used to inject your own earcut reference
  100068. * @returns a new Mesh
  100069. */
  100070. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  100071. /**
  100072. * Creates an extruded shape mesh.
  100073. * 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
  100074. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  100075. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  100076. * @param name defines the name of the mesh to create
  100077. * @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
  100078. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  100079. * @param scale is the value to scale the shape
  100080. * @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
  100081. * @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
  100082. * @param scene defines the hosting scene
  100083. * @param updatable defines if the mesh must be flagged as updatable
  100084. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  100085. * @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)
  100086. * @returns a new Mesh
  100087. */
  100088. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  100089. /**
  100090. * Creates an custom extruded shape mesh.
  100091. * The custom extrusion is a parametric shape.
  100092. * It has no predefined shape. Its final shape will depend on the input parameters.
  100093. * Please consider using the same method from the MeshBuilder class instead
  100094. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  100095. * @param name defines the name of the mesh to create
  100096. * @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
  100097. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  100098. * @param scaleFunction is a custom Javascript function called on each path point
  100099. * @param rotationFunction is a custom Javascript function called on each path point
  100100. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  100101. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  100102. * @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
  100103. * @param scene defines the hosting scene
  100104. * @param updatable defines if the mesh must be flagged as updatable
  100105. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  100106. * @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)
  100107. * @returns a new Mesh
  100108. */
  100109. 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;
  100110. /**
  100111. * Creates lathe mesh.
  100112. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  100113. * Please consider using the same method from the MeshBuilder class instead
  100114. * @param name defines the name of the mesh to create
  100115. * @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
  100116. * @param radius is the radius value of the lathe
  100117. * @param tessellation is the side number of the lathe.
  100118. * @param scene defines the hosting scene
  100119. * @param updatable defines if the mesh must be flagged as updatable
  100120. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  100121. * @returns a new Mesh
  100122. */
  100123. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  100124. /**
  100125. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  100126. * @param name defines the name of the mesh to create
  100127. * @param size sets the size (float) of both sides of the plane at once (default 1)
  100128. * @param scene defines the hosting scene
  100129. * @param updatable defines if the mesh must be flagged as updatable
  100130. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  100131. * @returns a new Mesh
  100132. */
  100133. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  100134. /**
  100135. * Creates a ground mesh.
  100136. * Please consider using the same method from the MeshBuilder class instead
  100137. * @param name defines the name of the mesh to create
  100138. * @param width set the width of the ground
  100139. * @param height set the height of the ground
  100140. * @param subdivisions sets the number of subdivisions per side
  100141. * @param scene defines the hosting scene
  100142. * @param updatable defines if the mesh must be flagged as updatable
  100143. * @returns a new Mesh
  100144. */
  100145. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  100146. /**
  100147. * Creates a tiled ground mesh.
  100148. * Please consider using the same method from the MeshBuilder class instead
  100149. * @param name defines the name of the mesh to create
  100150. * @param xmin set the ground minimum X coordinate
  100151. * @param zmin set the ground minimum Y coordinate
  100152. * @param xmax set the ground maximum X coordinate
  100153. * @param zmax set the ground maximum Z coordinate
  100154. * @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
  100155. * @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
  100156. * @param scene defines the hosting scene
  100157. * @param updatable defines if the mesh must be flagged as updatable
  100158. * @returns a new Mesh
  100159. */
  100160. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  100161. w: number;
  100162. h: number;
  100163. }, precision: {
  100164. w: number;
  100165. h: number;
  100166. }, scene: Scene, updatable?: boolean): Mesh;
  100167. /**
  100168. * Creates a ground mesh from a height map.
  100169. * Please consider using the same method from the MeshBuilder class instead
  100170. * @see http://doc.babylonjs.com/babylon101/height_map
  100171. * @param name defines the name of the mesh to create
  100172. * @param url sets the URL of the height map image resource
  100173. * @param width set the ground width size
  100174. * @param height set the ground height size
  100175. * @param subdivisions sets the number of subdivision per side
  100176. * @param minHeight is the minimum altitude on the ground
  100177. * @param maxHeight is the maximum altitude on the ground
  100178. * @param scene defines the hosting scene
  100179. * @param updatable defines if the mesh must be flagged as updatable
  100180. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  100181. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  100182. * @returns a new Mesh
  100183. */
  100184. 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;
  100185. /**
  100186. * Creates a tube mesh.
  100187. * The tube is a parametric shape.
  100188. * It has no predefined shape. Its final shape will depend on the input parameters.
  100189. * Please consider using the same method from the MeshBuilder class instead
  100190. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  100191. * @param name defines the name of the mesh to create
  100192. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  100193. * @param radius sets the tube radius size
  100194. * @param tessellation is the number of sides on the tubular surface
  100195. * @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
  100196. * @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
  100197. * @param scene defines the hosting scene
  100198. * @param updatable defines if the mesh must be flagged as updatable
  100199. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  100200. * @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)
  100201. * @returns a new Mesh
  100202. */
  100203. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  100204. (i: number, distance: number): number;
  100205. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  100206. /**
  100207. * Creates a polyhedron mesh.
  100208. * Please consider using the same method from the MeshBuilder class instead.
  100209. * * 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
  100210. * * The parameter `size` (positive float, default 1) sets the polygon size
  100211. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  100212. * * 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`
  100213. * * 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
  100214. * * 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)`)
  100215. * * 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
  100216. * * 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
  100217. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  100218. * * If you create a double-sided mesh, you can choose what parts of 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
  100219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100220. * @param name defines the name of the mesh to create
  100221. * @param options defines the options used to create the mesh
  100222. * @param scene defines the hosting scene
  100223. * @returns a new Mesh
  100224. */
  100225. static CreatePolyhedron(name: string, options: {
  100226. type?: number;
  100227. size?: number;
  100228. sizeX?: number;
  100229. sizeY?: number;
  100230. sizeZ?: number;
  100231. custom?: any;
  100232. faceUV?: Vector4[];
  100233. faceColors?: Color4[];
  100234. updatable?: boolean;
  100235. sideOrientation?: number;
  100236. }, scene: Scene): Mesh;
  100237. /**
  100238. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  100239. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  100240. * * 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`)
  100241. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  100242. * * 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
  100243. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  100244. * * If you create a double-sided mesh, you can choose what parts of 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
  100245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100246. * @param name defines the name of the mesh
  100247. * @param options defines the options used to create the mesh
  100248. * @param scene defines the hosting scene
  100249. * @returns a new Mesh
  100250. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  100251. */
  100252. static CreateIcoSphere(name: string, options: {
  100253. radius?: number;
  100254. flat?: boolean;
  100255. subdivisions?: number;
  100256. sideOrientation?: number;
  100257. updatable?: boolean;
  100258. }, scene: Scene): Mesh;
  100259. /**
  100260. * Creates a decal mesh.
  100261. * Please consider using the same method from the MeshBuilder class instead.
  100262. * A decal is a mesh usually applied as a model onto the surface of another mesh
  100263. * @param name defines the name of the mesh
  100264. * @param sourceMesh defines the mesh receiving the decal
  100265. * @param position sets the position of the decal in world coordinates
  100266. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  100267. * @param size sets the decal scaling
  100268. * @param angle sets the angle to rotate the decal
  100269. * @returns a new Mesh
  100270. */
  100271. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  100272. /**
  100273. * Prepare internal position array for software CPU skinning
  100274. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  100275. */
  100276. setPositionsForCPUSkinning(): Float32Array;
  100277. /**
  100278. * Prepare internal normal array for software CPU skinning
  100279. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  100280. */
  100281. setNormalsForCPUSkinning(): Float32Array;
  100282. /**
  100283. * Updates the vertex buffer by applying transformation from the bones
  100284. * @param skeleton defines the skeleton to apply to current mesh
  100285. * @returns the current mesh
  100286. */
  100287. applySkeleton(skeleton: Skeleton): Mesh;
  100288. /**
  100289. * 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
  100290. * @param meshes defines the list of meshes to scan
  100291. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  100292. */
  100293. static MinMax(meshes: AbstractMesh[]): {
  100294. min: Vector3;
  100295. max: Vector3;
  100296. };
  100297. /**
  100298. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  100299. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  100300. * @returns a vector3
  100301. */
  100302. static Center(meshesOrMinMaxVector: {
  100303. min: Vector3;
  100304. max: Vector3;
  100305. } | AbstractMesh[]): Vector3;
  100306. /**
  100307. * Merge the array of meshes into a single mesh for performance reasons.
  100308. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  100309. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  100310. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  100311. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  100312. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  100313. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  100314. * @returns a new mesh
  100315. */
  100316. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  100317. /** @hidden */
  100318. addInstance(instance: InstancedMesh): void;
  100319. /** @hidden */
  100320. removeInstance(instance: InstancedMesh): void;
  100321. }
  100322. }
  100323. declare module BABYLON {
  100324. /**
  100325. * This is the base class of all the camera used in the application.
  100326. * @see http://doc.babylonjs.com/features/cameras
  100327. */
  100328. export class Camera extends Node {
  100329. /** @hidden */
  100330. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  100331. /**
  100332. * This is the default projection mode used by the cameras.
  100333. * It helps recreating a feeling of perspective and better appreciate depth.
  100334. * This is the best way to simulate real life cameras.
  100335. */
  100336. static readonly PERSPECTIVE_CAMERA: number;
  100337. /**
  100338. * This helps creating camera with an orthographic mode.
  100339. * 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.
  100340. */
  100341. static readonly ORTHOGRAPHIC_CAMERA: number;
  100342. /**
  100343. * This is the default FOV mode for perspective cameras.
  100344. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  100345. */
  100346. static readonly FOVMODE_VERTICAL_FIXED: number;
  100347. /**
  100348. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  100349. */
  100350. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  100351. /**
  100352. * This specifies ther is no need for a camera rig.
  100353. * Basically only one eye is rendered corresponding to the camera.
  100354. */
  100355. static readonly RIG_MODE_NONE: number;
  100356. /**
  100357. * Simulates a camera Rig with one blue eye and one red eye.
  100358. * This can be use with 3d blue and red glasses.
  100359. */
  100360. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  100361. /**
  100362. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  100363. */
  100364. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  100365. /**
  100366. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  100367. */
  100368. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  100369. /**
  100370. * Defines that both eyes of the camera will be rendered over under each other.
  100371. */
  100372. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  100373. /**
  100374. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  100375. */
  100376. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  100377. /**
  100378. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  100379. */
  100380. static readonly RIG_MODE_VR: number;
  100381. /**
  100382. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  100383. */
  100384. static readonly RIG_MODE_WEBVR: number;
  100385. /**
  100386. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  100387. */
  100388. static readonly RIG_MODE_CUSTOM: number;
  100389. /**
  100390. * Defines if by default attaching controls should prevent the default javascript event to continue.
  100391. */
  100392. static ForceAttachControlToAlwaysPreventDefault: boolean;
  100393. /**
  100394. * Define the input manager associated with the camera.
  100395. */
  100396. inputs: CameraInputsManager<Camera>;
  100397. /** @hidden */
  100398. _position: Vector3;
  100399. /**
  100400. * Define the current local position of the camera in the scene
  100401. */
  100402. get position(): Vector3;
  100403. set position(newPosition: Vector3);
  100404. /**
  100405. * The vector the camera should consider as up.
  100406. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  100407. */
  100408. upVector: Vector3;
  100409. /**
  100410. * Define the current limit on the left side for an orthographic camera
  100411. * In scene unit
  100412. */
  100413. orthoLeft: Nullable<number>;
  100414. /**
  100415. * Define the current limit on the right side for an orthographic camera
  100416. * In scene unit
  100417. */
  100418. orthoRight: Nullable<number>;
  100419. /**
  100420. * Define the current limit on the bottom side for an orthographic camera
  100421. * In scene unit
  100422. */
  100423. orthoBottom: Nullable<number>;
  100424. /**
  100425. * Define the current limit on the top side for an orthographic camera
  100426. * In scene unit
  100427. */
  100428. orthoTop: Nullable<number>;
  100429. /**
  100430. * Field Of View is set in Radians. (default is 0.8)
  100431. */
  100432. fov: number;
  100433. /**
  100434. * Define the minimum distance the camera can see from.
  100435. * This is important to note that the depth buffer are not infinite and the closer it starts
  100436. * the more your scene might encounter depth fighting issue.
  100437. */
  100438. minZ: number;
  100439. /**
  100440. * Define the maximum distance the camera can see to.
  100441. * This is important to note that the depth buffer are not infinite and the further it end
  100442. * the more your scene might encounter depth fighting issue.
  100443. */
  100444. maxZ: number;
  100445. /**
  100446. * Define the default inertia of the camera.
  100447. * This helps giving a smooth feeling to the camera movement.
  100448. */
  100449. inertia: number;
  100450. /**
  100451. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  100452. */
  100453. mode: number;
  100454. /**
  100455. * Define whether the camera is intermediate.
  100456. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  100457. */
  100458. isIntermediate: boolean;
  100459. /**
  100460. * Define the viewport of the camera.
  100461. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  100462. */
  100463. viewport: Viewport;
  100464. /**
  100465. * Restricts the camera to viewing objects with the same layerMask.
  100466. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  100467. */
  100468. layerMask: number;
  100469. /**
  100470. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  100471. */
  100472. fovMode: number;
  100473. /**
  100474. * Rig mode of the camera.
  100475. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  100476. * This is normally controlled byt the camera themselves as internal use.
  100477. */
  100478. cameraRigMode: number;
  100479. /**
  100480. * Defines the distance between both "eyes" in case of a RIG
  100481. */
  100482. interaxialDistance: number;
  100483. /**
  100484. * Defines if stereoscopic rendering is done side by side or over under.
  100485. */
  100486. isStereoscopicSideBySide: boolean;
  100487. /**
  100488. * 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
  100489. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  100490. * else in the scene. (Eg. security camera)
  100491. *
  100492. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  100493. */
  100494. customRenderTargets: RenderTargetTexture[];
  100495. /**
  100496. * When set, the camera will render to this render target instead of the default canvas
  100497. *
  100498. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  100499. */
  100500. outputRenderTarget: Nullable<RenderTargetTexture>;
  100501. /**
  100502. * Observable triggered when the camera view matrix has changed.
  100503. */
  100504. onViewMatrixChangedObservable: Observable<Camera>;
  100505. /**
  100506. * Observable triggered when the camera Projection matrix has changed.
  100507. */
  100508. onProjectionMatrixChangedObservable: Observable<Camera>;
  100509. /**
  100510. * Observable triggered when the inputs have been processed.
  100511. */
  100512. onAfterCheckInputsObservable: Observable<Camera>;
  100513. /**
  100514. * Observable triggered when reset has been called and applied to the camera.
  100515. */
  100516. onRestoreStateObservable: Observable<Camera>;
  100517. /**
  100518. * Is this camera a part of a rig system?
  100519. */
  100520. isRigCamera: boolean;
  100521. /**
  100522. * If isRigCamera set to true this will be set with the parent camera.
  100523. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  100524. */
  100525. rigParent?: Camera;
  100526. /** @hidden */
  100527. _cameraRigParams: any;
  100528. /** @hidden */
  100529. _rigCameras: Camera[];
  100530. /** @hidden */
  100531. _rigPostProcess: Nullable<PostProcess>;
  100532. protected _webvrViewMatrix: Matrix;
  100533. /** @hidden */
  100534. _skipRendering: boolean;
  100535. /** @hidden */
  100536. _projectionMatrix: Matrix;
  100537. /** @hidden */
  100538. _postProcesses: Nullable<PostProcess>[];
  100539. /** @hidden */
  100540. _activeMeshes: SmartArray<AbstractMesh>;
  100541. protected _globalPosition: Vector3;
  100542. /** @hidden */
  100543. _computedViewMatrix: Matrix;
  100544. private _doNotComputeProjectionMatrix;
  100545. private _transformMatrix;
  100546. private _frustumPlanes;
  100547. private _refreshFrustumPlanes;
  100548. private _storedFov;
  100549. private _stateStored;
  100550. /**
  100551. * Instantiates a new camera object.
  100552. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  100553. * @see http://doc.babylonjs.com/features/cameras
  100554. * @param name Defines the name of the camera in the scene
  100555. * @param position Defines the position of the camera
  100556. * @param scene Defines the scene the camera belongs too
  100557. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  100558. */
  100559. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  100560. /**
  100561. * Store current camera state (fov, position, etc..)
  100562. * @returns the camera
  100563. */
  100564. storeState(): Camera;
  100565. /**
  100566. * Restores the camera state values if it has been stored. You must call storeState() first
  100567. */
  100568. protected _restoreStateValues(): boolean;
  100569. /**
  100570. * Restored camera state. You must call storeState() first.
  100571. * @returns true if restored and false otherwise
  100572. */
  100573. restoreState(): boolean;
  100574. /**
  100575. * Gets the class name of the camera.
  100576. * @returns the class name
  100577. */
  100578. getClassName(): string;
  100579. /** @hidden */
  100580. readonly _isCamera: boolean;
  100581. /**
  100582. * Gets a string representation of the camera useful for debug purpose.
  100583. * @param fullDetails Defines that a more verboe level of logging is required
  100584. * @returns the string representation
  100585. */
  100586. toString(fullDetails?: boolean): string;
  100587. /**
  100588. * Gets the current world space position of the camera.
  100589. */
  100590. get globalPosition(): Vector3;
  100591. /**
  100592. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  100593. * @returns the active meshe list
  100594. */
  100595. getActiveMeshes(): SmartArray<AbstractMesh>;
  100596. /**
  100597. * Check whether a mesh is part of the current active mesh list of the camera
  100598. * @param mesh Defines the mesh to check
  100599. * @returns true if active, false otherwise
  100600. */
  100601. isActiveMesh(mesh: Mesh): boolean;
  100602. /**
  100603. * Is this camera ready to be used/rendered
  100604. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  100605. * @return true if the camera is ready
  100606. */
  100607. isReady(completeCheck?: boolean): boolean;
  100608. /** @hidden */
  100609. _initCache(): void;
  100610. /** @hidden */
  100611. _updateCache(ignoreParentClass?: boolean): void;
  100612. /** @hidden */
  100613. _isSynchronized(): boolean;
  100614. /** @hidden */
  100615. _isSynchronizedViewMatrix(): boolean;
  100616. /** @hidden */
  100617. _isSynchronizedProjectionMatrix(): boolean;
  100618. /**
  100619. * Attach the input controls to a specific dom element to get the input from.
  100620. * @param element Defines the element the controls should be listened from
  100621. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100622. */
  100623. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100624. /**
  100625. * Detach the current controls from the specified dom element.
  100626. * @param element Defines the element to stop listening the inputs from
  100627. */
  100628. detachControl(element: HTMLElement): void;
  100629. /**
  100630. * Update the camera state according to the different inputs gathered during the frame.
  100631. */
  100632. update(): void;
  100633. /** @hidden */
  100634. _checkInputs(): void;
  100635. /** @hidden */
  100636. get rigCameras(): Camera[];
  100637. /**
  100638. * Gets the post process used by the rig cameras
  100639. */
  100640. get rigPostProcess(): Nullable<PostProcess>;
  100641. /**
  100642. * Internal, gets the first post proces.
  100643. * @returns the first post process to be run on this camera.
  100644. */
  100645. _getFirstPostProcess(): Nullable<PostProcess>;
  100646. private _cascadePostProcessesToRigCams;
  100647. /**
  100648. * Attach a post process to the camera.
  100649. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  100650. * @param postProcess The post process to attach to the camera
  100651. * @param insertAt The position of the post process in case several of them are in use in the scene
  100652. * @returns the position the post process has been inserted at
  100653. */
  100654. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  100655. /**
  100656. * Detach a post process to the camera.
  100657. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  100658. * @param postProcess The post process to detach from the camera
  100659. */
  100660. detachPostProcess(postProcess: PostProcess): void;
  100661. /**
  100662. * Gets the current world matrix of the camera
  100663. */
  100664. getWorldMatrix(): Matrix;
  100665. /** @hidden */
  100666. _getViewMatrix(): Matrix;
  100667. /**
  100668. * Gets the current view matrix of the camera.
  100669. * @param force forces the camera to recompute the matrix without looking at the cached state
  100670. * @returns the view matrix
  100671. */
  100672. getViewMatrix(force?: boolean): Matrix;
  100673. /**
  100674. * Freeze the projection matrix.
  100675. * It will prevent the cache check of the camera projection compute and can speed up perf
  100676. * if no parameter of the camera are meant to change
  100677. * @param projection Defines manually a projection if necessary
  100678. */
  100679. freezeProjectionMatrix(projection?: Matrix): void;
  100680. /**
  100681. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  100682. */
  100683. unfreezeProjectionMatrix(): void;
  100684. /**
  100685. * Gets the current projection matrix of the camera.
  100686. * @param force forces the camera to recompute the matrix without looking at the cached state
  100687. * @returns the projection matrix
  100688. */
  100689. getProjectionMatrix(force?: boolean): Matrix;
  100690. /**
  100691. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  100692. * @returns a Matrix
  100693. */
  100694. getTransformationMatrix(): Matrix;
  100695. private _updateFrustumPlanes;
  100696. /**
  100697. * Checks if a cullable object (mesh...) is in the camera frustum
  100698. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  100699. * @param target The object to check
  100700. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  100701. * @returns true if the object is in frustum otherwise false
  100702. */
  100703. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  100704. /**
  100705. * Checks if a cullable object (mesh...) is in the camera frustum
  100706. * Unlike isInFrustum this cheks the full bounding box
  100707. * @param target The object to check
  100708. * @returns true if the object is in frustum otherwise false
  100709. */
  100710. isCompletelyInFrustum(target: ICullable): boolean;
  100711. /**
  100712. * Gets a ray in the forward direction from the camera.
  100713. * @param length Defines the length of the ray to create
  100714. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  100715. * @param origin Defines the start point of the ray which defaults to the camera position
  100716. * @returns the forward ray
  100717. */
  100718. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  100719. /**
  100720. * Releases resources associated with this node.
  100721. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  100722. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  100723. */
  100724. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  100725. /** @hidden */
  100726. _isLeftCamera: boolean;
  100727. /**
  100728. * Gets the left camera of a rig setup in case of Rigged Camera
  100729. */
  100730. get isLeftCamera(): boolean;
  100731. /** @hidden */
  100732. _isRightCamera: boolean;
  100733. /**
  100734. * Gets the right camera of a rig setup in case of Rigged Camera
  100735. */
  100736. get isRightCamera(): boolean;
  100737. /**
  100738. * Gets the left camera of a rig setup in case of Rigged Camera
  100739. */
  100740. get leftCamera(): Nullable<FreeCamera>;
  100741. /**
  100742. * Gets the right camera of a rig setup in case of Rigged Camera
  100743. */
  100744. get rightCamera(): Nullable<FreeCamera>;
  100745. /**
  100746. * Gets the left camera target of a rig setup in case of Rigged Camera
  100747. * @returns the target position
  100748. */
  100749. getLeftTarget(): Nullable<Vector3>;
  100750. /**
  100751. * Gets the right camera target of a rig setup in case of Rigged Camera
  100752. * @returns the target position
  100753. */
  100754. getRightTarget(): Nullable<Vector3>;
  100755. /**
  100756. * @hidden
  100757. */
  100758. setCameraRigMode(mode: number, rigParams: any): void;
  100759. /** @hidden */
  100760. static _setStereoscopicRigMode(camera: Camera): void;
  100761. /** @hidden */
  100762. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  100763. /** @hidden */
  100764. static _setVRRigMode(camera: Camera, rigParams: any): void;
  100765. /** @hidden */
  100766. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  100767. /** @hidden */
  100768. _getVRProjectionMatrix(): Matrix;
  100769. protected _updateCameraRotationMatrix(): void;
  100770. protected _updateWebVRCameraRotationMatrix(): void;
  100771. /**
  100772. * This function MUST be overwritten by the different WebVR cameras available.
  100773. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  100774. * @hidden
  100775. */
  100776. _getWebVRProjectionMatrix(): Matrix;
  100777. /**
  100778. * This function MUST be overwritten by the different WebVR cameras available.
  100779. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  100780. * @hidden
  100781. */
  100782. _getWebVRViewMatrix(): Matrix;
  100783. /** @hidden */
  100784. setCameraRigParameter(name: string, value: any): void;
  100785. /**
  100786. * needs to be overridden by children so sub has required properties to be copied
  100787. * @hidden
  100788. */
  100789. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  100790. /**
  100791. * May need to be overridden by children
  100792. * @hidden
  100793. */
  100794. _updateRigCameras(): void;
  100795. /** @hidden */
  100796. _setupInputs(): void;
  100797. /**
  100798. * Serialiaze the camera setup to a json represention
  100799. * @returns the JSON representation
  100800. */
  100801. serialize(): any;
  100802. /**
  100803. * Clones the current camera.
  100804. * @param name The cloned camera name
  100805. * @returns the cloned camera
  100806. */
  100807. clone(name: string): Camera;
  100808. /**
  100809. * Gets the direction of the camera relative to a given local axis.
  100810. * @param localAxis Defines the reference axis to provide a relative direction.
  100811. * @return the direction
  100812. */
  100813. getDirection(localAxis: Vector3): Vector3;
  100814. /**
  100815. * Returns the current camera absolute rotation
  100816. */
  100817. get absoluteRotation(): Quaternion;
  100818. /**
  100819. * Gets the direction of the camera relative to a given local axis into a passed vector.
  100820. * @param localAxis Defines the reference axis to provide a relative direction.
  100821. * @param result Defines the vector to store the result in
  100822. */
  100823. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  100824. /**
  100825. * Gets a camera constructor for a given camera type
  100826. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  100827. * @param name The name of the camera the result will be able to instantiate
  100828. * @param scene The scene the result will construct the camera in
  100829. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  100830. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  100831. * @returns a factory method to construc the camera
  100832. */
  100833. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  100834. /**
  100835. * Compute the world matrix of the camera.
  100836. * @returns the camera world matrix
  100837. */
  100838. computeWorldMatrix(): Matrix;
  100839. /**
  100840. * Parse a JSON and creates the camera from the parsed information
  100841. * @param parsedCamera The JSON to parse
  100842. * @param scene The scene to instantiate the camera in
  100843. * @returns the newly constructed camera
  100844. */
  100845. static Parse(parsedCamera: any, scene: Scene): Camera;
  100846. }
  100847. }
  100848. declare module BABYLON {
  100849. /**
  100850. * Class containing static functions to help procedurally build meshes
  100851. */
  100852. export class DiscBuilder {
  100853. /**
  100854. * Creates a plane polygonal mesh. By default, this is a disc
  100855. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  100856. * * 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
  100857. * * 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
  100858. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100859. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100860. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100861. * @param name defines the name of the mesh
  100862. * @param options defines the options used to create the mesh
  100863. * @param scene defines the hosting scene
  100864. * @returns the plane polygonal mesh
  100865. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  100866. */
  100867. static CreateDisc(name: string, options: {
  100868. radius?: number;
  100869. tessellation?: number;
  100870. arc?: number;
  100871. updatable?: boolean;
  100872. sideOrientation?: number;
  100873. frontUVs?: Vector4;
  100874. backUVs?: Vector4;
  100875. }, scene?: Nullable<Scene>): Mesh;
  100876. }
  100877. }
  100878. declare module BABYLON {
  100879. /**
  100880. * Options to be used when creating a FresnelParameters.
  100881. */
  100882. export type IFresnelParametersCreationOptions = {
  100883. /**
  100884. * Define the color used on edges (grazing angle)
  100885. */
  100886. leftColor?: Color3;
  100887. /**
  100888. * Define the color used on center
  100889. */
  100890. rightColor?: Color3;
  100891. /**
  100892. * Define bias applied to computed fresnel term
  100893. */
  100894. bias?: number;
  100895. /**
  100896. * Defined the power exponent applied to fresnel term
  100897. */
  100898. power?: number;
  100899. /**
  100900. * Define if the fresnel effect is enable or not.
  100901. */
  100902. isEnabled?: boolean;
  100903. };
  100904. /**
  100905. * Serialized format for FresnelParameters.
  100906. */
  100907. export type IFresnelParametersSerialized = {
  100908. /**
  100909. * Define the color used on edges (grazing angle) [as an array]
  100910. */
  100911. leftColor: number[];
  100912. /**
  100913. * Define the color used on center [as an array]
  100914. */
  100915. rightColor: number[];
  100916. /**
  100917. * Define bias applied to computed fresnel term
  100918. */
  100919. bias: number;
  100920. /**
  100921. * Defined the power exponent applied to fresnel term
  100922. */
  100923. power?: number;
  100924. /**
  100925. * Define if the fresnel effect is enable or not.
  100926. */
  100927. isEnabled: boolean;
  100928. };
  100929. /**
  100930. * This represents all the required information to add a fresnel effect on a material:
  100931. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100932. */
  100933. export class FresnelParameters {
  100934. private _isEnabled;
  100935. /**
  100936. * Define if the fresnel effect is enable or not.
  100937. */
  100938. get isEnabled(): boolean;
  100939. set isEnabled(value: boolean);
  100940. /**
  100941. * Define the color used on edges (grazing angle)
  100942. */
  100943. leftColor: Color3;
  100944. /**
  100945. * Define the color used on center
  100946. */
  100947. rightColor: Color3;
  100948. /**
  100949. * Define bias applied to computed fresnel term
  100950. */
  100951. bias: number;
  100952. /**
  100953. * Defined the power exponent applied to fresnel term
  100954. */
  100955. power: number;
  100956. /**
  100957. * Creates a new FresnelParameters object.
  100958. *
  100959. * @param options provide your own settings to optionally to override defaults
  100960. */
  100961. constructor(options?: IFresnelParametersCreationOptions);
  100962. /**
  100963. * Clones the current fresnel and its valuues
  100964. * @returns a clone fresnel configuration
  100965. */
  100966. clone(): FresnelParameters;
  100967. /**
  100968. * Determines equality between FresnelParameters objects
  100969. * @param otherFresnelParameters defines the second operand
  100970. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  100971. */
  100972. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  100973. /**
  100974. * Serializes the current fresnel parameters to a JSON representation.
  100975. * @return the JSON serialization
  100976. */
  100977. serialize(): IFresnelParametersSerialized;
  100978. /**
  100979. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  100980. * @param parsedFresnelParameters Define the JSON representation
  100981. * @returns the parsed parameters
  100982. */
  100983. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  100984. }
  100985. }
  100986. declare module BABYLON {
  100987. /**
  100988. * Base class of materials working in push mode in babylon JS
  100989. * @hidden
  100990. */
  100991. export class PushMaterial extends Material {
  100992. protected _activeEffect: Effect;
  100993. protected _normalMatrix: Matrix;
  100994. /**
  100995. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  100996. * This means that the material can keep using a previous shader while a new one is being compiled.
  100997. * This is mostly used when shader parallel compilation is supported (true by default)
  100998. */
  100999. allowShaderHotSwapping: boolean;
  101000. constructor(name: string, scene: Scene);
  101001. getEffect(): Effect;
  101002. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101003. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  101004. /**
  101005. * Binds the given world matrix to the active effect
  101006. *
  101007. * @param world the matrix to bind
  101008. */
  101009. bindOnlyWorldMatrix(world: Matrix): void;
  101010. /**
  101011. * Binds the given normal matrix to the active effect
  101012. *
  101013. * @param normalMatrix the matrix to bind
  101014. */
  101015. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  101016. bind(world: Matrix, mesh?: Mesh): void;
  101017. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  101018. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  101019. }
  101020. }
  101021. declare module BABYLON {
  101022. /**
  101023. * This groups all the flags used to control the materials channel.
  101024. */
  101025. export class MaterialFlags {
  101026. private static _DiffuseTextureEnabled;
  101027. /**
  101028. * Are diffuse textures enabled in the application.
  101029. */
  101030. static get DiffuseTextureEnabled(): boolean;
  101031. static set DiffuseTextureEnabled(value: boolean);
  101032. private static _AmbientTextureEnabled;
  101033. /**
  101034. * Are ambient textures enabled in the application.
  101035. */
  101036. static get AmbientTextureEnabled(): boolean;
  101037. static set AmbientTextureEnabled(value: boolean);
  101038. private static _OpacityTextureEnabled;
  101039. /**
  101040. * Are opacity textures enabled in the application.
  101041. */
  101042. static get OpacityTextureEnabled(): boolean;
  101043. static set OpacityTextureEnabled(value: boolean);
  101044. private static _ReflectionTextureEnabled;
  101045. /**
  101046. * Are reflection textures enabled in the application.
  101047. */
  101048. static get ReflectionTextureEnabled(): boolean;
  101049. static set ReflectionTextureEnabled(value: boolean);
  101050. private static _EmissiveTextureEnabled;
  101051. /**
  101052. * Are emissive textures enabled in the application.
  101053. */
  101054. static get EmissiveTextureEnabled(): boolean;
  101055. static set EmissiveTextureEnabled(value: boolean);
  101056. private static _SpecularTextureEnabled;
  101057. /**
  101058. * Are specular textures enabled in the application.
  101059. */
  101060. static get SpecularTextureEnabled(): boolean;
  101061. static set SpecularTextureEnabled(value: boolean);
  101062. private static _BumpTextureEnabled;
  101063. /**
  101064. * Are bump textures enabled in the application.
  101065. */
  101066. static get BumpTextureEnabled(): boolean;
  101067. static set BumpTextureEnabled(value: boolean);
  101068. private static _LightmapTextureEnabled;
  101069. /**
  101070. * Are lightmap textures enabled in the application.
  101071. */
  101072. static get LightmapTextureEnabled(): boolean;
  101073. static set LightmapTextureEnabled(value: boolean);
  101074. private static _RefractionTextureEnabled;
  101075. /**
  101076. * Are refraction textures enabled in the application.
  101077. */
  101078. static get RefractionTextureEnabled(): boolean;
  101079. static set RefractionTextureEnabled(value: boolean);
  101080. private static _ColorGradingTextureEnabled;
  101081. /**
  101082. * Are color grading textures enabled in the application.
  101083. */
  101084. static get ColorGradingTextureEnabled(): boolean;
  101085. static set ColorGradingTextureEnabled(value: boolean);
  101086. private static _FresnelEnabled;
  101087. /**
  101088. * Are fresnels enabled in the application.
  101089. */
  101090. static get FresnelEnabled(): boolean;
  101091. static set FresnelEnabled(value: boolean);
  101092. private static _ClearCoatTextureEnabled;
  101093. /**
  101094. * Are clear coat textures enabled in the application.
  101095. */
  101096. static get ClearCoatTextureEnabled(): boolean;
  101097. static set ClearCoatTextureEnabled(value: boolean);
  101098. private static _ClearCoatBumpTextureEnabled;
  101099. /**
  101100. * Are clear coat bump textures enabled in the application.
  101101. */
  101102. static get ClearCoatBumpTextureEnabled(): boolean;
  101103. static set ClearCoatBumpTextureEnabled(value: boolean);
  101104. private static _ClearCoatTintTextureEnabled;
  101105. /**
  101106. * Are clear coat tint textures enabled in the application.
  101107. */
  101108. static get ClearCoatTintTextureEnabled(): boolean;
  101109. static set ClearCoatTintTextureEnabled(value: boolean);
  101110. private static _SheenTextureEnabled;
  101111. /**
  101112. * Are sheen textures enabled in the application.
  101113. */
  101114. static get SheenTextureEnabled(): boolean;
  101115. static set SheenTextureEnabled(value: boolean);
  101116. private static _AnisotropicTextureEnabled;
  101117. /**
  101118. * Are anisotropic textures enabled in the application.
  101119. */
  101120. static get AnisotropicTextureEnabled(): boolean;
  101121. static set AnisotropicTextureEnabled(value: boolean);
  101122. private static _ThicknessTextureEnabled;
  101123. /**
  101124. * Are thickness textures enabled in the application.
  101125. */
  101126. static get ThicknessTextureEnabled(): boolean;
  101127. static set ThicknessTextureEnabled(value: boolean);
  101128. }
  101129. }
  101130. declare module BABYLON {
  101131. /** @hidden */
  101132. export var defaultFragmentDeclaration: {
  101133. name: string;
  101134. shader: string;
  101135. };
  101136. }
  101137. declare module BABYLON {
  101138. /** @hidden */
  101139. export var defaultUboDeclaration: {
  101140. name: string;
  101141. shader: string;
  101142. };
  101143. }
  101144. declare module BABYLON {
  101145. /** @hidden */
  101146. export var lightFragmentDeclaration: {
  101147. name: string;
  101148. shader: string;
  101149. };
  101150. }
  101151. declare module BABYLON {
  101152. /** @hidden */
  101153. export var lightUboDeclaration: {
  101154. name: string;
  101155. shader: string;
  101156. };
  101157. }
  101158. declare module BABYLON {
  101159. /** @hidden */
  101160. export var lightsFragmentFunctions: {
  101161. name: string;
  101162. shader: string;
  101163. };
  101164. }
  101165. declare module BABYLON {
  101166. /** @hidden */
  101167. export var shadowsFragmentFunctions: {
  101168. name: string;
  101169. shader: string;
  101170. };
  101171. }
  101172. declare module BABYLON {
  101173. /** @hidden */
  101174. export var fresnelFunction: {
  101175. name: string;
  101176. shader: string;
  101177. };
  101178. }
  101179. declare module BABYLON {
  101180. /** @hidden */
  101181. export var reflectionFunction: {
  101182. name: string;
  101183. shader: string;
  101184. };
  101185. }
  101186. declare module BABYLON {
  101187. /** @hidden */
  101188. export var bumpFragmentFunctions: {
  101189. name: string;
  101190. shader: string;
  101191. };
  101192. }
  101193. declare module BABYLON {
  101194. /** @hidden */
  101195. export var logDepthDeclaration: {
  101196. name: string;
  101197. shader: string;
  101198. };
  101199. }
  101200. declare module BABYLON {
  101201. /** @hidden */
  101202. export var bumpFragment: {
  101203. name: string;
  101204. shader: string;
  101205. };
  101206. }
  101207. declare module BABYLON {
  101208. /** @hidden */
  101209. export var depthPrePass: {
  101210. name: string;
  101211. shader: string;
  101212. };
  101213. }
  101214. declare module BABYLON {
  101215. /** @hidden */
  101216. export var lightFragment: {
  101217. name: string;
  101218. shader: string;
  101219. };
  101220. }
  101221. declare module BABYLON {
  101222. /** @hidden */
  101223. export var logDepthFragment: {
  101224. name: string;
  101225. shader: string;
  101226. };
  101227. }
  101228. declare module BABYLON {
  101229. /** @hidden */
  101230. export var defaultPixelShader: {
  101231. name: string;
  101232. shader: string;
  101233. };
  101234. }
  101235. declare module BABYLON {
  101236. /** @hidden */
  101237. export var defaultVertexDeclaration: {
  101238. name: string;
  101239. shader: string;
  101240. };
  101241. }
  101242. declare module BABYLON {
  101243. /** @hidden */
  101244. export var bumpVertexDeclaration: {
  101245. name: string;
  101246. shader: string;
  101247. };
  101248. }
  101249. declare module BABYLON {
  101250. /** @hidden */
  101251. export var bumpVertex: {
  101252. name: string;
  101253. shader: string;
  101254. };
  101255. }
  101256. declare module BABYLON {
  101257. /** @hidden */
  101258. export var fogVertex: {
  101259. name: string;
  101260. shader: string;
  101261. };
  101262. }
  101263. declare module BABYLON {
  101264. /** @hidden */
  101265. export var shadowsVertex: {
  101266. name: string;
  101267. shader: string;
  101268. };
  101269. }
  101270. declare module BABYLON {
  101271. /** @hidden */
  101272. export var pointCloudVertex: {
  101273. name: string;
  101274. shader: string;
  101275. };
  101276. }
  101277. declare module BABYLON {
  101278. /** @hidden */
  101279. export var logDepthVertex: {
  101280. name: string;
  101281. shader: string;
  101282. };
  101283. }
  101284. declare module BABYLON {
  101285. /** @hidden */
  101286. export var defaultVertexShader: {
  101287. name: string;
  101288. shader: string;
  101289. };
  101290. }
  101291. declare module BABYLON {
  101292. /** @hidden */
  101293. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  101294. MAINUV1: boolean;
  101295. MAINUV2: boolean;
  101296. DIFFUSE: boolean;
  101297. DIFFUSEDIRECTUV: number;
  101298. AMBIENT: boolean;
  101299. AMBIENTDIRECTUV: number;
  101300. OPACITY: boolean;
  101301. OPACITYDIRECTUV: number;
  101302. OPACITYRGB: boolean;
  101303. REFLECTION: boolean;
  101304. EMISSIVE: boolean;
  101305. EMISSIVEDIRECTUV: number;
  101306. SPECULAR: boolean;
  101307. SPECULARDIRECTUV: number;
  101308. BUMP: boolean;
  101309. BUMPDIRECTUV: number;
  101310. PARALLAX: boolean;
  101311. PARALLAXOCCLUSION: boolean;
  101312. SPECULAROVERALPHA: boolean;
  101313. CLIPPLANE: boolean;
  101314. CLIPPLANE2: boolean;
  101315. CLIPPLANE3: boolean;
  101316. CLIPPLANE4: boolean;
  101317. CLIPPLANE5: boolean;
  101318. CLIPPLANE6: boolean;
  101319. ALPHATEST: boolean;
  101320. DEPTHPREPASS: boolean;
  101321. ALPHAFROMDIFFUSE: boolean;
  101322. POINTSIZE: boolean;
  101323. FOG: boolean;
  101324. SPECULARTERM: boolean;
  101325. DIFFUSEFRESNEL: boolean;
  101326. OPACITYFRESNEL: boolean;
  101327. REFLECTIONFRESNEL: boolean;
  101328. REFRACTIONFRESNEL: boolean;
  101329. EMISSIVEFRESNEL: boolean;
  101330. FRESNEL: boolean;
  101331. NORMAL: boolean;
  101332. UV1: boolean;
  101333. UV2: boolean;
  101334. VERTEXCOLOR: boolean;
  101335. VERTEXALPHA: boolean;
  101336. NUM_BONE_INFLUENCERS: number;
  101337. BonesPerMesh: number;
  101338. BONETEXTURE: boolean;
  101339. INSTANCES: boolean;
  101340. GLOSSINESS: boolean;
  101341. ROUGHNESS: boolean;
  101342. EMISSIVEASILLUMINATION: boolean;
  101343. LINKEMISSIVEWITHDIFFUSE: boolean;
  101344. REFLECTIONFRESNELFROMSPECULAR: boolean;
  101345. LIGHTMAP: boolean;
  101346. LIGHTMAPDIRECTUV: number;
  101347. OBJECTSPACE_NORMALMAP: boolean;
  101348. USELIGHTMAPASSHADOWMAP: boolean;
  101349. REFLECTIONMAP_3D: boolean;
  101350. REFLECTIONMAP_SPHERICAL: boolean;
  101351. REFLECTIONMAP_PLANAR: boolean;
  101352. REFLECTIONMAP_CUBIC: boolean;
  101353. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  101354. REFLECTIONMAP_PROJECTION: boolean;
  101355. REFLECTIONMAP_SKYBOX: boolean;
  101356. REFLECTIONMAP_EXPLICIT: boolean;
  101357. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  101358. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  101359. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  101360. INVERTCUBICMAP: boolean;
  101361. LOGARITHMICDEPTH: boolean;
  101362. REFRACTION: boolean;
  101363. REFRACTIONMAP_3D: boolean;
  101364. REFLECTIONOVERALPHA: boolean;
  101365. TWOSIDEDLIGHTING: boolean;
  101366. SHADOWFLOAT: boolean;
  101367. MORPHTARGETS: boolean;
  101368. MORPHTARGETS_NORMAL: boolean;
  101369. MORPHTARGETS_TANGENT: boolean;
  101370. MORPHTARGETS_UV: boolean;
  101371. NUM_MORPH_INFLUENCERS: number;
  101372. NONUNIFORMSCALING: boolean;
  101373. PREMULTIPLYALPHA: boolean;
  101374. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  101375. ALPHABLEND: boolean;
  101376. IMAGEPROCESSING: boolean;
  101377. VIGNETTE: boolean;
  101378. VIGNETTEBLENDMODEMULTIPLY: boolean;
  101379. VIGNETTEBLENDMODEOPAQUE: boolean;
  101380. TONEMAPPING: boolean;
  101381. TONEMAPPING_ACES: boolean;
  101382. CONTRAST: boolean;
  101383. COLORCURVES: boolean;
  101384. COLORGRADING: boolean;
  101385. COLORGRADING3D: boolean;
  101386. SAMPLER3DGREENDEPTH: boolean;
  101387. SAMPLER3DBGRMAP: boolean;
  101388. IMAGEPROCESSINGPOSTPROCESS: boolean;
  101389. MULTIVIEW: boolean;
  101390. /**
  101391. * If the reflection texture on this material is in linear color space
  101392. * @hidden
  101393. */
  101394. IS_REFLECTION_LINEAR: boolean;
  101395. /**
  101396. * If the refraction texture on this material is in linear color space
  101397. * @hidden
  101398. */
  101399. IS_REFRACTION_LINEAR: boolean;
  101400. EXPOSURE: boolean;
  101401. constructor();
  101402. setReflectionMode(modeToEnable: string): void;
  101403. }
  101404. /**
  101405. * This is the default material used in Babylon. It is the best trade off between quality
  101406. * and performances.
  101407. * @see http://doc.babylonjs.com/babylon101/materials
  101408. */
  101409. export class StandardMaterial extends PushMaterial {
  101410. private _diffuseTexture;
  101411. /**
  101412. * The basic texture of the material as viewed under a light.
  101413. */
  101414. diffuseTexture: Nullable<BaseTexture>;
  101415. private _ambientTexture;
  101416. /**
  101417. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  101418. */
  101419. ambientTexture: Nullable<BaseTexture>;
  101420. private _opacityTexture;
  101421. /**
  101422. * Define the transparency of the material from a texture.
  101423. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  101424. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  101425. */
  101426. opacityTexture: Nullable<BaseTexture>;
  101427. private _reflectionTexture;
  101428. /**
  101429. * Define the texture used to display the reflection.
  101430. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101431. */
  101432. reflectionTexture: Nullable<BaseTexture>;
  101433. private _emissiveTexture;
  101434. /**
  101435. * Define texture of the material as if self lit.
  101436. * This will be mixed in the final result even in the absence of light.
  101437. */
  101438. emissiveTexture: Nullable<BaseTexture>;
  101439. private _specularTexture;
  101440. /**
  101441. * Define how the color and intensity of the highlight given by the light in the material.
  101442. */
  101443. specularTexture: Nullable<BaseTexture>;
  101444. private _bumpTexture;
  101445. /**
  101446. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  101447. * 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.
  101448. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  101449. */
  101450. bumpTexture: Nullable<BaseTexture>;
  101451. private _lightmapTexture;
  101452. /**
  101453. * Complex lighting can be computationally expensive to compute at runtime.
  101454. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  101455. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  101456. */
  101457. lightmapTexture: Nullable<BaseTexture>;
  101458. private _refractionTexture;
  101459. /**
  101460. * Define the texture used to display the refraction.
  101461. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101462. */
  101463. refractionTexture: Nullable<BaseTexture>;
  101464. /**
  101465. * The color of the material lit by the environmental background lighting.
  101466. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  101467. */
  101468. ambientColor: Color3;
  101469. /**
  101470. * The basic color of the material as viewed under a light.
  101471. */
  101472. diffuseColor: Color3;
  101473. /**
  101474. * Define how the color and intensity of the highlight given by the light in the material.
  101475. */
  101476. specularColor: Color3;
  101477. /**
  101478. * Define the color of the material as if self lit.
  101479. * This will be mixed in the final result even in the absence of light.
  101480. */
  101481. emissiveColor: Color3;
  101482. /**
  101483. * Defines how sharp are the highlights in the material.
  101484. * The bigger the value the sharper giving a more glossy feeling to the result.
  101485. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  101486. */
  101487. specularPower: number;
  101488. private _useAlphaFromDiffuseTexture;
  101489. /**
  101490. * Does the transparency come from the diffuse texture alpha channel.
  101491. */
  101492. useAlphaFromDiffuseTexture: boolean;
  101493. private _useEmissiveAsIllumination;
  101494. /**
  101495. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  101496. */
  101497. useEmissiveAsIllumination: boolean;
  101498. private _linkEmissiveWithDiffuse;
  101499. /**
  101500. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  101501. * the emissive level when the final color is close to one.
  101502. */
  101503. linkEmissiveWithDiffuse: boolean;
  101504. private _useSpecularOverAlpha;
  101505. /**
  101506. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  101507. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101508. */
  101509. useSpecularOverAlpha: boolean;
  101510. private _useReflectionOverAlpha;
  101511. /**
  101512. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101513. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101514. */
  101515. useReflectionOverAlpha: boolean;
  101516. private _disableLighting;
  101517. /**
  101518. * Does lights from the scene impacts this material.
  101519. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  101520. */
  101521. disableLighting: boolean;
  101522. private _useObjectSpaceNormalMap;
  101523. /**
  101524. * Allows using an object space normal map (instead of tangent space).
  101525. */
  101526. useObjectSpaceNormalMap: boolean;
  101527. private _useParallax;
  101528. /**
  101529. * Is parallax enabled or not.
  101530. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  101531. */
  101532. useParallax: boolean;
  101533. private _useParallaxOcclusion;
  101534. /**
  101535. * Is parallax occlusion enabled or not.
  101536. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  101537. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  101538. */
  101539. useParallaxOcclusion: boolean;
  101540. /**
  101541. * 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.
  101542. */
  101543. parallaxScaleBias: number;
  101544. private _roughness;
  101545. /**
  101546. * Helps to define how blurry the reflections should appears in the material.
  101547. */
  101548. roughness: number;
  101549. /**
  101550. * In case of refraction, define the value of the index of refraction.
  101551. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101552. */
  101553. indexOfRefraction: number;
  101554. /**
  101555. * Invert the refraction texture alongside the y axis.
  101556. * It can be useful with procedural textures or probe for instance.
  101557. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101558. */
  101559. invertRefractionY: boolean;
  101560. /**
  101561. * Defines the alpha limits in alpha test mode.
  101562. */
  101563. alphaCutOff: number;
  101564. private _useLightmapAsShadowmap;
  101565. /**
  101566. * In case of light mapping, define whether the map contains light or shadow informations.
  101567. */
  101568. useLightmapAsShadowmap: boolean;
  101569. private _diffuseFresnelParameters;
  101570. /**
  101571. * Define the diffuse fresnel parameters of the material.
  101572. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101573. */
  101574. diffuseFresnelParameters: FresnelParameters;
  101575. private _opacityFresnelParameters;
  101576. /**
  101577. * Define the opacity fresnel parameters of the material.
  101578. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101579. */
  101580. opacityFresnelParameters: FresnelParameters;
  101581. private _reflectionFresnelParameters;
  101582. /**
  101583. * Define the reflection fresnel parameters of the material.
  101584. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101585. */
  101586. reflectionFresnelParameters: FresnelParameters;
  101587. private _refractionFresnelParameters;
  101588. /**
  101589. * Define the refraction fresnel parameters of the material.
  101590. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101591. */
  101592. refractionFresnelParameters: FresnelParameters;
  101593. private _emissiveFresnelParameters;
  101594. /**
  101595. * Define the emissive fresnel parameters of the material.
  101596. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101597. */
  101598. emissiveFresnelParameters: FresnelParameters;
  101599. private _useReflectionFresnelFromSpecular;
  101600. /**
  101601. * If true automatically deducts the fresnels values from the material specularity.
  101602. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101603. */
  101604. useReflectionFresnelFromSpecular: boolean;
  101605. private _useGlossinessFromSpecularMapAlpha;
  101606. /**
  101607. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  101608. */
  101609. useGlossinessFromSpecularMapAlpha: boolean;
  101610. private _maxSimultaneousLights;
  101611. /**
  101612. * Defines the maximum number of lights that can be used in the material
  101613. */
  101614. maxSimultaneousLights: number;
  101615. private _invertNormalMapX;
  101616. /**
  101617. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  101618. */
  101619. invertNormalMapX: boolean;
  101620. private _invertNormalMapY;
  101621. /**
  101622. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  101623. */
  101624. invertNormalMapY: boolean;
  101625. private _twoSidedLighting;
  101626. /**
  101627. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101628. */
  101629. twoSidedLighting: boolean;
  101630. /**
  101631. * Default configuration related to image processing available in the standard Material.
  101632. */
  101633. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101634. /**
  101635. * Gets the image processing configuration used either in this material.
  101636. */
  101637. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  101638. /**
  101639. * Sets the Default image processing configuration used either in the this material.
  101640. *
  101641. * If sets to null, the scene one is in use.
  101642. */
  101643. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  101644. /**
  101645. * Keep track of the image processing observer to allow dispose and replace.
  101646. */
  101647. private _imageProcessingObserver;
  101648. /**
  101649. * Attaches a new image processing configuration to the Standard Material.
  101650. * @param configuration
  101651. */
  101652. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101653. /**
  101654. * Gets wether the color curves effect is enabled.
  101655. */
  101656. get cameraColorCurvesEnabled(): boolean;
  101657. /**
  101658. * Sets wether the color curves effect is enabled.
  101659. */
  101660. set cameraColorCurvesEnabled(value: boolean);
  101661. /**
  101662. * Gets wether the color grading effect is enabled.
  101663. */
  101664. get cameraColorGradingEnabled(): boolean;
  101665. /**
  101666. * Gets wether the color grading effect is enabled.
  101667. */
  101668. set cameraColorGradingEnabled(value: boolean);
  101669. /**
  101670. * Gets wether tonemapping is enabled or not.
  101671. */
  101672. get cameraToneMappingEnabled(): boolean;
  101673. /**
  101674. * Sets wether tonemapping is enabled or not
  101675. */
  101676. set cameraToneMappingEnabled(value: boolean);
  101677. /**
  101678. * The camera exposure used on this material.
  101679. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101680. * This corresponds to a photographic exposure.
  101681. */
  101682. get cameraExposure(): number;
  101683. /**
  101684. * The camera exposure used on this material.
  101685. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101686. * This corresponds to a photographic exposure.
  101687. */
  101688. set cameraExposure(value: number);
  101689. /**
  101690. * Gets The camera contrast used on this material.
  101691. */
  101692. get cameraContrast(): number;
  101693. /**
  101694. * Sets The camera contrast used on this material.
  101695. */
  101696. set cameraContrast(value: number);
  101697. /**
  101698. * Gets the Color Grading 2D Lookup Texture.
  101699. */
  101700. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  101701. /**
  101702. * Sets the Color Grading 2D Lookup Texture.
  101703. */
  101704. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  101705. /**
  101706. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101707. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101708. * 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;
  101709. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101710. */
  101711. get cameraColorCurves(): Nullable<ColorCurves>;
  101712. /**
  101713. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101714. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101715. * 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;
  101716. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101717. */
  101718. set cameraColorCurves(value: Nullable<ColorCurves>);
  101719. protected _renderTargets: SmartArray<RenderTargetTexture>;
  101720. protected _worldViewProjectionMatrix: Matrix;
  101721. protected _globalAmbientColor: Color3;
  101722. protected _useLogarithmicDepth: boolean;
  101723. protected _rebuildInParallel: boolean;
  101724. /**
  101725. * Instantiates a new standard material.
  101726. * This is the default material used in Babylon. It is the best trade off between quality
  101727. * and performances.
  101728. * @see http://doc.babylonjs.com/babylon101/materials
  101729. * @param name Define the name of the material in the scene
  101730. * @param scene Define the scene the material belong to
  101731. */
  101732. constructor(name: string, scene: Scene);
  101733. /**
  101734. * Gets a boolean indicating that current material needs to register RTT
  101735. */
  101736. get hasRenderTargetTextures(): boolean;
  101737. /**
  101738. * Gets the current class name of the material e.g. "StandardMaterial"
  101739. * Mainly use in serialization.
  101740. * @returns the class name
  101741. */
  101742. getClassName(): string;
  101743. /**
  101744. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  101745. * You can try switching to logarithmic depth.
  101746. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  101747. */
  101748. get useLogarithmicDepth(): boolean;
  101749. set useLogarithmicDepth(value: boolean);
  101750. /**
  101751. * Specifies if the material will require alpha blending
  101752. * @returns a boolean specifying if alpha blending is needed
  101753. */
  101754. needAlphaBlending(): boolean;
  101755. /**
  101756. * Specifies if this material should be rendered in alpha test mode
  101757. * @returns a boolean specifying if an alpha test is needed.
  101758. */
  101759. needAlphaTesting(): boolean;
  101760. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  101761. /**
  101762. * Get the texture used for alpha test purpose.
  101763. * @returns the diffuse texture in case of the standard material.
  101764. */
  101765. getAlphaTestTexture(): Nullable<BaseTexture>;
  101766. /**
  101767. * Get if the submesh is ready to be used and all its information available.
  101768. * Child classes can use it to update shaders
  101769. * @param mesh defines the mesh to check
  101770. * @param subMesh defines which submesh to check
  101771. * @param useInstances specifies that instances should be used
  101772. * @returns a boolean indicating that the submesh is ready or not
  101773. */
  101774. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101775. /**
  101776. * Builds the material UBO layouts.
  101777. * Used internally during the effect preparation.
  101778. */
  101779. buildUniformLayout(): void;
  101780. /**
  101781. * Unbinds the material from the mesh
  101782. */
  101783. unbind(): void;
  101784. /**
  101785. * Binds the submesh to this material by preparing the effect and shader to draw
  101786. * @param world defines the world transformation matrix
  101787. * @param mesh defines the mesh containing the submesh
  101788. * @param subMesh defines the submesh to bind the material to
  101789. */
  101790. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101791. /**
  101792. * Get the list of animatables in the material.
  101793. * @returns the list of animatables object used in the material
  101794. */
  101795. getAnimatables(): IAnimatable[];
  101796. /**
  101797. * Gets the active textures from the material
  101798. * @returns an array of textures
  101799. */
  101800. getActiveTextures(): BaseTexture[];
  101801. /**
  101802. * Specifies if the material uses a texture
  101803. * @param texture defines the texture to check against the material
  101804. * @returns a boolean specifying if the material uses the texture
  101805. */
  101806. hasTexture(texture: BaseTexture): boolean;
  101807. /**
  101808. * Disposes the material
  101809. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  101810. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  101811. */
  101812. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  101813. /**
  101814. * Makes a duplicate of the material, and gives it a new name
  101815. * @param name defines the new name for the duplicated material
  101816. * @returns the cloned material
  101817. */
  101818. clone(name: string): StandardMaterial;
  101819. /**
  101820. * Serializes this material in a JSON representation
  101821. * @returns the serialized material object
  101822. */
  101823. serialize(): any;
  101824. /**
  101825. * Creates a standard material from parsed material data
  101826. * @param source defines the JSON representation of the material
  101827. * @param scene defines the hosting scene
  101828. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101829. * @returns a new standard material
  101830. */
  101831. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  101832. /**
  101833. * Are diffuse textures enabled in the application.
  101834. */
  101835. static get DiffuseTextureEnabled(): boolean;
  101836. static set DiffuseTextureEnabled(value: boolean);
  101837. /**
  101838. * Are ambient textures enabled in the application.
  101839. */
  101840. static get AmbientTextureEnabled(): boolean;
  101841. static set AmbientTextureEnabled(value: boolean);
  101842. /**
  101843. * Are opacity textures enabled in the application.
  101844. */
  101845. static get OpacityTextureEnabled(): boolean;
  101846. static set OpacityTextureEnabled(value: boolean);
  101847. /**
  101848. * Are reflection textures enabled in the application.
  101849. */
  101850. static get ReflectionTextureEnabled(): boolean;
  101851. static set ReflectionTextureEnabled(value: boolean);
  101852. /**
  101853. * Are emissive textures enabled in the application.
  101854. */
  101855. static get EmissiveTextureEnabled(): boolean;
  101856. static set EmissiveTextureEnabled(value: boolean);
  101857. /**
  101858. * Are specular textures enabled in the application.
  101859. */
  101860. static get SpecularTextureEnabled(): boolean;
  101861. static set SpecularTextureEnabled(value: boolean);
  101862. /**
  101863. * Are bump textures enabled in the application.
  101864. */
  101865. static get BumpTextureEnabled(): boolean;
  101866. static set BumpTextureEnabled(value: boolean);
  101867. /**
  101868. * Are lightmap textures enabled in the application.
  101869. */
  101870. static get LightmapTextureEnabled(): boolean;
  101871. static set LightmapTextureEnabled(value: boolean);
  101872. /**
  101873. * Are refraction textures enabled in the application.
  101874. */
  101875. static get RefractionTextureEnabled(): boolean;
  101876. static set RefractionTextureEnabled(value: boolean);
  101877. /**
  101878. * Are color grading textures enabled in the application.
  101879. */
  101880. static get ColorGradingTextureEnabled(): boolean;
  101881. static set ColorGradingTextureEnabled(value: boolean);
  101882. /**
  101883. * Are fresnels enabled in the application.
  101884. */
  101885. static get FresnelEnabled(): boolean;
  101886. static set FresnelEnabled(value: boolean);
  101887. }
  101888. }
  101889. declare module BABYLON {
  101890. /**
  101891. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  101892. *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.
  101893. * The SPS is also a particle system. It provides some methods to manage the particles.
  101894. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  101895. *
  101896. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  101897. */
  101898. export class SolidParticleSystem implements IDisposable {
  101899. /**
  101900. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  101901. * Example : var p = SPS.particles[i];
  101902. */
  101903. particles: SolidParticle[];
  101904. /**
  101905. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  101906. */
  101907. nbParticles: number;
  101908. /**
  101909. * If the particles must ever face the camera (default false). Useful for planar particles.
  101910. */
  101911. billboard: boolean;
  101912. /**
  101913. * Recompute normals when adding a shape
  101914. */
  101915. recomputeNormals: boolean;
  101916. /**
  101917. * This a counter ofr your own usage. It's not set by any SPS functions.
  101918. */
  101919. counter: number;
  101920. /**
  101921. * The SPS name. This name is also given to the underlying mesh.
  101922. */
  101923. name: string;
  101924. /**
  101925. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  101926. */
  101927. mesh: Mesh;
  101928. /**
  101929. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  101930. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  101931. */
  101932. vars: any;
  101933. /**
  101934. * This array is populated when the SPS is set as 'pickable'.
  101935. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  101936. * Each element of this array is an object `{idx: int, faceId: int}`.
  101937. * `idx` is the picked particle index in the `SPS.particles` array
  101938. * `faceId` is the picked face index counted within this particle.
  101939. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  101940. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  101941. * Use the method SPS.pickedParticle(pickingInfo) instead.
  101942. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  101943. */
  101944. pickedParticles: {
  101945. idx: number;
  101946. faceId: number;
  101947. }[];
  101948. /**
  101949. * This array is populated when the SPS is set as 'pickable'
  101950. * Each key of this array is a submesh index.
  101951. * Each element of this array is a second array defined like this :
  101952. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  101953. * Each element of this second array is an object `{idx: int, faceId: int}`.
  101954. * `idx` is the picked particle index in the `SPS.particles` array
  101955. * `faceId` is the picked face index counted within this particle.
  101956. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  101957. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  101958. */
  101959. pickedBySubMesh: {
  101960. idx: number;
  101961. faceId: number;
  101962. }[][];
  101963. /**
  101964. * This array is populated when `enableDepthSort` is set to true.
  101965. * Each element of this array is an instance of the class DepthSortedParticle.
  101966. */
  101967. depthSortedParticles: DepthSortedParticle[];
  101968. /**
  101969. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  101970. * @hidden
  101971. */
  101972. _bSphereOnly: boolean;
  101973. /**
  101974. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  101975. * @hidden
  101976. */
  101977. _bSphereRadiusFactor: number;
  101978. private _scene;
  101979. private _positions;
  101980. private _indices;
  101981. private _normals;
  101982. private _colors;
  101983. private _uvs;
  101984. private _indices32;
  101985. private _positions32;
  101986. private _normals32;
  101987. private _fixedNormal32;
  101988. private _colors32;
  101989. private _uvs32;
  101990. private _index;
  101991. private _updatable;
  101992. private _pickable;
  101993. private _isVisibilityBoxLocked;
  101994. private _alwaysVisible;
  101995. private _depthSort;
  101996. private _expandable;
  101997. private _shapeCounter;
  101998. private _copy;
  101999. private _color;
  102000. private _computeParticleColor;
  102001. private _computeParticleTexture;
  102002. private _computeParticleRotation;
  102003. private _computeParticleVertex;
  102004. private _computeBoundingBox;
  102005. private _depthSortParticles;
  102006. private _camera;
  102007. private _mustUnrotateFixedNormals;
  102008. private _particlesIntersect;
  102009. private _needs32Bits;
  102010. private _isNotBuilt;
  102011. private _lastParticleId;
  102012. private _idxOfId;
  102013. private _multimaterialEnabled;
  102014. private _useModelMaterial;
  102015. private _indicesByMaterial;
  102016. private _materialIndexes;
  102017. private _depthSortFunction;
  102018. private _materialSortFunction;
  102019. private _materials;
  102020. private _multimaterial;
  102021. private _materialIndexesById;
  102022. private _defaultMaterial;
  102023. private _autoUpdateSubMeshes;
  102024. /**
  102025. * Creates a SPS (Solid Particle System) object.
  102026. * @param name (String) is the SPS name, this will be the underlying mesh name.
  102027. * @param scene (Scene) is the scene in which the SPS is added.
  102028. * @param options defines the options of the sps e.g.
  102029. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  102030. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  102031. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  102032. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  102033. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  102034. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  102035. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  102036. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  102037. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  102038. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  102039. */
  102040. constructor(name: string, scene: Scene, options?: {
  102041. updatable?: boolean;
  102042. isPickable?: boolean;
  102043. enableDepthSort?: boolean;
  102044. particleIntersection?: boolean;
  102045. boundingSphereOnly?: boolean;
  102046. bSphereRadiusFactor?: number;
  102047. expandable?: boolean;
  102048. useModelMaterial?: boolean;
  102049. enableMultiMaterial?: boolean;
  102050. });
  102051. /**
  102052. * Builds the SPS underlying mesh. Returns a standard Mesh.
  102053. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  102054. * @returns the created mesh
  102055. */
  102056. buildMesh(): Mesh;
  102057. /**
  102058. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  102059. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  102060. * Thus the particles generated from `digest()` have their property `position` set yet.
  102061. * @param mesh ( Mesh ) is the mesh to be digested
  102062. * @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
  102063. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  102064. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  102065. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  102066. * @returns the current SPS
  102067. */
  102068. digest(mesh: Mesh, options?: {
  102069. facetNb?: number;
  102070. number?: number;
  102071. delta?: number;
  102072. storage?: [];
  102073. }): SolidParticleSystem;
  102074. /**
  102075. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  102076. * @hidden
  102077. */
  102078. private _unrotateFixedNormals;
  102079. /**
  102080. * Resets the temporary working copy particle
  102081. * @hidden
  102082. */
  102083. private _resetCopy;
  102084. /**
  102085. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  102086. * @param p the current index in the positions array to be updated
  102087. * @param ind the current index in the indices array
  102088. * @param shape a Vector3 array, the shape geometry
  102089. * @param positions the positions array to be updated
  102090. * @param meshInd the shape indices array
  102091. * @param indices the indices array to be updated
  102092. * @param meshUV the shape uv array
  102093. * @param uvs the uv array to be updated
  102094. * @param meshCol the shape color array
  102095. * @param colors the color array to be updated
  102096. * @param meshNor the shape normals array
  102097. * @param normals the normals array to be updated
  102098. * @param idx the particle index
  102099. * @param idxInShape the particle index in its shape
  102100. * @param options the addShape() method passed options
  102101. * @model the particle model
  102102. * @hidden
  102103. */
  102104. private _meshBuilder;
  102105. /**
  102106. * Returns a shape Vector3 array from positions float array
  102107. * @param positions float array
  102108. * @returns a vector3 array
  102109. * @hidden
  102110. */
  102111. private _posToShape;
  102112. /**
  102113. * Returns a shapeUV array from a float uvs (array deep copy)
  102114. * @param uvs as a float array
  102115. * @returns a shapeUV array
  102116. * @hidden
  102117. */
  102118. private _uvsToShapeUV;
  102119. /**
  102120. * Adds a new particle object in the particles array
  102121. * @param idx particle index in particles array
  102122. * @param id particle id
  102123. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  102124. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  102125. * @param model particle ModelShape object
  102126. * @param shapeId model shape identifier
  102127. * @param idxInShape index of the particle in the current model
  102128. * @param bInfo model bounding info object
  102129. * @param storage target storage array, if any
  102130. * @hidden
  102131. */
  102132. private _addParticle;
  102133. /**
  102134. * Adds some particles to the SPS from the model shape. Returns the shape id.
  102135. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  102136. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  102137. * @param nb (positive integer) the number of particles to be created from this model
  102138. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  102139. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  102140. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  102141. * @returns the number of shapes in the system
  102142. */
  102143. addShape(mesh: Mesh, nb: number, options?: {
  102144. positionFunction?: any;
  102145. vertexFunction?: any;
  102146. storage?: [];
  102147. }): number;
  102148. /**
  102149. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  102150. * @hidden
  102151. */
  102152. private _rebuildParticle;
  102153. /**
  102154. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  102155. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  102156. * @returns the SPS.
  102157. */
  102158. rebuildMesh(reset?: boolean): SolidParticleSystem;
  102159. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  102160. * Returns an array with the removed particles.
  102161. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  102162. * The SPS can't be empty so at least one particle needs to remain in place.
  102163. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  102164. * @param start index of the first particle to remove
  102165. * @param end index of the last particle to remove (included)
  102166. * @returns an array populated with the removed particles
  102167. */
  102168. removeParticles(start: number, end: number): SolidParticle[];
  102169. /**
  102170. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  102171. * @param solidParticleArray an array populated with Solid Particles objects
  102172. * @returns the SPS
  102173. */
  102174. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  102175. /**
  102176. * Creates a new particle and modifies the SPS mesh geometry :
  102177. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  102178. * - calls _addParticle() to populate the particle array
  102179. * factorized code from addShape() and insertParticlesFromArray()
  102180. * @param idx particle index in the particles array
  102181. * @param i particle index in its shape
  102182. * @param modelShape particle ModelShape object
  102183. * @param shape shape vertex array
  102184. * @param meshInd shape indices array
  102185. * @param meshUV shape uv array
  102186. * @param meshCol shape color array
  102187. * @param meshNor shape normals array
  102188. * @param bbInfo shape bounding info
  102189. * @param storage target particle storage
  102190. * @options addShape() passed options
  102191. * @hidden
  102192. */
  102193. private _insertNewParticle;
  102194. /**
  102195. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  102196. * This method calls `updateParticle()` for each particle of the SPS.
  102197. * For an animated SPS, it is usually called within the render loop.
  102198. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  102199. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  102200. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  102201. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  102202. * @returns the SPS.
  102203. */
  102204. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  102205. /**
  102206. * Disposes the SPS.
  102207. */
  102208. dispose(): void;
  102209. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  102210. * idx is the particle index in the SPS
  102211. * faceId is the picked face index counted within this particle.
  102212. * Returns null if the pickInfo can't identify a picked particle.
  102213. * @param pickingInfo (PickingInfo object)
  102214. * @returns {idx: number, faceId: number} or null
  102215. */
  102216. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  102217. idx: number;
  102218. faceId: number;
  102219. }>;
  102220. /**
  102221. * Returns a SolidParticle object from its identifier : particle.id
  102222. * @param id (integer) the particle Id
  102223. * @returns the searched particle or null if not found in the SPS.
  102224. */
  102225. getParticleById(id: number): Nullable<SolidParticle>;
  102226. /**
  102227. * Returns a new array populated with the particles having the passed shapeId.
  102228. * @param shapeId (integer) the shape identifier
  102229. * @returns a new solid particle array
  102230. */
  102231. getParticlesByShapeId(shapeId: number): SolidParticle[];
  102232. /**
  102233. * Populates the passed array "ref" with the particles having the passed shapeId.
  102234. * @param shapeId the shape identifier
  102235. * @returns the SPS
  102236. * @param ref
  102237. */
  102238. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  102239. /**
  102240. * Computes the required SubMeshes according the materials assigned to the particles.
  102241. * @returns the solid particle system.
  102242. * Does nothing if called before the SPS mesh is built.
  102243. */
  102244. computeSubMeshes(): SolidParticleSystem;
  102245. /**
  102246. * Sorts the solid particles by material when MultiMaterial is enabled.
  102247. * Updates the indices32 array.
  102248. * Updates the indicesByMaterial array.
  102249. * Updates the mesh indices array.
  102250. * @returns the SPS
  102251. * @hidden
  102252. */
  102253. private _sortParticlesByMaterial;
  102254. /**
  102255. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  102256. * @hidden
  102257. */
  102258. private _setMaterialIndexesById;
  102259. /**
  102260. * Returns an array with unique values of Materials from the passed array
  102261. * @param array the material array to be checked and filtered
  102262. * @hidden
  102263. */
  102264. private _filterUniqueMaterialId;
  102265. /**
  102266. * Sets a new Standard Material as _defaultMaterial if not already set.
  102267. * @hidden
  102268. */
  102269. private _setDefaultMaterial;
  102270. /**
  102271. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  102272. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  102273. * @returns the SPS.
  102274. */
  102275. refreshVisibleSize(): SolidParticleSystem;
  102276. /**
  102277. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  102278. * @param size the size (float) of the visibility box
  102279. * note : this doesn't lock the SPS mesh bounding box.
  102280. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  102281. */
  102282. setVisibilityBox(size: number): void;
  102283. /**
  102284. * Gets whether the SPS as always visible or not
  102285. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  102286. */
  102287. get isAlwaysVisible(): boolean;
  102288. /**
  102289. * Sets the SPS as always visible or not
  102290. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  102291. */
  102292. set isAlwaysVisible(val: boolean);
  102293. /**
  102294. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  102295. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  102296. */
  102297. set isVisibilityBoxLocked(val: boolean);
  102298. /**
  102299. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  102300. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  102301. */
  102302. get isVisibilityBoxLocked(): boolean;
  102303. /**
  102304. * Tells to `setParticles()` to compute the particle rotations or not.
  102305. * Default value : true. The SPS is faster when it's set to false.
  102306. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  102307. */
  102308. set computeParticleRotation(val: boolean);
  102309. /**
  102310. * Tells to `setParticles()` to compute the particle colors or not.
  102311. * Default value : true. The SPS is faster when it's set to false.
  102312. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  102313. */
  102314. set computeParticleColor(val: boolean);
  102315. set computeParticleTexture(val: boolean);
  102316. /**
  102317. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  102318. * Default value : false. The SPS is faster when it's set to false.
  102319. * Note : the particle custom vertex positions aren't stored values.
  102320. */
  102321. set computeParticleVertex(val: boolean);
  102322. /**
  102323. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  102324. */
  102325. set computeBoundingBox(val: boolean);
  102326. /**
  102327. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  102328. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  102329. * Default : `true`
  102330. */
  102331. set depthSortParticles(val: boolean);
  102332. /**
  102333. * Gets if `setParticles()` computes the particle rotations or not.
  102334. * Default value : true. The SPS is faster when it's set to false.
  102335. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  102336. */
  102337. get computeParticleRotation(): boolean;
  102338. /**
  102339. * Gets if `setParticles()` computes the particle colors or not.
  102340. * Default value : true. The SPS is faster when it's set to false.
  102341. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  102342. */
  102343. get computeParticleColor(): boolean;
  102344. /**
  102345. * Gets if `setParticles()` computes the particle textures or not.
  102346. * Default value : true. The SPS is faster when it's set to false.
  102347. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  102348. */
  102349. get computeParticleTexture(): boolean;
  102350. /**
  102351. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  102352. * Default value : false. The SPS is faster when it's set to false.
  102353. * Note : the particle custom vertex positions aren't stored values.
  102354. */
  102355. get computeParticleVertex(): boolean;
  102356. /**
  102357. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  102358. */
  102359. get computeBoundingBox(): boolean;
  102360. /**
  102361. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  102362. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  102363. * Default : `true`
  102364. */
  102365. get depthSortParticles(): boolean;
  102366. /**
  102367. * Gets if the SPS is created as expandable at construction time.
  102368. * Default : `false`
  102369. */
  102370. get expandable(): boolean;
  102371. /**
  102372. * Gets if the SPS supports the Multi Materials
  102373. */
  102374. get multimaterialEnabled(): boolean;
  102375. /**
  102376. * Gets if the SPS uses the model materials for its own multimaterial.
  102377. */
  102378. get useModelMaterial(): boolean;
  102379. /**
  102380. * The SPS used material array.
  102381. */
  102382. get materials(): Material[];
  102383. /**
  102384. * Sets the SPS MultiMaterial from the passed materials.
  102385. * Note : the passed array is internally copied and not used then by reference.
  102386. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  102387. */
  102388. setMultiMaterial(materials: Material[]): void;
  102389. /**
  102390. * The SPS computed multimaterial object
  102391. */
  102392. get multimaterial(): MultiMaterial;
  102393. set multimaterial(mm: MultiMaterial);
  102394. /**
  102395. * If the subMeshes must be updated on the next call to setParticles()
  102396. */
  102397. get autoUpdateSubMeshes(): boolean;
  102398. set autoUpdateSubMeshes(val: boolean);
  102399. /**
  102400. * This function does nothing. It may be overwritten to set all the particle first values.
  102401. * The SPS doesn't call this function, you may have to call it by your own.
  102402. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  102403. */
  102404. initParticles(): void;
  102405. /**
  102406. * This function does nothing. It may be overwritten to recycle a particle.
  102407. * The SPS doesn't call this function, you may have to call it by your own.
  102408. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  102409. * @param particle The particle to recycle
  102410. * @returns the recycled particle
  102411. */
  102412. recycleParticle(particle: SolidParticle): SolidParticle;
  102413. /**
  102414. * Updates a particle : this function should be overwritten by the user.
  102415. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  102416. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  102417. * @example : just set a particle position or velocity and recycle conditions
  102418. * @param particle The particle to update
  102419. * @returns the updated particle
  102420. */
  102421. updateParticle(particle: SolidParticle): SolidParticle;
  102422. /**
  102423. * Updates a vertex of a particle : it can be overwritten by the user.
  102424. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  102425. * @param particle the current particle
  102426. * @param vertex the current index of the current particle
  102427. * @param pt the index of the current vertex in the particle shape
  102428. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  102429. * @example : just set a vertex particle position
  102430. * @returns the updated vertex
  102431. */
  102432. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  102433. /**
  102434. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  102435. * This does nothing and may be overwritten by the user.
  102436. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  102437. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  102438. * @param update the boolean update value actually passed to setParticles()
  102439. */
  102440. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  102441. /**
  102442. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  102443. * This will be passed three parameters.
  102444. * This does nothing and may be overwritten by the user.
  102445. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  102446. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  102447. * @param update the boolean update value actually passed to setParticles()
  102448. */
  102449. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  102450. }
  102451. }
  102452. declare module BABYLON {
  102453. /**
  102454. * Represents one particle of a solid particle system.
  102455. */
  102456. export class SolidParticle {
  102457. /**
  102458. * particle global index
  102459. */
  102460. idx: number;
  102461. /**
  102462. * particle identifier
  102463. */
  102464. id: number;
  102465. /**
  102466. * The color of the particle
  102467. */
  102468. color: Nullable<Color4>;
  102469. /**
  102470. * The world space position of the particle.
  102471. */
  102472. position: Vector3;
  102473. /**
  102474. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  102475. */
  102476. rotation: Vector3;
  102477. /**
  102478. * The world space rotation quaternion of the particle.
  102479. */
  102480. rotationQuaternion: Nullable<Quaternion>;
  102481. /**
  102482. * The scaling of the particle.
  102483. */
  102484. scaling: Vector3;
  102485. /**
  102486. * The uvs of the particle.
  102487. */
  102488. uvs: Vector4;
  102489. /**
  102490. * The current speed of the particle.
  102491. */
  102492. velocity: Vector3;
  102493. /**
  102494. * The pivot point in the particle local space.
  102495. */
  102496. pivot: Vector3;
  102497. /**
  102498. * Must the particle be translated from its pivot point in its local space ?
  102499. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  102500. * Default : false
  102501. */
  102502. translateFromPivot: boolean;
  102503. /**
  102504. * Is the particle active or not ?
  102505. */
  102506. alive: boolean;
  102507. /**
  102508. * Is the particle visible or not ?
  102509. */
  102510. isVisible: boolean;
  102511. /**
  102512. * Index of this particle in the global "positions" array (Internal use)
  102513. * @hidden
  102514. */
  102515. _pos: number;
  102516. /**
  102517. * @hidden Index of this particle in the global "indices" array (Internal use)
  102518. */
  102519. _ind: number;
  102520. /**
  102521. * @hidden ModelShape of this particle (Internal use)
  102522. */
  102523. _model: ModelShape;
  102524. /**
  102525. * ModelShape id of this particle
  102526. */
  102527. shapeId: number;
  102528. /**
  102529. * Index of the particle in its shape id
  102530. */
  102531. idxInShape: number;
  102532. /**
  102533. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  102534. */
  102535. _modelBoundingInfo: BoundingInfo;
  102536. /**
  102537. * @hidden Particle BoundingInfo object (Internal use)
  102538. */
  102539. _boundingInfo: BoundingInfo;
  102540. /**
  102541. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  102542. */
  102543. _sps: SolidParticleSystem;
  102544. /**
  102545. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  102546. */
  102547. _stillInvisible: boolean;
  102548. /**
  102549. * @hidden Last computed particle rotation matrix
  102550. */
  102551. _rotationMatrix: number[];
  102552. /**
  102553. * Parent particle Id, if any.
  102554. * Default null.
  102555. */
  102556. parentId: Nullable<number>;
  102557. /**
  102558. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  102559. */
  102560. materialIndex: Nullable<number>;
  102561. /**
  102562. * Custom object or properties.
  102563. */
  102564. props: Nullable<any>;
  102565. /**
  102566. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  102567. * The possible values are :
  102568. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  102569. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  102570. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  102571. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  102572. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  102573. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  102574. * */
  102575. cullingStrategy: number;
  102576. /**
  102577. * @hidden Internal global position in the SPS.
  102578. */
  102579. _globalPosition: Vector3;
  102580. /**
  102581. * Creates a Solid Particle object.
  102582. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  102583. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  102584. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  102585. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  102586. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  102587. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  102588. * @param shapeId (integer) is the model shape identifier in the SPS.
  102589. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  102590. * @param sps defines the sps it is associated to
  102591. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  102592. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  102593. */
  102594. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  102595. /**
  102596. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  102597. * @param target the particle target
  102598. * @returns the current particle
  102599. */
  102600. copyToRef(target: SolidParticle): SolidParticle;
  102601. /**
  102602. * Legacy support, changed scale to scaling
  102603. */
  102604. get scale(): Vector3;
  102605. /**
  102606. * Legacy support, changed scale to scaling
  102607. */
  102608. set scale(scale: Vector3);
  102609. /**
  102610. * Legacy support, changed quaternion to rotationQuaternion
  102611. */
  102612. get quaternion(): Nullable<Quaternion>;
  102613. /**
  102614. * Legacy support, changed quaternion to rotationQuaternion
  102615. */
  102616. set quaternion(q: Nullable<Quaternion>);
  102617. /**
  102618. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  102619. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  102620. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  102621. * @returns true if it intersects
  102622. */
  102623. intersectsMesh(target: Mesh | SolidParticle): boolean;
  102624. /**
  102625. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  102626. * A particle is in the frustum if its bounding box intersects the frustum
  102627. * @param frustumPlanes defines the frustum to test
  102628. * @returns true if the particle is in the frustum planes
  102629. */
  102630. isInFrustum(frustumPlanes: Plane[]): boolean;
  102631. /**
  102632. * get the rotation matrix of the particle
  102633. * @hidden
  102634. */
  102635. getRotationMatrix(m: Matrix): void;
  102636. }
  102637. /**
  102638. * Represents the shape of the model used by one particle of a solid particle system.
  102639. * SPS internal tool, don't use it manually.
  102640. */
  102641. export class ModelShape {
  102642. /**
  102643. * The shape id
  102644. * @hidden
  102645. */
  102646. shapeID: number;
  102647. /**
  102648. * flat array of model positions (internal use)
  102649. * @hidden
  102650. */
  102651. _shape: Vector3[];
  102652. /**
  102653. * flat array of model UVs (internal use)
  102654. * @hidden
  102655. */
  102656. _shapeUV: number[];
  102657. /**
  102658. * color array of the model
  102659. * @hidden
  102660. */
  102661. _shapeColors: number[];
  102662. /**
  102663. * indices array of the model
  102664. * @hidden
  102665. */
  102666. _indices: number[];
  102667. /**
  102668. * normals array of the model
  102669. * @hidden
  102670. */
  102671. _normals: number[];
  102672. /**
  102673. * length of the shape in the model indices array (internal use)
  102674. * @hidden
  102675. */
  102676. _indicesLength: number;
  102677. /**
  102678. * Custom position function (internal use)
  102679. * @hidden
  102680. */
  102681. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  102682. /**
  102683. * Custom vertex function (internal use)
  102684. * @hidden
  102685. */
  102686. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  102687. /**
  102688. * Model material (internal use)
  102689. * @hidden
  102690. */
  102691. _material: Nullable<Material>;
  102692. /**
  102693. * 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.
  102694. * SPS internal tool, don't use it manually.
  102695. * @hidden
  102696. */
  102697. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  102698. }
  102699. /**
  102700. * Represents a Depth Sorted Particle in the solid particle system.
  102701. * @hidden
  102702. */
  102703. export class DepthSortedParticle {
  102704. /**
  102705. * Particle index
  102706. */
  102707. idx: number;
  102708. /**
  102709. * Index of the particle in the "indices" array
  102710. */
  102711. ind: number;
  102712. /**
  102713. * Length of the particle shape in the "indices" array
  102714. */
  102715. indicesLength: number;
  102716. /**
  102717. * Squared distance from the particle to the camera
  102718. */
  102719. sqDistance: number;
  102720. /**
  102721. * Material index when used with MultiMaterials
  102722. */
  102723. materialIndex: number;
  102724. /**
  102725. * Creates a new sorted particle
  102726. * @param materialIndex
  102727. */
  102728. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  102729. }
  102730. }
  102731. declare module BABYLON {
  102732. /**
  102733. * @hidden
  102734. */
  102735. export class _MeshCollisionData {
  102736. _checkCollisions: boolean;
  102737. _collisionMask: number;
  102738. _collisionGroup: number;
  102739. _surroundingMeshes: Nullable<AbstractMesh[]>;
  102740. _collider: Nullable<Collider>;
  102741. _oldPositionForCollisions: Vector3;
  102742. _diffPositionForCollisions: Vector3;
  102743. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  102744. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  102745. }
  102746. }
  102747. declare module BABYLON {
  102748. /** @hidden */
  102749. class _FacetDataStorage {
  102750. facetPositions: Vector3[];
  102751. facetNormals: Vector3[];
  102752. facetPartitioning: number[][];
  102753. facetNb: number;
  102754. partitioningSubdivisions: number;
  102755. partitioningBBoxRatio: number;
  102756. facetDataEnabled: boolean;
  102757. facetParameters: any;
  102758. bbSize: Vector3;
  102759. subDiv: {
  102760. max: number;
  102761. X: number;
  102762. Y: number;
  102763. Z: number;
  102764. };
  102765. facetDepthSort: boolean;
  102766. facetDepthSortEnabled: boolean;
  102767. depthSortedIndices: IndicesArray;
  102768. depthSortedFacets: {
  102769. ind: number;
  102770. sqDistance: number;
  102771. }[];
  102772. facetDepthSortFunction: (f1: {
  102773. ind: number;
  102774. sqDistance: number;
  102775. }, f2: {
  102776. ind: number;
  102777. sqDistance: number;
  102778. }) => number;
  102779. facetDepthSortFrom: Vector3;
  102780. facetDepthSortOrigin: Vector3;
  102781. invertedMatrix: Matrix;
  102782. }
  102783. /**
  102784. * @hidden
  102785. **/
  102786. class _InternalAbstractMeshDataInfo {
  102787. _hasVertexAlpha: boolean;
  102788. _useVertexColors: boolean;
  102789. _numBoneInfluencers: number;
  102790. _applyFog: boolean;
  102791. _receiveShadows: boolean;
  102792. _facetData: _FacetDataStorage;
  102793. _visibility: number;
  102794. _skeleton: Nullable<Skeleton>;
  102795. _layerMask: number;
  102796. _computeBonesUsingShaders: boolean;
  102797. _isActive: boolean;
  102798. _onlyForInstances: boolean;
  102799. _isActiveIntermediate: boolean;
  102800. _onlyForInstancesIntermediate: boolean;
  102801. _actAsRegularMesh: boolean;
  102802. }
  102803. /**
  102804. * Class used to store all common mesh properties
  102805. */
  102806. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  102807. /** No occlusion */
  102808. static OCCLUSION_TYPE_NONE: number;
  102809. /** Occlusion set to optimisitic */
  102810. static OCCLUSION_TYPE_OPTIMISTIC: number;
  102811. /** Occlusion set to strict */
  102812. static OCCLUSION_TYPE_STRICT: number;
  102813. /** Use an accurante occlusion algorithm */
  102814. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  102815. /** Use a conservative occlusion algorithm */
  102816. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  102817. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  102818. * Test order :
  102819. * Is the bounding sphere outside the frustum ?
  102820. * If not, are the bounding box vertices outside the frustum ?
  102821. * It not, then the cullable object is in the frustum.
  102822. */
  102823. static readonly CULLINGSTRATEGY_STANDARD: number;
  102824. /** Culling strategy : Bounding Sphere Only.
  102825. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  102826. * It's also less accurate than the standard because some not visible objects can still be selected.
  102827. * Test : is the bounding sphere outside the frustum ?
  102828. * If not, then the cullable object is in the frustum.
  102829. */
  102830. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  102831. /** Culling strategy : Optimistic Inclusion.
  102832. * This in an inclusion test first, then the standard exclusion test.
  102833. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  102834. * 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.
  102835. * Anyway, it's as accurate as the standard strategy.
  102836. * Test :
  102837. * Is the cullable object bounding sphere center in the frustum ?
  102838. * If not, apply the default culling strategy.
  102839. */
  102840. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  102841. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  102842. * This in an inclusion test first, then the bounding sphere only exclusion test.
  102843. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  102844. * 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.
  102845. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  102846. * Test :
  102847. * Is the cullable object bounding sphere center in the frustum ?
  102848. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  102849. */
  102850. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  102851. /**
  102852. * No billboard
  102853. */
  102854. static get BILLBOARDMODE_NONE(): number;
  102855. /** Billboard on X axis */
  102856. static get BILLBOARDMODE_X(): number;
  102857. /** Billboard on Y axis */
  102858. static get BILLBOARDMODE_Y(): number;
  102859. /** Billboard on Z axis */
  102860. static get BILLBOARDMODE_Z(): number;
  102861. /** Billboard on all axes */
  102862. static get BILLBOARDMODE_ALL(): number;
  102863. /** Billboard on using position instead of orientation */
  102864. static get BILLBOARDMODE_USE_POSITION(): number;
  102865. /** @hidden */
  102866. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  102867. /**
  102868. * The culling strategy to use to check whether the mesh must be rendered or not.
  102869. * This value can be changed at any time and will be used on the next render mesh selection.
  102870. * The possible values are :
  102871. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  102872. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  102873. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  102874. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  102875. * Please read each static variable documentation to get details about the culling process.
  102876. * */
  102877. cullingStrategy: number;
  102878. /**
  102879. * Gets the number of facets in the mesh
  102880. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  102881. */
  102882. get facetNb(): number;
  102883. /**
  102884. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  102885. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  102886. */
  102887. get partitioningSubdivisions(): number;
  102888. set partitioningSubdivisions(nb: number);
  102889. /**
  102890. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  102891. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  102892. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  102893. */
  102894. get partitioningBBoxRatio(): number;
  102895. set partitioningBBoxRatio(ratio: number);
  102896. /**
  102897. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  102898. * Works only for updatable meshes.
  102899. * Doesn't work with multi-materials
  102900. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  102901. */
  102902. get mustDepthSortFacets(): boolean;
  102903. set mustDepthSortFacets(sort: boolean);
  102904. /**
  102905. * The location (Vector3) where the facet depth sort must be computed from.
  102906. * By default, the active camera position.
  102907. * Used only when facet depth sort is enabled
  102908. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  102909. */
  102910. get facetDepthSortFrom(): Vector3;
  102911. set facetDepthSortFrom(location: Vector3);
  102912. /**
  102913. * gets a boolean indicating if facetData is enabled
  102914. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  102915. */
  102916. get isFacetDataEnabled(): boolean;
  102917. /** @hidden */
  102918. _updateNonUniformScalingState(value: boolean): boolean;
  102919. /**
  102920. * An event triggered when this mesh collides with another one
  102921. */
  102922. onCollideObservable: Observable<AbstractMesh>;
  102923. /** Set a function to call when this mesh collides with another one */
  102924. set onCollide(callback: () => void);
  102925. /**
  102926. * An event triggered when the collision's position changes
  102927. */
  102928. onCollisionPositionChangeObservable: Observable<Vector3>;
  102929. /** Set a function to call when the collision's position changes */
  102930. set onCollisionPositionChange(callback: () => void);
  102931. /**
  102932. * An event triggered when material is changed
  102933. */
  102934. onMaterialChangedObservable: Observable<AbstractMesh>;
  102935. /**
  102936. * Gets or sets the orientation for POV movement & rotation
  102937. */
  102938. definedFacingForward: boolean;
  102939. /** @hidden */
  102940. _occlusionQuery: Nullable<WebGLQuery>;
  102941. /** @hidden */
  102942. _renderingGroup: Nullable<RenderingGroup>;
  102943. /**
  102944. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  102945. */
  102946. get visibility(): number;
  102947. /**
  102948. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  102949. */
  102950. set visibility(value: number);
  102951. /** Gets or sets the alpha index used to sort transparent meshes
  102952. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  102953. */
  102954. alphaIndex: number;
  102955. /**
  102956. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  102957. */
  102958. isVisible: boolean;
  102959. /**
  102960. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  102961. */
  102962. isPickable: boolean;
  102963. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  102964. showSubMeshesBoundingBox: boolean;
  102965. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  102966. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102967. */
  102968. isBlocker: boolean;
  102969. /**
  102970. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  102971. */
  102972. enablePointerMoveEvents: boolean;
  102973. /**
  102974. * Specifies the rendering group id for this mesh (0 by default)
  102975. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  102976. */
  102977. renderingGroupId: number;
  102978. private _material;
  102979. /** Gets or sets current material */
  102980. get material(): Nullable<Material>;
  102981. set material(value: Nullable<Material>);
  102982. /**
  102983. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  102984. * @see http://doc.babylonjs.com/babylon101/shadows
  102985. */
  102986. get receiveShadows(): boolean;
  102987. set receiveShadows(value: boolean);
  102988. /** Defines color to use when rendering outline */
  102989. outlineColor: Color3;
  102990. /** Define width to use when rendering outline */
  102991. outlineWidth: number;
  102992. /** Defines color to use when rendering overlay */
  102993. overlayColor: Color3;
  102994. /** Defines alpha to use when rendering overlay */
  102995. overlayAlpha: number;
  102996. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  102997. get hasVertexAlpha(): boolean;
  102998. set hasVertexAlpha(value: boolean);
  102999. /** 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) */
  103000. get useVertexColors(): boolean;
  103001. set useVertexColors(value: boolean);
  103002. /**
  103003. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  103004. */
  103005. get computeBonesUsingShaders(): boolean;
  103006. set computeBonesUsingShaders(value: boolean);
  103007. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  103008. get numBoneInfluencers(): number;
  103009. set numBoneInfluencers(value: number);
  103010. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  103011. get applyFog(): boolean;
  103012. set applyFog(value: boolean);
  103013. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  103014. useOctreeForRenderingSelection: boolean;
  103015. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  103016. useOctreeForPicking: boolean;
  103017. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  103018. useOctreeForCollisions: boolean;
  103019. /**
  103020. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  103021. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  103022. */
  103023. get layerMask(): number;
  103024. set layerMask(value: number);
  103025. /**
  103026. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  103027. */
  103028. alwaysSelectAsActiveMesh: boolean;
  103029. /**
  103030. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  103031. */
  103032. doNotSyncBoundingInfo: boolean;
  103033. /**
  103034. * Gets or sets the current action manager
  103035. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  103036. */
  103037. actionManager: Nullable<AbstractActionManager>;
  103038. private _meshCollisionData;
  103039. /**
  103040. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  103041. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  103042. */
  103043. ellipsoid: Vector3;
  103044. /**
  103045. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  103046. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  103047. */
  103048. ellipsoidOffset: Vector3;
  103049. /**
  103050. * Gets or sets a collision mask used to mask collisions (default is -1).
  103051. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  103052. */
  103053. get collisionMask(): number;
  103054. set collisionMask(mask: number);
  103055. /**
  103056. * Gets or sets the current collision group mask (-1 by default).
  103057. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  103058. */
  103059. get collisionGroup(): number;
  103060. set collisionGroup(mask: number);
  103061. /**
  103062. * Gets or sets current surrounding meshes (null by default).
  103063. *
  103064. * By default collision detection is tested against every mesh in the scene.
  103065. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  103066. * meshes will be tested for the collision.
  103067. *
  103068. * Note: if set to an empty array no collision will happen when this mesh is moved.
  103069. */
  103070. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  103071. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  103072. /**
  103073. * Defines edge width used when edgesRenderer is enabled
  103074. * @see https://www.babylonjs-playground.com/#10OJSG#13
  103075. */
  103076. edgesWidth: number;
  103077. /**
  103078. * Defines edge color used when edgesRenderer is enabled
  103079. * @see https://www.babylonjs-playground.com/#10OJSG#13
  103080. */
  103081. edgesColor: Color4;
  103082. /** @hidden */
  103083. _edgesRenderer: Nullable<IEdgesRenderer>;
  103084. /** @hidden */
  103085. _masterMesh: Nullable<AbstractMesh>;
  103086. /** @hidden */
  103087. _boundingInfo: Nullable<BoundingInfo>;
  103088. /** @hidden */
  103089. _renderId: number;
  103090. /**
  103091. * Gets or sets the list of subMeshes
  103092. * @see http://doc.babylonjs.com/how_to/multi_materials
  103093. */
  103094. subMeshes: SubMesh[];
  103095. /** @hidden */
  103096. _intersectionsInProgress: AbstractMesh[];
  103097. /** @hidden */
  103098. _unIndexed: boolean;
  103099. /** @hidden */
  103100. _lightSources: Light[];
  103101. /** Gets the list of lights affecting that mesh */
  103102. get lightSources(): Light[];
  103103. /** @hidden */
  103104. get _positions(): Nullable<Vector3[]>;
  103105. /** @hidden */
  103106. _waitingData: {
  103107. lods: Nullable<any>;
  103108. actions: Nullable<any>;
  103109. freezeWorldMatrix: Nullable<boolean>;
  103110. };
  103111. /** @hidden */
  103112. _bonesTransformMatrices: Nullable<Float32Array>;
  103113. /** @hidden */
  103114. _transformMatrixTexture: Nullable<RawTexture>;
  103115. /**
  103116. * Gets or sets a skeleton to apply skining transformations
  103117. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  103118. */
  103119. set skeleton(value: Nullable<Skeleton>);
  103120. get skeleton(): Nullable<Skeleton>;
  103121. /**
  103122. * An event triggered when the mesh is rebuilt.
  103123. */
  103124. onRebuildObservable: Observable<AbstractMesh>;
  103125. /**
  103126. * Creates a new AbstractMesh
  103127. * @param name defines the name of the mesh
  103128. * @param scene defines the hosting scene
  103129. */
  103130. constructor(name: string, scene?: Nullable<Scene>);
  103131. /**
  103132. * Returns the string "AbstractMesh"
  103133. * @returns "AbstractMesh"
  103134. */
  103135. getClassName(): string;
  103136. /**
  103137. * Gets a string representation of the current mesh
  103138. * @param fullDetails defines a boolean indicating if full details must be included
  103139. * @returns a string representation of the current mesh
  103140. */
  103141. toString(fullDetails?: boolean): string;
  103142. /**
  103143. * @hidden
  103144. */
  103145. protected _getEffectiveParent(): Nullable<Node>;
  103146. /** @hidden */
  103147. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  103148. /** @hidden */
  103149. _rebuild(): void;
  103150. /** @hidden */
  103151. _resyncLightSources(): void;
  103152. /** @hidden */
  103153. _resyncLightSource(light: Light): void;
  103154. /** @hidden */
  103155. _unBindEffect(): void;
  103156. /** @hidden */
  103157. _removeLightSource(light: Light, dispose: boolean): void;
  103158. private _markSubMeshesAsDirty;
  103159. /** @hidden */
  103160. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  103161. /** @hidden */
  103162. _markSubMeshesAsAttributesDirty(): void;
  103163. /** @hidden */
  103164. _markSubMeshesAsMiscDirty(): void;
  103165. /**
  103166. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  103167. */
  103168. get scaling(): Vector3;
  103169. set scaling(newScaling: Vector3);
  103170. /**
  103171. * Returns true if the mesh is blocked. Implemented by child classes
  103172. */
  103173. get isBlocked(): boolean;
  103174. /**
  103175. * Returns the mesh itself by default. Implemented by child classes
  103176. * @param camera defines the camera to use to pick the right LOD level
  103177. * @returns the currentAbstractMesh
  103178. */
  103179. getLOD(camera: Camera): Nullable<AbstractMesh>;
  103180. /**
  103181. * Returns 0 by default. Implemented by child classes
  103182. * @returns an integer
  103183. */
  103184. getTotalVertices(): number;
  103185. /**
  103186. * Returns a positive integer : the total number of indices in this mesh geometry.
  103187. * @returns the numner of indices or zero if the mesh has no geometry.
  103188. */
  103189. getTotalIndices(): number;
  103190. /**
  103191. * Returns null by default. Implemented by child classes
  103192. * @returns null
  103193. */
  103194. getIndices(): Nullable<IndicesArray>;
  103195. /**
  103196. * Returns the array of the requested vertex data kind. Implemented by child classes
  103197. * @param kind defines the vertex data kind to use
  103198. * @returns null
  103199. */
  103200. getVerticesData(kind: string): Nullable<FloatArray>;
  103201. /**
  103202. * Sets the vertex data of the mesh geometry for the requested `kind`.
  103203. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  103204. * Note that a new underlying VertexBuffer object is created each call.
  103205. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  103206. * @param kind defines vertex data kind:
  103207. * * VertexBuffer.PositionKind
  103208. * * VertexBuffer.UVKind
  103209. * * VertexBuffer.UV2Kind
  103210. * * VertexBuffer.UV3Kind
  103211. * * VertexBuffer.UV4Kind
  103212. * * VertexBuffer.UV5Kind
  103213. * * VertexBuffer.UV6Kind
  103214. * * VertexBuffer.ColorKind
  103215. * * VertexBuffer.MatricesIndicesKind
  103216. * * VertexBuffer.MatricesIndicesExtraKind
  103217. * * VertexBuffer.MatricesWeightsKind
  103218. * * VertexBuffer.MatricesWeightsExtraKind
  103219. * @param data defines the data source
  103220. * @param updatable defines if the data must be flagged as updatable (or static)
  103221. * @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
  103222. * @returns the current mesh
  103223. */
  103224. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  103225. /**
  103226. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  103227. * If the mesh has no geometry, it is simply returned as it is.
  103228. * @param kind defines vertex data kind:
  103229. * * VertexBuffer.PositionKind
  103230. * * VertexBuffer.UVKind
  103231. * * VertexBuffer.UV2Kind
  103232. * * VertexBuffer.UV3Kind
  103233. * * VertexBuffer.UV4Kind
  103234. * * VertexBuffer.UV5Kind
  103235. * * VertexBuffer.UV6Kind
  103236. * * VertexBuffer.ColorKind
  103237. * * VertexBuffer.MatricesIndicesKind
  103238. * * VertexBuffer.MatricesIndicesExtraKind
  103239. * * VertexBuffer.MatricesWeightsKind
  103240. * * VertexBuffer.MatricesWeightsExtraKind
  103241. * @param data defines the data source
  103242. * @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
  103243. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  103244. * @returns the current mesh
  103245. */
  103246. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  103247. /**
  103248. * Sets the mesh indices,
  103249. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  103250. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  103251. * @param totalVertices Defines the total number of vertices
  103252. * @returns the current mesh
  103253. */
  103254. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  103255. /**
  103256. * Gets a boolean indicating if specific vertex data is present
  103257. * @param kind defines the vertex data kind to use
  103258. * @returns true is data kind is present
  103259. */
  103260. isVerticesDataPresent(kind: string): boolean;
  103261. /**
  103262. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  103263. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  103264. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  103265. * @returns a BoundingInfo
  103266. */
  103267. getBoundingInfo(): BoundingInfo;
  103268. /**
  103269. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  103270. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  103271. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  103272. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  103273. * @returns the current mesh
  103274. */
  103275. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  103276. /**
  103277. * Overwrite the current bounding info
  103278. * @param boundingInfo defines the new bounding info
  103279. * @returns the current mesh
  103280. */
  103281. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  103282. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  103283. get useBones(): boolean;
  103284. /** @hidden */
  103285. _preActivate(): void;
  103286. /** @hidden */
  103287. _preActivateForIntermediateRendering(renderId: number): void;
  103288. /** @hidden */
  103289. _activate(renderId: number, intermediateRendering: boolean): boolean;
  103290. /** @hidden */
  103291. _postActivate(): void;
  103292. /** @hidden */
  103293. _freeze(): void;
  103294. /** @hidden */
  103295. _unFreeze(): void;
  103296. /**
  103297. * Gets the current world matrix
  103298. * @returns a Matrix
  103299. */
  103300. getWorldMatrix(): Matrix;
  103301. /** @hidden */
  103302. _getWorldMatrixDeterminant(): number;
  103303. /**
  103304. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  103305. */
  103306. get isAnInstance(): boolean;
  103307. /**
  103308. * Gets a boolean indicating if this mesh has instances
  103309. */
  103310. get hasInstances(): boolean;
  103311. /**
  103312. * Perform relative position change from the point of view of behind the front of the mesh.
  103313. * This is performed taking into account the meshes current rotation, so you do not have to care.
  103314. * Supports definition of mesh facing forward or backward
  103315. * @param amountRight defines the distance on the right axis
  103316. * @param amountUp defines the distance on the up axis
  103317. * @param amountForward defines the distance on the forward axis
  103318. * @returns the current mesh
  103319. */
  103320. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  103321. /**
  103322. * Calculate relative position change from the point of view of behind the front of the mesh.
  103323. * This is performed taking into account the meshes current rotation, so you do not have to care.
  103324. * Supports definition of mesh facing forward or backward
  103325. * @param amountRight defines the distance on the right axis
  103326. * @param amountUp defines the distance on the up axis
  103327. * @param amountForward defines the distance on the forward axis
  103328. * @returns the new displacement vector
  103329. */
  103330. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  103331. /**
  103332. * Perform relative rotation change from the point of view of behind the front of the mesh.
  103333. * Supports definition of mesh facing forward or backward
  103334. * @param flipBack defines the flip
  103335. * @param twirlClockwise defines the twirl
  103336. * @param tiltRight defines the tilt
  103337. * @returns the current mesh
  103338. */
  103339. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  103340. /**
  103341. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  103342. * Supports definition of mesh facing forward or backward.
  103343. * @param flipBack defines the flip
  103344. * @param twirlClockwise defines the twirl
  103345. * @param tiltRight defines the tilt
  103346. * @returns the new rotation vector
  103347. */
  103348. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  103349. /**
  103350. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  103351. * This means the mesh underlying bounding box and sphere are recomputed.
  103352. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  103353. * @returns the current mesh
  103354. */
  103355. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  103356. /** @hidden */
  103357. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  103358. /** @hidden */
  103359. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  103360. /** @hidden */
  103361. _updateBoundingInfo(): AbstractMesh;
  103362. /** @hidden */
  103363. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  103364. /** @hidden */
  103365. protected _afterComputeWorldMatrix(): void;
  103366. /** @hidden */
  103367. get _effectiveMesh(): AbstractMesh;
  103368. /**
  103369. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  103370. * A mesh is in the frustum if its bounding box intersects the frustum
  103371. * @param frustumPlanes defines the frustum to test
  103372. * @returns true if the mesh is in the frustum planes
  103373. */
  103374. isInFrustum(frustumPlanes: Plane[]): boolean;
  103375. /**
  103376. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  103377. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  103378. * @param frustumPlanes defines the frustum to test
  103379. * @returns true if the mesh is completely in the frustum planes
  103380. */
  103381. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  103382. /**
  103383. * True if the mesh intersects another mesh or a SolidParticle object
  103384. * @param mesh defines a target mesh or SolidParticle to test
  103385. * @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)
  103386. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  103387. * @returns true if there is an intersection
  103388. */
  103389. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  103390. /**
  103391. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  103392. * @param point defines the point to test
  103393. * @returns true if there is an intersection
  103394. */
  103395. intersectsPoint(point: Vector3): boolean;
  103396. /**
  103397. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  103398. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  103399. */
  103400. get checkCollisions(): boolean;
  103401. set checkCollisions(collisionEnabled: boolean);
  103402. /**
  103403. * Gets Collider object used to compute collisions (not physics)
  103404. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  103405. */
  103406. get collider(): Nullable<Collider>;
  103407. /**
  103408. * Move the mesh using collision engine
  103409. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  103410. * @param displacement defines the requested displacement vector
  103411. * @returns the current mesh
  103412. */
  103413. moveWithCollisions(displacement: Vector3): AbstractMesh;
  103414. private _onCollisionPositionChange;
  103415. /** @hidden */
  103416. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  103417. /** @hidden */
  103418. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  103419. /** @hidden */
  103420. _checkCollision(collider: Collider): AbstractMesh;
  103421. /** @hidden */
  103422. _generatePointsArray(): boolean;
  103423. /**
  103424. * Checks if the passed Ray intersects with the mesh
  103425. * @param ray defines the ray to use
  103426. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  103427. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103428. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  103429. * @returns the picking info
  103430. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  103431. */
  103432. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  103433. /**
  103434. * Clones the current mesh
  103435. * @param name defines the mesh name
  103436. * @param newParent defines the new mesh parent
  103437. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  103438. * @returns the new mesh
  103439. */
  103440. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  103441. /**
  103442. * Disposes all the submeshes of the current meshnp
  103443. * @returns the current mesh
  103444. */
  103445. releaseSubMeshes(): AbstractMesh;
  103446. /**
  103447. * Releases resources associated with this abstract mesh.
  103448. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103449. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103450. */
  103451. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103452. /**
  103453. * Adds the passed mesh as a child to the current mesh
  103454. * @param mesh defines the child mesh
  103455. * @returns the current mesh
  103456. */
  103457. addChild(mesh: AbstractMesh): AbstractMesh;
  103458. /**
  103459. * Removes the passed mesh from the current mesh children list
  103460. * @param mesh defines the child mesh
  103461. * @returns the current mesh
  103462. */
  103463. removeChild(mesh: AbstractMesh): AbstractMesh;
  103464. /** @hidden */
  103465. private _initFacetData;
  103466. /**
  103467. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  103468. * This method can be called within the render loop.
  103469. * 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
  103470. * @returns the current mesh
  103471. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103472. */
  103473. updateFacetData(): AbstractMesh;
  103474. /**
  103475. * Returns the facetLocalNormals array.
  103476. * The normals are expressed in the mesh local spac
  103477. * @returns an array of Vector3
  103478. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103479. */
  103480. getFacetLocalNormals(): Vector3[];
  103481. /**
  103482. * Returns the facetLocalPositions array.
  103483. * The facet positions are expressed in the mesh local space
  103484. * @returns an array of Vector3
  103485. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103486. */
  103487. getFacetLocalPositions(): Vector3[];
  103488. /**
  103489. * Returns the facetLocalPartioning array
  103490. * @returns an array of array of numbers
  103491. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103492. */
  103493. getFacetLocalPartitioning(): number[][];
  103494. /**
  103495. * Returns the i-th facet position in the world system.
  103496. * This method allocates a new Vector3 per call
  103497. * @param i defines the facet index
  103498. * @returns a new Vector3
  103499. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103500. */
  103501. getFacetPosition(i: number): Vector3;
  103502. /**
  103503. * Sets the reference Vector3 with the i-th facet position in the world system
  103504. * @param i defines the facet index
  103505. * @param ref defines the target vector
  103506. * @returns the current mesh
  103507. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103508. */
  103509. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  103510. /**
  103511. * Returns the i-th facet normal in the world system.
  103512. * This method allocates a new Vector3 per call
  103513. * @param i defines the facet index
  103514. * @returns a new Vector3
  103515. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103516. */
  103517. getFacetNormal(i: number): Vector3;
  103518. /**
  103519. * Sets the reference Vector3 with the i-th facet normal in the world system
  103520. * @param i defines the facet index
  103521. * @param ref defines the target vector
  103522. * @returns the current mesh
  103523. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103524. */
  103525. getFacetNormalToRef(i: number, ref: Vector3): this;
  103526. /**
  103527. * 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)
  103528. * @param x defines x coordinate
  103529. * @param y defines y coordinate
  103530. * @param z defines z coordinate
  103531. * @returns the array of facet indexes
  103532. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103533. */
  103534. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  103535. /**
  103536. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  103537. * @param projected sets as the (x,y,z) world projection on the facet
  103538. * @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
  103539. * @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
  103540. * @param x defines x coordinate
  103541. * @param y defines y coordinate
  103542. * @param z defines z coordinate
  103543. * @returns the face index if found (or null instead)
  103544. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103545. */
  103546. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  103547. /**
  103548. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  103549. * @param projected sets as the (x,y,z) local projection on the facet
  103550. * @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
  103551. * @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
  103552. * @param x defines x coordinate
  103553. * @param y defines y coordinate
  103554. * @param z defines z coordinate
  103555. * @returns the face index if found (or null instead)
  103556. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103557. */
  103558. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  103559. /**
  103560. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  103561. * @returns the parameters
  103562. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103563. */
  103564. getFacetDataParameters(): any;
  103565. /**
  103566. * Disables the feature FacetData and frees the related memory
  103567. * @returns the current mesh
  103568. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103569. */
  103570. disableFacetData(): AbstractMesh;
  103571. /**
  103572. * Updates the AbstractMesh indices array
  103573. * @param indices defines the data source
  103574. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  103575. * @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)
  103576. * @returns the current mesh
  103577. */
  103578. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  103579. /**
  103580. * Creates new normals data for the mesh
  103581. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  103582. * @returns the current mesh
  103583. */
  103584. createNormals(updatable: boolean): AbstractMesh;
  103585. /**
  103586. * Align the mesh with a normal
  103587. * @param normal defines the normal to use
  103588. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  103589. * @returns the current mesh
  103590. */
  103591. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  103592. /** @hidden */
  103593. _checkOcclusionQuery(): boolean;
  103594. /**
  103595. * Disables the mesh edge rendering mode
  103596. * @returns the currentAbstractMesh
  103597. */
  103598. disableEdgesRendering(): AbstractMesh;
  103599. /**
  103600. * Enables the edge rendering mode on the mesh.
  103601. * This mode makes the mesh edges visible
  103602. * @param epsilon defines the maximal distance between two angles to detect a face
  103603. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  103604. * @returns the currentAbstractMesh
  103605. * @see https://www.babylonjs-playground.com/#19O9TU#0
  103606. */
  103607. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  103608. }
  103609. }
  103610. declare module BABYLON {
  103611. /**
  103612. * Interface used to define ActionEvent
  103613. */
  103614. export interface IActionEvent {
  103615. /** The mesh or sprite that triggered the action */
  103616. source: any;
  103617. /** The X mouse cursor position at the time of the event */
  103618. pointerX: number;
  103619. /** The Y mouse cursor position at the time of the event */
  103620. pointerY: number;
  103621. /** The mesh that is currently pointed at (can be null) */
  103622. meshUnderPointer: Nullable<AbstractMesh>;
  103623. /** the original (browser) event that triggered the ActionEvent */
  103624. sourceEvent?: any;
  103625. /** additional data for the event */
  103626. additionalData?: any;
  103627. }
  103628. /**
  103629. * ActionEvent is the event being sent when an action is triggered.
  103630. */
  103631. export class ActionEvent implements IActionEvent {
  103632. /** The mesh or sprite that triggered the action */
  103633. source: any;
  103634. /** The X mouse cursor position at the time of the event */
  103635. pointerX: number;
  103636. /** The Y mouse cursor position at the time of the event */
  103637. pointerY: number;
  103638. /** The mesh that is currently pointed at (can be null) */
  103639. meshUnderPointer: Nullable<AbstractMesh>;
  103640. /** the original (browser) event that triggered the ActionEvent */
  103641. sourceEvent?: any;
  103642. /** additional data for the event */
  103643. additionalData?: any;
  103644. /**
  103645. * Creates a new ActionEvent
  103646. * @param source The mesh or sprite that triggered the action
  103647. * @param pointerX The X mouse cursor position at the time of the event
  103648. * @param pointerY The Y mouse cursor position at the time of the event
  103649. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  103650. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  103651. * @param additionalData additional data for the event
  103652. */
  103653. constructor(
  103654. /** The mesh or sprite that triggered the action */
  103655. source: any,
  103656. /** The X mouse cursor position at the time of the event */
  103657. pointerX: number,
  103658. /** The Y mouse cursor position at the time of the event */
  103659. pointerY: number,
  103660. /** The mesh that is currently pointed at (can be null) */
  103661. meshUnderPointer: Nullable<AbstractMesh>,
  103662. /** the original (browser) event that triggered the ActionEvent */
  103663. sourceEvent?: any,
  103664. /** additional data for the event */
  103665. additionalData?: any);
  103666. /**
  103667. * Helper function to auto-create an ActionEvent from a source mesh.
  103668. * @param source The source mesh that triggered the event
  103669. * @param evt The original (browser) event
  103670. * @param additionalData additional data for the event
  103671. * @returns the new ActionEvent
  103672. */
  103673. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  103674. /**
  103675. * Helper function to auto-create an ActionEvent from a source sprite
  103676. * @param source The source sprite that triggered the event
  103677. * @param scene Scene associated with the sprite
  103678. * @param evt The original (browser) event
  103679. * @param additionalData additional data for the event
  103680. * @returns the new ActionEvent
  103681. */
  103682. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  103683. /**
  103684. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  103685. * @param scene the scene where the event occurred
  103686. * @param evt The original (browser) event
  103687. * @returns the new ActionEvent
  103688. */
  103689. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  103690. /**
  103691. * Helper function to auto-create an ActionEvent from a primitive
  103692. * @param prim defines the target primitive
  103693. * @param pointerPos defines the pointer position
  103694. * @param evt The original (browser) event
  103695. * @param additionalData additional data for the event
  103696. * @returns the new ActionEvent
  103697. */
  103698. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  103699. }
  103700. }
  103701. declare module BABYLON {
  103702. /**
  103703. * Abstract class used to decouple action Manager from scene and meshes.
  103704. * Do not instantiate.
  103705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  103706. */
  103707. export abstract class AbstractActionManager implements IDisposable {
  103708. /** Gets the list of active triggers */
  103709. static Triggers: {
  103710. [key: string]: number;
  103711. };
  103712. /** Gets the cursor to use when hovering items */
  103713. hoverCursor: string;
  103714. /** Gets the list of actions */
  103715. actions: IAction[];
  103716. /**
  103717. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  103718. */
  103719. isRecursive: boolean;
  103720. /**
  103721. * Releases all associated resources
  103722. */
  103723. abstract dispose(): void;
  103724. /**
  103725. * Does this action manager has pointer triggers
  103726. */
  103727. abstract get hasPointerTriggers(): boolean;
  103728. /**
  103729. * Does this action manager has pick triggers
  103730. */
  103731. abstract get hasPickTriggers(): boolean;
  103732. /**
  103733. * Process a specific trigger
  103734. * @param trigger defines the trigger to process
  103735. * @param evt defines the event details to be processed
  103736. */
  103737. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  103738. /**
  103739. * Does this action manager handles actions of any of the given triggers
  103740. * @param triggers defines the triggers to be tested
  103741. * @return a boolean indicating whether one (or more) of the triggers is handled
  103742. */
  103743. abstract hasSpecificTriggers(triggers: number[]): boolean;
  103744. /**
  103745. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  103746. * speed.
  103747. * @param triggerA defines the trigger to be tested
  103748. * @param triggerB defines the trigger to be tested
  103749. * @return a boolean indicating whether one (or more) of the triggers is handled
  103750. */
  103751. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  103752. /**
  103753. * Does this action manager handles actions of a given trigger
  103754. * @param trigger defines the trigger to be tested
  103755. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  103756. * @return whether the trigger is handled
  103757. */
  103758. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  103759. /**
  103760. * Serialize this manager to a JSON object
  103761. * @param name defines the property name to store this manager
  103762. * @returns a JSON representation of this manager
  103763. */
  103764. abstract serialize(name: string): any;
  103765. /**
  103766. * Registers an action to this action manager
  103767. * @param action defines the action to be registered
  103768. * @return the action amended (prepared) after registration
  103769. */
  103770. abstract registerAction(action: IAction): Nullable<IAction>;
  103771. /**
  103772. * Unregisters an action to this action manager
  103773. * @param action defines the action to be unregistered
  103774. * @return a boolean indicating whether the action has been unregistered
  103775. */
  103776. abstract unregisterAction(action: IAction): Boolean;
  103777. /**
  103778. * Does exist one action manager with at least one trigger
  103779. **/
  103780. static get HasTriggers(): boolean;
  103781. /**
  103782. * Does exist one action manager with at least one pick trigger
  103783. **/
  103784. static get HasPickTriggers(): boolean;
  103785. /**
  103786. * Does exist one action manager that handles actions of a given trigger
  103787. * @param trigger defines the trigger to be tested
  103788. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  103789. **/
  103790. static HasSpecificTrigger(trigger: number): boolean;
  103791. }
  103792. }
  103793. declare module BABYLON {
  103794. /**
  103795. * Defines how a node can be built from a string name.
  103796. */
  103797. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  103798. /**
  103799. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  103800. */
  103801. export class Node implements IBehaviorAware<Node> {
  103802. /** @hidden */
  103803. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  103804. private static _NodeConstructors;
  103805. /**
  103806. * Add a new node constructor
  103807. * @param type defines the type name of the node to construct
  103808. * @param constructorFunc defines the constructor function
  103809. */
  103810. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  103811. /**
  103812. * Returns a node constructor based on type name
  103813. * @param type defines the type name
  103814. * @param name defines the new node name
  103815. * @param scene defines the hosting scene
  103816. * @param options defines optional options to transmit to constructors
  103817. * @returns the new constructor or null
  103818. */
  103819. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  103820. /**
  103821. * Gets or sets the name of the node
  103822. */
  103823. name: string;
  103824. /**
  103825. * Gets or sets the id of the node
  103826. */
  103827. id: string;
  103828. /**
  103829. * Gets or sets the unique id of the node
  103830. */
  103831. uniqueId: number;
  103832. /**
  103833. * Gets or sets a string used to store user defined state for the node
  103834. */
  103835. state: string;
  103836. /**
  103837. * Gets or sets an object used to store user defined information for the node
  103838. */
  103839. metadata: any;
  103840. /**
  103841. * For internal use only. Please do not use.
  103842. */
  103843. reservedDataStore: any;
  103844. /**
  103845. * List of inspectable custom properties (used by the Inspector)
  103846. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103847. */
  103848. inspectableCustomProperties: IInspectable[];
  103849. private _doNotSerialize;
  103850. /**
  103851. * Gets or sets a boolean used to define if the node must be serialized
  103852. */
  103853. get doNotSerialize(): boolean;
  103854. set doNotSerialize(value: boolean);
  103855. /** @hidden */
  103856. _isDisposed: boolean;
  103857. /**
  103858. * Gets a list of Animations associated with the node
  103859. */
  103860. animations: Animation[];
  103861. protected _ranges: {
  103862. [name: string]: Nullable<AnimationRange>;
  103863. };
  103864. /**
  103865. * Callback raised when the node is ready to be used
  103866. */
  103867. onReady: Nullable<(node: Node) => void>;
  103868. private _isEnabled;
  103869. private _isParentEnabled;
  103870. private _isReady;
  103871. /** @hidden */
  103872. _currentRenderId: number;
  103873. private _parentUpdateId;
  103874. /** @hidden */
  103875. _childUpdateId: number;
  103876. /** @hidden */
  103877. _waitingParentId: Nullable<string>;
  103878. /** @hidden */
  103879. _scene: Scene;
  103880. /** @hidden */
  103881. _cache: any;
  103882. private _parentNode;
  103883. private _children;
  103884. /** @hidden */
  103885. _worldMatrix: Matrix;
  103886. /** @hidden */
  103887. _worldMatrixDeterminant: number;
  103888. /** @hidden */
  103889. _worldMatrixDeterminantIsDirty: boolean;
  103890. /** @hidden */
  103891. private _sceneRootNodesIndex;
  103892. /**
  103893. * Gets a boolean indicating if the node has been disposed
  103894. * @returns true if the node was disposed
  103895. */
  103896. isDisposed(): boolean;
  103897. /**
  103898. * Gets or sets the parent of the node (without keeping the current position in the scene)
  103899. * @see https://doc.babylonjs.com/how_to/parenting
  103900. */
  103901. set parent(parent: Nullable<Node>);
  103902. get parent(): Nullable<Node>;
  103903. /** @hidden */
  103904. _addToSceneRootNodes(): void;
  103905. /** @hidden */
  103906. _removeFromSceneRootNodes(): void;
  103907. private _animationPropertiesOverride;
  103908. /**
  103909. * Gets or sets the animation properties override
  103910. */
  103911. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  103912. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  103913. /**
  103914. * Gets a string idenfifying the name of the class
  103915. * @returns "Node" string
  103916. */
  103917. getClassName(): string;
  103918. /** @hidden */
  103919. readonly _isNode: boolean;
  103920. /**
  103921. * An event triggered when the mesh is disposed
  103922. */
  103923. onDisposeObservable: Observable<Node>;
  103924. private _onDisposeObserver;
  103925. /**
  103926. * Sets a callback that will be raised when the node will be disposed
  103927. */
  103928. set onDispose(callback: () => void);
  103929. /**
  103930. * Creates a new Node
  103931. * @param name the name and id to be given to this node
  103932. * @param scene the scene this node will be added to
  103933. */
  103934. constructor(name: string, scene?: Nullable<Scene>);
  103935. /**
  103936. * Gets the scene of the node
  103937. * @returns a scene
  103938. */
  103939. getScene(): Scene;
  103940. /**
  103941. * Gets the engine of the node
  103942. * @returns a Engine
  103943. */
  103944. getEngine(): Engine;
  103945. private _behaviors;
  103946. /**
  103947. * Attach a behavior to the node
  103948. * @see http://doc.babylonjs.com/features/behaviour
  103949. * @param behavior defines the behavior to attach
  103950. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  103951. * @returns the current Node
  103952. */
  103953. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  103954. /**
  103955. * Remove an attached behavior
  103956. * @see http://doc.babylonjs.com/features/behaviour
  103957. * @param behavior defines the behavior to attach
  103958. * @returns the current Node
  103959. */
  103960. removeBehavior(behavior: Behavior<Node>): Node;
  103961. /**
  103962. * Gets the list of attached behaviors
  103963. * @see http://doc.babylonjs.com/features/behaviour
  103964. */
  103965. get behaviors(): Behavior<Node>[];
  103966. /**
  103967. * Gets an attached behavior by name
  103968. * @param name defines the name of the behavior to look for
  103969. * @see http://doc.babylonjs.com/features/behaviour
  103970. * @returns null if behavior was not found else the requested behavior
  103971. */
  103972. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  103973. /**
  103974. * Returns the latest update of the World matrix
  103975. * @returns a Matrix
  103976. */
  103977. getWorldMatrix(): Matrix;
  103978. /** @hidden */
  103979. _getWorldMatrixDeterminant(): number;
  103980. /**
  103981. * Returns directly the latest state of the mesh World matrix.
  103982. * A Matrix is returned.
  103983. */
  103984. get worldMatrixFromCache(): Matrix;
  103985. /** @hidden */
  103986. _initCache(): void;
  103987. /** @hidden */
  103988. updateCache(force?: boolean): void;
  103989. /** @hidden */
  103990. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  103991. /** @hidden */
  103992. _updateCache(ignoreParentClass?: boolean): void;
  103993. /** @hidden */
  103994. _isSynchronized(): boolean;
  103995. /** @hidden */
  103996. _markSyncedWithParent(): void;
  103997. /** @hidden */
  103998. isSynchronizedWithParent(): boolean;
  103999. /** @hidden */
  104000. isSynchronized(): boolean;
  104001. /**
  104002. * Is this node ready to be used/rendered
  104003. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  104004. * @return true if the node is ready
  104005. */
  104006. isReady(completeCheck?: boolean): boolean;
  104007. /**
  104008. * Is this node enabled?
  104009. * 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
  104010. * @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
  104011. * @return whether this node (and its parent) is enabled
  104012. */
  104013. isEnabled(checkAncestors?: boolean): boolean;
  104014. /** @hidden */
  104015. protected _syncParentEnabledState(): void;
  104016. /**
  104017. * Set the enabled state of this node
  104018. * @param value defines the new enabled state
  104019. */
  104020. setEnabled(value: boolean): void;
  104021. /**
  104022. * Is this node a descendant of the given node?
  104023. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  104024. * @param ancestor defines the parent node to inspect
  104025. * @returns a boolean indicating if this node is a descendant of the given node
  104026. */
  104027. isDescendantOf(ancestor: Node): boolean;
  104028. /** @hidden */
  104029. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  104030. /**
  104031. * Will return all nodes that have this node as ascendant
  104032. * @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
  104033. * @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
  104034. * @return all children nodes of all types
  104035. */
  104036. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  104037. /**
  104038. * Get all child-meshes of this node
  104039. * @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)
  104040. * @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
  104041. * @returns an array of AbstractMesh
  104042. */
  104043. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  104044. /**
  104045. * Get all direct children of this node
  104046. * @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
  104047. * @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)
  104048. * @returns an array of Node
  104049. */
  104050. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  104051. /** @hidden */
  104052. _setReady(state: boolean): void;
  104053. /**
  104054. * Get an animation by name
  104055. * @param name defines the name of the animation to look for
  104056. * @returns null if not found else the requested animation
  104057. */
  104058. getAnimationByName(name: string): Nullable<Animation>;
  104059. /**
  104060. * Creates an animation range for this node
  104061. * @param name defines the name of the range
  104062. * @param from defines the starting key
  104063. * @param to defines the end key
  104064. */
  104065. createAnimationRange(name: string, from: number, to: number): void;
  104066. /**
  104067. * Delete a specific animation range
  104068. * @param name defines the name of the range to delete
  104069. * @param deleteFrames defines if animation frames from the range must be deleted as well
  104070. */
  104071. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  104072. /**
  104073. * Get an animation range by name
  104074. * @param name defines the name of the animation range to look for
  104075. * @returns null if not found else the requested animation range
  104076. */
  104077. getAnimationRange(name: string): Nullable<AnimationRange>;
  104078. /**
  104079. * Gets the list of all animation ranges defined on this node
  104080. * @returns an array
  104081. */
  104082. getAnimationRanges(): Nullable<AnimationRange>[];
  104083. /**
  104084. * Will start the animation sequence
  104085. * @param name defines the range frames for animation sequence
  104086. * @param loop defines if the animation should loop (false by default)
  104087. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  104088. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  104089. * @returns the object created for this animation. If range does not exist, it will return null
  104090. */
  104091. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  104092. /**
  104093. * Serialize animation ranges into a JSON compatible object
  104094. * @returns serialization object
  104095. */
  104096. serializeAnimationRanges(): any;
  104097. /**
  104098. * Computes the world matrix of the node
  104099. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  104100. * @returns the world matrix
  104101. */
  104102. computeWorldMatrix(force?: boolean): Matrix;
  104103. /**
  104104. * Releases resources associated with this node.
  104105. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  104106. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  104107. */
  104108. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  104109. /**
  104110. * Parse animation range data from a serialization object and store them into a given node
  104111. * @param node defines where to store the animation ranges
  104112. * @param parsedNode defines the serialization object to read data from
  104113. * @param scene defines the hosting scene
  104114. */
  104115. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  104116. /**
  104117. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  104118. * @param includeDescendants Include bounding info from descendants as well (true by default)
  104119. * @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
  104120. * @returns the new bounding vectors
  104121. */
  104122. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  104123. min: Vector3;
  104124. max: Vector3;
  104125. };
  104126. }
  104127. }
  104128. declare module BABYLON {
  104129. /**
  104130. * @hidden
  104131. */
  104132. export class _IAnimationState {
  104133. key: number;
  104134. repeatCount: number;
  104135. workValue?: any;
  104136. loopMode?: number;
  104137. offsetValue?: any;
  104138. highLimitValue?: any;
  104139. }
  104140. /**
  104141. * Class used to store any kind of animation
  104142. */
  104143. export class Animation {
  104144. /**Name of the animation */
  104145. name: string;
  104146. /**Property to animate */
  104147. targetProperty: string;
  104148. /**The frames per second of the animation */
  104149. framePerSecond: number;
  104150. /**The data type of the animation */
  104151. dataType: number;
  104152. /**The loop mode of the animation */
  104153. loopMode?: number | undefined;
  104154. /**Specifies if blending should be enabled */
  104155. enableBlending?: boolean | undefined;
  104156. /**
  104157. * Use matrix interpolation instead of using direct key value when animating matrices
  104158. */
  104159. static AllowMatricesInterpolation: boolean;
  104160. /**
  104161. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  104162. */
  104163. static AllowMatrixDecomposeForInterpolation: boolean;
  104164. /**
  104165. * Stores the key frames of the animation
  104166. */
  104167. private _keys;
  104168. /**
  104169. * Stores the easing function of the animation
  104170. */
  104171. private _easingFunction;
  104172. /**
  104173. * @hidden Internal use only
  104174. */
  104175. _runtimeAnimations: RuntimeAnimation[];
  104176. /**
  104177. * The set of event that will be linked to this animation
  104178. */
  104179. private _events;
  104180. /**
  104181. * Stores an array of target property paths
  104182. */
  104183. targetPropertyPath: string[];
  104184. /**
  104185. * Stores the blending speed of the animation
  104186. */
  104187. blendingSpeed: number;
  104188. /**
  104189. * Stores the animation ranges for the animation
  104190. */
  104191. private _ranges;
  104192. /**
  104193. * @hidden Internal use
  104194. */
  104195. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  104196. /**
  104197. * Sets up an animation
  104198. * @param property The property to animate
  104199. * @param animationType The animation type to apply
  104200. * @param framePerSecond The frames per second of the animation
  104201. * @param easingFunction The easing function used in the animation
  104202. * @returns The created animation
  104203. */
  104204. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  104205. /**
  104206. * Create and start an animation on a node
  104207. * @param name defines the name of the global animation that will be run on all nodes
  104208. * @param node defines the root node where the animation will take place
  104209. * @param targetProperty defines property to animate
  104210. * @param framePerSecond defines the number of frame per second yo use
  104211. * @param totalFrame defines the number of frames in total
  104212. * @param from defines the initial value
  104213. * @param to defines the final value
  104214. * @param loopMode defines which loop mode you want to use (off by default)
  104215. * @param easingFunction defines the easing function to use (linear by default)
  104216. * @param onAnimationEnd defines the callback to call when animation end
  104217. * @returns the animatable created for this animation
  104218. */
  104219. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  104220. /**
  104221. * Create and start an animation on a node and its descendants
  104222. * @param name defines the name of the global animation that will be run on all nodes
  104223. * @param node defines the root node where the animation will take place
  104224. * @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
  104225. * @param targetProperty defines property to animate
  104226. * @param framePerSecond defines the number of frame per second to use
  104227. * @param totalFrame defines the number of frames in total
  104228. * @param from defines the initial value
  104229. * @param to defines the final value
  104230. * @param loopMode defines which loop mode you want to use (off by default)
  104231. * @param easingFunction defines the easing function to use (linear by default)
  104232. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  104233. * @returns the list of animatables created for all nodes
  104234. * @example https://www.babylonjs-playground.com/#MH0VLI
  104235. */
  104236. 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[]>;
  104237. /**
  104238. * Creates a new animation, merges it with the existing animations and starts it
  104239. * @param name Name of the animation
  104240. * @param node Node which contains the scene that begins the animations
  104241. * @param targetProperty Specifies which property to animate
  104242. * @param framePerSecond The frames per second of the animation
  104243. * @param totalFrame The total number of frames
  104244. * @param from The frame at the beginning of the animation
  104245. * @param to The frame at the end of the animation
  104246. * @param loopMode Specifies the loop mode of the animation
  104247. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  104248. * @param onAnimationEnd Callback to run once the animation is complete
  104249. * @returns Nullable animation
  104250. */
  104251. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  104252. /**
  104253. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  104254. * @param sourceAnimation defines the Animation containing keyframes to convert
  104255. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  104256. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  104257. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  104258. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  104259. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  104260. */
  104261. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  104262. /**
  104263. * Transition property of an host to the target Value
  104264. * @param property The property to transition
  104265. * @param targetValue The target Value of the property
  104266. * @param host The object where the property to animate belongs
  104267. * @param scene Scene used to run the animation
  104268. * @param frameRate Framerate (in frame/s) to use
  104269. * @param transition The transition type we want to use
  104270. * @param duration The duration of the animation, in milliseconds
  104271. * @param onAnimationEnd Callback trigger at the end of the animation
  104272. * @returns Nullable animation
  104273. */
  104274. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  104275. /**
  104276. * Return the array of runtime animations currently using this animation
  104277. */
  104278. get runtimeAnimations(): RuntimeAnimation[];
  104279. /**
  104280. * Specifies if any of the runtime animations are currently running
  104281. */
  104282. get hasRunningRuntimeAnimations(): boolean;
  104283. /**
  104284. * Initializes the animation
  104285. * @param name Name of the animation
  104286. * @param targetProperty Property to animate
  104287. * @param framePerSecond The frames per second of the animation
  104288. * @param dataType The data type of the animation
  104289. * @param loopMode The loop mode of the animation
  104290. * @param enableBlending Specifies if blending should be enabled
  104291. */
  104292. constructor(
  104293. /**Name of the animation */
  104294. name: string,
  104295. /**Property to animate */
  104296. targetProperty: string,
  104297. /**The frames per second of the animation */
  104298. framePerSecond: number,
  104299. /**The data type of the animation */
  104300. dataType: number,
  104301. /**The loop mode of the animation */
  104302. loopMode?: number | undefined,
  104303. /**Specifies if blending should be enabled */
  104304. enableBlending?: boolean | undefined);
  104305. /**
  104306. * Converts the animation to a string
  104307. * @param fullDetails support for multiple levels of logging within scene loading
  104308. * @returns String form of the animation
  104309. */
  104310. toString(fullDetails?: boolean): string;
  104311. /**
  104312. * Add an event to this animation
  104313. * @param event Event to add
  104314. */
  104315. addEvent(event: AnimationEvent): void;
  104316. /**
  104317. * Remove all events found at the given frame
  104318. * @param frame The frame to remove events from
  104319. */
  104320. removeEvents(frame: number): void;
  104321. /**
  104322. * Retrieves all the events from the animation
  104323. * @returns Events from the animation
  104324. */
  104325. getEvents(): AnimationEvent[];
  104326. /**
  104327. * Creates an animation range
  104328. * @param name Name of the animation range
  104329. * @param from Starting frame of the animation range
  104330. * @param to Ending frame of the animation
  104331. */
  104332. createRange(name: string, from: number, to: number): void;
  104333. /**
  104334. * Deletes an animation range by name
  104335. * @param name Name of the animation range to delete
  104336. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  104337. */
  104338. deleteRange(name: string, deleteFrames?: boolean): void;
  104339. /**
  104340. * Gets the animation range by name, or null if not defined
  104341. * @param name Name of the animation range
  104342. * @returns Nullable animation range
  104343. */
  104344. getRange(name: string): Nullable<AnimationRange>;
  104345. /**
  104346. * Gets the key frames from the animation
  104347. * @returns The key frames of the animation
  104348. */
  104349. getKeys(): Array<IAnimationKey>;
  104350. /**
  104351. * Gets the highest frame rate of the animation
  104352. * @returns Highest frame rate of the animation
  104353. */
  104354. getHighestFrame(): number;
  104355. /**
  104356. * Gets the easing function of the animation
  104357. * @returns Easing function of the animation
  104358. */
  104359. getEasingFunction(): IEasingFunction;
  104360. /**
  104361. * Sets the easing function of the animation
  104362. * @param easingFunction A custom mathematical formula for animation
  104363. */
  104364. setEasingFunction(easingFunction: EasingFunction): void;
  104365. /**
  104366. * Interpolates a scalar linearly
  104367. * @param startValue Start value of the animation curve
  104368. * @param endValue End value of the animation curve
  104369. * @param gradient Scalar amount to interpolate
  104370. * @returns Interpolated scalar value
  104371. */
  104372. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  104373. /**
  104374. * Interpolates a scalar cubically
  104375. * @param startValue Start value of the animation curve
  104376. * @param outTangent End tangent of the animation
  104377. * @param endValue End value of the animation curve
  104378. * @param inTangent Start tangent of the animation curve
  104379. * @param gradient Scalar amount to interpolate
  104380. * @returns Interpolated scalar value
  104381. */
  104382. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  104383. /**
  104384. * Interpolates a quaternion using a spherical linear interpolation
  104385. * @param startValue Start value of the animation curve
  104386. * @param endValue End value of the animation curve
  104387. * @param gradient Scalar amount to interpolate
  104388. * @returns Interpolated quaternion value
  104389. */
  104390. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  104391. /**
  104392. * Interpolates a quaternion cubically
  104393. * @param startValue Start value of the animation curve
  104394. * @param outTangent End tangent of the animation curve
  104395. * @param endValue End value of the animation curve
  104396. * @param inTangent Start tangent of the animation curve
  104397. * @param gradient Scalar amount to interpolate
  104398. * @returns Interpolated quaternion value
  104399. */
  104400. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  104401. /**
  104402. * Interpolates a Vector3 linearl
  104403. * @param startValue Start value of the animation curve
  104404. * @param endValue End value of the animation curve
  104405. * @param gradient Scalar amount to interpolate
  104406. * @returns Interpolated scalar value
  104407. */
  104408. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  104409. /**
  104410. * Interpolates a Vector3 cubically
  104411. * @param startValue Start value of the animation curve
  104412. * @param outTangent End tangent of the animation
  104413. * @param endValue End value of the animation curve
  104414. * @param inTangent Start tangent of the animation curve
  104415. * @param gradient Scalar amount to interpolate
  104416. * @returns InterpolatedVector3 value
  104417. */
  104418. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  104419. /**
  104420. * Interpolates a Vector2 linearly
  104421. * @param startValue Start value of the animation curve
  104422. * @param endValue End value of the animation curve
  104423. * @param gradient Scalar amount to interpolate
  104424. * @returns Interpolated Vector2 value
  104425. */
  104426. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  104427. /**
  104428. * Interpolates a Vector2 cubically
  104429. * @param startValue Start value of the animation curve
  104430. * @param outTangent End tangent of the animation
  104431. * @param endValue End value of the animation curve
  104432. * @param inTangent Start tangent of the animation curve
  104433. * @param gradient Scalar amount to interpolate
  104434. * @returns Interpolated Vector2 value
  104435. */
  104436. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  104437. /**
  104438. * Interpolates a size linearly
  104439. * @param startValue Start value of the animation curve
  104440. * @param endValue End value of the animation curve
  104441. * @param gradient Scalar amount to interpolate
  104442. * @returns Interpolated Size value
  104443. */
  104444. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  104445. /**
  104446. * Interpolates a Color3 linearly
  104447. * @param startValue Start value of the animation curve
  104448. * @param endValue End value of the animation curve
  104449. * @param gradient Scalar amount to interpolate
  104450. * @returns Interpolated Color3 value
  104451. */
  104452. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  104453. /**
  104454. * Interpolates a Color4 linearly
  104455. * @param startValue Start value of the animation curve
  104456. * @param endValue End value of the animation curve
  104457. * @param gradient Scalar amount to interpolate
  104458. * @returns Interpolated Color3 value
  104459. */
  104460. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  104461. /**
  104462. * @hidden Internal use only
  104463. */
  104464. _getKeyValue(value: any): any;
  104465. /**
  104466. * @hidden Internal use only
  104467. */
  104468. _interpolate(currentFrame: number, state: _IAnimationState): any;
  104469. /**
  104470. * Defines the function to use to interpolate matrices
  104471. * @param startValue defines the start matrix
  104472. * @param endValue defines the end matrix
  104473. * @param gradient defines the gradient between both matrices
  104474. * @param result defines an optional target matrix where to store the interpolation
  104475. * @returns the interpolated matrix
  104476. */
  104477. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  104478. /**
  104479. * Makes a copy of the animation
  104480. * @returns Cloned animation
  104481. */
  104482. clone(): Animation;
  104483. /**
  104484. * Sets the key frames of the animation
  104485. * @param values The animation key frames to set
  104486. */
  104487. setKeys(values: Array<IAnimationKey>): void;
  104488. /**
  104489. * Serializes the animation to an object
  104490. * @returns Serialized object
  104491. */
  104492. serialize(): any;
  104493. /**
  104494. * Float animation type
  104495. */
  104496. static readonly ANIMATIONTYPE_FLOAT: number;
  104497. /**
  104498. * Vector3 animation type
  104499. */
  104500. static readonly ANIMATIONTYPE_VECTOR3: number;
  104501. /**
  104502. * Quaternion animation type
  104503. */
  104504. static readonly ANIMATIONTYPE_QUATERNION: number;
  104505. /**
  104506. * Matrix animation type
  104507. */
  104508. static readonly ANIMATIONTYPE_MATRIX: number;
  104509. /**
  104510. * Color3 animation type
  104511. */
  104512. static readonly ANIMATIONTYPE_COLOR3: number;
  104513. /**
  104514. * Color3 animation type
  104515. */
  104516. static readonly ANIMATIONTYPE_COLOR4: number;
  104517. /**
  104518. * Vector2 animation type
  104519. */
  104520. static readonly ANIMATIONTYPE_VECTOR2: number;
  104521. /**
  104522. * Size animation type
  104523. */
  104524. static readonly ANIMATIONTYPE_SIZE: number;
  104525. /**
  104526. * Relative Loop Mode
  104527. */
  104528. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  104529. /**
  104530. * Cycle Loop Mode
  104531. */
  104532. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  104533. /**
  104534. * Constant Loop Mode
  104535. */
  104536. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  104537. /** @hidden */
  104538. static _UniversalLerp(left: any, right: any, amount: number): any;
  104539. /**
  104540. * Parses an animation object and creates an animation
  104541. * @param parsedAnimation Parsed animation object
  104542. * @returns Animation object
  104543. */
  104544. static Parse(parsedAnimation: any): Animation;
  104545. /**
  104546. * Appends the serialized animations from the source animations
  104547. * @param source Source containing the animations
  104548. * @param destination Target to store the animations
  104549. */
  104550. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  104551. }
  104552. }
  104553. declare module BABYLON {
  104554. /**
  104555. * Interface containing an array of animations
  104556. */
  104557. export interface IAnimatable {
  104558. /**
  104559. * Array of animations
  104560. */
  104561. animations: Nullable<Array<Animation>>;
  104562. }
  104563. }
  104564. declare module BABYLON {
  104565. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  104566. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104567. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104568. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104569. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104570. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104571. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104572. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104573. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104574. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104575. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104576. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104577. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104578. /**
  104579. * Decorator used to define property that can be serialized as reference to a camera
  104580. * @param sourceName defines the name of the property to decorate
  104581. */
  104582. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104583. /**
  104584. * Class used to help serialization objects
  104585. */
  104586. export class SerializationHelper {
  104587. /** @hidden */
  104588. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  104589. /** @hidden */
  104590. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  104591. /** @hidden */
  104592. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  104593. /** @hidden */
  104594. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  104595. /**
  104596. * Appends the serialized animations from the source animations
  104597. * @param source Source containing the animations
  104598. * @param destination Target to store the animations
  104599. */
  104600. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  104601. /**
  104602. * Static function used to serialized a specific entity
  104603. * @param entity defines the entity to serialize
  104604. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  104605. * @returns a JSON compatible object representing the serialization of the entity
  104606. */
  104607. static Serialize<T>(entity: T, serializationObject?: any): any;
  104608. /**
  104609. * Creates a new entity from a serialization data object
  104610. * @param creationFunction defines a function used to instanciated the new entity
  104611. * @param source defines the source serialization data
  104612. * @param scene defines the hosting scene
  104613. * @param rootUrl defines the root url for resources
  104614. * @returns a new entity
  104615. */
  104616. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  104617. /**
  104618. * Clones an object
  104619. * @param creationFunction defines the function used to instanciate the new object
  104620. * @param source defines the source object
  104621. * @returns the cloned object
  104622. */
  104623. static Clone<T>(creationFunction: () => T, source: T): T;
  104624. /**
  104625. * Instanciates a new object based on a source one (some data will be shared between both object)
  104626. * @param creationFunction defines the function used to instanciate the new object
  104627. * @param source defines the source object
  104628. * @returns the new object
  104629. */
  104630. static Instanciate<T>(creationFunction: () => T, source: T): T;
  104631. }
  104632. }
  104633. declare module BABYLON {
  104634. /**
  104635. * Base class of all the textures in babylon.
  104636. * It groups all the common properties the materials, post process, lights... might need
  104637. * in order to make a correct use of the texture.
  104638. */
  104639. export class BaseTexture implements IAnimatable {
  104640. /**
  104641. * Default anisotropic filtering level for the application.
  104642. * It is set to 4 as a good tradeoff between perf and quality.
  104643. */
  104644. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  104645. /**
  104646. * Gets or sets the unique id of the texture
  104647. */
  104648. uniqueId: number;
  104649. /**
  104650. * Define the name of the texture.
  104651. */
  104652. name: string;
  104653. /**
  104654. * Gets or sets an object used to store user defined information.
  104655. */
  104656. metadata: any;
  104657. /**
  104658. * For internal use only. Please do not use.
  104659. */
  104660. reservedDataStore: any;
  104661. private _hasAlpha;
  104662. /**
  104663. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  104664. */
  104665. set hasAlpha(value: boolean);
  104666. get hasAlpha(): boolean;
  104667. /**
  104668. * Defines if the alpha value should be determined via the rgb values.
  104669. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  104670. */
  104671. getAlphaFromRGB: boolean;
  104672. /**
  104673. * Intensity or strength of the texture.
  104674. * It is commonly used by materials to fine tune the intensity of the texture
  104675. */
  104676. level: number;
  104677. /**
  104678. * Define the UV chanel to use starting from 0 and defaulting to 0.
  104679. * This is part of the texture as textures usually maps to one uv set.
  104680. */
  104681. coordinatesIndex: number;
  104682. private _coordinatesMode;
  104683. /**
  104684. * How a texture is mapped.
  104685. *
  104686. * | Value | Type | Description |
  104687. * | ----- | ----------------------------------- | ----------- |
  104688. * | 0 | EXPLICIT_MODE | |
  104689. * | 1 | SPHERICAL_MODE | |
  104690. * | 2 | PLANAR_MODE | |
  104691. * | 3 | CUBIC_MODE | |
  104692. * | 4 | PROJECTION_MODE | |
  104693. * | 5 | SKYBOX_MODE | |
  104694. * | 6 | INVCUBIC_MODE | |
  104695. * | 7 | EQUIRECTANGULAR_MODE | |
  104696. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  104697. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  104698. */
  104699. set coordinatesMode(value: number);
  104700. get coordinatesMode(): number;
  104701. /**
  104702. * | Value | Type | Description |
  104703. * | ----- | ------------------ | ----------- |
  104704. * | 0 | CLAMP_ADDRESSMODE | |
  104705. * | 1 | WRAP_ADDRESSMODE | |
  104706. * | 2 | MIRROR_ADDRESSMODE | |
  104707. */
  104708. wrapU: number;
  104709. /**
  104710. * | Value | Type | Description |
  104711. * | ----- | ------------------ | ----------- |
  104712. * | 0 | CLAMP_ADDRESSMODE | |
  104713. * | 1 | WRAP_ADDRESSMODE | |
  104714. * | 2 | MIRROR_ADDRESSMODE | |
  104715. */
  104716. wrapV: number;
  104717. /**
  104718. * | Value | Type | Description |
  104719. * | ----- | ------------------ | ----------- |
  104720. * | 0 | CLAMP_ADDRESSMODE | |
  104721. * | 1 | WRAP_ADDRESSMODE | |
  104722. * | 2 | MIRROR_ADDRESSMODE | |
  104723. */
  104724. wrapR: number;
  104725. /**
  104726. * With compliant hardware and browser (supporting anisotropic filtering)
  104727. * this defines the level of anisotropic filtering in the texture.
  104728. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  104729. */
  104730. anisotropicFilteringLevel: number;
  104731. /**
  104732. * Define if the texture is a cube texture or if false a 2d texture.
  104733. */
  104734. get isCube(): boolean;
  104735. set isCube(value: boolean);
  104736. /**
  104737. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  104738. */
  104739. get is3D(): boolean;
  104740. set is3D(value: boolean);
  104741. /**
  104742. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  104743. */
  104744. get is2DArray(): boolean;
  104745. set is2DArray(value: boolean);
  104746. /**
  104747. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  104748. * HDR texture are usually stored in linear space.
  104749. * This only impacts the PBR and Background materials
  104750. */
  104751. gammaSpace: boolean;
  104752. /**
  104753. * Gets or sets whether or not the texture contains RGBD data.
  104754. */
  104755. get isRGBD(): boolean;
  104756. set isRGBD(value: boolean);
  104757. /**
  104758. * Is Z inverted in the texture (useful in a cube texture).
  104759. */
  104760. invertZ: boolean;
  104761. /**
  104762. * Are mip maps generated for this texture or not.
  104763. */
  104764. get noMipmap(): boolean;
  104765. /**
  104766. * @hidden
  104767. */
  104768. lodLevelInAlpha: boolean;
  104769. /**
  104770. * With prefiltered texture, defined the offset used during the prefiltering steps.
  104771. */
  104772. get lodGenerationOffset(): number;
  104773. set lodGenerationOffset(value: number);
  104774. /**
  104775. * With prefiltered texture, defined the scale used during the prefiltering steps.
  104776. */
  104777. get lodGenerationScale(): number;
  104778. set lodGenerationScale(value: number);
  104779. /**
  104780. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  104781. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  104782. * average roughness values.
  104783. */
  104784. get linearSpecularLOD(): boolean;
  104785. set linearSpecularLOD(value: boolean);
  104786. /**
  104787. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  104788. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  104789. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  104790. */
  104791. get irradianceTexture(): Nullable<BaseTexture>;
  104792. set irradianceTexture(value: Nullable<BaseTexture>);
  104793. /**
  104794. * Define if the texture is a render target.
  104795. */
  104796. isRenderTarget: boolean;
  104797. /**
  104798. * Define the unique id of the texture in the scene.
  104799. */
  104800. get uid(): string;
  104801. /**
  104802. * Return a string representation of the texture.
  104803. * @returns the texture as a string
  104804. */
  104805. toString(): string;
  104806. /**
  104807. * Get the class name of the texture.
  104808. * @returns "BaseTexture"
  104809. */
  104810. getClassName(): string;
  104811. /**
  104812. * Define the list of animation attached to the texture.
  104813. */
  104814. animations: Animation[];
  104815. /**
  104816. * An event triggered when the texture is disposed.
  104817. */
  104818. onDisposeObservable: Observable<BaseTexture>;
  104819. private _onDisposeObserver;
  104820. /**
  104821. * Callback triggered when the texture has been disposed.
  104822. * Kept for back compatibility, you can use the onDisposeObservable instead.
  104823. */
  104824. set onDispose(callback: () => void);
  104825. /**
  104826. * Define the current state of the loading sequence when in delayed load mode.
  104827. */
  104828. delayLoadState: number;
  104829. private _scene;
  104830. /** @hidden */
  104831. _texture: Nullable<InternalTexture>;
  104832. private _uid;
  104833. /**
  104834. * Define if the texture is preventinga material to render or not.
  104835. * If not and the texture is not ready, the engine will use a default black texture instead.
  104836. */
  104837. get isBlocking(): boolean;
  104838. /**
  104839. * Instantiates a new BaseTexture.
  104840. * Base class of all the textures in babylon.
  104841. * It groups all the common properties the materials, post process, lights... might need
  104842. * in order to make a correct use of the texture.
  104843. * @param scene Define the scene the texture blongs to
  104844. */
  104845. constructor(scene: Nullable<Scene>);
  104846. /**
  104847. * Get the scene the texture belongs to.
  104848. * @returns the scene or null if undefined
  104849. */
  104850. getScene(): Nullable<Scene>;
  104851. /**
  104852. * Get the texture transform matrix used to offset tile the texture for istance.
  104853. * @returns the transformation matrix
  104854. */
  104855. getTextureMatrix(): Matrix;
  104856. /**
  104857. * Get the texture reflection matrix used to rotate/transform the reflection.
  104858. * @returns the reflection matrix
  104859. */
  104860. getReflectionTextureMatrix(): Matrix;
  104861. /**
  104862. * Get the underlying lower level texture from Babylon.
  104863. * @returns the insternal texture
  104864. */
  104865. getInternalTexture(): Nullable<InternalTexture>;
  104866. /**
  104867. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  104868. * @returns true if ready or not blocking
  104869. */
  104870. isReadyOrNotBlocking(): boolean;
  104871. /**
  104872. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  104873. * @returns true if fully ready
  104874. */
  104875. isReady(): boolean;
  104876. private _cachedSize;
  104877. /**
  104878. * Get the size of the texture.
  104879. * @returns the texture size.
  104880. */
  104881. getSize(): ISize;
  104882. /**
  104883. * Get the base size of the texture.
  104884. * It can be different from the size if the texture has been resized for POT for instance
  104885. * @returns the base size
  104886. */
  104887. getBaseSize(): ISize;
  104888. /**
  104889. * Update the sampling mode of the texture.
  104890. * Default is Trilinear mode.
  104891. *
  104892. * | Value | Type | Description |
  104893. * | ----- | ------------------ | ----------- |
  104894. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  104895. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  104896. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  104897. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  104898. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  104899. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  104900. * | 7 | NEAREST_LINEAR | |
  104901. * | 8 | NEAREST_NEAREST | |
  104902. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  104903. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  104904. * | 11 | LINEAR_LINEAR | |
  104905. * | 12 | LINEAR_NEAREST | |
  104906. *
  104907. * > _mag_: magnification filter (close to the viewer)
  104908. * > _min_: minification filter (far from the viewer)
  104909. * > _mip_: filter used between mip map levels
  104910. *@param samplingMode Define the new sampling mode of the texture
  104911. */
  104912. updateSamplingMode(samplingMode: number): void;
  104913. /**
  104914. * Scales the texture if is `canRescale()`
  104915. * @param ratio the resize factor we want to use to rescale
  104916. */
  104917. scale(ratio: number): void;
  104918. /**
  104919. * Get if the texture can rescale.
  104920. */
  104921. get canRescale(): boolean;
  104922. /** @hidden */
  104923. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  104924. /** @hidden */
  104925. _rebuild(): void;
  104926. /**
  104927. * Triggers the load sequence in delayed load mode.
  104928. */
  104929. delayLoad(): void;
  104930. /**
  104931. * Clones the texture.
  104932. * @returns the cloned texture
  104933. */
  104934. clone(): Nullable<BaseTexture>;
  104935. /**
  104936. * Get the texture underlying type (INT, FLOAT...)
  104937. */
  104938. get textureType(): number;
  104939. /**
  104940. * Get the texture underlying format (RGB, RGBA...)
  104941. */
  104942. get textureFormat(): number;
  104943. /**
  104944. * Indicates that textures need to be re-calculated for all materials
  104945. */
  104946. protected _markAllSubMeshesAsTexturesDirty(): void;
  104947. /**
  104948. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  104949. * This will returns an RGBA array buffer containing either in values (0-255) or
  104950. * float values (0-1) depending of the underlying buffer type.
  104951. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  104952. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  104953. * @param buffer defines a user defined buffer to fill with data (can be null)
  104954. * @returns The Array buffer containing the pixels data.
  104955. */
  104956. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  104957. /**
  104958. * Release and destroy the underlying lower level texture aka internalTexture.
  104959. */
  104960. releaseInternalTexture(): void;
  104961. /** @hidden */
  104962. get _lodTextureHigh(): Nullable<BaseTexture>;
  104963. /** @hidden */
  104964. get _lodTextureMid(): Nullable<BaseTexture>;
  104965. /** @hidden */
  104966. get _lodTextureLow(): Nullable<BaseTexture>;
  104967. /**
  104968. * Dispose the texture and release its associated resources.
  104969. */
  104970. dispose(): void;
  104971. /**
  104972. * Serialize the texture into a JSON representation that can be parsed later on.
  104973. * @returns the JSON representation of the texture
  104974. */
  104975. serialize(): any;
  104976. /**
  104977. * Helper function to be called back once a list of texture contains only ready textures.
  104978. * @param textures Define the list of textures to wait for
  104979. * @param callback Define the callback triggered once the entire list will be ready
  104980. */
  104981. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  104982. }
  104983. }
  104984. declare module BABYLON {
  104985. /**
  104986. * Options to be used when creating an effect.
  104987. */
  104988. export interface IEffectCreationOptions {
  104989. /**
  104990. * Atrributes that will be used in the shader.
  104991. */
  104992. attributes: string[];
  104993. /**
  104994. * Uniform varible names that will be set in the shader.
  104995. */
  104996. uniformsNames: string[];
  104997. /**
  104998. * Uniform buffer variable names that will be set in the shader.
  104999. */
  105000. uniformBuffersNames: string[];
  105001. /**
  105002. * Sampler texture variable names that will be set in the shader.
  105003. */
  105004. samplers: string[];
  105005. /**
  105006. * Define statements that will be set in the shader.
  105007. */
  105008. defines: any;
  105009. /**
  105010. * Possible fallbacks for this effect to improve performance when needed.
  105011. */
  105012. fallbacks: Nullable<IEffectFallbacks>;
  105013. /**
  105014. * Callback that will be called when the shader is compiled.
  105015. */
  105016. onCompiled: Nullable<(effect: Effect) => void>;
  105017. /**
  105018. * Callback that will be called if an error occurs during shader compilation.
  105019. */
  105020. onError: Nullable<(effect: Effect, errors: string) => void>;
  105021. /**
  105022. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  105023. */
  105024. indexParameters?: any;
  105025. /**
  105026. * Max number of lights that can be used in the shader.
  105027. */
  105028. maxSimultaneousLights?: number;
  105029. /**
  105030. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  105031. */
  105032. transformFeedbackVaryings?: Nullable<string[]>;
  105033. }
  105034. /**
  105035. * Effect containing vertex and fragment shader that can be executed on an object.
  105036. */
  105037. export class Effect implements IDisposable {
  105038. /**
  105039. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  105040. */
  105041. static ShadersRepository: string;
  105042. /**
  105043. * Enable logging of the shader code when a compilation error occurs
  105044. */
  105045. static LogShaderCodeOnCompilationError: boolean;
  105046. /**
  105047. * Name of the effect.
  105048. */
  105049. name: any;
  105050. /**
  105051. * String container all the define statements that should be set on the shader.
  105052. */
  105053. defines: string;
  105054. /**
  105055. * Callback that will be called when the shader is compiled.
  105056. */
  105057. onCompiled: Nullable<(effect: Effect) => void>;
  105058. /**
  105059. * Callback that will be called if an error occurs during shader compilation.
  105060. */
  105061. onError: Nullable<(effect: Effect, errors: string) => void>;
  105062. /**
  105063. * Callback that will be called when effect is bound.
  105064. */
  105065. onBind: Nullable<(effect: Effect) => void>;
  105066. /**
  105067. * Unique ID of the effect.
  105068. */
  105069. uniqueId: number;
  105070. /**
  105071. * Observable that will be called when the shader is compiled.
  105072. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  105073. */
  105074. onCompileObservable: Observable<Effect>;
  105075. /**
  105076. * Observable that will be called if an error occurs during shader compilation.
  105077. */
  105078. onErrorObservable: Observable<Effect>;
  105079. /** @hidden */
  105080. _onBindObservable: Nullable<Observable<Effect>>;
  105081. /**
  105082. * @hidden
  105083. * Specifies if the effect was previously ready
  105084. */
  105085. _wasPreviouslyReady: boolean;
  105086. /**
  105087. * Observable that will be called when effect is bound.
  105088. */
  105089. get onBindObservable(): Observable<Effect>;
  105090. /** @hidden */
  105091. _bonesComputationForcedToCPU: boolean;
  105092. private static _uniqueIdSeed;
  105093. private _engine;
  105094. private _uniformBuffersNames;
  105095. private _uniformBuffersNamesList;
  105096. private _uniformsNames;
  105097. private _samplerList;
  105098. private _samplers;
  105099. private _isReady;
  105100. private _compilationError;
  105101. private _allFallbacksProcessed;
  105102. private _attributesNames;
  105103. private _attributes;
  105104. private _attributeLocationByName;
  105105. private _uniforms;
  105106. /**
  105107. * Key for the effect.
  105108. * @hidden
  105109. */
  105110. _key: string;
  105111. private _indexParameters;
  105112. private _fallbacks;
  105113. private _vertexSourceCode;
  105114. private _fragmentSourceCode;
  105115. private _vertexSourceCodeOverride;
  105116. private _fragmentSourceCodeOverride;
  105117. private _transformFeedbackVaryings;
  105118. /**
  105119. * Compiled shader to webGL program.
  105120. * @hidden
  105121. */
  105122. _pipelineContext: Nullable<IPipelineContext>;
  105123. private _valueCache;
  105124. private static _baseCache;
  105125. /**
  105126. * Instantiates an effect.
  105127. * An effect can be used to create/manage/execute vertex and fragment shaders.
  105128. * @param baseName Name of the effect.
  105129. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  105130. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  105131. * @param samplers List of sampler variables that will be passed to the shader.
  105132. * @param engine Engine to be used to render the effect
  105133. * @param defines Define statements to be added to the shader.
  105134. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  105135. * @param onCompiled Callback that will be called when the shader is compiled.
  105136. * @param onError Callback that will be called if an error occurs during shader compilation.
  105137. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  105138. */
  105139. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  105140. private _useFinalCode;
  105141. /**
  105142. * Unique key for this effect
  105143. */
  105144. get key(): string;
  105145. /**
  105146. * If the effect has been compiled and prepared.
  105147. * @returns if the effect is compiled and prepared.
  105148. */
  105149. isReady(): boolean;
  105150. private _isReadyInternal;
  105151. /**
  105152. * The engine the effect was initialized with.
  105153. * @returns the engine.
  105154. */
  105155. getEngine(): Engine;
  105156. /**
  105157. * The pipeline context for this effect
  105158. * @returns the associated pipeline context
  105159. */
  105160. getPipelineContext(): Nullable<IPipelineContext>;
  105161. /**
  105162. * The set of names of attribute variables for the shader.
  105163. * @returns An array of attribute names.
  105164. */
  105165. getAttributesNames(): string[];
  105166. /**
  105167. * Returns the attribute at the given index.
  105168. * @param index The index of the attribute.
  105169. * @returns The location of the attribute.
  105170. */
  105171. getAttributeLocation(index: number): number;
  105172. /**
  105173. * Returns the attribute based on the name of the variable.
  105174. * @param name of the attribute to look up.
  105175. * @returns the attribute location.
  105176. */
  105177. getAttributeLocationByName(name: string): number;
  105178. /**
  105179. * The number of attributes.
  105180. * @returns the numnber of attributes.
  105181. */
  105182. getAttributesCount(): number;
  105183. /**
  105184. * Gets the index of a uniform variable.
  105185. * @param uniformName of the uniform to look up.
  105186. * @returns the index.
  105187. */
  105188. getUniformIndex(uniformName: string): number;
  105189. /**
  105190. * Returns the attribute based on the name of the variable.
  105191. * @param uniformName of the uniform to look up.
  105192. * @returns the location of the uniform.
  105193. */
  105194. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  105195. /**
  105196. * Returns an array of sampler variable names
  105197. * @returns The array of sampler variable names.
  105198. */
  105199. getSamplers(): string[];
  105200. /**
  105201. * Returns an array of uniform variable names
  105202. * @returns The array of uniform variable names.
  105203. */
  105204. getUniformNames(): string[];
  105205. /**
  105206. * Returns an array of uniform buffer variable names
  105207. * @returns The array of uniform buffer variable names.
  105208. */
  105209. getUniformBuffersNames(): string[];
  105210. /**
  105211. * Returns the index parameters used to create the effect
  105212. * @returns The index parameters object
  105213. */
  105214. getIndexParameters(): any;
  105215. /**
  105216. * The error from the last compilation.
  105217. * @returns the error string.
  105218. */
  105219. getCompilationError(): string;
  105220. /**
  105221. * Gets a boolean indicating that all fallbacks were used during compilation
  105222. * @returns true if all fallbacks were used
  105223. */
  105224. allFallbacksProcessed(): boolean;
  105225. /**
  105226. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  105227. * @param func The callback to be used.
  105228. */
  105229. executeWhenCompiled(func: (effect: Effect) => void): void;
  105230. private _checkIsReady;
  105231. private _loadShader;
  105232. /**
  105233. * Gets the vertex shader source code of this effect
  105234. */
  105235. get vertexSourceCode(): string;
  105236. /**
  105237. * Gets the fragment shader source code of this effect
  105238. */
  105239. get fragmentSourceCode(): string;
  105240. /**
  105241. * Recompiles the webGL program
  105242. * @param vertexSourceCode The source code for the vertex shader.
  105243. * @param fragmentSourceCode The source code for the fragment shader.
  105244. * @param onCompiled Callback called when completed.
  105245. * @param onError Callback called on error.
  105246. * @hidden
  105247. */
  105248. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  105249. /**
  105250. * Prepares the effect
  105251. * @hidden
  105252. */
  105253. _prepareEffect(): void;
  105254. private _getShaderCodeAndErrorLine;
  105255. private _processCompilationErrors;
  105256. /**
  105257. * Checks if the effect is supported. (Must be called after compilation)
  105258. */
  105259. get isSupported(): boolean;
  105260. /**
  105261. * Binds a texture to the engine to be used as output of the shader.
  105262. * @param channel Name of the output variable.
  105263. * @param texture Texture to bind.
  105264. * @hidden
  105265. */
  105266. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  105267. /**
  105268. * Sets a texture on the engine to be used in the shader.
  105269. * @param channel Name of the sampler variable.
  105270. * @param texture Texture to set.
  105271. */
  105272. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  105273. /**
  105274. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  105275. * @param channel Name of the sampler variable.
  105276. * @param texture Texture to set.
  105277. */
  105278. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  105279. /**
  105280. * Sets an array of textures on the engine to be used in the shader.
  105281. * @param channel Name of the variable.
  105282. * @param textures Textures to set.
  105283. */
  105284. setTextureArray(channel: string, textures: BaseTexture[]): void;
  105285. /**
  105286. * 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)
  105287. * @param channel Name of the sampler variable.
  105288. * @param postProcess Post process to get the input texture from.
  105289. */
  105290. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  105291. /**
  105292. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  105293. * 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)
  105294. * @param channel Name of the sampler variable.
  105295. * @param postProcess Post process to get the output texture from.
  105296. */
  105297. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  105298. /** @hidden */
  105299. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  105300. /** @hidden */
  105301. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  105302. /** @hidden */
  105303. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  105304. /** @hidden */
  105305. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  105306. /**
  105307. * Binds a buffer to a uniform.
  105308. * @param buffer Buffer to bind.
  105309. * @param name Name of the uniform variable to bind to.
  105310. */
  105311. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  105312. /**
  105313. * Binds block to a uniform.
  105314. * @param blockName Name of the block to bind.
  105315. * @param index Index to bind.
  105316. */
  105317. bindUniformBlock(blockName: string, index: number): void;
  105318. /**
  105319. * Sets an interger value on a uniform variable.
  105320. * @param uniformName Name of the variable.
  105321. * @param value Value to be set.
  105322. * @returns this effect.
  105323. */
  105324. setInt(uniformName: string, value: number): Effect;
  105325. /**
  105326. * Sets an int array on a uniform variable.
  105327. * @param uniformName Name of the variable.
  105328. * @param array array to be set.
  105329. * @returns this effect.
  105330. */
  105331. setIntArray(uniformName: string, array: Int32Array): Effect;
  105332. /**
  105333. * 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)
  105334. * @param uniformName Name of the variable.
  105335. * @param array array to be set.
  105336. * @returns this effect.
  105337. */
  105338. setIntArray2(uniformName: string, array: Int32Array): Effect;
  105339. /**
  105340. * 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)
  105341. * @param uniformName Name of the variable.
  105342. * @param array array to be set.
  105343. * @returns this effect.
  105344. */
  105345. setIntArray3(uniformName: string, array: Int32Array): Effect;
  105346. /**
  105347. * 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)
  105348. * @param uniformName Name of the variable.
  105349. * @param array array to be set.
  105350. * @returns this effect.
  105351. */
  105352. setIntArray4(uniformName: string, array: Int32Array): Effect;
  105353. /**
  105354. * Sets an float array on a uniform variable.
  105355. * @param uniformName Name of the variable.
  105356. * @param array array to be set.
  105357. * @returns this effect.
  105358. */
  105359. setFloatArray(uniformName: string, array: Float32Array): Effect;
  105360. /**
  105361. * 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)
  105362. * @param uniformName Name of the variable.
  105363. * @param array array to be set.
  105364. * @returns this effect.
  105365. */
  105366. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  105367. /**
  105368. * 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)
  105369. * @param uniformName Name of the variable.
  105370. * @param array array to be set.
  105371. * @returns this effect.
  105372. */
  105373. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  105374. /**
  105375. * 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)
  105376. * @param uniformName Name of the variable.
  105377. * @param array array to be set.
  105378. * @returns this effect.
  105379. */
  105380. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  105381. /**
  105382. * Sets an array on a uniform variable.
  105383. * @param uniformName Name of the variable.
  105384. * @param array array to be set.
  105385. * @returns this effect.
  105386. */
  105387. setArray(uniformName: string, array: number[]): Effect;
  105388. /**
  105389. * 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)
  105390. * @param uniformName Name of the variable.
  105391. * @param array array to be set.
  105392. * @returns this effect.
  105393. */
  105394. setArray2(uniformName: string, array: number[]): Effect;
  105395. /**
  105396. * 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)
  105397. * @param uniformName Name of the variable.
  105398. * @param array array to be set.
  105399. * @returns this effect.
  105400. */
  105401. setArray3(uniformName: string, array: number[]): Effect;
  105402. /**
  105403. * 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)
  105404. * @param uniformName Name of the variable.
  105405. * @param array array to be set.
  105406. * @returns this effect.
  105407. */
  105408. setArray4(uniformName: string, array: number[]): Effect;
  105409. /**
  105410. * Sets matrices on a uniform variable.
  105411. * @param uniformName Name of the variable.
  105412. * @param matrices matrices to be set.
  105413. * @returns this effect.
  105414. */
  105415. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  105416. /**
  105417. * Sets matrix on a uniform variable.
  105418. * @param uniformName Name of the variable.
  105419. * @param matrix matrix to be set.
  105420. * @returns this effect.
  105421. */
  105422. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  105423. /**
  105424. * 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)
  105425. * @param uniformName Name of the variable.
  105426. * @param matrix matrix to be set.
  105427. * @returns this effect.
  105428. */
  105429. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  105430. /**
  105431. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  105432. * @param uniformName Name of the variable.
  105433. * @param matrix matrix to be set.
  105434. * @returns this effect.
  105435. */
  105436. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  105437. /**
  105438. * Sets a float on a uniform variable.
  105439. * @param uniformName Name of the variable.
  105440. * @param value value to be set.
  105441. * @returns this effect.
  105442. */
  105443. setFloat(uniformName: string, value: number): Effect;
  105444. /**
  105445. * Sets a boolean on a uniform variable.
  105446. * @param uniformName Name of the variable.
  105447. * @param bool value to be set.
  105448. * @returns this effect.
  105449. */
  105450. setBool(uniformName: string, bool: boolean): Effect;
  105451. /**
  105452. * Sets a Vector2 on a uniform variable.
  105453. * @param uniformName Name of the variable.
  105454. * @param vector2 vector2 to be set.
  105455. * @returns this effect.
  105456. */
  105457. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  105458. /**
  105459. * Sets a float2 on a uniform variable.
  105460. * @param uniformName Name of the variable.
  105461. * @param x First float in float2.
  105462. * @param y Second float in float2.
  105463. * @returns this effect.
  105464. */
  105465. setFloat2(uniformName: string, x: number, y: number): Effect;
  105466. /**
  105467. * Sets a Vector3 on a uniform variable.
  105468. * @param uniformName Name of the variable.
  105469. * @param vector3 Value to be set.
  105470. * @returns this effect.
  105471. */
  105472. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  105473. /**
  105474. * Sets a float3 on a uniform variable.
  105475. * @param uniformName Name of the variable.
  105476. * @param x First float in float3.
  105477. * @param y Second float in float3.
  105478. * @param z Third float in float3.
  105479. * @returns this effect.
  105480. */
  105481. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  105482. /**
  105483. * Sets a Vector4 on a uniform variable.
  105484. * @param uniformName Name of the variable.
  105485. * @param vector4 Value to be set.
  105486. * @returns this effect.
  105487. */
  105488. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  105489. /**
  105490. * Sets a float4 on a uniform variable.
  105491. * @param uniformName Name of the variable.
  105492. * @param x First float in float4.
  105493. * @param y Second float in float4.
  105494. * @param z Third float in float4.
  105495. * @param w Fourth float in float4.
  105496. * @returns this effect.
  105497. */
  105498. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  105499. /**
  105500. * Sets a Color3 on a uniform variable.
  105501. * @param uniformName Name of the variable.
  105502. * @param color3 Value to be set.
  105503. * @returns this effect.
  105504. */
  105505. setColor3(uniformName: string, color3: IColor3Like): Effect;
  105506. /**
  105507. * Sets a Color4 on a uniform variable.
  105508. * @param uniformName Name of the variable.
  105509. * @param color3 Value to be set.
  105510. * @param alpha Alpha value to be set.
  105511. * @returns this effect.
  105512. */
  105513. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  105514. /**
  105515. * Sets a Color4 on a uniform variable
  105516. * @param uniformName defines the name of the variable
  105517. * @param color4 defines the value to be set
  105518. * @returns this effect.
  105519. */
  105520. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  105521. /** Release all associated resources */
  105522. dispose(): void;
  105523. /**
  105524. * This function will add a new shader to the shader store
  105525. * @param name the name of the shader
  105526. * @param pixelShader optional pixel shader content
  105527. * @param vertexShader optional vertex shader content
  105528. */
  105529. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  105530. /**
  105531. * Store of each shader (The can be looked up using effect.key)
  105532. */
  105533. static ShadersStore: {
  105534. [key: string]: string;
  105535. };
  105536. /**
  105537. * Store of each included file for a shader (The can be looked up using effect.key)
  105538. */
  105539. static IncludesShadersStore: {
  105540. [key: string]: string;
  105541. };
  105542. /**
  105543. * Resets the cache of effects.
  105544. */
  105545. static ResetCache(): void;
  105546. }
  105547. }
  105548. declare module BABYLON {
  105549. /**
  105550. * Interface used to describe the capabilities of the engine relatively to the current browser
  105551. */
  105552. export interface EngineCapabilities {
  105553. /** Maximum textures units per fragment shader */
  105554. maxTexturesImageUnits: number;
  105555. /** Maximum texture units per vertex shader */
  105556. maxVertexTextureImageUnits: number;
  105557. /** Maximum textures units in the entire pipeline */
  105558. maxCombinedTexturesImageUnits: number;
  105559. /** Maximum texture size */
  105560. maxTextureSize: number;
  105561. /** Maximum texture samples */
  105562. maxSamples?: number;
  105563. /** Maximum cube texture size */
  105564. maxCubemapTextureSize: number;
  105565. /** Maximum render texture size */
  105566. maxRenderTextureSize: number;
  105567. /** Maximum number of vertex attributes */
  105568. maxVertexAttribs: number;
  105569. /** Maximum number of varyings */
  105570. maxVaryingVectors: number;
  105571. /** Maximum number of uniforms per vertex shader */
  105572. maxVertexUniformVectors: number;
  105573. /** Maximum number of uniforms per fragment shader */
  105574. maxFragmentUniformVectors: number;
  105575. /** Defines if standard derivates (dx/dy) are supported */
  105576. standardDerivatives: boolean;
  105577. /** Defines if s3tc texture compression is supported */
  105578. s3tc?: WEBGL_compressed_texture_s3tc;
  105579. /** Defines if pvrtc texture compression is supported */
  105580. pvrtc: any;
  105581. /** Defines if etc1 texture compression is supported */
  105582. etc1: any;
  105583. /** Defines if etc2 texture compression is supported */
  105584. etc2: any;
  105585. /** Defines if astc texture compression is supported */
  105586. astc: any;
  105587. /** Defines if float textures are supported */
  105588. textureFloat: boolean;
  105589. /** Defines if vertex array objects are supported */
  105590. vertexArrayObject: boolean;
  105591. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  105592. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  105593. /** Gets the maximum level of anisotropy supported */
  105594. maxAnisotropy: number;
  105595. /** Defines if instancing is supported */
  105596. instancedArrays: boolean;
  105597. /** Defines if 32 bits indices are supported */
  105598. uintIndices: boolean;
  105599. /** Defines if high precision shaders are supported */
  105600. highPrecisionShaderSupported: boolean;
  105601. /** Defines if depth reading in the fragment shader is supported */
  105602. fragmentDepthSupported: boolean;
  105603. /** Defines if float texture linear filtering is supported*/
  105604. textureFloatLinearFiltering: boolean;
  105605. /** Defines if rendering to float textures is supported */
  105606. textureFloatRender: boolean;
  105607. /** Defines if half float textures are supported*/
  105608. textureHalfFloat: boolean;
  105609. /** Defines if half float texture linear filtering is supported*/
  105610. textureHalfFloatLinearFiltering: boolean;
  105611. /** Defines if rendering to half float textures is supported */
  105612. textureHalfFloatRender: boolean;
  105613. /** Defines if textureLOD shader command is supported */
  105614. textureLOD: boolean;
  105615. /** Defines if draw buffers extension is supported */
  105616. drawBuffersExtension: boolean;
  105617. /** Defines if depth textures are supported */
  105618. depthTextureExtension: boolean;
  105619. /** Defines if float color buffer are supported */
  105620. colorBufferFloat: boolean;
  105621. /** Gets disjoint timer query extension (null if not supported) */
  105622. timerQuery?: EXT_disjoint_timer_query;
  105623. /** Defines if timestamp can be used with timer query */
  105624. canUseTimestampForTimerQuery: boolean;
  105625. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  105626. multiview?: any;
  105627. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  105628. oculusMultiview?: any;
  105629. /** Function used to let the system compiles shaders in background */
  105630. parallelShaderCompile?: {
  105631. COMPLETION_STATUS_KHR: number;
  105632. };
  105633. /** Max number of texture samples for MSAA */
  105634. maxMSAASamples: number;
  105635. /** Defines if the blend min max extension is supported */
  105636. blendMinMax: boolean;
  105637. }
  105638. }
  105639. declare module BABYLON {
  105640. /**
  105641. * @hidden
  105642. **/
  105643. export class DepthCullingState {
  105644. private _isDepthTestDirty;
  105645. private _isDepthMaskDirty;
  105646. private _isDepthFuncDirty;
  105647. private _isCullFaceDirty;
  105648. private _isCullDirty;
  105649. private _isZOffsetDirty;
  105650. private _isFrontFaceDirty;
  105651. private _depthTest;
  105652. private _depthMask;
  105653. private _depthFunc;
  105654. private _cull;
  105655. private _cullFace;
  105656. private _zOffset;
  105657. private _frontFace;
  105658. /**
  105659. * Initializes the state.
  105660. */
  105661. constructor();
  105662. get isDirty(): boolean;
  105663. get zOffset(): number;
  105664. set zOffset(value: number);
  105665. get cullFace(): Nullable<number>;
  105666. set cullFace(value: Nullable<number>);
  105667. get cull(): Nullable<boolean>;
  105668. set cull(value: Nullable<boolean>);
  105669. get depthFunc(): Nullable<number>;
  105670. set depthFunc(value: Nullable<number>);
  105671. get depthMask(): boolean;
  105672. set depthMask(value: boolean);
  105673. get depthTest(): boolean;
  105674. set depthTest(value: boolean);
  105675. get frontFace(): Nullable<number>;
  105676. set frontFace(value: Nullable<number>);
  105677. reset(): void;
  105678. apply(gl: WebGLRenderingContext): void;
  105679. }
  105680. }
  105681. declare module BABYLON {
  105682. /**
  105683. * @hidden
  105684. **/
  105685. export class StencilState {
  105686. /** 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 */
  105687. static readonly ALWAYS: number;
  105688. /** Passed to stencilOperation to specify that stencil value must be kept */
  105689. static readonly KEEP: number;
  105690. /** Passed to stencilOperation to specify that stencil value must be replaced */
  105691. static readonly REPLACE: number;
  105692. private _isStencilTestDirty;
  105693. private _isStencilMaskDirty;
  105694. private _isStencilFuncDirty;
  105695. private _isStencilOpDirty;
  105696. private _stencilTest;
  105697. private _stencilMask;
  105698. private _stencilFunc;
  105699. private _stencilFuncRef;
  105700. private _stencilFuncMask;
  105701. private _stencilOpStencilFail;
  105702. private _stencilOpDepthFail;
  105703. private _stencilOpStencilDepthPass;
  105704. get isDirty(): boolean;
  105705. get stencilFunc(): number;
  105706. set stencilFunc(value: number);
  105707. get stencilFuncRef(): number;
  105708. set stencilFuncRef(value: number);
  105709. get stencilFuncMask(): number;
  105710. set stencilFuncMask(value: number);
  105711. get stencilOpStencilFail(): number;
  105712. set stencilOpStencilFail(value: number);
  105713. get stencilOpDepthFail(): number;
  105714. set stencilOpDepthFail(value: number);
  105715. get stencilOpStencilDepthPass(): number;
  105716. set stencilOpStencilDepthPass(value: number);
  105717. get stencilMask(): number;
  105718. set stencilMask(value: number);
  105719. get stencilTest(): boolean;
  105720. set stencilTest(value: boolean);
  105721. constructor();
  105722. reset(): void;
  105723. apply(gl: WebGLRenderingContext): void;
  105724. }
  105725. }
  105726. declare module BABYLON {
  105727. /**
  105728. * @hidden
  105729. **/
  105730. export class AlphaState {
  105731. private _isAlphaBlendDirty;
  105732. private _isBlendFunctionParametersDirty;
  105733. private _isBlendEquationParametersDirty;
  105734. private _isBlendConstantsDirty;
  105735. private _alphaBlend;
  105736. private _blendFunctionParameters;
  105737. private _blendEquationParameters;
  105738. private _blendConstants;
  105739. /**
  105740. * Initializes the state.
  105741. */
  105742. constructor();
  105743. get isDirty(): boolean;
  105744. get alphaBlend(): boolean;
  105745. set alphaBlend(value: boolean);
  105746. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  105747. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  105748. setAlphaEquationParameters(rgb: number, alpha: number): void;
  105749. reset(): void;
  105750. apply(gl: WebGLRenderingContext): void;
  105751. }
  105752. }
  105753. declare module BABYLON {
  105754. /** @hidden */
  105755. export class WebGL2ShaderProcessor implements IShaderProcessor {
  105756. attributeProcessor(attribute: string): string;
  105757. varyingProcessor(varying: string, isFragment: boolean): string;
  105758. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  105759. }
  105760. }
  105761. declare module BABYLON {
  105762. /**
  105763. * Interface for attribute information associated with buffer instanciation
  105764. */
  105765. export interface InstancingAttributeInfo {
  105766. /**
  105767. * Name of the GLSL attribute
  105768. * if attribute index is not specified, this is used to retrieve the index from the effect
  105769. */
  105770. attributeName: string;
  105771. /**
  105772. * Index/offset of the attribute in the vertex shader
  105773. * if not specified, this will be computes from the name.
  105774. */
  105775. index?: number;
  105776. /**
  105777. * size of the attribute, 1, 2, 3 or 4
  105778. */
  105779. attributeSize: number;
  105780. /**
  105781. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  105782. */
  105783. offset: number;
  105784. /**
  105785. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  105786. * default to 1
  105787. */
  105788. divisor?: number;
  105789. /**
  105790. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  105791. * default is FLOAT
  105792. */
  105793. attributeType?: number;
  105794. /**
  105795. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  105796. */
  105797. normalized?: boolean;
  105798. }
  105799. }
  105800. declare module BABYLON {
  105801. interface ThinEngine {
  105802. /**
  105803. * Update a video texture
  105804. * @param texture defines the texture to update
  105805. * @param video defines the video element to use
  105806. * @param invertY defines if data must be stored with Y axis inverted
  105807. */
  105808. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  105809. }
  105810. }
  105811. declare module BABYLON {
  105812. /**
  105813. * Settings for finer control over video usage
  105814. */
  105815. export interface VideoTextureSettings {
  105816. /**
  105817. * Applies `autoplay` to video, if specified
  105818. */
  105819. autoPlay?: boolean;
  105820. /**
  105821. * Applies `loop` to video, if specified
  105822. */
  105823. loop?: boolean;
  105824. /**
  105825. * Automatically updates internal texture from video at every frame in the render loop
  105826. */
  105827. autoUpdateTexture: boolean;
  105828. /**
  105829. * Image src displayed during the video loading or until the user interacts with the video.
  105830. */
  105831. poster?: string;
  105832. }
  105833. /**
  105834. * If you want to display a video in your scene, this is the special texture for that.
  105835. * This special texture works similar to other textures, with the exception of a few parameters.
  105836. * @see https://doc.babylonjs.com/how_to/video_texture
  105837. */
  105838. export class VideoTexture extends Texture {
  105839. /**
  105840. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  105841. */
  105842. readonly autoUpdateTexture: boolean;
  105843. /**
  105844. * The video instance used by the texture internally
  105845. */
  105846. readonly video: HTMLVideoElement;
  105847. private _onUserActionRequestedObservable;
  105848. /**
  105849. * Event triggerd when a dom action is required by the user to play the video.
  105850. * This happens due to recent changes in browser policies preventing video to auto start.
  105851. */
  105852. get onUserActionRequestedObservable(): Observable<Texture>;
  105853. private _generateMipMaps;
  105854. private _engine;
  105855. private _stillImageCaptured;
  105856. private _displayingPosterTexture;
  105857. private _settings;
  105858. private _createInternalTextureOnEvent;
  105859. private _frameId;
  105860. private _currentSrc;
  105861. /**
  105862. * Creates a video texture.
  105863. * If you want to display a video in your scene, this is the special texture for that.
  105864. * This special texture works similar to other textures, with the exception of a few parameters.
  105865. * @see https://doc.babylonjs.com/how_to/video_texture
  105866. * @param name optional name, will detect from video source, if not defined
  105867. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  105868. * @param scene is obviously the current scene.
  105869. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  105870. * @param invertY is false by default but can be used to invert video on Y axis
  105871. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  105872. * @param settings allows finer control over video usage
  105873. */
  105874. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  105875. private _getName;
  105876. private _getVideo;
  105877. private _createInternalTexture;
  105878. private reset;
  105879. /**
  105880. * @hidden Internal method to initiate `update`.
  105881. */
  105882. _rebuild(): void;
  105883. /**
  105884. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  105885. */
  105886. update(): void;
  105887. /**
  105888. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  105889. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  105890. */
  105891. updateTexture(isVisible: boolean): void;
  105892. protected _updateInternalTexture: () => void;
  105893. /**
  105894. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  105895. * @param url New url.
  105896. */
  105897. updateURL(url: string): void;
  105898. /**
  105899. * Clones the texture.
  105900. * @returns the cloned texture
  105901. */
  105902. clone(): VideoTexture;
  105903. /**
  105904. * Dispose the texture and release its associated resources.
  105905. */
  105906. dispose(): void;
  105907. /**
  105908. * Creates a video texture straight from a stream.
  105909. * @param scene Define the scene the texture should be created in
  105910. * @param stream Define the stream the texture should be created from
  105911. * @returns The created video texture as a promise
  105912. */
  105913. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  105914. /**
  105915. * Creates a video texture straight from your WebCam video feed.
  105916. * @param scene Define the scene the texture should be created in
  105917. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  105918. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  105919. * @returns The created video texture as a promise
  105920. */
  105921. static CreateFromWebCamAsync(scene: Scene, constraints: {
  105922. minWidth: number;
  105923. maxWidth: number;
  105924. minHeight: number;
  105925. maxHeight: number;
  105926. deviceId: string;
  105927. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  105928. /**
  105929. * Creates a video texture straight from your WebCam video feed.
  105930. * @param scene Define the scene the texture should be created in
  105931. * @param onReady Define a callback to triggered once the texture will be ready
  105932. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  105933. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  105934. */
  105935. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  105936. minWidth: number;
  105937. maxWidth: number;
  105938. minHeight: number;
  105939. maxHeight: number;
  105940. deviceId: string;
  105941. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  105942. }
  105943. }
  105944. declare module BABYLON {
  105945. /**
  105946. * Defines the interface used by objects working like Scene
  105947. * @hidden
  105948. */
  105949. export interface ISceneLike {
  105950. _addPendingData(data: any): void;
  105951. _removePendingData(data: any): void;
  105952. offlineProvider: IOfflineProvider;
  105953. }
  105954. /** Interface defining initialization parameters for Engine class */
  105955. export interface EngineOptions extends WebGLContextAttributes {
  105956. /**
  105957. * Defines if the engine should no exceed a specified device ratio
  105958. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  105959. */
  105960. limitDeviceRatio?: number;
  105961. /**
  105962. * Defines if webvr should be enabled automatically
  105963. * @see http://doc.babylonjs.com/how_to/webvr_camera
  105964. */
  105965. autoEnableWebVR?: boolean;
  105966. /**
  105967. * Defines if webgl2 should be turned off even if supported
  105968. * @see http://doc.babylonjs.com/features/webgl2
  105969. */
  105970. disableWebGL2Support?: boolean;
  105971. /**
  105972. * Defines if webaudio should be initialized as well
  105973. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105974. */
  105975. audioEngine?: boolean;
  105976. /**
  105977. * Defines if animations should run using a deterministic lock step
  105978. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105979. */
  105980. deterministicLockstep?: boolean;
  105981. /** Defines the maximum steps to use with deterministic lock step mode */
  105982. lockstepMaxSteps?: number;
  105983. /** Defines the seconds between each deterministic lock step */
  105984. timeStep?: number;
  105985. /**
  105986. * Defines that engine should ignore context lost events
  105987. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  105988. */
  105989. doNotHandleContextLost?: boolean;
  105990. /**
  105991. * Defines that engine should ignore modifying touch action attribute and style
  105992. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  105993. */
  105994. doNotHandleTouchAction?: boolean;
  105995. /**
  105996. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  105997. */
  105998. useHighPrecisionFloats?: boolean;
  105999. }
  106000. /**
  106001. * The base engine class (root of all engines)
  106002. */
  106003. export class ThinEngine {
  106004. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  106005. static ExceptionList: ({
  106006. key: string;
  106007. capture: string;
  106008. captureConstraint: number;
  106009. targets: string[];
  106010. } | {
  106011. key: string;
  106012. capture: null;
  106013. captureConstraint: null;
  106014. targets: string[];
  106015. })[];
  106016. /** @hidden */
  106017. static _TextureLoaders: IInternalTextureLoader[];
  106018. /**
  106019. * Returns the current npm package of the sdk
  106020. */
  106021. static get NpmPackage(): string;
  106022. /**
  106023. * Returns the current version of the framework
  106024. */
  106025. static get Version(): string;
  106026. /**
  106027. * Returns a string describing the current engine
  106028. */
  106029. get description(): string;
  106030. /**
  106031. * Gets or sets the epsilon value used by collision engine
  106032. */
  106033. static CollisionsEpsilon: number;
  106034. /**
  106035. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  106036. */
  106037. static get ShadersRepository(): string;
  106038. static set ShadersRepository(value: string);
  106039. /** @hidden */
  106040. _shaderProcessor: IShaderProcessor;
  106041. /**
  106042. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  106043. */
  106044. forcePOTTextures: boolean;
  106045. /**
  106046. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  106047. */
  106048. isFullscreen: boolean;
  106049. /**
  106050. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  106051. */
  106052. cullBackFaces: boolean;
  106053. /**
  106054. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  106055. */
  106056. renderEvenInBackground: boolean;
  106057. /**
  106058. * Gets or sets a boolean indicating that cache can be kept between frames
  106059. */
  106060. preventCacheWipeBetweenFrames: boolean;
  106061. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  106062. validateShaderPrograms: boolean;
  106063. /**
  106064. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  106065. * This can provide greater z depth for distant objects.
  106066. */
  106067. useReverseDepthBuffer: boolean;
  106068. /**
  106069. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  106070. */
  106071. disableUniformBuffers: boolean;
  106072. /** @hidden */
  106073. _uniformBuffers: UniformBuffer[];
  106074. /**
  106075. * Gets a boolean indicating that the engine supports uniform buffers
  106076. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  106077. */
  106078. get supportsUniformBuffers(): boolean;
  106079. /** @hidden */
  106080. _gl: WebGLRenderingContext;
  106081. /** @hidden */
  106082. _webGLVersion: number;
  106083. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  106084. protected _windowIsBackground: boolean;
  106085. protected _creationOptions: EngineOptions;
  106086. protected _highPrecisionShadersAllowed: boolean;
  106087. /** @hidden */
  106088. get _shouldUseHighPrecisionShader(): boolean;
  106089. /**
  106090. * Gets a boolean indicating that only power of 2 textures are supported
  106091. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  106092. */
  106093. get needPOTTextures(): boolean;
  106094. /** @hidden */
  106095. _badOS: boolean;
  106096. /** @hidden */
  106097. _badDesktopOS: boolean;
  106098. private _hardwareScalingLevel;
  106099. /** @hidden */
  106100. _caps: EngineCapabilities;
  106101. private _isStencilEnable;
  106102. private _glVersion;
  106103. private _glRenderer;
  106104. private _glVendor;
  106105. /** @hidden */
  106106. _videoTextureSupported: boolean;
  106107. protected _renderingQueueLaunched: boolean;
  106108. protected _activeRenderLoops: (() => void)[];
  106109. /**
  106110. * Observable signaled when a context lost event is raised
  106111. */
  106112. onContextLostObservable: Observable<ThinEngine>;
  106113. /**
  106114. * Observable signaled when a context restored event is raised
  106115. */
  106116. onContextRestoredObservable: Observable<ThinEngine>;
  106117. private _onContextLost;
  106118. private _onContextRestored;
  106119. protected _contextWasLost: boolean;
  106120. /** @hidden */
  106121. _doNotHandleContextLost: boolean;
  106122. /**
  106123. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  106124. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  106125. */
  106126. get doNotHandleContextLost(): boolean;
  106127. set doNotHandleContextLost(value: boolean);
  106128. /**
  106129. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  106130. */
  106131. disableVertexArrayObjects: boolean;
  106132. /** @hidden */
  106133. protected _colorWrite: boolean;
  106134. /** @hidden */
  106135. protected _colorWriteChanged: boolean;
  106136. /** @hidden */
  106137. protected _depthCullingState: DepthCullingState;
  106138. /** @hidden */
  106139. protected _stencilState: StencilState;
  106140. /** @hidden */
  106141. _alphaState: AlphaState;
  106142. /** @hidden */
  106143. _alphaMode: number;
  106144. /** @hidden */
  106145. _alphaEquation: number;
  106146. /** @hidden */
  106147. _internalTexturesCache: InternalTexture[];
  106148. /** @hidden */
  106149. protected _activeChannel: number;
  106150. private _currentTextureChannel;
  106151. /** @hidden */
  106152. protected _boundTexturesCache: {
  106153. [key: string]: Nullable<InternalTexture>;
  106154. };
  106155. /** @hidden */
  106156. protected _currentEffect: Nullable<Effect>;
  106157. /** @hidden */
  106158. protected _currentProgram: Nullable<WebGLProgram>;
  106159. private _compiledEffects;
  106160. private _vertexAttribArraysEnabled;
  106161. /** @hidden */
  106162. protected _cachedViewport: Nullable<IViewportLike>;
  106163. private _cachedVertexArrayObject;
  106164. /** @hidden */
  106165. protected _cachedVertexBuffers: any;
  106166. /** @hidden */
  106167. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  106168. /** @hidden */
  106169. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  106170. /** @hidden */
  106171. _currentRenderTarget: Nullable<InternalTexture>;
  106172. private _uintIndicesCurrentlySet;
  106173. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  106174. /** @hidden */
  106175. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  106176. private _currentBufferPointers;
  106177. private _currentInstanceLocations;
  106178. private _currentInstanceBuffers;
  106179. private _textureUnits;
  106180. /** @hidden */
  106181. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  106182. /** @hidden */
  106183. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  106184. /** @hidden */
  106185. _boundRenderFunction: any;
  106186. private _vaoRecordInProgress;
  106187. private _mustWipeVertexAttributes;
  106188. private _emptyTexture;
  106189. private _emptyCubeTexture;
  106190. private _emptyTexture3D;
  106191. private _emptyTexture2DArray;
  106192. /** @hidden */
  106193. _frameHandler: number;
  106194. private _nextFreeTextureSlots;
  106195. private _maxSimultaneousTextures;
  106196. private _activeRequests;
  106197. /** @hidden */
  106198. _transformTextureUrl: Nullable<(url: string) => string>;
  106199. protected get _supportsHardwareTextureRescaling(): boolean;
  106200. private _framebufferDimensionsObject;
  106201. /**
  106202. * sets the object from which width and height will be taken from when getting render width and height
  106203. * Will fallback to the gl object
  106204. * @param dimensions the framebuffer width and height that will be used.
  106205. */
  106206. set framebufferDimensionsObject(dimensions: Nullable<{
  106207. framebufferWidth: number;
  106208. framebufferHeight: number;
  106209. }>);
  106210. /**
  106211. * Gets the current viewport
  106212. */
  106213. get currentViewport(): Nullable<IViewportLike>;
  106214. /**
  106215. * Gets the default empty texture
  106216. */
  106217. get emptyTexture(): InternalTexture;
  106218. /**
  106219. * Gets the default empty 3D texture
  106220. */
  106221. get emptyTexture3D(): InternalTexture;
  106222. /**
  106223. * Gets the default empty 2D array texture
  106224. */
  106225. get emptyTexture2DArray(): InternalTexture;
  106226. /**
  106227. * Gets the default empty cube texture
  106228. */
  106229. get emptyCubeTexture(): InternalTexture;
  106230. /**
  106231. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  106232. */
  106233. readonly premultipliedAlpha: boolean;
  106234. /**
  106235. * Observable event triggered before each texture is initialized
  106236. */
  106237. onBeforeTextureInitObservable: Observable<Texture>;
  106238. /**
  106239. * Creates a new engine
  106240. * @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
  106241. * @param antialias defines enable antialiasing (default: false)
  106242. * @param options defines further options to be sent to the getContext() function
  106243. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  106244. */
  106245. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  106246. private _rebuildInternalTextures;
  106247. private _rebuildEffects;
  106248. /**
  106249. * Gets a boolean indicating if all created effects are ready
  106250. * @returns true if all effects are ready
  106251. */
  106252. areAllEffectsReady(): boolean;
  106253. protected _rebuildBuffers(): void;
  106254. protected _initGLContext(): void;
  106255. /**
  106256. * Gets version of the current webGL context
  106257. */
  106258. get webGLVersion(): number;
  106259. /**
  106260. * Gets a string idenfifying the name of the class
  106261. * @returns "Engine" string
  106262. */
  106263. getClassName(): string;
  106264. /**
  106265. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  106266. */
  106267. get isStencilEnable(): boolean;
  106268. /** @hidden */
  106269. _prepareWorkingCanvas(): void;
  106270. /**
  106271. * Reset the texture cache to empty state
  106272. */
  106273. resetTextureCache(): void;
  106274. /**
  106275. * Gets an object containing information about the current webGL context
  106276. * @returns an object containing the vender, the renderer and the version of the current webGL context
  106277. */
  106278. getGlInfo(): {
  106279. vendor: string;
  106280. renderer: string;
  106281. version: string;
  106282. };
  106283. /**
  106284. * Defines the hardware scaling level.
  106285. * By default the hardware scaling level is computed from the window device ratio.
  106286. * 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.
  106287. * @param level defines the level to use
  106288. */
  106289. setHardwareScalingLevel(level: number): void;
  106290. /**
  106291. * Gets the current hardware scaling level.
  106292. * By default the hardware scaling level is computed from the window device ratio.
  106293. * 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.
  106294. * @returns a number indicating the current hardware scaling level
  106295. */
  106296. getHardwareScalingLevel(): number;
  106297. /**
  106298. * Gets the list of loaded textures
  106299. * @returns an array containing all loaded textures
  106300. */
  106301. getLoadedTexturesCache(): InternalTexture[];
  106302. /**
  106303. * Gets the object containing all engine capabilities
  106304. * @returns the EngineCapabilities object
  106305. */
  106306. getCaps(): EngineCapabilities;
  106307. /**
  106308. * stop executing a render loop function and remove it from the execution array
  106309. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  106310. */
  106311. stopRenderLoop(renderFunction?: () => void): void;
  106312. /** @hidden */
  106313. _renderLoop(): void;
  106314. /**
  106315. * Gets the HTML canvas attached with the current webGL context
  106316. * @returns a HTML canvas
  106317. */
  106318. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  106319. /**
  106320. * Gets host window
  106321. * @returns the host window object
  106322. */
  106323. getHostWindow(): Nullable<Window>;
  106324. /**
  106325. * Gets the current render width
  106326. * @param useScreen defines if screen size must be used (or the current render target if any)
  106327. * @returns a number defining the current render width
  106328. */
  106329. getRenderWidth(useScreen?: boolean): number;
  106330. /**
  106331. * Gets the current render height
  106332. * @param useScreen defines if screen size must be used (or the current render target if any)
  106333. * @returns a number defining the current render height
  106334. */
  106335. getRenderHeight(useScreen?: boolean): number;
  106336. /**
  106337. * Can be used to override the current requestAnimationFrame requester.
  106338. * @hidden
  106339. */
  106340. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  106341. /**
  106342. * Register and execute a render loop. The engine can have more than one render function
  106343. * @param renderFunction defines the function to continuously execute
  106344. */
  106345. runRenderLoop(renderFunction: () => void): void;
  106346. /**
  106347. * Clear the current render buffer or the current render target (if any is set up)
  106348. * @param color defines the color to use
  106349. * @param backBuffer defines if the back buffer must be cleared
  106350. * @param depth defines if the depth buffer must be cleared
  106351. * @param stencil defines if the stencil buffer must be cleared
  106352. */
  106353. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  106354. private _viewportCached;
  106355. /** @hidden */
  106356. _viewport(x: number, y: number, width: number, height: number): void;
  106357. /**
  106358. * Set the WebGL's viewport
  106359. * @param viewport defines the viewport element to be used
  106360. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  106361. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  106362. */
  106363. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  106364. /**
  106365. * Begin a new frame
  106366. */
  106367. beginFrame(): void;
  106368. /**
  106369. * Enf the current frame
  106370. */
  106371. endFrame(): void;
  106372. /**
  106373. * Resize the view according to the canvas' size
  106374. */
  106375. resize(): void;
  106376. /**
  106377. * Force a specific size of the canvas
  106378. * @param width defines the new canvas' width
  106379. * @param height defines the new canvas' height
  106380. */
  106381. setSize(width: number, height: number): void;
  106382. /**
  106383. * Binds the frame buffer to the specified texture.
  106384. * @param texture The texture to render to or null for the default canvas
  106385. * @param faceIndex The face of the texture to render to in case of cube texture
  106386. * @param requiredWidth The width of the target to render to
  106387. * @param requiredHeight The height of the target to render to
  106388. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  106389. * @param lodLevel defines the lod level to bind to the frame buffer
  106390. * @param layer defines the 2d array index to bind to frame buffer to
  106391. */
  106392. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  106393. /** @hidden */
  106394. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  106395. /**
  106396. * Unbind the current render target texture from the webGL context
  106397. * @param texture defines the render target texture to unbind
  106398. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  106399. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  106400. */
  106401. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  106402. /**
  106403. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  106404. */
  106405. flushFramebuffer(): void;
  106406. /**
  106407. * Unbind the current render target and bind the default framebuffer
  106408. */
  106409. restoreDefaultFramebuffer(): void;
  106410. /** @hidden */
  106411. protected _resetVertexBufferBinding(): void;
  106412. /**
  106413. * Creates a vertex buffer
  106414. * @param data the data for the vertex buffer
  106415. * @returns the new WebGL static buffer
  106416. */
  106417. createVertexBuffer(data: DataArray): DataBuffer;
  106418. private _createVertexBuffer;
  106419. /**
  106420. * Creates a dynamic vertex buffer
  106421. * @param data the data for the dynamic vertex buffer
  106422. * @returns the new WebGL dynamic buffer
  106423. */
  106424. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  106425. protected _resetIndexBufferBinding(): void;
  106426. /**
  106427. * Creates a new index buffer
  106428. * @param indices defines the content of the index buffer
  106429. * @param updatable defines if the index buffer must be updatable
  106430. * @returns a new webGL buffer
  106431. */
  106432. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  106433. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  106434. /**
  106435. * Bind a webGL buffer to the webGL context
  106436. * @param buffer defines the buffer to bind
  106437. */
  106438. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  106439. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  106440. private bindBuffer;
  106441. /**
  106442. * update the bound buffer with the given data
  106443. * @param data defines the data to update
  106444. */
  106445. updateArrayBuffer(data: Float32Array): void;
  106446. private _vertexAttribPointer;
  106447. /** @hidden */
  106448. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  106449. private _bindVertexBuffersAttributes;
  106450. /**
  106451. * Records a vertex array object
  106452. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  106453. * @param vertexBuffers defines the list of vertex buffers to store
  106454. * @param indexBuffer defines the index buffer to store
  106455. * @param effect defines the effect to store
  106456. * @returns the new vertex array object
  106457. */
  106458. recordVertexArrayObject(vertexBuffers: {
  106459. [key: string]: VertexBuffer;
  106460. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  106461. /**
  106462. * Bind a specific vertex array object
  106463. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  106464. * @param vertexArrayObject defines the vertex array object to bind
  106465. * @param indexBuffer defines the index buffer to bind
  106466. */
  106467. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  106468. /**
  106469. * Bind webGl buffers directly to the webGL context
  106470. * @param vertexBuffer defines the vertex buffer to bind
  106471. * @param indexBuffer defines the index buffer to bind
  106472. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  106473. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  106474. * @param effect defines the effect associated with the vertex buffer
  106475. */
  106476. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  106477. private _unbindVertexArrayObject;
  106478. /**
  106479. * Bind a list of vertex buffers to the webGL context
  106480. * @param vertexBuffers defines the list of vertex buffers to bind
  106481. * @param indexBuffer defines the index buffer to bind
  106482. * @param effect defines the effect associated with the vertex buffers
  106483. */
  106484. bindBuffers(vertexBuffers: {
  106485. [key: string]: Nullable<VertexBuffer>;
  106486. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  106487. /**
  106488. * Unbind all instance attributes
  106489. */
  106490. unbindInstanceAttributes(): void;
  106491. /**
  106492. * Release and free the memory of a vertex array object
  106493. * @param vao defines the vertex array object to delete
  106494. */
  106495. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  106496. /** @hidden */
  106497. _releaseBuffer(buffer: DataBuffer): boolean;
  106498. protected _deleteBuffer(buffer: DataBuffer): void;
  106499. /**
  106500. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  106501. * @param instancesBuffer defines the webGL buffer to update and bind
  106502. * @param data defines the data to store in the buffer
  106503. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  106504. */
  106505. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  106506. /**
  106507. * Bind the content of a webGL buffer used with instantiation
  106508. * @param instancesBuffer defines the webGL buffer to bind
  106509. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  106510. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  106511. */
  106512. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  106513. /**
  106514. * Disable the instance attribute corresponding to the name in parameter
  106515. * @param name defines the name of the attribute to disable
  106516. */
  106517. disableInstanceAttributeByName(name: string): void;
  106518. /**
  106519. * Disable the instance attribute corresponding to the location in parameter
  106520. * @param attributeLocation defines the attribute location of the attribute to disable
  106521. */
  106522. disableInstanceAttribute(attributeLocation: number): void;
  106523. /**
  106524. * Disable the attribute corresponding to the location in parameter
  106525. * @param attributeLocation defines the attribute location of the attribute to disable
  106526. */
  106527. disableAttributeByIndex(attributeLocation: number): void;
  106528. /**
  106529. * Send a draw order
  106530. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  106531. * @param indexStart defines the starting index
  106532. * @param indexCount defines the number of index to draw
  106533. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  106534. */
  106535. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  106536. /**
  106537. * Draw a list of points
  106538. * @param verticesStart defines the index of first vertex to draw
  106539. * @param verticesCount defines the count of vertices to draw
  106540. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  106541. */
  106542. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  106543. /**
  106544. * Draw a list of unindexed primitives
  106545. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  106546. * @param verticesStart defines the index of first vertex to draw
  106547. * @param verticesCount defines the count of vertices to draw
  106548. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  106549. */
  106550. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  106551. /**
  106552. * Draw a list of indexed primitives
  106553. * @param fillMode defines the primitive to use
  106554. * @param indexStart defines the starting index
  106555. * @param indexCount defines the number of index to draw
  106556. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  106557. */
  106558. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  106559. /**
  106560. * Draw a list of unindexed primitives
  106561. * @param fillMode defines the primitive to use
  106562. * @param verticesStart defines the index of first vertex to draw
  106563. * @param verticesCount defines the count of vertices to draw
  106564. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  106565. */
  106566. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  106567. private _drawMode;
  106568. /** @hidden */
  106569. protected _reportDrawCall(): void;
  106570. /** @hidden */
  106571. _releaseEffect(effect: Effect): void;
  106572. /** @hidden */
  106573. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  106574. /**
  106575. * Create a new effect (used to store vertex/fragment shaders)
  106576. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  106577. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  106578. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  106579. * @param samplers defines an array of string used to represent textures
  106580. * @param defines defines the string containing the defines to use to compile the shaders
  106581. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  106582. * @param onCompiled defines a function to call when the effect creation is successful
  106583. * @param onError defines a function to call when the effect creation has failed
  106584. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  106585. * @returns the new Effect
  106586. */
  106587. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  106588. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  106589. private _compileShader;
  106590. private _compileRawShader;
  106591. /** @hidden */
  106592. _getShaderSource(shader: WebGLShader): Nullable<string>;
  106593. /**
  106594. * Directly creates a webGL program
  106595. * @param pipelineContext defines the pipeline context to attach to
  106596. * @param vertexCode defines the vertex shader code to use
  106597. * @param fragmentCode defines the fragment shader code to use
  106598. * @param context defines the webGL context to use (if not set, the current one will be used)
  106599. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  106600. * @returns the new webGL program
  106601. */
  106602. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106603. /**
  106604. * Creates a webGL program
  106605. * @param pipelineContext defines the pipeline context to attach to
  106606. * @param vertexCode defines the vertex shader code to use
  106607. * @param fragmentCode defines the fragment shader code to use
  106608. * @param defines defines the string containing the defines to use to compile the shaders
  106609. * @param context defines the webGL context to use (if not set, the current one will be used)
  106610. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  106611. * @returns the new webGL program
  106612. */
  106613. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106614. /**
  106615. * Creates a new pipeline context
  106616. * @returns the new pipeline
  106617. */
  106618. createPipelineContext(): IPipelineContext;
  106619. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106620. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  106621. /** @hidden */
  106622. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  106623. /** @hidden */
  106624. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  106625. /** @hidden */
  106626. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  106627. /**
  106628. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  106629. * @param pipelineContext defines the pipeline context to use
  106630. * @param uniformsNames defines the list of uniform names
  106631. * @returns an array of webGL uniform locations
  106632. */
  106633. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  106634. /**
  106635. * Gets the lsit of active attributes for a given webGL program
  106636. * @param pipelineContext defines the pipeline context to use
  106637. * @param attributesNames defines the list of attribute names to get
  106638. * @returns an array of indices indicating the offset of each attribute
  106639. */
  106640. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  106641. /**
  106642. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  106643. * @param effect defines the effect to activate
  106644. */
  106645. enableEffect(effect: Nullable<Effect>): void;
  106646. /**
  106647. * Set the value of an uniform to a number (int)
  106648. * @param uniform defines the webGL uniform location where to store the value
  106649. * @param value defines the int number to store
  106650. */
  106651. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  106652. /**
  106653. * Set the value of an uniform to an array of int32
  106654. * @param uniform defines the webGL uniform location where to store the value
  106655. * @param array defines the array of int32 to store
  106656. */
  106657. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  106658. /**
  106659. * Set the value of an uniform to an array of int32 (stored as vec2)
  106660. * @param uniform defines the webGL uniform location where to store the value
  106661. * @param array defines the array of int32 to store
  106662. */
  106663. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  106664. /**
  106665. * Set the value of an uniform to an array of int32 (stored as vec3)
  106666. * @param uniform defines the webGL uniform location where to store the value
  106667. * @param array defines the array of int32 to store
  106668. */
  106669. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  106670. /**
  106671. * Set the value of an uniform to an array of int32 (stored as vec4)
  106672. * @param uniform defines the webGL uniform location where to store the value
  106673. * @param array defines the array of int32 to store
  106674. */
  106675. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  106676. /**
  106677. * Set the value of an uniform to an array of number
  106678. * @param uniform defines the webGL uniform location where to store the value
  106679. * @param array defines the array of number to store
  106680. */
  106681. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  106682. /**
  106683. * Set the value of an uniform to an array of number (stored as vec2)
  106684. * @param uniform defines the webGL uniform location where to store the value
  106685. * @param array defines the array of number to store
  106686. */
  106687. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  106688. /**
  106689. * Set the value of an uniform to an array of number (stored as vec3)
  106690. * @param uniform defines the webGL uniform location where to store the value
  106691. * @param array defines the array of number to store
  106692. */
  106693. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  106694. /**
  106695. * Set the value of an uniform to an array of number (stored as vec4)
  106696. * @param uniform defines the webGL uniform location where to store the value
  106697. * @param array defines the array of number to store
  106698. */
  106699. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  106700. /**
  106701. * Set the value of an uniform to an array of float32 (stored as matrices)
  106702. * @param uniform defines the webGL uniform location where to store the value
  106703. * @param matrices defines the array of float32 to store
  106704. */
  106705. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  106706. /**
  106707. * Set the value of an uniform to a matrix (3x3)
  106708. * @param uniform defines the webGL uniform location where to store the value
  106709. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  106710. */
  106711. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  106712. /**
  106713. * Set the value of an uniform to a matrix (2x2)
  106714. * @param uniform defines the webGL uniform location where to store the value
  106715. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  106716. */
  106717. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  106718. /**
  106719. * Set the value of an uniform to a number (float)
  106720. * @param uniform defines the webGL uniform location where to store the value
  106721. * @param value defines the float number to store
  106722. */
  106723. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  106724. /**
  106725. * Set the value of an uniform to a vec2
  106726. * @param uniform defines the webGL uniform location where to store the value
  106727. * @param x defines the 1st component of the value
  106728. * @param y defines the 2nd component of the value
  106729. */
  106730. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  106731. /**
  106732. * Set the value of an uniform to a vec3
  106733. * @param uniform defines the webGL uniform location where to store the value
  106734. * @param x defines the 1st component of the value
  106735. * @param y defines the 2nd component of the value
  106736. * @param z defines the 3rd component of the value
  106737. */
  106738. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  106739. /**
  106740. * Set the value of an uniform to a vec4
  106741. * @param uniform defines the webGL uniform location where to store the value
  106742. * @param x defines the 1st component of the value
  106743. * @param y defines the 2nd component of the value
  106744. * @param z defines the 3rd component of the value
  106745. * @param w defines the 4th component of the value
  106746. */
  106747. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  106748. /**
  106749. * Apply all cached states (depth, culling, stencil and alpha)
  106750. */
  106751. applyStates(): void;
  106752. /**
  106753. * Enable or disable color writing
  106754. * @param enable defines the state to set
  106755. */
  106756. setColorWrite(enable: boolean): void;
  106757. /**
  106758. * Gets a boolean indicating if color writing is enabled
  106759. * @returns the current color writing state
  106760. */
  106761. getColorWrite(): boolean;
  106762. /**
  106763. * Gets the depth culling state manager
  106764. */
  106765. get depthCullingState(): DepthCullingState;
  106766. /**
  106767. * Gets the alpha state manager
  106768. */
  106769. get alphaState(): AlphaState;
  106770. /**
  106771. * Gets the stencil state manager
  106772. */
  106773. get stencilState(): StencilState;
  106774. /**
  106775. * Clears the list of texture accessible through engine.
  106776. * This can help preventing texture load conflict due to name collision.
  106777. */
  106778. clearInternalTexturesCache(): void;
  106779. /**
  106780. * Force the entire cache to be cleared
  106781. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  106782. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  106783. */
  106784. wipeCaches(bruteForce?: boolean): void;
  106785. /** @hidden */
  106786. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  106787. min: number;
  106788. mag: number;
  106789. };
  106790. /** @hidden */
  106791. _createTexture(): WebGLTexture;
  106792. /**
  106793. * Usually called from Texture.ts.
  106794. * Passed information to create a WebGLTexture
  106795. * @param url defines a value which contains one of the following:
  106796. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  106797. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  106798. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  106799. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  106800. * @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)
  106801. * @param scene needed for loading to the correct scene
  106802. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  106803. * @param onLoad optional callback to be called upon successful completion
  106804. * @param onError optional callback to be called upon failure
  106805. * @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
  106806. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  106807. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  106808. * @param forcedExtension defines the extension to use to pick the right loader
  106809. * @param mimeType defines an optional mime type
  106810. * @returns a InternalTexture for assignment back into BABYLON.Texture
  106811. */
  106812. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  106813. /**
  106814. * Loads an image as an HTMLImageElement.
  106815. * @param input url string, ArrayBuffer, or Blob to load
  106816. * @param onLoad callback called when the image successfully loads
  106817. * @param onError callback called when the image fails to load
  106818. * @param offlineProvider offline provider for caching
  106819. * @param mimeType optional mime type
  106820. * @returns the HTMLImageElement of the loaded image
  106821. * @hidden
  106822. */
  106823. static _FileToolsLoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  106824. /**
  106825. * @hidden
  106826. */
  106827. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  106828. private _unpackFlipYCached;
  106829. /**
  106830. * In case you are sharing the context with other applications, it might
  106831. * be interested to not cache the unpack flip y state to ensure a consistent
  106832. * value would be set.
  106833. */
  106834. enableUnpackFlipYCached: boolean;
  106835. /** @hidden */
  106836. _unpackFlipY(value: boolean): void;
  106837. /** @hidden */
  106838. _getUnpackAlignement(): number;
  106839. private _getTextureTarget;
  106840. /**
  106841. * Update the sampling mode of a given texture
  106842. * @param samplingMode defines the required sampling mode
  106843. * @param texture defines the texture to update
  106844. * @param generateMipMaps defines whether to generate mipmaps for the texture
  106845. */
  106846. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  106847. /**
  106848. * Update the sampling mode of a given texture
  106849. * @param texture defines the texture to update
  106850. * @param wrapU defines the texture wrap mode of the u coordinates
  106851. * @param wrapV defines the texture wrap mode of the v coordinates
  106852. * @param wrapR defines the texture wrap mode of the r coordinates
  106853. */
  106854. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  106855. /** @hidden */
  106856. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  106857. width: number;
  106858. height: number;
  106859. layers?: number;
  106860. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  106861. /** @hidden */
  106862. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  106863. /** @hidden */
  106864. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  106865. /**
  106866. * Update a portion of an internal texture
  106867. * @param texture defines the texture to update
  106868. * @param imageData defines the data to store into the texture
  106869. * @param xOffset defines the x coordinates of the update rectangle
  106870. * @param yOffset defines the y coordinates of the update rectangle
  106871. * @param width defines the width of the update rectangle
  106872. * @param height defines the height of the update rectangle
  106873. * @param faceIndex defines the face index if texture is a cube (0 by default)
  106874. * @param lod defines the lod level to update (0 by default)
  106875. */
  106876. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  106877. /** @hidden */
  106878. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  106879. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  106880. private _prepareWebGLTexture;
  106881. /** @hidden */
  106882. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  106883. private _getDepthStencilBuffer;
  106884. /** @hidden */
  106885. _releaseFramebufferObjects(texture: InternalTexture): void;
  106886. /** @hidden */
  106887. _releaseTexture(texture: InternalTexture): void;
  106888. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  106889. protected _setProgram(program: WebGLProgram): void;
  106890. protected _boundUniforms: {
  106891. [key: number]: WebGLUniformLocation;
  106892. };
  106893. /**
  106894. * Binds an effect to the webGL context
  106895. * @param effect defines the effect to bind
  106896. */
  106897. bindSamplers(effect: Effect): void;
  106898. private _activateCurrentTexture;
  106899. /** @hidden */
  106900. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  106901. /** @hidden */
  106902. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  106903. /**
  106904. * Unbind all textures from the webGL context
  106905. */
  106906. unbindAllTextures(): void;
  106907. /**
  106908. * Sets a texture to the according uniform.
  106909. * @param channel The texture channel
  106910. * @param uniform The uniform to set
  106911. * @param texture The texture to apply
  106912. */
  106913. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  106914. private _bindSamplerUniformToChannel;
  106915. private _getTextureWrapMode;
  106916. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  106917. /**
  106918. * Sets an array of texture to the webGL context
  106919. * @param channel defines the channel where the texture array must be set
  106920. * @param uniform defines the associated uniform location
  106921. * @param textures defines the array of textures to bind
  106922. */
  106923. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  106924. /** @hidden */
  106925. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  106926. private _setTextureParameterFloat;
  106927. private _setTextureParameterInteger;
  106928. /**
  106929. * Unbind all vertex attributes from the webGL context
  106930. */
  106931. unbindAllAttributes(): void;
  106932. /**
  106933. * 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
  106934. */
  106935. releaseEffects(): void;
  106936. /**
  106937. * Dispose and release all associated resources
  106938. */
  106939. dispose(): void;
  106940. /**
  106941. * Attach a new callback raised when context lost event is fired
  106942. * @param callback defines the callback to call
  106943. */
  106944. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  106945. /**
  106946. * Attach a new callback raised when context restored event is fired
  106947. * @param callback defines the callback to call
  106948. */
  106949. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  106950. /**
  106951. * Get the current error code of the webGL context
  106952. * @returns the error code
  106953. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  106954. */
  106955. getError(): number;
  106956. private _canRenderToFloatFramebuffer;
  106957. private _canRenderToHalfFloatFramebuffer;
  106958. private _canRenderToFramebuffer;
  106959. /** @hidden */
  106960. _getWebGLTextureType(type: number): number;
  106961. /** @hidden */
  106962. _getInternalFormat(format: number): number;
  106963. /** @hidden */
  106964. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  106965. /** @hidden */
  106966. _getRGBAMultiSampleBufferFormat(type: number): number;
  106967. /** @hidden */
  106968. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  106969. /**
  106970. * Loads a file from a url
  106971. * @param url url to load
  106972. * @param onSuccess callback called when the file successfully loads
  106973. * @param onProgress callback called while file is loading (if the server supports this mode)
  106974. * @param offlineProvider defines the offline provider for caching
  106975. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  106976. * @param onError callback called when the file fails to load
  106977. * @returns a file request object
  106978. * @hidden
  106979. */
  106980. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  106981. /**
  106982. * Reads pixels from the current frame buffer. Please note that this function can be slow
  106983. * @param x defines the x coordinate of the rectangle where pixels must be read
  106984. * @param y defines the y coordinate of the rectangle where pixels must be read
  106985. * @param width defines the width of the rectangle where pixels must be read
  106986. * @param height defines the height of the rectangle where pixels must be read
  106987. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  106988. * @returns a Uint8Array containing RGBA colors
  106989. */
  106990. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  106991. private static _isSupported;
  106992. /**
  106993. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  106994. * @returns true if the engine can be created
  106995. * @ignorenaming
  106996. */
  106997. static isSupported(): boolean;
  106998. /**
  106999. * Find the next highest power of two.
  107000. * @param x Number to start search from.
  107001. * @return Next highest power of two.
  107002. */
  107003. static CeilingPOT(x: number): number;
  107004. /**
  107005. * Find the next lowest power of two.
  107006. * @param x Number to start search from.
  107007. * @return Next lowest power of two.
  107008. */
  107009. static FloorPOT(x: number): number;
  107010. /**
  107011. * Find the nearest power of two.
  107012. * @param x Number to start search from.
  107013. * @return Next nearest power of two.
  107014. */
  107015. static NearestPOT(x: number): number;
  107016. /**
  107017. * Get the closest exponent of two
  107018. * @param value defines the value to approximate
  107019. * @param max defines the maximum value to return
  107020. * @param mode defines how to define the closest value
  107021. * @returns closest exponent of two of the given value
  107022. */
  107023. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  107024. /**
  107025. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  107026. * @param func - the function to be called
  107027. * @param requester - the object that will request the next frame. Falls back to window.
  107028. * @returns frame number
  107029. */
  107030. static QueueNewFrame(func: () => void, requester?: any): number;
  107031. /**
  107032. * Gets host document
  107033. * @returns the host document object
  107034. */
  107035. getHostDocument(): Nullable<Document>;
  107036. }
  107037. }
  107038. declare module BABYLON {
  107039. /**
  107040. * Class representing spherical harmonics coefficients to the 3rd degree
  107041. */
  107042. export class SphericalHarmonics {
  107043. /**
  107044. * Defines whether or not the harmonics have been prescaled for rendering.
  107045. */
  107046. preScaled: boolean;
  107047. /**
  107048. * The l0,0 coefficients of the spherical harmonics
  107049. */
  107050. l00: Vector3;
  107051. /**
  107052. * The l1,-1 coefficients of the spherical harmonics
  107053. */
  107054. l1_1: Vector3;
  107055. /**
  107056. * The l1,0 coefficients of the spherical harmonics
  107057. */
  107058. l10: Vector3;
  107059. /**
  107060. * The l1,1 coefficients of the spherical harmonics
  107061. */
  107062. l11: Vector3;
  107063. /**
  107064. * The l2,-2 coefficients of the spherical harmonics
  107065. */
  107066. l2_2: Vector3;
  107067. /**
  107068. * The l2,-1 coefficients of the spherical harmonics
  107069. */
  107070. l2_1: Vector3;
  107071. /**
  107072. * The l2,0 coefficients of the spherical harmonics
  107073. */
  107074. l20: Vector3;
  107075. /**
  107076. * The l2,1 coefficients of the spherical harmonics
  107077. */
  107078. l21: Vector3;
  107079. /**
  107080. * The l2,2 coefficients of the spherical harmonics
  107081. */
  107082. l22: Vector3;
  107083. /**
  107084. * Adds a light to the spherical harmonics
  107085. * @param direction the direction of the light
  107086. * @param color the color of the light
  107087. * @param deltaSolidAngle the delta solid angle of the light
  107088. */
  107089. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  107090. /**
  107091. * Scales the spherical harmonics by the given amount
  107092. * @param scale the amount to scale
  107093. */
  107094. scaleInPlace(scale: number): void;
  107095. /**
  107096. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  107097. *
  107098. * ```
  107099. * E_lm = A_l * L_lm
  107100. * ```
  107101. *
  107102. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  107103. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  107104. * the scaling factors are given in equation 9.
  107105. */
  107106. convertIncidentRadianceToIrradiance(): void;
  107107. /**
  107108. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  107109. *
  107110. * ```
  107111. * L = (1/pi) * E * rho
  107112. * ```
  107113. *
  107114. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  107115. */
  107116. convertIrradianceToLambertianRadiance(): void;
  107117. /**
  107118. * Integrates the reconstruction coefficients directly in to the SH preventing further
  107119. * required operations at run time.
  107120. *
  107121. * This is simply done by scaling back the SH with Ylm constants parameter.
  107122. * The trigonometric part being applied by the shader at run time.
  107123. */
  107124. preScaleForRendering(): void;
  107125. /**
  107126. * Constructs a spherical harmonics from an array.
  107127. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  107128. * @returns the spherical harmonics
  107129. */
  107130. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  107131. /**
  107132. * Gets the spherical harmonics from polynomial
  107133. * @param polynomial the spherical polynomial
  107134. * @returns the spherical harmonics
  107135. */
  107136. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  107137. }
  107138. /**
  107139. * Class representing spherical polynomial coefficients to the 3rd degree
  107140. */
  107141. export class SphericalPolynomial {
  107142. private _harmonics;
  107143. /**
  107144. * The spherical harmonics used to create the polynomials.
  107145. */
  107146. get preScaledHarmonics(): SphericalHarmonics;
  107147. /**
  107148. * The x coefficients of the spherical polynomial
  107149. */
  107150. x: Vector3;
  107151. /**
  107152. * The y coefficients of the spherical polynomial
  107153. */
  107154. y: Vector3;
  107155. /**
  107156. * The z coefficients of the spherical polynomial
  107157. */
  107158. z: Vector3;
  107159. /**
  107160. * The xx coefficients of the spherical polynomial
  107161. */
  107162. xx: Vector3;
  107163. /**
  107164. * The yy coefficients of the spherical polynomial
  107165. */
  107166. yy: Vector3;
  107167. /**
  107168. * The zz coefficients of the spherical polynomial
  107169. */
  107170. zz: Vector3;
  107171. /**
  107172. * The xy coefficients of the spherical polynomial
  107173. */
  107174. xy: Vector3;
  107175. /**
  107176. * The yz coefficients of the spherical polynomial
  107177. */
  107178. yz: Vector3;
  107179. /**
  107180. * The zx coefficients of the spherical polynomial
  107181. */
  107182. zx: Vector3;
  107183. /**
  107184. * Adds an ambient color to the spherical polynomial
  107185. * @param color the color to add
  107186. */
  107187. addAmbient(color: Color3): void;
  107188. /**
  107189. * Scales the spherical polynomial by the given amount
  107190. * @param scale the amount to scale
  107191. */
  107192. scaleInPlace(scale: number): void;
  107193. /**
  107194. * Gets the spherical polynomial from harmonics
  107195. * @param harmonics the spherical harmonics
  107196. * @returns the spherical polynomial
  107197. */
  107198. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  107199. /**
  107200. * Constructs a spherical polynomial from an array.
  107201. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  107202. * @returns the spherical polynomial
  107203. */
  107204. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  107205. }
  107206. }
  107207. declare module BABYLON {
  107208. /**
  107209. * Defines the source of the internal texture
  107210. */
  107211. export enum InternalTextureSource {
  107212. /**
  107213. * The source of the texture data is unknown
  107214. */
  107215. Unknown = 0,
  107216. /**
  107217. * Texture data comes from an URL
  107218. */
  107219. Url = 1,
  107220. /**
  107221. * Texture data is only used for temporary storage
  107222. */
  107223. Temp = 2,
  107224. /**
  107225. * Texture data comes from raw data (ArrayBuffer)
  107226. */
  107227. Raw = 3,
  107228. /**
  107229. * Texture content is dynamic (video or dynamic texture)
  107230. */
  107231. Dynamic = 4,
  107232. /**
  107233. * Texture content is generated by rendering to it
  107234. */
  107235. RenderTarget = 5,
  107236. /**
  107237. * Texture content is part of a multi render target process
  107238. */
  107239. MultiRenderTarget = 6,
  107240. /**
  107241. * Texture data comes from a cube data file
  107242. */
  107243. Cube = 7,
  107244. /**
  107245. * Texture data comes from a raw cube data
  107246. */
  107247. CubeRaw = 8,
  107248. /**
  107249. * Texture data come from a prefiltered cube data file
  107250. */
  107251. CubePrefiltered = 9,
  107252. /**
  107253. * Texture content is raw 3D data
  107254. */
  107255. Raw3D = 10,
  107256. /**
  107257. * Texture content is raw 2D array data
  107258. */
  107259. Raw2DArray = 11,
  107260. /**
  107261. * Texture content is a depth texture
  107262. */
  107263. Depth = 12,
  107264. /**
  107265. * Texture data comes from a raw cube data encoded with RGBD
  107266. */
  107267. CubeRawRGBD = 13
  107268. }
  107269. /**
  107270. * Class used to store data associated with WebGL texture data for the engine
  107271. * This class should not be used directly
  107272. */
  107273. export class InternalTexture {
  107274. /** @hidden */
  107275. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  107276. /**
  107277. * Defines if the texture is ready
  107278. */
  107279. isReady: boolean;
  107280. /**
  107281. * Defines if the texture is a cube texture
  107282. */
  107283. isCube: boolean;
  107284. /**
  107285. * Defines if the texture contains 3D data
  107286. */
  107287. is3D: boolean;
  107288. /**
  107289. * Defines if the texture contains 2D array data
  107290. */
  107291. is2DArray: boolean;
  107292. /**
  107293. * Defines if the texture contains multiview data
  107294. */
  107295. isMultiview: boolean;
  107296. /**
  107297. * Gets the URL used to load this texture
  107298. */
  107299. url: string;
  107300. /**
  107301. * Gets the sampling mode of the texture
  107302. */
  107303. samplingMode: number;
  107304. /**
  107305. * Gets a boolean indicating if the texture needs mipmaps generation
  107306. */
  107307. generateMipMaps: boolean;
  107308. /**
  107309. * Gets the number of samples used by the texture (WebGL2+ only)
  107310. */
  107311. samples: number;
  107312. /**
  107313. * Gets the type of the texture (int, float...)
  107314. */
  107315. type: number;
  107316. /**
  107317. * Gets the format of the texture (RGB, RGBA...)
  107318. */
  107319. format: number;
  107320. /**
  107321. * Observable called when the texture is loaded
  107322. */
  107323. onLoadedObservable: Observable<InternalTexture>;
  107324. /**
  107325. * Gets the width of the texture
  107326. */
  107327. width: number;
  107328. /**
  107329. * Gets the height of the texture
  107330. */
  107331. height: number;
  107332. /**
  107333. * Gets the depth of the texture
  107334. */
  107335. depth: number;
  107336. /**
  107337. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  107338. */
  107339. baseWidth: number;
  107340. /**
  107341. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  107342. */
  107343. baseHeight: number;
  107344. /**
  107345. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  107346. */
  107347. baseDepth: number;
  107348. /**
  107349. * Gets a boolean indicating if the texture is inverted on Y axis
  107350. */
  107351. invertY: boolean;
  107352. /** @hidden */
  107353. _invertVScale: boolean;
  107354. /** @hidden */
  107355. _associatedChannel: number;
  107356. /** @hidden */
  107357. _source: InternalTextureSource;
  107358. /** @hidden */
  107359. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  107360. /** @hidden */
  107361. _bufferView: Nullable<ArrayBufferView>;
  107362. /** @hidden */
  107363. _bufferViewArray: Nullable<ArrayBufferView[]>;
  107364. /** @hidden */
  107365. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  107366. /** @hidden */
  107367. _size: number;
  107368. /** @hidden */
  107369. _extension: string;
  107370. /** @hidden */
  107371. _files: Nullable<string[]>;
  107372. /** @hidden */
  107373. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  107374. /** @hidden */
  107375. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  107376. /** @hidden */
  107377. _framebuffer: Nullable<WebGLFramebuffer>;
  107378. /** @hidden */
  107379. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  107380. /** @hidden */
  107381. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  107382. /** @hidden */
  107383. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  107384. /** @hidden */
  107385. _attachments: Nullable<number[]>;
  107386. /** @hidden */
  107387. _cachedCoordinatesMode: Nullable<number>;
  107388. /** @hidden */
  107389. _cachedWrapU: Nullable<number>;
  107390. /** @hidden */
  107391. _cachedWrapV: Nullable<number>;
  107392. /** @hidden */
  107393. _cachedWrapR: Nullable<number>;
  107394. /** @hidden */
  107395. _cachedAnisotropicFilteringLevel: Nullable<number>;
  107396. /** @hidden */
  107397. _isDisabled: boolean;
  107398. /** @hidden */
  107399. _compression: Nullable<string>;
  107400. /** @hidden */
  107401. _generateStencilBuffer: boolean;
  107402. /** @hidden */
  107403. _generateDepthBuffer: boolean;
  107404. /** @hidden */
  107405. _comparisonFunction: number;
  107406. /** @hidden */
  107407. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  107408. /** @hidden */
  107409. _lodGenerationScale: number;
  107410. /** @hidden */
  107411. _lodGenerationOffset: number;
  107412. /** @hidden */
  107413. _depthStencilTexture: Nullable<InternalTexture>;
  107414. /** @hidden */
  107415. _colorTextureArray: Nullable<WebGLTexture>;
  107416. /** @hidden */
  107417. _depthStencilTextureArray: Nullable<WebGLTexture>;
  107418. /** @hidden */
  107419. _lodTextureHigh: Nullable<BaseTexture>;
  107420. /** @hidden */
  107421. _lodTextureMid: Nullable<BaseTexture>;
  107422. /** @hidden */
  107423. _lodTextureLow: Nullable<BaseTexture>;
  107424. /** @hidden */
  107425. _isRGBD: boolean;
  107426. /** @hidden */
  107427. _linearSpecularLOD: boolean;
  107428. /** @hidden */
  107429. _irradianceTexture: Nullable<BaseTexture>;
  107430. /** @hidden */
  107431. _webGLTexture: Nullable<WebGLTexture>;
  107432. /** @hidden */
  107433. _references: number;
  107434. private _engine;
  107435. /**
  107436. * Gets the Engine the texture belongs to.
  107437. * @returns The babylon engine
  107438. */
  107439. getEngine(): ThinEngine;
  107440. /**
  107441. * Gets the data source type of the texture
  107442. */
  107443. get source(): InternalTextureSource;
  107444. /**
  107445. * Creates a new InternalTexture
  107446. * @param engine defines the engine to use
  107447. * @param source defines the type of data that will be used
  107448. * @param delayAllocation if the texture allocation should be delayed (default: false)
  107449. */
  107450. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  107451. /**
  107452. * Increments the number of references (ie. the number of Texture that point to it)
  107453. */
  107454. incrementReferences(): void;
  107455. /**
  107456. * Change the size of the texture (not the size of the content)
  107457. * @param width defines the new width
  107458. * @param height defines the new height
  107459. * @param depth defines the new depth (1 by default)
  107460. */
  107461. updateSize(width: int, height: int, depth?: int): void;
  107462. /** @hidden */
  107463. _rebuild(): void;
  107464. /** @hidden */
  107465. _swapAndDie(target: InternalTexture): void;
  107466. /**
  107467. * Dispose the current allocated resources
  107468. */
  107469. dispose(): void;
  107470. }
  107471. }
  107472. declare module BABYLON {
  107473. /**
  107474. * Class used to work with sound analyzer using fast fourier transform (FFT)
  107475. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107476. */
  107477. export class Analyser {
  107478. /**
  107479. * Gets or sets the smoothing
  107480. * @ignorenaming
  107481. */
  107482. SMOOTHING: number;
  107483. /**
  107484. * Gets or sets the FFT table size
  107485. * @ignorenaming
  107486. */
  107487. FFT_SIZE: number;
  107488. /**
  107489. * Gets or sets the bar graph amplitude
  107490. * @ignorenaming
  107491. */
  107492. BARGRAPHAMPLITUDE: number;
  107493. /**
  107494. * Gets or sets the position of the debug canvas
  107495. * @ignorenaming
  107496. */
  107497. DEBUGCANVASPOS: {
  107498. x: number;
  107499. y: number;
  107500. };
  107501. /**
  107502. * Gets or sets the debug canvas size
  107503. * @ignorenaming
  107504. */
  107505. DEBUGCANVASSIZE: {
  107506. width: number;
  107507. height: number;
  107508. };
  107509. private _byteFreqs;
  107510. private _byteTime;
  107511. private _floatFreqs;
  107512. private _webAudioAnalyser;
  107513. private _debugCanvas;
  107514. private _debugCanvasContext;
  107515. private _scene;
  107516. private _registerFunc;
  107517. private _audioEngine;
  107518. /**
  107519. * Creates a new analyser
  107520. * @param scene defines hosting scene
  107521. */
  107522. constructor(scene: Scene);
  107523. /**
  107524. * Get the number of data values you will have to play with for the visualization
  107525. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  107526. * @returns a number
  107527. */
  107528. getFrequencyBinCount(): number;
  107529. /**
  107530. * Gets the current frequency data as a byte array
  107531. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  107532. * @returns a Uint8Array
  107533. */
  107534. getByteFrequencyData(): Uint8Array;
  107535. /**
  107536. * Gets the current waveform as a byte array
  107537. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  107538. * @returns a Uint8Array
  107539. */
  107540. getByteTimeDomainData(): Uint8Array;
  107541. /**
  107542. * Gets the current frequency data as a float array
  107543. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  107544. * @returns a Float32Array
  107545. */
  107546. getFloatFrequencyData(): Float32Array;
  107547. /**
  107548. * Renders the debug canvas
  107549. */
  107550. drawDebugCanvas(): void;
  107551. /**
  107552. * Stops rendering the debug canvas and removes it
  107553. */
  107554. stopDebugCanvas(): void;
  107555. /**
  107556. * Connects two audio nodes
  107557. * @param inputAudioNode defines first node to connect
  107558. * @param outputAudioNode defines second node to connect
  107559. */
  107560. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  107561. /**
  107562. * Releases all associated resources
  107563. */
  107564. dispose(): void;
  107565. }
  107566. }
  107567. declare module BABYLON {
  107568. /**
  107569. * This represents an audio engine and it is responsible
  107570. * to play, synchronize and analyse sounds throughout the application.
  107571. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107572. */
  107573. export interface IAudioEngine extends IDisposable {
  107574. /**
  107575. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  107576. */
  107577. readonly canUseWebAudio: boolean;
  107578. /**
  107579. * Gets the current AudioContext if available.
  107580. */
  107581. readonly audioContext: Nullable<AudioContext>;
  107582. /**
  107583. * The master gain node defines the global audio volume of your audio engine.
  107584. */
  107585. readonly masterGain: GainNode;
  107586. /**
  107587. * Gets whether or not mp3 are supported by your browser.
  107588. */
  107589. readonly isMP3supported: boolean;
  107590. /**
  107591. * Gets whether or not ogg are supported by your browser.
  107592. */
  107593. readonly isOGGsupported: boolean;
  107594. /**
  107595. * Defines if Babylon should emit a warning if WebAudio is not supported.
  107596. * @ignoreNaming
  107597. */
  107598. WarnedWebAudioUnsupported: boolean;
  107599. /**
  107600. * Defines if the audio engine relies on a custom unlocked button.
  107601. * In this case, the embedded button will not be displayed.
  107602. */
  107603. useCustomUnlockedButton: boolean;
  107604. /**
  107605. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  107606. */
  107607. readonly unlocked: boolean;
  107608. /**
  107609. * Event raised when audio has been unlocked on the browser.
  107610. */
  107611. onAudioUnlockedObservable: Observable<AudioEngine>;
  107612. /**
  107613. * Event raised when audio has been locked on the browser.
  107614. */
  107615. onAudioLockedObservable: Observable<AudioEngine>;
  107616. /**
  107617. * Flags the audio engine in Locked state.
  107618. * This happens due to new browser policies preventing audio to autoplay.
  107619. */
  107620. lock(): void;
  107621. /**
  107622. * Unlocks the audio engine once a user action has been done on the dom.
  107623. * This is helpful to resume play once browser policies have been satisfied.
  107624. */
  107625. unlock(): void;
  107626. /**
  107627. * Gets the global volume sets on the master gain.
  107628. * @returns the global volume if set or -1 otherwise
  107629. */
  107630. getGlobalVolume(): number;
  107631. /**
  107632. * Sets the global volume of your experience (sets on the master gain).
  107633. * @param newVolume Defines the new global volume of the application
  107634. */
  107635. setGlobalVolume(newVolume: number): void;
  107636. /**
  107637. * Connect the audio engine to an audio analyser allowing some amazing
  107638. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  107639. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  107640. * @param analyser The analyser to connect to the engine
  107641. */
  107642. connectToAnalyser(analyser: Analyser): void;
  107643. }
  107644. /**
  107645. * This represents the default audio engine used in babylon.
  107646. * It is responsible to play, synchronize and analyse sounds throughout the application.
  107647. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107648. */
  107649. export class AudioEngine implements IAudioEngine {
  107650. private _audioContext;
  107651. private _audioContextInitialized;
  107652. private _muteButton;
  107653. private _hostElement;
  107654. /**
  107655. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  107656. */
  107657. canUseWebAudio: boolean;
  107658. /**
  107659. * The master gain node defines the global audio volume of your audio engine.
  107660. */
  107661. masterGain: GainNode;
  107662. /**
  107663. * Defines if Babylon should emit a warning if WebAudio is not supported.
  107664. * @ignoreNaming
  107665. */
  107666. WarnedWebAudioUnsupported: boolean;
  107667. /**
  107668. * Gets whether or not mp3 are supported by your browser.
  107669. */
  107670. isMP3supported: boolean;
  107671. /**
  107672. * Gets whether or not ogg are supported by your browser.
  107673. */
  107674. isOGGsupported: boolean;
  107675. /**
  107676. * Gets whether audio has been unlocked on the device.
  107677. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  107678. * a user interaction has happened.
  107679. */
  107680. unlocked: boolean;
  107681. /**
  107682. * Defines if the audio engine relies on a custom unlocked button.
  107683. * In this case, the embedded button will not be displayed.
  107684. */
  107685. useCustomUnlockedButton: boolean;
  107686. /**
  107687. * Event raised when audio has been unlocked on the browser.
  107688. */
  107689. onAudioUnlockedObservable: Observable<AudioEngine>;
  107690. /**
  107691. * Event raised when audio has been locked on the browser.
  107692. */
  107693. onAudioLockedObservable: Observable<AudioEngine>;
  107694. /**
  107695. * Gets the current AudioContext if available.
  107696. */
  107697. get audioContext(): Nullable<AudioContext>;
  107698. private _connectedAnalyser;
  107699. /**
  107700. * Instantiates a new audio engine.
  107701. *
  107702. * There should be only one per page as some browsers restrict the number
  107703. * of audio contexts you can create.
  107704. * @param hostElement defines the host element where to display the mute icon if necessary
  107705. */
  107706. constructor(hostElement?: Nullable<HTMLElement>);
  107707. /**
  107708. * Flags the audio engine in Locked state.
  107709. * This happens due to new browser policies preventing audio to autoplay.
  107710. */
  107711. lock(): void;
  107712. /**
  107713. * Unlocks the audio engine once a user action has been done on the dom.
  107714. * This is helpful to resume play once browser policies have been satisfied.
  107715. */
  107716. unlock(): void;
  107717. private _resumeAudioContext;
  107718. private _initializeAudioContext;
  107719. private _tryToRun;
  107720. private _triggerRunningState;
  107721. private _triggerSuspendedState;
  107722. private _displayMuteButton;
  107723. private _moveButtonToTopLeft;
  107724. private _onResize;
  107725. private _hideMuteButton;
  107726. /**
  107727. * Destroy and release the resources associated with the audio ccontext.
  107728. */
  107729. dispose(): void;
  107730. /**
  107731. * Gets the global volume sets on the master gain.
  107732. * @returns the global volume if set or -1 otherwise
  107733. */
  107734. getGlobalVolume(): number;
  107735. /**
  107736. * Sets the global volume of your experience (sets on the master gain).
  107737. * @param newVolume Defines the new global volume of the application
  107738. */
  107739. setGlobalVolume(newVolume: number): void;
  107740. /**
  107741. * Connect the audio engine to an audio analyser allowing some amazing
  107742. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  107743. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  107744. * @param analyser The analyser to connect to the engine
  107745. */
  107746. connectToAnalyser(analyser: Analyser): void;
  107747. }
  107748. }
  107749. declare module BABYLON {
  107750. /**
  107751. * Interface used to present a loading screen while loading a scene
  107752. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107753. */
  107754. export interface ILoadingScreen {
  107755. /**
  107756. * Function called to display the loading screen
  107757. */
  107758. displayLoadingUI: () => void;
  107759. /**
  107760. * Function called to hide the loading screen
  107761. */
  107762. hideLoadingUI: () => void;
  107763. /**
  107764. * Gets or sets the color to use for the background
  107765. */
  107766. loadingUIBackgroundColor: string;
  107767. /**
  107768. * Gets or sets the text to display while loading
  107769. */
  107770. loadingUIText: string;
  107771. }
  107772. /**
  107773. * Class used for the default loading screen
  107774. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107775. */
  107776. export class DefaultLoadingScreen implements ILoadingScreen {
  107777. private _renderingCanvas;
  107778. private _loadingText;
  107779. private _loadingDivBackgroundColor;
  107780. private _loadingDiv;
  107781. private _loadingTextDiv;
  107782. /** Gets or sets the logo url to use for the default loading screen */
  107783. static DefaultLogoUrl: string;
  107784. /** Gets or sets the spinner url to use for the default loading screen */
  107785. static DefaultSpinnerUrl: string;
  107786. /**
  107787. * Creates a new default loading screen
  107788. * @param _renderingCanvas defines the canvas used to render the scene
  107789. * @param _loadingText defines the default text to display
  107790. * @param _loadingDivBackgroundColor defines the default background color
  107791. */
  107792. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  107793. /**
  107794. * Function called to display the loading screen
  107795. */
  107796. displayLoadingUI(): void;
  107797. /**
  107798. * Function called to hide the loading screen
  107799. */
  107800. hideLoadingUI(): void;
  107801. /**
  107802. * Gets or sets the text to display while loading
  107803. */
  107804. set loadingUIText(text: string);
  107805. get loadingUIText(): string;
  107806. /**
  107807. * Gets or sets the color to use for the background
  107808. */
  107809. get loadingUIBackgroundColor(): string;
  107810. set loadingUIBackgroundColor(color: string);
  107811. private _resizeLoadingUI;
  107812. }
  107813. }
  107814. declare module BABYLON {
  107815. /**
  107816. * Interface for any object that can request an animation frame
  107817. */
  107818. export interface ICustomAnimationFrameRequester {
  107819. /**
  107820. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  107821. */
  107822. renderFunction?: Function;
  107823. /**
  107824. * Called to request the next frame to render to
  107825. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  107826. */
  107827. requestAnimationFrame: Function;
  107828. /**
  107829. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  107830. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  107831. */
  107832. requestID?: number;
  107833. }
  107834. }
  107835. declare module BABYLON {
  107836. /**
  107837. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  107838. */
  107839. export class PerformanceMonitor {
  107840. private _enabled;
  107841. private _rollingFrameTime;
  107842. private _lastFrameTimeMs;
  107843. /**
  107844. * constructor
  107845. * @param frameSampleSize The number of samples required to saturate the sliding window
  107846. */
  107847. constructor(frameSampleSize?: number);
  107848. /**
  107849. * Samples current frame
  107850. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  107851. */
  107852. sampleFrame(timeMs?: number): void;
  107853. /**
  107854. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  107855. */
  107856. get averageFrameTime(): number;
  107857. /**
  107858. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  107859. */
  107860. get averageFrameTimeVariance(): number;
  107861. /**
  107862. * Returns the frame time of the most recent frame
  107863. */
  107864. get instantaneousFrameTime(): number;
  107865. /**
  107866. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  107867. */
  107868. get averageFPS(): number;
  107869. /**
  107870. * Returns the average framerate in frames per second using the most recent frame time
  107871. */
  107872. get instantaneousFPS(): number;
  107873. /**
  107874. * Returns true if enough samples have been taken to completely fill the sliding window
  107875. */
  107876. get isSaturated(): boolean;
  107877. /**
  107878. * Enables contributions to the sliding window sample set
  107879. */
  107880. enable(): void;
  107881. /**
  107882. * Disables contributions to the sliding window sample set
  107883. * Samples will not be interpolated over the disabled period
  107884. */
  107885. disable(): void;
  107886. /**
  107887. * Returns true if sampling is enabled
  107888. */
  107889. get isEnabled(): boolean;
  107890. /**
  107891. * Resets performance monitor
  107892. */
  107893. reset(): void;
  107894. }
  107895. /**
  107896. * RollingAverage
  107897. *
  107898. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  107899. */
  107900. export class RollingAverage {
  107901. /**
  107902. * Current average
  107903. */
  107904. average: number;
  107905. /**
  107906. * Current variance
  107907. */
  107908. variance: number;
  107909. protected _samples: Array<number>;
  107910. protected _sampleCount: number;
  107911. protected _pos: number;
  107912. protected _m2: number;
  107913. /**
  107914. * constructor
  107915. * @param length The number of samples required to saturate the sliding window
  107916. */
  107917. constructor(length: number);
  107918. /**
  107919. * Adds a sample to the sample set
  107920. * @param v The sample value
  107921. */
  107922. add(v: number): void;
  107923. /**
  107924. * Returns previously added values or null if outside of history or outside the sliding window domain
  107925. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  107926. * @return Value previously recorded with add() or null if outside of range
  107927. */
  107928. history(i: number): number;
  107929. /**
  107930. * Returns true if enough samples have been taken to completely fill the sliding window
  107931. * @return true if sample-set saturated
  107932. */
  107933. isSaturated(): boolean;
  107934. /**
  107935. * Resets the rolling average (equivalent to 0 samples taken so far)
  107936. */
  107937. reset(): void;
  107938. /**
  107939. * Wraps a value around the sample range boundaries
  107940. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  107941. * @return Wrapped position in sample range
  107942. */
  107943. protected _wrapPosition(i: number): number;
  107944. }
  107945. }
  107946. declare module BABYLON {
  107947. /**
  107948. * This class is used to track a performance counter which is number based.
  107949. * The user has access to many properties which give statistics of different nature.
  107950. *
  107951. * The implementer can track two kinds of Performance Counter: time and count.
  107952. * 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.
  107953. * 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.
  107954. */
  107955. export class PerfCounter {
  107956. /**
  107957. * Gets or sets a global boolean to turn on and off all the counters
  107958. */
  107959. static Enabled: boolean;
  107960. /**
  107961. * Returns the smallest value ever
  107962. */
  107963. get min(): number;
  107964. /**
  107965. * Returns the biggest value ever
  107966. */
  107967. get max(): number;
  107968. /**
  107969. * Returns the average value since the performance counter is running
  107970. */
  107971. get average(): number;
  107972. /**
  107973. * Returns the average value of the last second the counter was monitored
  107974. */
  107975. get lastSecAverage(): number;
  107976. /**
  107977. * Returns the current value
  107978. */
  107979. get current(): number;
  107980. /**
  107981. * Gets the accumulated total
  107982. */
  107983. get total(): number;
  107984. /**
  107985. * Gets the total value count
  107986. */
  107987. get count(): number;
  107988. /**
  107989. * Creates a new counter
  107990. */
  107991. constructor();
  107992. /**
  107993. * Call this method to start monitoring a new frame.
  107994. * 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.
  107995. */
  107996. fetchNewFrame(): void;
  107997. /**
  107998. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  107999. * @param newCount the count value to add to the monitored count
  108000. * @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.
  108001. */
  108002. addCount(newCount: number, fetchResult: boolean): void;
  108003. /**
  108004. * Start monitoring this performance counter
  108005. */
  108006. beginMonitoring(): void;
  108007. /**
  108008. * Compute the time lapsed since the previous beginMonitoring() call.
  108009. * @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
  108010. */
  108011. endMonitoring(newFrame?: boolean): void;
  108012. private _fetchResult;
  108013. private _startMonitoringTime;
  108014. private _min;
  108015. private _max;
  108016. private _average;
  108017. private _current;
  108018. private _totalValueCount;
  108019. private _totalAccumulated;
  108020. private _lastSecAverage;
  108021. private _lastSecAccumulated;
  108022. private _lastSecTime;
  108023. private _lastSecValueCount;
  108024. }
  108025. }
  108026. declare module BABYLON {
  108027. interface ThinEngine {
  108028. /**
  108029. * Sets alpha constants used by some alpha blending modes
  108030. * @param r defines the red component
  108031. * @param g defines the green component
  108032. * @param b defines the blue component
  108033. * @param a defines the alpha component
  108034. */
  108035. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  108036. /**
  108037. * Sets the current alpha mode
  108038. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  108039. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  108040. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  108041. */
  108042. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  108043. /**
  108044. * Gets the current alpha mode
  108045. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  108046. * @returns the current alpha mode
  108047. */
  108048. getAlphaMode(): number;
  108049. /**
  108050. * Sets the current alpha equation
  108051. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  108052. */
  108053. setAlphaEquation(equation: number): void;
  108054. /**
  108055. * Gets the current alpha equation.
  108056. * @returns the current alpha equation
  108057. */
  108058. getAlphaEquation(): number;
  108059. }
  108060. }
  108061. declare module BABYLON {
  108062. /**
  108063. * Defines the interface used by display changed events
  108064. */
  108065. export interface IDisplayChangedEventArgs {
  108066. /** Gets the vrDisplay object (if any) */
  108067. vrDisplay: Nullable<any>;
  108068. /** Gets a boolean indicating if webVR is supported */
  108069. vrSupported: boolean;
  108070. }
  108071. /**
  108072. * Defines the interface used by objects containing a viewport (like a camera)
  108073. */
  108074. interface IViewportOwnerLike {
  108075. /**
  108076. * Gets or sets the viewport
  108077. */
  108078. viewport: IViewportLike;
  108079. }
  108080. /**
  108081. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  108082. */
  108083. export class Engine extends ThinEngine {
  108084. /** Defines that alpha blending is disabled */
  108085. static readonly ALPHA_DISABLE: number;
  108086. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  108087. static readonly ALPHA_ADD: number;
  108088. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  108089. static readonly ALPHA_COMBINE: number;
  108090. /** Defines that alpha blending to DEST - SRC * DEST */
  108091. static readonly ALPHA_SUBTRACT: number;
  108092. /** Defines that alpha blending to SRC * DEST */
  108093. static readonly ALPHA_MULTIPLY: number;
  108094. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  108095. static readonly ALPHA_MAXIMIZED: number;
  108096. /** Defines that alpha blending to SRC + DEST */
  108097. static readonly ALPHA_ONEONE: number;
  108098. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  108099. static readonly ALPHA_PREMULTIPLIED: number;
  108100. /**
  108101. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  108102. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  108103. */
  108104. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  108105. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  108106. static readonly ALPHA_INTERPOLATE: number;
  108107. /**
  108108. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  108109. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  108110. */
  108111. static readonly ALPHA_SCREENMODE: number;
  108112. /** Defines that the ressource is not delayed*/
  108113. static readonly DELAYLOADSTATE_NONE: number;
  108114. /** Defines that the ressource was successfully delay loaded */
  108115. static readonly DELAYLOADSTATE_LOADED: number;
  108116. /** Defines that the ressource is currently delay loading */
  108117. static readonly DELAYLOADSTATE_LOADING: number;
  108118. /** Defines that the ressource is delayed and has not started loading */
  108119. static readonly DELAYLOADSTATE_NOTLOADED: number;
  108120. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  108121. static readonly NEVER: number;
  108122. /** 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 */
  108123. static readonly ALWAYS: number;
  108124. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  108125. static readonly LESS: number;
  108126. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  108127. static readonly EQUAL: number;
  108128. /** 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 */
  108129. static readonly LEQUAL: number;
  108130. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  108131. static readonly GREATER: number;
  108132. /** 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 */
  108133. static readonly GEQUAL: number;
  108134. /** 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 */
  108135. static readonly NOTEQUAL: number;
  108136. /** Passed to stencilOperation to specify that stencil value must be kept */
  108137. static readonly KEEP: number;
  108138. /** Passed to stencilOperation to specify that stencil value must be replaced */
  108139. static readonly REPLACE: number;
  108140. /** Passed to stencilOperation to specify that stencil value must be incremented */
  108141. static readonly INCR: number;
  108142. /** Passed to stencilOperation to specify that stencil value must be decremented */
  108143. static readonly DECR: number;
  108144. /** Passed to stencilOperation to specify that stencil value must be inverted */
  108145. static readonly INVERT: number;
  108146. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  108147. static readonly INCR_WRAP: number;
  108148. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  108149. static readonly DECR_WRAP: number;
  108150. /** Texture is not repeating outside of 0..1 UVs */
  108151. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  108152. /** Texture is repeating outside of 0..1 UVs */
  108153. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  108154. /** Texture is repeating and mirrored */
  108155. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  108156. /** ALPHA */
  108157. static readonly TEXTUREFORMAT_ALPHA: number;
  108158. /** LUMINANCE */
  108159. static readonly TEXTUREFORMAT_LUMINANCE: number;
  108160. /** LUMINANCE_ALPHA */
  108161. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  108162. /** RGB */
  108163. static readonly TEXTUREFORMAT_RGB: number;
  108164. /** RGBA */
  108165. static readonly TEXTUREFORMAT_RGBA: number;
  108166. /** RED */
  108167. static readonly TEXTUREFORMAT_RED: number;
  108168. /** RED (2nd reference) */
  108169. static readonly TEXTUREFORMAT_R: number;
  108170. /** RG */
  108171. static readonly TEXTUREFORMAT_RG: number;
  108172. /** RED_INTEGER */
  108173. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  108174. /** RED_INTEGER (2nd reference) */
  108175. static readonly TEXTUREFORMAT_R_INTEGER: number;
  108176. /** RG_INTEGER */
  108177. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  108178. /** RGB_INTEGER */
  108179. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  108180. /** RGBA_INTEGER */
  108181. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  108182. /** UNSIGNED_BYTE */
  108183. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  108184. /** UNSIGNED_BYTE (2nd reference) */
  108185. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  108186. /** FLOAT */
  108187. static readonly TEXTURETYPE_FLOAT: number;
  108188. /** HALF_FLOAT */
  108189. static readonly TEXTURETYPE_HALF_FLOAT: number;
  108190. /** BYTE */
  108191. static readonly TEXTURETYPE_BYTE: number;
  108192. /** SHORT */
  108193. static readonly TEXTURETYPE_SHORT: number;
  108194. /** UNSIGNED_SHORT */
  108195. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  108196. /** INT */
  108197. static readonly TEXTURETYPE_INT: number;
  108198. /** UNSIGNED_INT */
  108199. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  108200. /** UNSIGNED_SHORT_4_4_4_4 */
  108201. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  108202. /** UNSIGNED_SHORT_5_5_5_1 */
  108203. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  108204. /** UNSIGNED_SHORT_5_6_5 */
  108205. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  108206. /** UNSIGNED_INT_2_10_10_10_REV */
  108207. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  108208. /** UNSIGNED_INT_24_8 */
  108209. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  108210. /** UNSIGNED_INT_10F_11F_11F_REV */
  108211. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  108212. /** UNSIGNED_INT_5_9_9_9_REV */
  108213. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  108214. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  108215. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  108216. /** nearest is mag = nearest and min = nearest and mip = linear */
  108217. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  108218. /** Bilinear is mag = linear and min = linear and mip = nearest */
  108219. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  108220. /** Trilinear is mag = linear and min = linear and mip = linear */
  108221. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  108222. /** nearest is mag = nearest and min = nearest and mip = linear */
  108223. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  108224. /** Bilinear is mag = linear and min = linear and mip = nearest */
  108225. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  108226. /** Trilinear is mag = linear and min = linear and mip = linear */
  108227. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  108228. /** mag = nearest and min = nearest and mip = nearest */
  108229. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  108230. /** mag = nearest and min = linear and mip = nearest */
  108231. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  108232. /** mag = nearest and min = linear and mip = linear */
  108233. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  108234. /** mag = nearest and min = linear and mip = none */
  108235. static readonly TEXTURE_NEAREST_LINEAR: number;
  108236. /** mag = nearest and min = nearest and mip = none */
  108237. static readonly TEXTURE_NEAREST_NEAREST: number;
  108238. /** mag = linear and min = nearest and mip = nearest */
  108239. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  108240. /** mag = linear and min = nearest and mip = linear */
  108241. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  108242. /** mag = linear and min = linear and mip = none */
  108243. static readonly TEXTURE_LINEAR_LINEAR: number;
  108244. /** mag = linear and min = nearest and mip = none */
  108245. static readonly TEXTURE_LINEAR_NEAREST: number;
  108246. /** Explicit coordinates mode */
  108247. static readonly TEXTURE_EXPLICIT_MODE: number;
  108248. /** Spherical coordinates mode */
  108249. static readonly TEXTURE_SPHERICAL_MODE: number;
  108250. /** Planar coordinates mode */
  108251. static readonly TEXTURE_PLANAR_MODE: number;
  108252. /** Cubic coordinates mode */
  108253. static readonly TEXTURE_CUBIC_MODE: number;
  108254. /** Projection coordinates mode */
  108255. static readonly TEXTURE_PROJECTION_MODE: number;
  108256. /** Skybox coordinates mode */
  108257. static readonly TEXTURE_SKYBOX_MODE: number;
  108258. /** Inverse Cubic coordinates mode */
  108259. static readonly TEXTURE_INVCUBIC_MODE: number;
  108260. /** Equirectangular coordinates mode */
  108261. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  108262. /** Equirectangular Fixed coordinates mode */
  108263. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  108264. /** Equirectangular Fixed Mirrored coordinates mode */
  108265. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  108266. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  108267. static readonly SCALEMODE_FLOOR: number;
  108268. /** Defines that texture rescaling will look for the nearest power of 2 size */
  108269. static readonly SCALEMODE_NEAREST: number;
  108270. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  108271. static readonly SCALEMODE_CEILING: number;
  108272. /**
  108273. * Returns the current npm package of the sdk
  108274. */
  108275. static get NpmPackage(): string;
  108276. /**
  108277. * Returns the current version of the framework
  108278. */
  108279. static get Version(): string;
  108280. /** Gets the list of created engines */
  108281. static get Instances(): Engine[];
  108282. /**
  108283. * Gets the latest created engine
  108284. */
  108285. static get LastCreatedEngine(): Nullable<Engine>;
  108286. /**
  108287. * Gets the latest created scene
  108288. */
  108289. static get LastCreatedScene(): Nullable<Scene>;
  108290. /**
  108291. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  108292. * @param flag defines which part of the materials must be marked as dirty
  108293. * @param predicate defines a predicate used to filter which materials should be affected
  108294. */
  108295. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  108296. /**
  108297. * Method called to create the default loading screen.
  108298. * This can be overriden in your own app.
  108299. * @param canvas The rendering canvas element
  108300. * @returns The loading screen
  108301. */
  108302. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  108303. /**
  108304. * Method called to create the default rescale post process on each engine.
  108305. */
  108306. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  108307. /**
  108308. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  108309. **/
  108310. enableOfflineSupport: boolean;
  108311. /**
  108312. * 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)
  108313. **/
  108314. disableManifestCheck: boolean;
  108315. /**
  108316. * Gets the list of created scenes
  108317. */
  108318. scenes: Scene[];
  108319. /**
  108320. * Event raised when a new scene is created
  108321. */
  108322. onNewSceneAddedObservable: Observable<Scene>;
  108323. /**
  108324. * Gets the list of created postprocesses
  108325. */
  108326. postProcesses: PostProcess[];
  108327. /**
  108328. * Gets a boolean indicating if the pointer is currently locked
  108329. */
  108330. isPointerLock: boolean;
  108331. /**
  108332. * Observable event triggered each time the rendering canvas is resized
  108333. */
  108334. onResizeObservable: Observable<Engine>;
  108335. /**
  108336. * Observable event triggered each time the canvas loses focus
  108337. */
  108338. onCanvasBlurObservable: Observable<Engine>;
  108339. /**
  108340. * Observable event triggered each time the canvas gains focus
  108341. */
  108342. onCanvasFocusObservable: Observable<Engine>;
  108343. /**
  108344. * Observable event triggered each time the canvas receives pointerout event
  108345. */
  108346. onCanvasPointerOutObservable: Observable<PointerEvent>;
  108347. /**
  108348. * Observable raised when the engine begins a new frame
  108349. */
  108350. onBeginFrameObservable: Observable<Engine>;
  108351. /**
  108352. * If set, will be used to request the next animation frame for the render loop
  108353. */
  108354. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  108355. /**
  108356. * Observable raised when the engine ends the current frame
  108357. */
  108358. onEndFrameObservable: Observable<Engine>;
  108359. /**
  108360. * Observable raised when the engine is about to compile a shader
  108361. */
  108362. onBeforeShaderCompilationObservable: Observable<Engine>;
  108363. /**
  108364. * Observable raised when the engine has jsut compiled a shader
  108365. */
  108366. onAfterShaderCompilationObservable: Observable<Engine>;
  108367. /**
  108368. * Gets the audio engine
  108369. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108370. * @ignorenaming
  108371. */
  108372. static audioEngine: IAudioEngine;
  108373. /**
  108374. * Default AudioEngine factory responsible of creating the Audio Engine.
  108375. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  108376. */
  108377. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  108378. /**
  108379. * Default offline support factory responsible of creating a tool used to store data locally.
  108380. * By default, this will create a Database object if the workload has been embedded.
  108381. */
  108382. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  108383. private _loadingScreen;
  108384. private _pointerLockRequested;
  108385. private _dummyFramebuffer;
  108386. private _rescalePostProcess;
  108387. private _deterministicLockstep;
  108388. private _lockstepMaxSteps;
  108389. private _timeStep;
  108390. protected get _supportsHardwareTextureRescaling(): boolean;
  108391. private _fps;
  108392. private _deltaTime;
  108393. /** @hidden */
  108394. _drawCalls: PerfCounter;
  108395. /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
  108396. canvasTabIndex: number;
  108397. /**
  108398. * Turn this value on if you want to pause FPS computation when in background
  108399. */
  108400. disablePerformanceMonitorInBackground: boolean;
  108401. private _performanceMonitor;
  108402. /**
  108403. * Gets the performance monitor attached to this engine
  108404. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  108405. */
  108406. get performanceMonitor(): PerformanceMonitor;
  108407. private _onFocus;
  108408. private _onBlur;
  108409. private _onCanvasPointerOut;
  108410. private _onCanvasBlur;
  108411. private _onCanvasFocus;
  108412. private _onFullscreenChange;
  108413. private _onPointerLockChange;
  108414. /**
  108415. * Gets the HTML element used to attach event listeners
  108416. * @returns a HTML element
  108417. */
  108418. getInputElement(): Nullable<HTMLElement>;
  108419. /**
  108420. * Creates a new engine
  108421. * @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
  108422. * @param antialias defines enable antialiasing (default: false)
  108423. * @param options defines further options to be sent to the getContext() function
  108424. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  108425. */
  108426. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  108427. /**
  108428. * Gets current aspect ratio
  108429. * @param viewportOwner defines the camera to use to get the aspect ratio
  108430. * @param useScreen defines if screen size must be used (or the current render target if any)
  108431. * @returns a number defining the aspect ratio
  108432. */
  108433. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  108434. /**
  108435. * Gets current screen aspect ratio
  108436. * @returns a number defining the aspect ratio
  108437. */
  108438. getScreenAspectRatio(): number;
  108439. /**
  108440. * Gets the client rect of the HTML canvas attached with the current webGL context
  108441. * @returns a client rectanglee
  108442. */
  108443. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  108444. /**
  108445. * Gets the client rect of the HTML element used for events
  108446. * @returns a client rectanglee
  108447. */
  108448. getInputElementClientRect(): Nullable<ClientRect>;
  108449. /**
  108450. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  108451. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108452. * @returns true if engine is in deterministic lock step mode
  108453. */
  108454. isDeterministicLockStep(): boolean;
  108455. /**
  108456. * Gets the max steps when engine is running in deterministic lock step
  108457. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108458. * @returns the max steps
  108459. */
  108460. getLockstepMaxSteps(): number;
  108461. /**
  108462. * Returns the time in ms between steps when using deterministic lock step.
  108463. * @returns time step in (ms)
  108464. */
  108465. getTimeStep(): number;
  108466. /**
  108467. * Force the mipmap generation for the given render target texture
  108468. * @param texture defines the render target texture to use
  108469. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  108470. */
  108471. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  108472. /** States */
  108473. /**
  108474. * Set various states to the webGL context
  108475. * @param culling defines backface culling state
  108476. * @param zOffset defines the value to apply to zOffset (0 by default)
  108477. * @param force defines if states must be applied even if cache is up to date
  108478. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  108479. */
  108480. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  108481. /**
  108482. * Set the z offset to apply to current rendering
  108483. * @param value defines the offset to apply
  108484. */
  108485. setZOffset(value: number): void;
  108486. /**
  108487. * Gets the current value of the zOffset
  108488. * @returns the current zOffset state
  108489. */
  108490. getZOffset(): number;
  108491. /**
  108492. * Enable or disable depth buffering
  108493. * @param enable defines the state to set
  108494. */
  108495. setDepthBuffer(enable: boolean): void;
  108496. /**
  108497. * Gets a boolean indicating if depth writing is enabled
  108498. * @returns the current depth writing state
  108499. */
  108500. getDepthWrite(): boolean;
  108501. /**
  108502. * Enable or disable depth writing
  108503. * @param enable defines the state to set
  108504. */
  108505. setDepthWrite(enable: boolean): void;
  108506. /**
  108507. * Gets a boolean indicating if stencil buffer is enabled
  108508. * @returns the current stencil buffer state
  108509. */
  108510. getStencilBuffer(): boolean;
  108511. /**
  108512. * Enable or disable the stencil buffer
  108513. * @param enable defines if the stencil buffer must be enabled or disabled
  108514. */
  108515. setStencilBuffer(enable: boolean): void;
  108516. /**
  108517. * Gets the current stencil mask
  108518. * @returns a number defining the new stencil mask to use
  108519. */
  108520. getStencilMask(): number;
  108521. /**
  108522. * Sets the current stencil mask
  108523. * @param mask defines the new stencil mask to use
  108524. */
  108525. setStencilMask(mask: number): void;
  108526. /**
  108527. * Gets the current stencil function
  108528. * @returns a number defining the stencil function to use
  108529. */
  108530. getStencilFunction(): number;
  108531. /**
  108532. * Gets the current stencil reference value
  108533. * @returns a number defining the stencil reference value to use
  108534. */
  108535. getStencilFunctionReference(): number;
  108536. /**
  108537. * Gets the current stencil mask
  108538. * @returns a number defining the stencil mask to use
  108539. */
  108540. getStencilFunctionMask(): number;
  108541. /**
  108542. * Sets the current stencil function
  108543. * @param stencilFunc defines the new stencil function to use
  108544. */
  108545. setStencilFunction(stencilFunc: number): void;
  108546. /**
  108547. * Sets the current stencil reference
  108548. * @param reference defines the new stencil reference to use
  108549. */
  108550. setStencilFunctionReference(reference: number): void;
  108551. /**
  108552. * Sets the current stencil mask
  108553. * @param mask defines the new stencil mask to use
  108554. */
  108555. setStencilFunctionMask(mask: number): void;
  108556. /**
  108557. * Gets the current stencil operation when stencil fails
  108558. * @returns a number defining stencil operation to use when stencil fails
  108559. */
  108560. getStencilOperationFail(): number;
  108561. /**
  108562. * Gets the current stencil operation when depth fails
  108563. * @returns a number defining stencil operation to use when depth fails
  108564. */
  108565. getStencilOperationDepthFail(): number;
  108566. /**
  108567. * Gets the current stencil operation when stencil passes
  108568. * @returns a number defining stencil operation to use when stencil passes
  108569. */
  108570. getStencilOperationPass(): number;
  108571. /**
  108572. * Sets the stencil operation to use when stencil fails
  108573. * @param operation defines the stencil operation to use when stencil fails
  108574. */
  108575. setStencilOperationFail(operation: number): void;
  108576. /**
  108577. * Sets the stencil operation to use when depth fails
  108578. * @param operation defines the stencil operation to use when depth fails
  108579. */
  108580. setStencilOperationDepthFail(operation: number): void;
  108581. /**
  108582. * Sets the stencil operation to use when stencil passes
  108583. * @param operation defines the stencil operation to use when stencil passes
  108584. */
  108585. setStencilOperationPass(operation: number): void;
  108586. /**
  108587. * Sets a boolean indicating if the dithering state is enabled or disabled
  108588. * @param value defines the dithering state
  108589. */
  108590. setDitheringState(value: boolean): void;
  108591. /**
  108592. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  108593. * @param value defines the rasterizer state
  108594. */
  108595. setRasterizerState(value: boolean): void;
  108596. /**
  108597. * Gets the current depth function
  108598. * @returns a number defining the depth function
  108599. */
  108600. getDepthFunction(): Nullable<number>;
  108601. /**
  108602. * Sets the current depth function
  108603. * @param depthFunc defines the function to use
  108604. */
  108605. setDepthFunction(depthFunc: number): void;
  108606. /**
  108607. * Sets the current depth function to GREATER
  108608. */
  108609. setDepthFunctionToGreater(): void;
  108610. /**
  108611. * Sets the current depth function to GEQUAL
  108612. */
  108613. setDepthFunctionToGreaterOrEqual(): void;
  108614. /**
  108615. * Sets the current depth function to LESS
  108616. */
  108617. setDepthFunctionToLess(): void;
  108618. /**
  108619. * Sets the current depth function to LEQUAL
  108620. */
  108621. setDepthFunctionToLessOrEqual(): void;
  108622. private _cachedStencilBuffer;
  108623. private _cachedStencilFunction;
  108624. private _cachedStencilMask;
  108625. private _cachedStencilOperationPass;
  108626. private _cachedStencilOperationFail;
  108627. private _cachedStencilOperationDepthFail;
  108628. private _cachedStencilReference;
  108629. /**
  108630. * Caches the the state of the stencil buffer
  108631. */
  108632. cacheStencilState(): void;
  108633. /**
  108634. * Restores the state of the stencil buffer
  108635. */
  108636. restoreStencilState(): void;
  108637. /**
  108638. * Directly set the WebGL Viewport
  108639. * @param x defines the x coordinate of the viewport (in screen space)
  108640. * @param y defines the y coordinate of the viewport (in screen space)
  108641. * @param width defines the width of the viewport (in screen space)
  108642. * @param height defines the height of the viewport (in screen space)
  108643. * @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
  108644. */
  108645. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  108646. /**
  108647. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  108648. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  108649. * @param y defines the y-coordinate of the corner of the clear rectangle
  108650. * @param width defines the width of the clear rectangle
  108651. * @param height defines the height of the clear rectangle
  108652. * @param clearColor defines the clear color
  108653. */
  108654. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  108655. /**
  108656. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  108657. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  108658. * @param y defines the y-coordinate of the corner of the clear rectangle
  108659. * @param width defines the width of the clear rectangle
  108660. * @param height defines the height of the clear rectangle
  108661. */
  108662. enableScissor(x: number, y: number, width: number, height: number): void;
  108663. /**
  108664. * Disable previously set scissor test rectangle
  108665. */
  108666. disableScissor(): void;
  108667. protected _reportDrawCall(): void;
  108668. /**
  108669. * Initializes a webVR display and starts listening to display change events
  108670. * The onVRDisplayChangedObservable will be notified upon these changes
  108671. * @returns The onVRDisplayChangedObservable
  108672. */
  108673. initWebVR(): Observable<IDisplayChangedEventArgs>;
  108674. /** @hidden */
  108675. _prepareVRComponent(): void;
  108676. /** @hidden */
  108677. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  108678. /** @hidden */
  108679. _submitVRFrame(): void;
  108680. /**
  108681. * Call this function to leave webVR mode
  108682. * Will do nothing if webVR is not supported or if there is no webVR device
  108683. * @see http://doc.babylonjs.com/how_to/webvr_camera
  108684. */
  108685. disableVR(): void;
  108686. /**
  108687. * Gets a boolean indicating that the system is in VR mode and is presenting
  108688. * @returns true if VR mode is engaged
  108689. */
  108690. isVRPresenting(): boolean;
  108691. /** @hidden */
  108692. _requestVRFrame(): void;
  108693. /** @hidden */
  108694. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  108695. /**
  108696. * Gets the source code of the vertex shader associated with a specific webGL program
  108697. * @param program defines the program to use
  108698. * @returns a string containing the source code of the vertex shader associated with the program
  108699. */
  108700. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  108701. /**
  108702. * Gets the source code of the fragment shader associated with a specific webGL program
  108703. * @param program defines the program to use
  108704. * @returns a string containing the source code of the fragment shader associated with the program
  108705. */
  108706. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  108707. /**
  108708. * Sets a depth stencil texture from a render target to the according uniform.
  108709. * @param channel The texture channel
  108710. * @param uniform The uniform to set
  108711. * @param texture The render target texture containing the depth stencil texture to apply
  108712. */
  108713. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  108714. /**
  108715. * Sets a texture to the webGL context from a postprocess
  108716. * @param channel defines the channel to use
  108717. * @param postProcess defines the source postprocess
  108718. */
  108719. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  108720. /**
  108721. * Binds the output of the passed in post process to the texture channel specified
  108722. * @param channel The channel the texture should be bound to
  108723. * @param postProcess The post process which's output should be bound
  108724. */
  108725. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  108726. protected _rebuildBuffers(): void;
  108727. /** @hidden */
  108728. _renderFrame(): void;
  108729. _renderLoop(): void;
  108730. /** @hidden */
  108731. _renderViews(): boolean;
  108732. /**
  108733. * Toggle full screen mode
  108734. * @param requestPointerLock defines if a pointer lock should be requested from the user
  108735. */
  108736. switchFullscreen(requestPointerLock: boolean): void;
  108737. /**
  108738. * Enters full screen mode
  108739. * @param requestPointerLock defines if a pointer lock should be requested from the user
  108740. */
  108741. enterFullscreen(requestPointerLock: boolean): void;
  108742. /**
  108743. * Exits full screen mode
  108744. */
  108745. exitFullscreen(): void;
  108746. /**
  108747. * Enters Pointerlock mode
  108748. */
  108749. enterPointerlock(): void;
  108750. /**
  108751. * Exits Pointerlock mode
  108752. */
  108753. exitPointerlock(): void;
  108754. /**
  108755. * Begin a new frame
  108756. */
  108757. beginFrame(): void;
  108758. /**
  108759. * Enf the current frame
  108760. */
  108761. endFrame(): void;
  108762. resize(): void;
  108763. /**
  108764. * Force a specific size of the canvas
  108765. * @param width defines the new canvas' width
  108766. * @param height defines the new canvas' height
  108767. */
  108768. setSize(width: number, height: number): void;
  108769. /**
  108770. * Updates a dynamic vertex buffer.
  108771. * @param vertexBuffer the vertex buffer to update
  108772. * @param data the data used to update the vertex buffer
  108773. * @param byteOffset the byte offset of the data
  108774. * @param byteLength the byte length of the data
  108775. */
  108776. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  108777. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  108778. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  108779. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  108780. _releaseTexture(texture: InternalTexture): void;
  108781. /**
  108782. * @hidden
  108783. * Rescales a texture
  108784. * @param source input texutre
  108785. * @param destination destination texture
  108786. * @param scene scene to use to render the resize
  108787. * @param internalFormat format to use when resizing
  108788. * @param onComplete callback to be called when resize has completed
  108789. */
  108790. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  108791. /**
  108792. * Gets the current framerate
  108793. * @returns a number representing the framerate
  108794. */
  108795. getFps(): number;
  108796. /**
  108797. * Gets the time spent between current and previous frame
  108798. * @returns a number representing the delta time in ms
  108799. */
  108800. getDeltaTime(): number;
  108801. private _measureFps;
  108802. /** @hidden */
  108803. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  108804. /**
  108805. * Update a dynamic index buffer
  108806. * @param indexBuffer defines the target index buffer
  108807. * @param indices defines the data to update
  108808. * @param offset defines the offset in the target index buffer where update should start
  108809. */
  108810. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  108811. /**
  108812. * Updates the sample count of a render target texture
  108813. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  108814. * @param texture defines the texture to update
  108815. * @param samples defines the sample count to set
  108816. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  108817. */
  108818. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  108819. /**
  108820. * Updates a depth texture Comparison Mode and Function.
  108821. * If the comparison Function is equal to 0, the mode will be set to none.
  108822. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  108823. * @param texture The texture to set the comparison function for
  108824. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  108825. */
  108826. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  108827. /**
  108828. * Creates a webGL buffer to use with instanciation
  108829. * @param capacity defines the size of the buffer
  108830. * @returns the webGL buffer
  108831. */
  108832. createInstancesBuffer(capacity: number): DataBuffer;
  108833. /**
  108834. * Delete a webGL buffer used with instanciation
  108835. * @param buffer defines the webGL buffer to delete
  108836. */
  108837. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  108838. private _clientWaitAsync;
  108839. /** @hidden */
  108840. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  108841. /** @hidden */
  108842. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  108843. dispose(): void;
  108844. private _disableTouchAction;
  108845. /**
  108846. * Display the loading screen
  108847. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108848. */
  108849. displayLoadingUI(): void;
  108850. /**
  108851. * Hide the loading screen
  108852. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108853. */
  108854. hideLoadingUI(): void;
  108855. /**
  108856. * Gets the current loading screen object
  108857. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108858. */
  108859. get loadingScreen(): ILoadingScreen;
  108860. /**
  108861. * Sets the current loading screen object
  108862. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108863. */
  108864. set loadingScreen(loadingScreen: ILoadingScreen);
  108865. /**
  108866. * Sets the current loading screen text
  108867. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108868. */
  108869. set loadingUIText(text: string);
  108870. /**
  108871. * Sets the current loading screen background color
  108872. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108873. */
  108874. set loadingUIBackgroundColor(color: string);
  108875. /** Pointerlock and fullscreen */
  108876. /**
  108877. * Ask the browser to promote the current element to pointerlock mode
  108878. * @param element defines the DOM element to promote
  108879. */
  108880. static _RequestPointerlock(element: HTMLElement): void;
  108881. /**
  108882. * Asks the browser to exit pointerlock mode
  108883. */
  108884. static _ExitPointerlock(): void;
  108885. /**
  108886. * Ask the browser to promote the current element to fullscreen rendering mode
  108887. * @param element defines the DOM element to promote
  108888. */
  108889. static _RequestFullscreen(element: HTMLElement): void;
  108890. /**
  108891. * Asks the browser to exit fullscreen mode
  108892. */
  108893. static _ExitFullscreen(): void;
  108894. }
  108895. }
  108896. declare module BABYLON {
  108897. /**
  108898. * The engine store class is responsible to hold all the instances of Engine and Scene created
  108899. * during the life time of the application.
  108900. */
  108901. export class EngineStore {
  108902. /** Gets the list of created engines */
  108903. static Instances: Engine[];
  108904. /** @hidden */
  108905. static _LastCreatedScene: Nullable<Scene>;
  108906. /**
  108907. * Gets the latest created engine
  108908. */
  108909. static get LastCreatedEngine(): Nullable<Engine>;
  108910. /**
  108911. * Gets the latest created scene
  108912. */
  108913. static get LastCreatedScene(): Nullable<Scene>;
  108914. /**
  108915. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  108916. * @ignorenaming
  108917. */
  108918. static UseFallbackTexture: boolean;
  108919. /**
  108920. * Texture content used if a texture cannot loaded
  108921. * @ignorenaming
  108922. */
  108923. static FallbackTexture: string;
  108924. }
  108925. }
  108926. declare module BABYLON {
  108927. /**
  108928. * Helper class that provides a small promise polyfill
  108929. */
  108930. export class PromisePolyfill {
  108931. /**
  108932. * Static function used to check if the polyfill is required
  108933. * If this is the case then the function will inject the polyfill to window.Promise
  108934. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  108935. */
  108936. static Apply(force?: boolean): void;
  108937. }
  108938. }
  108939. declare module BABYLON {
  108940. /**
  108941. * Interface for screenshot methods with describe argument called `size` as object with options
  108942. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  108943. */
  108944. export interface IScreenshotSize {
  108945. /**
  108946. * number in pixels for canvas height
  108947. */
  108948. height?: number;
  108949. /**
  108950. * multiplier allowing render at a higher or lower resolution
  108951. * If value is defined then height and width will be ignored and taken from camera
  108952. */
  108953. precision?: number;
  108954. /**
  108955. * number in pixels for canvas width
  108956. */
  108957. width?: number;
  108958. }
  108959. }
  108960. declare module BABYLON {
  108961. interface IColor4Like {
  108962. r: float;
  108963. g: float;
  108964. b: float;
  108965. a: float;
  108966. }
  108967. /**
  108968. * Class containing a set of static utilities functions
  108969. */
  108970. export class Tools {
  108971. /**
  108972. * Gets or sets the base URL to use to load assets
  108973. */
  108974. static get BaseUrl(): string;
  108975. static set BaseUrl(value: string);
  108976. /**
  108977. * Enable/Disable Custom HTTP Request Headers globally.
  108978. * default = false
  108979. * @see CustomRequestHeaders
  108980. */
  108981. static UseCustomRequestHeaders: boolean;
  108982. /**
  108983. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  108984. * i.e. when loading files, where the server/service expects an Authorization header
  108985. */
  108986. static CustomRequestHeaders: {
  108987. [key: string]: string;
  108988. };
  108989. /**
  108990. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  108991. */
  108992. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  108993. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  108994. /**
  108995. * Default behaviour for cors in the application.
  108996. * It can be a string if the expected behavior is identical in the entire app.
  108997. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  108998. */
  108999. static get CorsBehavior(): string | ((url: string | string[]) => string);
  109000. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  109001. /**
  109002. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  109003. * @ignorenaming
  109004. */
  109005. static get UseFallbackTexture(): boolean;
  109006. static set UseFallbackTexture(value: boolean);
  109007. /**
  109008. * Use this object to register external classes like custom textures or material
  109009. * to allow the laoders to instantiate them
  109010. */
  109011. static get RegisteredExternalClasses(): {
  109012. [key: string]: Object;
  109013. };
  109014. static set RegisteredExternalClasses(classes: {
  109015. [key: string]: Object;
  109016. });
  109017. /**
  109018. * Texture content used if a texture cannot loaded
  109019. * @ignorenaming
  109020. */
  109021. static get fallbackTexture(): string;
  109022. static set fallbackTexture(value: string);
  109023. /**
  109024. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  109025. * @param u defines the coordinate on X axis
  109026. * @param v defines the coordinate on Y axis
  109027. * @param width defines the width of the source data
  109028. * @param height defines the height of the source data
  109029. * @param pixels defines the source byte array
  109030. * @param color defines the output color
  109031. */
  109032. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  109033. /**
  109034. * Interpolates between a and b via alpha
  109035. * @param a The lower value (returned when alpha = 0)
  109036. * @param b The upper value (returned when alpha = 1)
  109037. * @param alpha The interpolation-factor
  109038. * @return The mixed value
  109039. */
  109040. static Mix(a: number, b: number, alpha: number): number;
  109041. /**
  109042. * Tries to instantiate a new object from a given class name
  109043. * @param className defines the class name to instantiate
  109044. * @returns the new object or null if the system was not able to do the instantiation
  109045. */
  109046. static Instantiate(className: string): any;
  109047. /**
  109048. * Provides a slice function that will work even on IE
  109049. * @param data defines the array to slice
  109050. * @param start defines the start of the data (optional)
  109051. * @param end defines the end of the data (optional)
  109052. * @returns the new sliced array
  109053. */
  109054. static Slice<T>(data: T, start?: number, end?: number): T;
  109055. /**
  109056. * Polyfill for setImmediate
  109057. * @param action defines the action to execute after the current execution block
  109058. */
  109059. static SetImmediate(action: () => void): void;
  109060. /**
  109061. * Function indicating if a number is an exponent of 2
  109062. * @param value defines the value to test
  109063. * @returns true if the value is an exponent of 2
  109064. */
  109065. static IsExponentOfTwo(value: number): boolean;
  109066. private static _tmpFloatArray;
  109067. /**
  109068. * Returns the nearest 32-bit single precision float representation of a Number
  109069. * @param value A Number. If the parameter is of a different type, it will get converted
  109070. * to a number or to NaN if it cannot be converted
  109071. * @returns number
  109072. */
  109073. static FloatRound(value: number): number;
  109074. /**
  109075. * Extracts the filename from a path
  109076. * @param path defines the path to use
  109077. * @returns the filename
  109078. */
  109079. static GetFilename(path: string): string;
  109080. /**
  109081. * Extracts the "folder" part of a path (everything before the filename).
  109082. * @param uri The URI to extract the info from
  109083. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  109084. * @returns The "folder" part of the path
  109085. */
  109086. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  109087. /**
  109088. * Extracts text content from a DOM element hierarchy
  109089. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  109090. */
  109091. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  109092. /**
  109093. * Convert an angle in radians to degrees
  109094. * @param angle defines the angle to convert
  109095. * @returns the angle in degrees
  109096. */
  109097. static ToDegrees(angle: number): number;
  109098. /**
  109099. * Convert an angle in degrees to radians
  109100. * @param angle defines the angle to convert
  109101. * @returns the angle in radians
  109102. */
  109103. static ToRadians(angle: number): number;
  109104. /**
  109105. * Returns an array if obj is not an array
  109106. * @param obj defines the object to evaluate as an array
  109107. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  109108. * @returns either obj directly if obj is an array or a new array containing obj
  109109. */
  109110. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  109111. /**
  109112. * Gets the pointer prefix to use
  109113. * @returns "pointer" if touch is enabled. Else returns "mouse"
  109114. */
  109115. static GetPointerPrefix(): string;
  109116. /**
  109117. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  109118. * @param url define the url we are trying
  109119. * @param element define the dom element where to configure the cors policy
  109120. */
  109121. static SetCorsBehavior(url: string | string[], element: {
  109122. crossOrigin: string | null;
  109123. }): void;
  109124. /**
  109125. * Removes unwanted characters from an url
  109126. * @param url defines the url to clean
  109127. * @returns the cleaned url
  109128. */
  109129. static CleanUrl(url: string): string;
  109130. /**
  109131. * Gets or sets a function used to pre-process url before using them to load assets
  109132. */
  109133. static get PreprocessUrl(): (url: string) => string;
  109134. static set PreprocessUrl(processor: (url: string) => string);
  109135. /**
  109136. * Loads an image as an HTMLImageElement.
  109137. * @param input url string, ArrayBuffer, or Blob to load
  109138. * @param onLoad callback called when the image successfully loads
  109139. * @param onError callback called when the image fails to load
  109140. * @param offlineProvider offline provider for caching
  109141. * @param mimeType optional mime type
  109142. * @returns the HTMLImageElement of the loaded image
  109143. */
  109144. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  109145. /**
  109146. * Loads a file from a url
  109147. * @param url url string, ArrayBuffer, or Blob to load
  109148. * @param onSuccess callback called when the file successfully loads
  109149. * @param onProgress callback called while file is loading (if the server supports this mode)
  109150. * @param offlineProvider defines the offline provider for caching
  109151. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  109152. * @param onError callback called when the file fails to load
  109153. * @returns a file request object
  109154. */
  109155. 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;
  109156. /**
  109157. * Loads a file from a url
  109158. * @param url the file url to load
  109159. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  109160. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  109161. */
  109162. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  109163. /**
  109164. * Load a script (identified by an url). When the url returns, the
  109165. * content of this file is added into a new script element, attached to the DOM (body element)
  109166. * @param scriptUrl defines the url of the script to laod
  109167. * @param onSuccess defines the callback called when the script is loaded
  109168. * @param onError defines the callback to call if an error occurs
  109169. * @param scriptId defines the id of the script element
  109170. */
  109171. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  109172. /**
  109173. * Load an asynchronous script (identified by an url). When the url returns, the
  109174. * content of this file is added into a new script element, attached to the DOM (body element)
  109175. * @param scriptUrl defines the url of the script to laod
  109176. * @param scriptId defines the id of the script element
  109177. * @returns a promise request object
  109178. */
  109179. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  109180. /**
  109181. * Loads a file from a blob
  109182. * @param fileToLoad defines the blob to use
  109183. * @param callback defines the callback to call when data is loaded
  109184. * @param progressCallback defines the callback to call during loading process
  109185. * @returns a file request object
  109186. */
  109187. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  109188. /**
  109189. * Reads a file from a File object
  109190. * @param file defines the file to load
  109191. * @param onSuccess defines the callback to call when data is loaded
  109192. * @param onProgress defines the callback to call during loading process
  109193. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  109194. * @param onError defines the callback to call when an error occurs
  109195. * @returns a file request object
  109196. */
  109197. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  109198. /**
  109199. * Creates a data url from a given string content
  109200. * @param content defines the content to convert
  109201. * @returns the new data url link
  109202. */
  109203. static FileAsURL(content: string): string;
  109204. /**
  109205. * Format the given number to a specific decimal format
  109206. * @param value defines the number to format
  109207. * @param decimals defines the number of decimals to use
  109208. * @returns the formatted string
  109209. */
  109210. static Format(value: number, decimals?: number): string;
  109211. /**
  109212. * Tries to copy an object by duplicating every property
  109213. * @param source defines the source object
  109214. * @param destination defines the target object
  109215. * @param doNotCopyList defines a list of properties to avoid
  109216. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  109217. */
  109218. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  109219. /**
  109220. * Gets a boolean indicating if the given object has no own property
  109221. * @param obj defines the object to test
  109222. * @returns true if object has no own property
  109223. */
  109224. static IsEmpty(obj: any): boolean;
  109225. /**
  109226. * Function used to register events at window level
  109227. * @param windowElement defines the Window object to use
  109228. * @param events defines the events to register
  109229. */
  109230. static RegisterTopRootEvents(windowElement: Window, events: {
  109231. name: string;
  109232. handler: Nullable<(e: FocusEvent) => any>;
  109233. }[]): void;
  109234. /**
  109235. * Function used to unregister events from window level
  109236. * @param windowElement defines the Window object to use
  109237. * @param events defines the events to unregister
  109238. */
  109239. static UnregisterTopRootEvents(windowElement: Window, events: {
  109240. name: string;
  109241. handler: Nullable<(e: FocusEvent) => any>;
  109242. }[]): void;
  109243. /**
  109244. * @ignore
  109245. */
  109246. static _ScreenshotCanvas: HTMLCanvasElement;
  109247. /**
  109248. * Dumps the current bound framebuffer
  109249. * @param width defines the rendering width
  109250. * @param height defines the rendering height
  109251. * @param engine defines the hosting engine
  109252. * @param successCallback defines the callback triggered once the data are available
  109253. * @param mimeType defines the mime type of the result
  109254. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  109255. */
  109256. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  109257. /**
  109258. * Converts the canvas data to blob.
  109259. * This acts as a polyfill for browsers not supporting the to blob function.
  109260. * @param canvas Defines the canvas to extract the data from
  109261. * @param successCallback Defines the callback triggered once the data are available
  109262. * @param mimeType Defines the mime type of the result
  109263. */
  109264. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  109265. /**
  109266. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  109267. * @param successCallback defines the callback triggered once the data are available
  109268. * @param mimeType defines the mime type of the result
  109269. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  109270. */
  109271. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  109272. /**
  109273. * Downloads a blob in the browser
  109274. * @param blob defines the blob to download
  109275. * @param fileName defines the name of the downloaded file
  109276. */
  109277. static Download(blob: Blob, fileName: string): void;
  109278. /**
  109279. * Captures a screenshot of the current rendering
  109280. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  109281. * @param engine defines the rendering engine
  109282. * @param camera defines the source camera
  109283. * @param size This parameter can be set to a single number or to an object with the
  109284. * following (optional) properties: precision, width, height. If a single number is passed,
  109285. * it will be used for both width and height. If an object is passed, the screenshot size
  109286. * will be derived from the parameters. The precision property is a multiplier allowing
  109287. * rendering at a higher or lower resolution
  109288. * @param successCallback defines the callback receives a single parameter which contains the
  109289. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  109290. * src parameter of an <img> to display it
  109291. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  109292. * Check your browser for supported MIME types
  109293. */
  109294. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  109295. /**
  109296. * Captures a screenshot of the current rendering
  109297. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  109298. * @param engine defines the rendering engine
  109299. * @param camera defines the source camera
  109300. * @param size This parameter can be set to a single number or to an object with the
  109301. * following (optional) properties: precision, width, height. If a single number is passed,
  109302. * it will be used for both width and height. If an object is passed, the screenshot size
  109303. * will be derived from the parameters. The precision property is a multiplier allowing
  109304. * rendering at a higher or lower resolution
  109305. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  109306. * Check your browser for supported MIME types
  109307. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  109308. * to the src parameter of an <img> to display it
  109309. */
  109310. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  109311. /**
  109312. * Generates an image screenshot from the specified camera.
  109313. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  109314. * @param engine The engine to use for rendering
  109315. * @param camera The camera to use for rendering
  109316. * @param size This parameter can be set to a single number or to an object with the
  109317. * following (optional) properties: precision, width, height. If a single number is passed,
  109318. * it will be used for both width and height. If an object is passed, the screenshot size
  109319. * will be derived from the parameters. The precision property is a multiplier allowing
  109320. * rendering at a higher or lower resolution
  109321. * @param successCallback The callback receives a single parameter which contains the
  109322. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  109323. * src parameter of an <img> to display it
  109324. * @param mimeType The MIME type of the screenshot image (default: image/png).
  109325. * Check your browser for supported MIME types
  109326. * @param samples Texture samples (default: 1)
  109327. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  109328. * @param fileName A name for for the downloaded file.
  109329. */
  109330. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  109331. /**
  109332. * Generates an image screenshot from the specified camera.
  109333. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  109334. * @param engine The engine to use for rendering
  109335. * @param camera The camera to use for rendering
  109336. * @param size This parameter can be set to a single number or to an object with the
  109337. * following (optional) properties: precision, width, height. If a single number is passed,
  109338. * it will be used for both width and height. If an object is passed, the screenshot size
  109339. * will be derived from the parameters. The precision property is a multiplier allowing
  109340. * rendering at a higher or lower resolution
  109341. * @param mimeType The MIME type of the screenshot image (default: image/png).
  109342. * Check your browser for supported MIME types
  109343. * @param samples Texture samples (default: 1)
  109344. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  109345. * @param fileName A name for for the downloaded file.
  109346. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  109347. * to the src parameter of an <img> to display it
  109348. */
  109349. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  109350. /**
  109351. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  109352. * Be aware Math.random() could cause collisions, but:
  109353. * "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"
  109354. * @returns a pseudo random id
  109355. */
  109356. static RandomId(): string;
  109357. /**
  109358. * Test if the given uri is a base64 string
  109359. * @param uri The uri to test
  109360. * @return True if the uri is a base64 string or false otherwise
  109361. */
  109362. static IsBase64(uri: string): boolean;
  109363. /**
  109364. * Decode the given base64 uri.
  109365. * @param uri The uri to decode
  109366. * @return The decoded base64 data.
  109367. */
  109368. static DecodeBase64(uri: string): ArrayBuffer;
  109369. /**
  109370. * Gets the absolute url.
  109371. * @param url the input url
  109372. * @return the absolute url
  109373. */
  109374. static GetAbsoluteUrl(url: string): string;
  109375. /**
  109376. * No log
  109377. */
  109378. static readonly NoneLogLevel: number;
  109379. /**
  109380. * Only message logs
  109381. */
  109382. static readonly MessageLogLevel: number;
  109383. /**
  109384. * Only warning logs
  109385. */
  109386. static readonly WarningLogLevel: number;
  109387. /**
  109388. * Only error logs
  109389. */
  109390. static readonly ErrorLogLevel: number;
  109391. /**
  109392. * All logs
  109393. */
  109394. static readonly AllLogLevel: number;
  109395. /**
  109396. * Gets a value indicating the number of loading errors
  109397. * @ignorenaming
  109398. */
  109399. static get errorsCount(): number;
  109400. /**
  109401. * Callback called when a new log is added
  109402. */
  109403. static OnNewCacheEntry: (entry: string) => void;
  109404. /**
  109405. * Log a message to the console
  109406. * @param message defines the message to log
  109407. */
  109408. static Log(message: string): void;
  109409. /**
  109410. * Write a warning message to the console
  109411. * @param message defines the message to log
  109412. */
  109413. static Warn(message: string): void;
  109414. /**
  109415. * Write an error message to the console
  109416. * @param message defines the message to log
  109417. */
  109418. static Error(message: string): void;
  109419. /**
  109420. * Gets current log cache (list of logs)
  109421. */
  109422. static get LogCache(): string;
  109423. /**
  109424. * Clears the log cache
  109425. */
  109426. static ClearLogCache(): void;
  109427. /**
  109428. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  109429. */
  109430. static set LogLevels(level: number);
  109431. /**
  109432. * Checks if the window object exists
  109433. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  109434. */
  109435. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  109436. /**
  109437. * No performance log
  109438. */
  109439. static readonly PerformanceNoneLogLevel: number;
  109440. /**
  109441. * Use user marks to log performance
  109442. */
  109443. static readonly PerformanceUserMarkLogLevel: number;
  109444. /**
  109445. * Log performance to the console
  109446. */
  109447. static readonly PerformanceConsoleLogLevel: number;
  109448. private static _performance;
  109449. /**
  109450. * Sets the current performance log level
  109451. */
  109452. static set PerformanceLogLevel(level: number);
  109453. private static _StartPerformanceCounterDisabled;
  109454. private static _EndPerformanceCounterDisabled;
  109455. private static _StartUserMark;
  109456. private static _EndUserMark;
  109457. private static _StartPerformanceConsole;
  109458. private static _EndPerformanceConsole;
  109459. /**
  109460. * Starts a performance counter
  109461. */
  109462. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  109463. /**
  109464. * Ends a specific performance coutner
  109465. */
  109466. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  109467. /**
  109468. * Gets either window.performance.now() if supported or Date.now() else
  109469. */
  109470. static get Now(): number;
  109471. /**
  109472. * This method will return the name of the class used to create the instance of the given object.
  109473. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  109474. * @param object the object to get the class name from
  109475. * @param isType defines if the object is actually a type
  109476. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  109477. */
  109478. static GetClassName(object: any, isType?: boolean): string;
  109479. /**
  109480. * Gets the first element of an array satisfying a given predicate
  109481. * @param array defines the array to browse
  109482. * @param predicate defines the predicate to use
  109483. * @returns null if not found or the element
  109484. */
  109485. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  109486. /**
  109487. * This method will return the name of the full name of the class, including its owning module (if any).
  109488. * 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).
  109489. * @param object the object to get the class name from
  109490. * @param isType defines if the object is actually a type
  109491. * @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.
  109492. * @ignorenaming
  109493. */
  109494. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  109495. /**
  109496. * Returns a promise that resolves after the given amount of time.
  109497. * @param delay Number of milliseconds to delay
  109498. * @returns Promise that resolves after the given amount of time
  109499. */
  109500. static DelayAsync(delay: number): Promise<void>;
  109501. /**
  109502. * Utility function to detect if the current user agent is Safari
  109503. * @returns whether or not the current user agent is safari
  109504. */
  109505. static IsSafari(): boolean;
  109506. }
  109507. /**
  109508. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  109509. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  109510. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  109511. * @param name The name of the class, case should be preserved
  109512. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  109513. */
  109514. export function className(name: string, module?: string): (target: Object) => void;
  109515. /**
  109516. * An implementation of a loop for asynchronous functions.
  109517. */
  109518. export class AsyncLoop {
  109519. /**
  109520. * Defines the number of iterations for the loop
  109521. */
  109522. iterations: number;
  109523. /**
  109524. * Defines the current index of the loop.
  109525. */
  109526. index: number;
  109527. private _done;
  109528. private _fn;
  109529. private _successCallback;
  109530. /**
  109531. * Constructor.
  109532. * @param iterations the number of iterations.
  109533. * @param func the function to run each iteration
  109534. * @param successCallback the callback that will be called upon succesful execution
  109535. * @param offset starting offset.
  109536. */
  109537. constructor(
  109538. /**
  109539. * Defines the number of iterations for the loop
  109540. */
  109541. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  109542. /**
  109543. * Execute the next iteration. Must be called after the last iteration was finished.
  109544. */
  109545. executeNext(): void;
  109546. /**
  109547. * Break the loop and run the success callback.
  109548. */
  109549. breakLoop(): void;
  109550. /**
  109551. * Create and run an async loop.
  109552. * @param iterations the number of iterations.
  109553. * @param fn the function to run each iteration
  109554. * @param successCallback the callback that will be called upon succesful execution
  109555. * @param offset starting offset.
  109556. * @returns the created async loop object
  109557. */
  109558. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  109559. /**
  109560. * A for-loop that will run a given number of iterations synchronous and the rest async.
  109561. * @param iterations total number of iterations
  109562. * @param syncedIterations number of synchronous iterations in each async iteration.
  109563. * @param fn the function to call each iteration.
  109564. * @param callback a success call back that will be called when iterating stops.
  109565. * @param breakFunction a break condition (optional)
  109566. * @param timeout timeout settings for the setTimeout function. default - 0.
  109567. * @returns the created async loop object
  109568. */
  109569. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  109570. }
  109571. }
  109572. declare module BABYLON {
  109573. /**
  109574. * This class implement a typical dictionary using a string as key and the generic type T as value.
  109575. * The underlying implementation relies on an associative array to ensure the best performances.
  109576. * The value can be anything including 'null' but except 'undefined'
  109577. */
  109578. export class StringDictionary<T> {
  109579. /**
  109580. * This will clear this dictionary and copy the content from the 'source' one.
  109581. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  109582. * @param source the dictionary to take the content from and copy to this dictionary
  109583. */
  109584. copyFrom(source: StringDictionary<T>): void;
  109585. /**
  109586. * Get a value based from its key
  109587. * @param key the given key to get the matching value from
  109588. * @return the value if found, otherwise undefined is returned
  109589. */
  109590. get(key: string): T | undefined;
  109591. /**
  109592. * Get a value from its key or add it if it doesn't exist.
  109593. * This method will ensure you that a given key/data will be present in the dictionary.
  109594. * @param key the given key to get the matching value from
  109595. * @param factory the factory that will create the value if the key is not present in the dictionary.
  109596. * The factory will only be invoked if there's no data for the given key.
  109597. * @return the value corresponding to the key.
  109598. */
  109599. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  109600. /**
  109601. * Get a value from its key if present in the dictionary otherwise add it
  109602. * @param key the key to get the value from
  109603. * @param val if there's no such key/value pair in the dictionary add it with this value
  109604. * @return the value corresponding to the key
  109605. */
  109606. getOrAdd(key: string, val: T): T;
  109607. /**
  109608. * Check if there's a given key in the dictionary
  109609. * @param key the key to check for
  109610. * @return true if the key is present, false otherwise
  109611. */
  109612. contains(key: string): boolean;
  109613. /**
  109614. * Add a new key and its corresponding value
  109615. * @param key the key to add
  109616. * @param value the value corresponding to the key
  109617. * @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
  109618. */
  109619. add(key: string, value: T): boolean;
  109620. /**
  109621. * Update a specific value associated to a key
  109622. * @param key defines the key to use
  109623. * @param value defines the value to store
  109624. * @returns true if the value was updated (or false if the key was not found)
  109625. */
  109626. set(key: string, value: T): boolean;
  109627. /**
  109628. * Get the element of the given key and remove it from the dictionary
  109629. * @param key defines the key to search
  109630. * @returns the value associated with the key or null if not found
  109631. */
  109632. getAndRemove(key: string): Nullable<T>;
  109633. /**
  109634. * Remove a key/value from the dictionary.
  109635. * @param key the key to remove
  109636. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  109637. */
  109638. remove(key: string): boolean;
  109639. /**
  109640. * Clear the whole content of the dictionary
  109641. */
  109642. clear(): void;
  109643. /**
  109644. * Gets the current count
  109645. */
  109646. get count(): number;
  109647. /**
  109648. * Execute a callback on each key/val of the dictionary.
  109649. * Note that you can remove any element in this dictionary in the callback implementation
  109650. * @param callback the callback to execute on a given key/value pair
  109651. */
  109652. forEach(callback: (key: string, val: T) => void): void;
  109653. /**
  109654. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  109655. * If the callback returns null or undefined the method will iterate to the next key/value pair
  109656. * Note that you can remove any element in this dictionary in the callback implementation
  109657. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  109658. * @returns the first item
  109659. */
  109660. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  109661. private _count;
  109662. private _data;
  109663. }
  109664. }
  109665. declare module BABYLON {
  109666. /** @hidden */
  109667. export interface ICollisionCoordinator {
  109668. createCollider(): Collider;
  109669. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  109670. init(scene: Scene): void;
  109671. }
  109672. /** @hidden */
  109673. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  109674. private _scene;
  109675. private _scaledPosition;
  109676. private _scaledVelocity;
  109677. private _finalPosition;
  109678. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  109679. createCollider(): Collider;
  109680. init(scene: Scene): void;
  109681. private _collideWithWorld;
  109682. }
  109683. }
  109684. declare module BABYLON {
  109685. /**
  109686. * Class used to manage all inputs for the scene.
  109687. */
  109688. export class InputManager {
  109689. /** The distance in pixel that you have to move to prevent some events */
  109690. static DragMovementThreshold: number;
  109691. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  109692. static LongPressDelay: number;
  109693. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  109694. static DoubleClickDelay: number;
  109695. /** If you need to check double click without raising a single click at first click, enable this flag */
  109696. static ExclusiveDoubleClickMode: boolean;
  109697. private _wheelEventName;
  109698. private _onPointerMove;
  109699. private _onPointerDown;
  109700. private _onPointerUp;
  109701. private _initClickEvent;
  109702. private _initActionManager;
  109703. private _delayedSimpleClick;
  109704. private _delayedSimpleClickTimeout;
  109705. private _previousDelayedSimpleClickTimeout;
  109706. private _meshPickProceed;
  109707. private _previousButtonPressed;
  109708. private _currentPickResult;
  109709. private _previousPickResult;
  109710. private _totalPointersPressed;
  109711. private _doubleClickOccured;
  109712. private _pointerOverMesh;
  109713. private _pickedDownMesh;
  109714. private _pickedUpMesh;
  109715. private _pointerX;
  109716. private _pointerY;
  109717. private _unTranslatedPointerX;
  109718. private _unTranslatedPointerY;
  109719. private _startingPointerPosition;
  109720. private _previousStartingPointerPosition;
  109721. private _startingPointerTime;
  109722. private _previousStartingPointerTime;
  109723. private _pointerCaptures;
  109724. private _onKeyDown;
  109725. private _onKeyUp;
  109726. private _onCanvasFocusObserver;
  109727. private _onCanvasBlurObserver;
  109728. private _scene;
  109729. /**
  109730. * Creates a new InputManager
  109731. * @param scene defines the hosting scene
  109732. */
  109733. constructor(scene: Scene);
  109734. /**
  109735. * Gets the mesh that is currently under the pointer
  109736. */
  109737. get meshUnderPointer(): Nullable<AbstractMesh>;
  109738. /**
  109739. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  109740. */
  109741. get unTranslatedPointer(): Vector2;
  109742. /**
  109743. * Gets or sets the current on-screen X position of the pointer
  109744. */
  109745. get pointerX(): number;
  109746. set pointerX(value: number);
  109747. /**
  109748. * Gets or sets the current on-screen Y position of the pointer
  109749. */
  109750. get pointerY(): number;
  109751. set pointerY(value: number);
  109752. private _updatePointerPosition;
  109753. private _processPointerMove;
  109754. private _setRayOnPointerInfo;
  109755. private _checkPrePointerObservable;
  109756. /**
  109757. * Use this method to simulate a pointer move on a mesh
  109758. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109759. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109760. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109761. */
  109762. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  109763. /**
  109764. * Use this method to simulate a pointer down on a mesh
  109765. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109766. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109767. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109768. */
  109769. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  109770. private _processPointerDown;
  109771. /** @hidden */
  109772. _isPointerSwiping(): boolean;
  109773. /**
  109774. * Use this method to simulate a pointer up on a mesh
  109775. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109776. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109777. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109778. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  109779. */
  109780. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  109781. private _processPointerUp;
  109782. /**
  109783. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  109784. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  109785. * @returns true if the pointer was captured
  109786. */
  109787. isPointerCaptured(pointerId?: number): boolean;
  109788. /**
  109789. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  109790. * @param attachUp defines if you want to attach events to pointerup
  109791. * @param attachDown defines if you want to attach events to pointerdown
  109792. * @param attachMove defines if you want to attach events to pointermove
  109793. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  109794. */
  109795. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  109796. /**
  109797. * Detaches all event handlers
  109798. */
  109799. detachControl(): void;
  109800. /**
  109801. * Force the value of meshUnderPointer
  109802. * @param mesh defines the mesh to use
  109803. */
  109804. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  109805. /**
  109806. * Gets the mesh under the pointer
  109807. * @returns a Mesh or null if no mesh is under the pointer
  109808. */
  109809. getPointerOverMesh(): Nullable<AbstractMesh>;
  109810. }
  109811. }
  109812. declare module BABYLON {
  109813. /**
  109814. * Helper class used to generate session unique ID
  109815. */
  109816. export class UniqueIdGenerator {
  109817. private static _UniqueIdCounter;
  109818. /**
  109819. * Gets an unique (relatively to the current scene) Id
  109820. */
  109821. static get UniqueId(): number;
  109822. }
  109823. }
  109824. declare module BABYLON {
  109825. /**
  109826. * This class defines the direct association between an animation and a target
  109827. */
  109828. export class TargetedAnimation {
  109829. /**
  109830. * Animation to perform
  109831. */
  109832. animation: Animation;
  109833. /**
  109834. * Target to animate
  109835. */
  109836. target: any;
  109837. /**
  109838. * Serialize the object
  109839. * @returns the JSON object representing the current entity
  109840. */
  109841. serialize(): any;
  109842. }
  109843. /**
  109844. * Use this class to create coordinated animations on multiple targets
  109845. */
  109846. export class AnimationGroup implements IDisposable {
  109847. /** The name of the animation group */
  109848. name: string;
  109849. private _scene;
  109850. private _targetedAnimations;
  109851. private _animatables;
  109852. private _from;
  109853. private _to;
  109854. private _isStarted;
  109855. private _isPaused;
  109856. private _speedRatio;
  109857. private _loopAnimation;
  109858. private _isAdditive;
  109859. /**
  109860. * Gets or sets the unique id of the node
  109861. */
  109862. uniqueId: number;
  109863. /**
  109864. * This observable will notify when one animation have ended
  109865. */
  109866. onAnimationEndObservable: Observable<TargetedAnimation>;
  109867. /**
  109868. * Observer raised when one animation loops
  109869. */
  109870. onAnimationLoopObservable: Observable<TargetedAnimation>;
  109871. /**
  109872. * Observer raised when all animations have looped
  109873. */
  109874. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  109875. /**
  109876. * This observable will notify when all animations have ended.
  109877. */
  109878. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  109879. /**
  109880. * This observable will notify when all animations have paused.
  109881. */
  109882. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  109883. /**
  109884. * This observable will notify when all animations are playing.
  109885. */
  109886. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  109887. /**
  109888. * Gets the first frame
  109889. */
  109890. get from(): number;
  109891. /**
  109892. * Gets the last frame
  109893. */
  109894. get to(): number;
  109895. /**
  109896. * Define if the animations are started
  109897. */
  109898. get isStarted(): boolean;
  109899. /**
  109900. * Gets a value indicating that the current group is playing
  109901. */
  109902. get isPlaying(): boolean;
  109903. /**
  109904. * Gets or sets the speed ratio to use for all animations
  109905. */
  109906. get speedRatio(): number;
  109907. /**
  109908. * Gets or sets the speed ratio to use for all animations
  109909. */
  109910. set speedRatio(value: number);
  109911. /**
  109912. * Gets or sets if all animations should loop or not
  109913. */
  109914. get loopAnimation(): boolean;
  109915. set loopAnimation(value: boolean);
  109916. /**
  109917. * Gets or sets if all animations should be evaluated additively
  109918. */
  109919. get isAdditive(): boolean;
  109920. set isAdditive(value: boolean);
  109921. /**
  109922. * Gets the targeted animations for this animation group
  109923. */
  109924. get targetedAnimations(): Array<TargetedAnimation>;
  109925. /**
  109926. * returning the list of animatables controlled by this animation group.
  109927. */
  109928. get animatables(): Array<Animatable>;
  109929. /**
  109930. * Instantiates a new Animation Group.
  109931. * This helps managing several animations at once.
  109932. * @see http://doc.babylonjs.com/how_to/group
  109933. * @param name Defines the name of the group
  109934. * @param scene Defines the scene the group belongs to
  109935. */
  109936. constructor(
  109937. /** The name of the animation group */
  109938. name: string, scene?: Nullable<Scene>);
  109939. /**
  109940. * Add an animation (with its target) in the group
  109941. * @param animation defines the animation we want to add
  109942. * @param target defines the target of the animation
  109943. * @returns the TargetedAnimation object
  109944. */
  109945. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  109946. /**
  109947. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  109948. * It can add constant keys at begin or end
  109949. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  109950. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  109951. * @returns the animation group
  109952. */
  109953. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  109954. private _animationLoopCount;
  109955. private _animationLoopFlags;
  109956. private _processLoop;
  109957. /**
  109958. * Start all animations on given targets
  109959. * @param loop defines if animations must loop
  109960. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  109961. * @param from defines the from key (optional)
  109962. * @param to defines the to key (optional)
  109963. * @param isAdditive defines the additive state for the resulting animatables (optional)
  109964. * @returns the current animation group
  109965. */
  109966. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  109967. /**
  109968. * Pause all animations
  109969. * @returns the animation group
  109970. */
  109971. pause(): AnimationGroup;
  109972. /**
  109973. * Play all animations to initial state
  109974. * This function will start() the animations if they were not started or will restart() them if they were paused
  109975. * @param loop defines if animations must loop
  109976. * @returns the animation group
  109977. */
  109978. play(loop?: boolean): AnimationGroup;
  109979. /**
  109980. * Reset all animations to initial state
  109981. * @returns the animation group
  109982. */
  109983. reset(): AnimationGroup;
  109984. /**
  109985. * Restart animations from key 0
  109986. * @returns the animation group
  109987. */
  109988. restart(): AnimationGroup;
  109989. /**
  109990. * Stop all animations
  109991. * @returns the animation group
  109992. */
  109993. stop(): AnimationGroup;
  109994. /**
  109995. * Set animation weight for all animatables
  109996. * @param weight defines the weight to use
  109997. * @return the animationGroup
  109998. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  109999. */
  110000. setWeightForAllAnimatables(weight: number): AnimationGroup;
  110001. /**
  110002. * Synchronize and normalize all animatables with a source animatable
  110003. * @param root defines the root animatable to synchronize with
  110004. * @return the animationGroup
  110005. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  110006. */
  110007. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  110008. /**
  110009. * Goes to a specific frame in this animation group
  110010. * @param frame the frame number to go to
  110011. * @return the animationGroup
  110012. */
  110013. goToFrame(frame: number): AnimationGroup;
  110014. /**
  110015. * Dispose all associated resources
  110016. */
  110017. dispose(): void;
  110018. private _checkAnimationGroupEnded;
  110019. /**
  110020. * Clone the current animation group and returns a copy
  110021. * @param newName defines the name of the new group
  110022. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  110023. * @returns the new aniamtion group
  110024. */
  110025. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  110026. /**
  110027. * Serializes the animationGroup to an object
  110028. * @returns Serialized object
  110029. */
  110030. serialize(): any;
  110031. /**
  110032. * Returns a new AnimationGroup object parsed from the source provided.
  110033. * @param parsedAnimationGroup defines the source
  110034. * @param scene defines the scene that will receive the animationGroup
  110035. * @returns a new AnimationGroup
  110036. */
  110037. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  110038. /**
  110039. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  110040. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  110041. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  110042. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  110043. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  110044. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  110045. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  110046. */
  110047. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  110048. /**
  110049. * Returns the string "AnimationGroup"
  110050. * @returns "AnimationGroup"
  110051. */
  110052. getClassName(): string;
  110053. /**
  110054. * Creates a detailled string about the object
  110055. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  110056. * @returns a string representing the object
  110057. */
  110058. toString(fullDetails?: boolean): string;
  110059. }
  110060. }
  110061. declare module BABYLON {
  110062. /**
  110063. * Define an interface for all classes that will hold resources
  110064. */
  110065. export interface IDisposable {
  110066. /**
  110067. * Releases all held resources
  110068. */
  110069. dispose(): void;
  110070. }
  110071. /** Interface defining initialization parameters for Scene class */
  110072. export interface SceneOptions {
  110073. /**
  110074. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  110075. * It will improve performance when the number of geometries becomes important.
  110076. */
  110077. useGeometryUniqueIdsMap?: boolean;
  110078. /**
  110079. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  110080. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  110081. */
  110082. useMaterialMeshMap?: boolean;
  110083. /**
  110084. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  110085. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  110086. */
  110087. useClonedMeshMap?: boolean;
  110088. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  110089. virtual?: boolean;
  110090. }
  110091. /**
  110092. * Represents a scene to be rendered by the engine.
  110093. * @see http://doc.babylonjs.com/features/scene
  110094. */
  110095. export class Scene extends AbstractScene implements IAnimatable {
  110096. /** The fog is deactivated */
  110097. static readonly FOGMODE_NONE: number;
  110098. /** The fog density is following an exponential function */
  110099. static readonly FOGMODE_EXP: number;
  110100. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  110101. static readonly FOGMODE_EXP2: number;
  110102. /** The fog density is following a linear function. */
  110103. static readonly FOGMODE_LINEAR: number;
  110104. /**
  110105. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  110106. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110107. */
  110108. static MinDeltaTime: number;
  110109. /**
  110110. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  110111. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110112. */
  110113. static MaxDeltaTime: number;
  110114. /**
  110115. * Factory used to create the default material.
  110116. * @param name The name of the material to create
  110117. * @param scene The scene to create the material for
  110118. * @returns The default material
  110119. */
  110120. static DefaultMaterialFactory(scene: Scene): Material;
  110121. /**
  110122. * Factory used to create the a collision coordinator.
  110123. * @returns The collision coordinator
  110124. */
  110125. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  110126. /** @hidden */
  110127. _inputManager: InputManager;
  110128. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  110129. cameraToUseForPointers: Nullable<Camera>;
  110130. /** @hidden */
  110131. readonly _isScene: boolean;
  110132. /** @hidden */
  110133. _blockEntityCollection: boolean;
  110134. /**
  110135. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  110136. */
  110137. autoClear: boolean;
  110138. /**
  110139. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  110140. */
  110141. autoClearDepthAndStencil: boolean;
  110142. /**
  110143. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  110144. */
  110145. clearColor: Color4;
  110146. /**
  110147. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  110148. */
  110149. ambientColor: Color3;
  110150. /**
  110151. * This is use to store the default BRDF lookup for PBR materials in your scene.
  110152. * It should only be one of the following (if not the default embedded one):
  110153. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  110154. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  110155. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  110156. * The material properties need to be setup according to the type of texture in use.
  110157. */
  110158. environmentBRDFTexture: BaseTexture;
  110159. /** @hidden */
  110160. protected _environmentTexture: Nullable<BaseTexture>;
  110161. /**
  110162. * Texture used in all pbr material as the reflection texture.
  110163. * As in the majority of the scene they are the same (exception for multi room and so on),
  110164. * this is easier to reference from here than from all the materials.
  110165. */
  110166. get environmentTexture(): Nullable<BaseTexture>;
  110167. /**
  110168. * Texture used in all pbr material as the reflection texture.
  110169. * As in the majority of the scene they are the same (exception for multi room and so on),
  110170. * this is easier to set here than in all the materials.
  110171. */
  110172. set environmentTexture(value: Nullable<BaseTexture>);
  110173. /** @hidden */
  110174. protected _environmentIntensity: number;
  110175. /**
  110176. * Intensity of the environment in all pbr material.
  110177. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  110178. * As in the majority of the scene they are the same (exception for multi room and so on),
  110179. * this is easier to reference from here than from all the materials.
  110180. */
  110181. get environmentIntensity(): number;
  110182. /**
  110183. * Intensity of the environment in all pbr material.
  110184. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  110185. * As in the majority of the scene they are the same (exception for multi room and so on),
  110186. * this is easier to set here than in all the materials.
  110187. */
  110188. set environmentIntensity(value: number);
  110189. /** @hidden */
  110190. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  110191. /**
  110192. * Default image processing configuration used either in the rendering
  110193. * Forward main pass or through the imageProcessingPostProcess if present.
  110194. * As in the majority of the scene they are the same (exception for multi camera),
  110195. * this is easier to reference from here than from all the materials and post process.
  110196. *
  110197. * No setter as we it is a shared configuration, you can set the values instead.
  110198. */
  110199. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  110200. private _forceWireframe;
  110201. /**
  110202. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  110203. */
  110204. set forceWireframe(value: boolean);
  110205. get forceWireframe(): boolean;
  110206. private _skipFrustumClipping;
  110207. /**
  110208. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  110209. */
  110210. set skipFrustumClipping(value: boolean);
  110211. get skipFrustumClipping(): boolean;
  110212. private _forcePointsCloud;
  110213. /**
  110214. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  110215. */
  110216. set forcePointsCloud(value: boolean);
  110217. get forcePointsCloud(): boolean;
  110218. /**
  110219. * Gets or sets the active clipplane 1
  110220. */
  110221. clipPlane: Nullable<Plane>;
  110222. /**
  110223. * Gets or sets the active clipplane 2
  110224. */
  110225. clipPlane2: Nullable<Plane>;
  110226. /**
  110227. * Gets or sets the active clipplane 3
  110228. */
  110229. clipPlane3: Nullable<Plane>;
  110230. /**
  110231. * Gets or sets the active clipplane 4
  110232. */
  110233. clipPlane4: Nullable<Plane>;
  110234. /**
  110235. * Gets or sets the active clipplane 5
  110236. */
  110237. clipPlane5: Nullable<Plane>;
  110238. /**
  110239. * Gets or sets the active clipplane 6
  110240. */
  110241. clipPlane6: Nullable<Plane>;
  110242. /**
  110243. * Gets or sets a boolean indicating if animations are enabled
  110244. */
  110245. animationsEnabled: boolean;
  110246. private _animationPropertiesOverride;
  110247. /**
  110248. * Gets or sets the animation properties override
  110249. */
  110250. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  110251. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  110252. /**
  110253. * Gets or sets a boolean indicating if a constant deltatime has to be used
  110254. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  110255. */
  110256. useConstantAnimationDeltaTime: boolean;
  110257. /**
  110258. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  110259. * Please note that it requires to run a ray cast through the scene on every frame
  110260. */
  110261. constantlyUpdateMeshUnderPointer: boolean;
  110262. /**
  110263. * Defines the HTML cursor to use when hovering over interactive elements
  110264. */
  110265. hoverCursor: string;
  110266. /**
  110267. * Defines the HTML default cursor to use (empty by default)
  110268. */
  110269. defaultCursor: string;
  110270. /**
  110271. * Defines whether cursors are handled by the scene.
  110272. */
  110273. doNotHandleCursors: boolean;
  110274. /**
  110275. * This is used to call preventDefault() on pointer down
  110276. * in order to block unwanted artifacts like system double clicks
  110277. */
  110278. preventDefaultOnPointerDown: boolean;
  110279. /**
  110280. * This is used to call preventDefault() on pointer up
  110281. * in order to block unwanted artifacts like system double clicks
  110282. */
  110283. preventDefaultOnPointerUp: boolean;
  110284. /**
  110285. * Gets or sets user defined metadata
  110286. */
  110287. metadata: any;
  110288. /**
  110289. * For internal use only. Please do not use.
  110290. */
  110291. reservedDataStore: any;
  110292. /**
  110293. * Gets the name of the plugin used to load this scene (null by default)
  110294. */
  110295. loadingPluginName: string;
  110296. /**
  110297. * Use this array to add regular expressions used to disable offline support for specific urls
  110298. */
  110299. disableOfflineSupportExceptionRules: RegExp[];
  110300. /**
  110301. * An event triggered when the scene is disposed.
  110302. */
  110303. onDisposeObservable: Observable<Scene>;
  110304. private _onDisposeObserver;
  110305. /** Sets a function to be executed when this scene is disposed. */
  110306. set onDispose(callback: () => void);
  110307. /**
  110308. * An event triggered before rendering the scene (right after animations and physics)
  110309. */
  110310. onBeforeRenderObservable: Observable<Scene>;
  110311. private _onBeforeRenderObserver;
  110312. /** Sets a function to be executed before rendering this scene */
  110313. set beforeRender(callback: Nullable<() => void>);
  110314. /**
  110315. * An event triggered after rendering the scene
  110316. */
  110317. onAfterRenderObservable: Observable<Scene>;
  110318. /**
  110319. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  110320. */
  110321. onAfterRenderCameraObservable: Observable<Camera>;
  110322. private _onAfterRenderObserver;
  110323. /** Sets a function to be executed after rendering this scene */
  110324. set afterRender(callback: Nullable<() => void>);
  110325. /**
  110326. * An event triggered before animating the scene
  110327. */
  110328. onBeforeAnimationsObservable: Observable<Scene>;
  110329. /**
  110330. * An event triggered after animations processing
  110331. */
  110332. onAfterAnimationsObservable: Observable<Scene>;
  110333. /**
  110334. * An event triggered before draw calls are ready to be sent
  110335. */
  110336. onBeforeDrawPhaseObservable: Observable<Scene>;
  110337. /**
  110338. * An event triggered after draw calls have been sent
  110339. */
  110340. onAfterDrawPhaseObservable: Observable<Scene>;
  110341. /**
  110342. * An event triggered when the scene is ready
  110343. */
  110344. onReadyObservable: Observable<Scene>;
  110345. /**
  110346. * An event triggered before rendering a camera
  110347. */
  110348. onBeforeCameraRenderObservable: Observable<Camera>;
  110349. private _onBeforeCameraRenderObserver;
  110350. /** Sets a function to be executed before rendering a camera*/
  110351. set beforeCameraRender(callback: () => void);
  110352. /**
  110353. * An event triggered after rendering a camera
  110354. */
  110355. onAfterCameraRenderObservable: Observable<Camera>;
  110356. private _onAfterCameraRenderObserver;
  110357. /** Sets a function to be executed after rendering a camera*/
  110358. set afterCameraRender(callback: () => void);
  110359. /**
  110360. * An event triggered when active meshes evaluation is about to start
  110361. */
  110362. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  110363. /**
  110364. * An event triggered when active meshes evaluation is done
  110365. */
  110366. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  110367. /**
  110368. * An event triggered when particles rendering is about to start
  110369. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  110370. */
  110371. onBeforeParticlesRenderingObservable: Observable<Scene>;
  110372. /**
  110373. * An event triggered when particles rendering is done
  110374. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  110375. */
  110376. onAfterParticlesRenderingObservable: Observable<Scene>;
  110377. /**
  110378. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  110379. */
  110380. onDataLoadedObservable: Observable<Scene>;
  110381. /**
  110382. * An event triggered when a camera is created
  110383. */
  110384. onNewCameraAddedObservable: Observable<Camera>;
  110385. /**
  110386. * An event triggered when a camera is removed
  110387. */
  110388. onCameraRemovedObservable: Observable<Camera>;
  110389. /**
  110390. * An event triggered when a light is created
  110391. */
  110392. onNewLightAddedObservable: Observable<Light>;
  110393. /**
  110394. * An event triggered when a light is removed
  110395. */
  110396. onLightRemovedObservable: Observable<Light>;
  110397. /**
  110398. * An event triggered when a geometry is created
  110399. */
  110400. onNewGeometryAddedObservable: Observable<Geometry>;
  110401. /**
  110402. * An event triggered when a geometry is removed
  110403. */
  110404. onGeometryRemovedObservable: Observable<Geometry>;
  110405. /**
  110406. * An event triggered when a transform node is created
  110407. */
  110408. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  110409. /**
  110410. * An event triggered when a transform node is removed
  110411. */
  110412. onTransformNodeRemovedObservable: Observable<TransformNode>;
  110413. /**
  110414. * An event triggered when a mesh is created
  110415. */
  110416. onNewMeshAddedObservable: Observable<AbstractMesh>;
  110417. /**
  110418. * An event triggered when a mesh is removed
  110419. */
  110420. onMeshRemovedObservable: Observable<AbstractMesh>;
  110421. /**
  110422. * An event triggered when a skeleton is created
  110423. */
  110424. onNewSkeletonAddedObservable: Observable<Skeleton>;
  110425. /**
  110426. * An event triggered when a skeleton is removed
  110427. */
  110428. onSkeletonRemovedObservable: Observable<Skeleton>;
  110429. /**
  110430. * An event triggered when a material is created
  110431. */
  110432. onNewMaterialAddedObservable: Observable<Material>;
  110433. /**
  110434. * An event triggered when a material is removed
  110435. */
  110436. onMaterialRemovedObservable: Observable<Material>;
  110437. /**
  110438. * An event triggered when a texture is created
  110439. */
  110440. onNewTextureAddedObservable: Observable<BaseTexture>;
  110441. /**
  110442. * An event triggered when a texture is removed
  110443. */
  110444. onTextureRemovedObservable: Observable<BaseTexture>;
  110445. /**
  110446. * An event triggered when render targets are about to be rendered
  110447. * Can happen multiple times per frame.
  110448. */
  110449. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  110450. /**
  110451. * An event triggered when render targets were rendered.
  110452. * Can happen multiple times per frame.
  110453. */
  110454. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  110455. /**
  110456. * An event triggered before calculating deterministic simulation step
  110457. */
  110458. onBeforeStepObservable: Observable<Scene>;
  110459. /**
  110460. * An event triggered after calculating deterministic simulation step
  110461. */
  110462. onAfterStepObservable: Observable<Scene>;
  110463. /**
  110464. * An event triggered when the activeCamera property is updated
  110465. */
  110466. onActiveCameraChanged: Observable<Scene>;
  110467. /**
  110468. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  110469. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  110470. * 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)
  110471. */
  110472. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  110473. /**
  110474. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  110475. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  110476. * 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)
  110477. */
  110478. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  110479. /**
  110480. * This Observable will when a mesh has been imported into the scene.
  110481. */
  110482. onMeshImportedObservable: Observable<AbstractMesh>;
  110483. /**
  110484. * This Observable will when an animation file has been imported into the scene.
  110485. */
  110486. onAnimationFileImportedObservable: Observable<Scene>;
  110487. /**
  110488. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  110489. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  110490. */
  110491. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  110492. /** @hidden */
  110493. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  110494. /**
  110495. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  110496. */
  110497. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  110498. /**
  110499. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  110500. */
  110501. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  110502. /**
  110503. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  110504. */
  110505. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  110506. /** Callback called when a pointer move is detected */
  110507. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  110508. /** Callback called when a pointer down is detected */
  110509. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  110510. /** Callback called when a pointer up is detected */
  110511. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  110512. /** Callback called when a pointer pick is detected */
  110513. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  110514. /**
  110515. * 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).
  110516. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  110517. */
  110518. onPrePointerObservable: Observable<PointerInfoPre>;
  110519. /**
  110520. * Observable event triggered each time an input event is received from the rendering canvas
  110521. */
  110522. onPointerObservable: Observable<PointerInfo>;
  110523. /**
  110524. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  110525. */
  110526. get unTranslatedPointer(): Vector2;
  110527. /**
  110528. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  110529. */
  110530. static get DragMovementThreshold(): number;
  110531. static set DragMovementThreshold(value: number);
  110532. /**
  110533. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  110534. */
  110535. static get LongPressDelay(): number;
  110536. static set LongPressDelay(value: number);
  110537. /**
  110538. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  110539. */
  110540. static get DoubleClickDelay(): number;
  110541. static set DoubleClickDelay(value: number);
  110542. /** If you need to check double click without raising a single click at first click, enable this flag */
  110543. static get ExclusiveDoubleClickMode(): boolean;
  110544. static set ExclusiveDoubleClickMode(value: boolean);
  110545. /** @hidden */
  110546. _mirroredCameraPosition: Nullable<Vector3>;
  110547. /**
  110548. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  110549. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  110550. */
  110551. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  110552. /**
  110553. * Observable event triggered each time an keyboard event is received from the hosting window
  110554. */
  110555. onKeyboardObservable: Observable<KeyboardInfo>;
  110556. private _useRightHandedSystem;
  110557. /**
  110558. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  110559. */
  110560. set useRightHandedSystem(value: boolean);
  110561. get useRightHandedSystem(): boolean;
  110562. private _timeAccumulator;
  110563. private _currentStepId;
  110564. private _currentInternalStep;
  110565. /**
  110566. * Sets the step Id used by deterministic lock step
  110567. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110568. * @param newStepId defines the step Id
  110569. */
  110570. setStepId(newStepId: number): void;
  110571. /**
  110572. * Gets the step Id used by deterministic lock step
  110573. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110574. * @returns the step Id
  110575. */
  110576. getStepId(): number;
  110577. /**
  110578. * Gets the internal step used by deterministic lock step
  110579. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110580. * @returns the internal step
  110581. */
  110582. getInternalStep(): number;
  110583. private _fogEnabled;
  110584. /**
  110585. * Gets or sets a boolean indicating if fog is enabled on this scene
  110586. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110587. * (Default is true)
  110588. */
  110589. set fogEnabled(value: boolean);
  110590. get fogEnabled(): boolean;
  110591. private _fogMode;
  110592. /**
  110593. * Gets or sets the fog mode to use
  110594. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110595. * | mode | value |
  110596. * | --- | --- |
  110597. * | FOGMODE_NONE | 0 |
  110598. * | FOGMODE_EXP | 1 |
  110599. * | FOGMODE_EXP2 | 2 |
  110600. * | FOGMODE_LINEAR | 3 |
  110601. */
  110602. set fogMode(value: number);
  110603. get fogMode(): number;
  110604. /**
  110605. * Gets or sets the fog color to use
  110606. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110607. * (Default is Color3(0.2, 0.2, 0.3))
  110608. */
  110609. fogColor: Color3;
  110610. /**
  110611. * Gets or sets the fog density to use
  110612. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110613. * (Default is 0.1)
  110614. */
  110615. fogDensity: number;
  110616. /**
  110617. * Gets or sets the fog start distance to use
  110618. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110619. * (Default is 0)
  110620. */
  110621. fogStart: number;
  110622. /**
  110623. * Gets or sets the fog end distance to use
  110624. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110625. * (Default is 1000)
  110626. */
  110627. fogEnd: number;
  110628. private _shadowsEnabled;
  110629. /**
  110630. * Gets or sets a boolean indicating if shadows are enabled on this scene
  110631. */
  110632. set shadowsEnabled(value: boolean);
  110633. get shadowsEnabled(): boolean;
  110634. private _lightsEnabled;
  110635. /**
  110636. * Gets or sets a boolean indicating if lights are enabled on this scene
  110637. */
  110638. set lightsEnabled(value: boolean);
  110639. get lightsEnabled(): boolean;
  110640. /** All of the active cameras added to this scene. */
  110641. activeCameras: Camera[];
  110642. /** @hidden */
  110643. _activeCamera: Nullable<Camera>;
  110644. /** Gets or sets the current active camera */
  110645. get activeCamera(): Nullable<Camera>;
  110646. set activeCamera(value: Nullable<Camera>);
  110647. private _defaultMaterial;
  110648. /** The default material used on meshes when no material is affected */
  110649. get defaultMaterial(): Material;
  110650. /** The default material used on meshes when no material is affected */
  110651. set defaultMaterial(value: Material);
  110652. private _texturesEnabled;
  110653. /**
  110654. * Gets or sets a boolean indicating if textures are enabled on this scene
  110655. */
  110656. set texturesEnabled(value: boolean);
  110657. get texturesEnabled(): boolean;
  110658. /**
  110659. * Gets or sets a boolean indicating if particles are enabled on this scene
  110660. */
  110661. particlesEnabled: boolean;
  110662. /**
  110663. * Gets or sets a boolean indicating if sprites are enabled on this scene
  110664. */
  110665. spritesEnabled: boolean;
  110666. private _skeletonsEnabled;
  110667. /**
  110668. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  110669. */
  110670. set skeletonsEnabled(value: boolean);
  110671. get skeletonsEnabled(): boolean;
  110672. /**
  110673. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  110674. */
  110675. lensFlaresEnabled: boolean;
  110676. /**
  110677. * Gets or sets a boolean indicating if collisions are enabled on this scene
  110678. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110679. */
  110680. collisionsEnabled: boolean;
  110681. private _collisionCoordinator;
  110682. /** @hidden */
  110683. get collisionCoordinator(): ICollisionCoordinator;
  110684. /**
  110685. * Defines the gravity applied to this scene (used only for collisions)
  110686. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110687. */
  110688. gravity: Vector3;
  110689. /**
  110690. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  110691. */
  110692. postProcessesEnabled: boolean;
  110693. /**
  110694. * The list of postprocesses added to the scene
  110695. */
  110696. postProcesses: PostProcess[];
  110697. /**
  110698. * Gets the current postprocess manager
  110699. */
  110700. postProcessManager: PostProcessManager;
  110701. /**
  110702. * Gets or sets a boolean indicating if render targets are enabled on this scene
  110703. */
  110704. renderTargetsEnabled: boolean;
  110705. /**
  110706. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  110707. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  110708. */
  110709. dumpNextRenderTargets: boolean;
  110710. /**
  110711. * The list of user defined render targets added to the scene
  110712. */
  110713. customRenderTargets: RenderTargetTexture[];
  110714. /**
  110715. * Defines if texture loading must be delayed
  110716. * If true, textures will only be loaded when they need to be rendered
  110717. */
  110718. useDelayedTextureLoading: boolean;
  110719. /**
  110720. * Gets the list of meshes imported to the scene through SceneLoader
  110721. */
  110722. importedMeshesFiles: String[];
  110723. /**
  110724. * Gets or sets a boolean indicating if probes are enabled on this scene
  110725. */
  110726. probesEnabled: boolean;
  110727. /**
  110728. * Gets or sets the current offline provider to use to store scene data
  110729. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  110730. */
  110731. offlineProvider: IOfflineProvider;
  110732. /**
  110733. * Gets or sets the action manager associated with the scene
  110734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  110735. */
  110736. actionManager: AbstractActionManager;
  110737. private _meshesForIntersections;
  110738. /**
  110739. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  110740. */
  110741. proceduralTexturesEnabled: boolean;
  110742. private _engine;
  110743. private _totalVertices;
  110744. /** @hidden */
  110745. _activeIndices: PerfCounter;
  110746. /** @hidden */
  110747. _activeParticles: PerfCounter;
  110748. /** @hidden */
  110749. _activeBones: PerfCounter;
  110750. private _animationRatio;
  110751. /** @hidden */
  110752. _animationTimeLast: number;
  110753. /** @hidden */
  110754. _animationTime: number;
  110755. /**
  110756. * Gets or sets a general scale for animation speed
  110757. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  110758. */
  110759. animationTimeScale: number;
  110760. /** @hidden */
  110761. _cachedMaterial: Nullable<Material>;
  110762. /** @hidden */
  110763. _cachedEffect: Nullable<Effect>;
  110764. /** @hidden */
  110765. _cachedVisibility: Nullable<number>;
  110766. private _renderId;
  110767. private _frameId;
  110768. private _executeWhenReadyTimeoutId;
  110769. private _intermediateRendering;
  110770. private _viewUpdateFlag;
  110771. private _projectionUpdateFlag;
  110772. /** @hidden */
  110773. _toBeDisposed: Nullable<IDisposable>[];
  110774. private _activeRequests;
  110775. /** @hidden */
  110776. _pendingData: any[];
  110777. private _isDisposed;
  110778. /**
  110779. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  110780. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  110781. */
  110782. dispatchAllSubMeshesOfActiveMeshes: boolean;
  110783. private _activeMeshes;
  110784. private _processedMaterials;
  110785. private _renderTargets;
  110786. /** @hidden */
  110787. _activeParticleSystems: SmartArray<IParticleSystem>;
  110788. private _activeSkeletons;
  110789. private _softwareSkinnedMeshes;
  110790. private _renderingManager;
  110791. /** @hidden */
  110792. _activeAnimatables: Animatable[];
  110793. private _transformMatrix;
  110794. private _sceneUbo;
  110795. /** @hidden */
  110796. _viewMatrix: Matrix;
  110797. private _projectionMatrix;
  110798. /** @hidden */
  110799. _forcedViewPosition: Nullable<Vector3>;
  110800. /** @hidden */
  110801. _frustumPlanes: Plane[];
  110802. /**
  110803. * Gets the list of frustum planes (built from the active camera)
  110804. */
  110805. get frustumPlanes(): Plane[];
  110806. /**
  110807. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  110808. * This is useful if there are more lights that the maximum simulteanous authorized
  110809. */
  110810. requireLightSorting: boolean;
  110811. /** @hidden */
  110812. readonly useMaterialMeshMap: boolean;
  110813. /** @hidden */
  110814. readonly useClonedMeshMap: boolean;
  110815. private _externalData;
  110816. private _uid;
  110817. /**
  110818. * @hidden
  110819. * Backing store of defined scene components.
  110820. */
  110821. _components: ISceneComponent[];
  110822. /**
  110823. * @hidden
  110824. * Backing store of defined scene components.
  110825. */
  110826. _serializableComponents: ISceneSerializableComponent[];
  110827. /**
  110828. * List of components to register on the next registration step.
  110829. */
  110830. private _transientComponents;
  110831. /**
  110832. * Registers the transient components if needed.
  110833. */
  110834. private _registerTransientComponents;
  110835. /**
  110836. * @hidden
  110837. * Add a component to the scene.
  110838. * Note that the ccomponent could be registered on th next frame if this is called after
  110839. * the register component stage.
  110840. * @param component Defines the component to add to the scene
  110841. */
  110842. _addComponent(component: ISceneComponent): void;
  110843. /**
  110844. * @hidden
  110845. * Gets a component from the scene.
  110846. * @param name defines the name of the component to retrieve
  110847. * @returns the component or null if not present
  110848. */
  110849. _getComponent(name: string): Nullable<ISceneComponent>;
  110850. /**
  110851. * @hidden
  110852. * Defines the actions happening before camera updates.
  110853. */
  110854. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  110855. /**
  110856. * @hidden
  110857. * Defines the actions happening before clear the canvas.
  110858. */
  110859. _beforeClearStage: Stage<SimpleStageAction>;
  110860. /**
  110861. * @hidden
  110862. * Defines the actions when collecting render targets for the frame.
  110863. */
  110864. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  110865. /**
  110866. * @hidden
  110867. * Defines the actions happening for one camera in the frame.
  110868. */
  110869. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  110870. /**
  110871. * @hidden
  110872. * Defines the actions happening during the per mesh ready checks.
  110873. */
  110874. _isReadyForMeshStage: Stage<MeshStageAction>;
  110875. /**
  110876. * @hidden
  110877. * Defines the actions happening before evaluate active mesh checks.
  110878. */
  110879. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  110880. /**
  110881. * @hidden
  110882. * Defines the actions happening during the evaluate sub mesh checks.
  110883. */
  110884. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  110885. /**
  110886. * @hidden
  110887. * Defines the actions happening during the active mesh stage.
  110888. */
  110889. _activeMeshStage: Stage<ActiveMeshStageAction>;
  110890. /**
  110891. * @hidden
  110892. * Defines the actions happening during the per camera render target step.
  110893. */
  110894. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  110895. /**
  110896. * @hidden
  110897. * Defines the actions happening just before the active camera is drawing.
  110898. */
  110899. _beforeCameraDrawStage: Stage<CameraStageAction>;
  110900. /**
  110901. * @hidden
  110902. * Defines the actions happening just before a render target is drawing.
  110903. */
  110904. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  110905. /**
  110906. * @hidden
  110907. * Defines the actions happening just before a rendering group is drawing.
  110908. */
  110909. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  110910. /**
  110911. * @hidden
  110912. * Defines the actions happening just before a mesh is drawing.
  110913. */
  110914. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  110915. /**
  110916. * @hidden
  110917. * Defines the actions happening just after a mesh has been drawn.
  110918. */
  110919. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  110920. /**
  110921. * @hidden
  110922. * Defines the actions happening just after a rendering group has been drawn.
  110923. */
  110924. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  110925. /**
  110926. * @hidden
  110927. * Defines the actions happening just after the active camera has been drawn.
  110928. */
  110929. _afterCameraDrawStage: Stage<CameraStageAction>;
  110930. /**
  110931. * @hidden
  110932. * Defines the actions happening just after a render target has been drawn.
  110933. */
  110934. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  110935. /**
  110936. * @hidden
  110937. * Defines the actions happening just after rendering all cameras and computing intersections.
  110938. */
  110939. _afterRenderStage: Stage<SimpleStageAction>;
  110940. /**
  110941. * @hidden
  110942. * Defines the actions happening when a pointer move event happens.
  110943. */
  110944. _pointerMoveStage: Stage<PointerMoveStageAction>;
  110945. /**
  110946. * @hidden
  110947. * Defines the actions happening when a pointer down event happens.
  110948. */
  110949. _pointerDownStage: Stage<PointerUpDownStageAction>;
  110950. /**
  110951. * @hidden
  110952. * Defines the actions happening when a pointer up event happens.
  110953. */
  110954. _pointerUpStage: Stage<PointerUpDownStageAction>;
  110955. /**
  110956. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  110957. */
  110958. private geometriesByUniqueId;
  110959. /**
  110960. * Creates a new Scene
  110961. * @param engine defines the engine to use to render this scene
  110962. * @param options defines the scene options
  110963. */
  110964. constructor(engine: Engine, options?: SceneOptions);
  110965. /**
  110966. * Gets a string idenfifying the name of the class
  110967. * @returns "Scene" string
  110968. */
  110969. getClassName(): string;
  110970. private _defaultMeshCandidates;
  110971. /**
  110972. * @hidden
  110973. */
  110974. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  110975. private _defaultSubMeshCandidates;
  110976. /**
  110977. * @hidden
  110978. */
  110979. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  110980. /**
  110981. * Sets the default candidate providers for the scene.
  110982. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  110983. * and getCollidingSubMeshCandidates to their default function
  110984. */
  110985. setDefaultCandidateProviders(): void;
  110986. /**
  110987. * Gets the mesh that is currently under the pointer
  110988. */
  110989. get meshUnderPointer(): Nullable<AbstractMesh>;
  110990. /**
  110991. * Gets or sets the current on-screen X position of the pointer
  110992. */
  110993. get pointerX(): number;
  110994. set pointerX(value: number);
  110995. /**
  110996. * Gets or sets the current on-screen Y position of the pointer
  110997. */
  110998. get pointerY(): number;
  110999. set pointerY(value: number);
  111000. /**
  111001. * Gets the cached material (ie. the latest rendered one)
  111002. * @returns the cached material
  111003. */
  111004. getCachedMaterial(): Nullable<Material>;
  111005. /**
  111006. * Gets the cached effect (ie. the latest rendered one)
  111007. * @returns the cached effect
  111008. */
  111009. getCachedEffect(): Nullable<Effect>;
  111010. /**
  111011. * Gets the cached visibility state (ie. the latest rendered one)
  111012. * @returns the cached visibility state
  111013. */
  111014. getCachedVisibility(): Nullable<number>;
  111015. /**
  111016. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  111017. * @param material defines the current material
  111018. * @param effect defines the current effect
  111019. * @param visibility defines the current visibility state
  111020. * @returns true if one parameter is not cached
  111021. */
  111022. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  111023. /**
  111024. * Gets the engine associated with the scene
  111025. * @returns an Engine
  111026. */
  111027. getEngine(): Engine;
  111028. /**
  111029. * Gets the total number of vertices rendered per frame
  111030. * @returns the total number of vertices rendered per frame
  111031. */
  111032. getTotalVertices(): number;
  111033. /**
  111034. * Gets the performance counter for total vertices
  111035. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  111036. */
  111037. get totalVerticesPerfCounter(): PerfCounter;
  111038. /**
  111039. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  111040. * @returns the total number of active indices rendered per frame
  111041. */
  111042. getActiveIndices(): number;
  111043. /**
  111044. * Gets the performance counter for active indices
  111045. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  111046. */
  111047. get totalActiveIndicesPerfCounter(): PerfCounter;
  111048. /**
  111049. * Gets the total number of active particles rendered per frame
  111050. * @returns the total number of active particles rendered per frame
  111051. */
  111052. getActiveParticles(): number;
  111053. /**
  111054. * Gets the performance counter for active particles
  111055. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  111056. */
  111057. get activeParticlesPerfCounter(): PerfCounter;
  111058. /**
  111059. * Gets the total number of active bones rendered per frame
  111060. * @returns the total number of active bones rendered per frame
  111061. */
  111062. getActiveBones(): number;
  111063. /**
  111064. * Gets the performance counter for active bones
  111065. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  111066. */
  111067. get activeBonesPerfCounter(): PerfCounter;
  111068. /**
  111069. * Gets the array of active meshes
  111070. * @returns an array of AbstractMesh
  111071. */
  111072. getActiveMeshes(): SmartArray<AbstractMesh>;
  111073. /**
  111074. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  111075. * @returns a number
  111076. */
  111077. getAnimationRatio(): number;
  111078. /**
  111079. * Gets an unique Id for the current render phase
  111080. * @returns a number
  111081. */
  111082. getRenderId(): number;
  111083. /**
  111084. * Gets an unique Id for the current frame
  111085. * @returns a number
  111086. */
  111087. getFrameId(): number;
  111088. /** Call this function if you want to manually increment the render Id*/
  111089. incrementRenderId(): void;
  111090. private _createUbo;
  111091. /**
  111092. * Use this method to simulate a pointer move on a mesh
  111093. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  111094. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  111095. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  111096. * @returns the current scene
  111097. */
  111098. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  111099. /**
  111100. * Use this method to simulate a pointer down on a mesh
  111101. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  111102. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  111103. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  111104. * @returns the current scene
  111105. */
  111106. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  111107. /**
  111108. * Use this method to simulate a pointer up on a mesh
  111109. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  111110. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  111111. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  111112. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  111113. * @returns the current scene
  111114. */
  111115. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  111116. /**
  111117. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  111118. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  111119. * @returns true if the pointer was captured
  111120. */
  111121. isPointerCaptured(pointerId?: number): boolean;
  111122. /**
  111123. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  111124. * @param attachUp defines if you want to attach events to pointerup
  111125. * @param attachDown defines if you want to attach events to pointerdown
  111126. * @param attachMove defines if you want to attach events to pointermove
  111127. */
  111128. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  111129. /** Detaches all event handlers*/
  111130. detachControl(): void;
  111131. /**
  111132. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  111133. * Delay loaded resources are not taking in account
  111134. * @return true if all required resources are ready
  111135. */
  111136. isReady(): boolean;
  111137. /** Resets all cached information relative to material (including effect and visibility) */
  111138. resetCachedMaterial(): void;
  111139. /**
  111140. * Registers a function to be called before every frame render
  111141. * @param func defines the function to register
  111142. */
  111143. registerBeforeRender(func: () => void): void;
  111144. /**
  111145. * Unregisters a function called before every frame render
  111146. * @param func defines the function to unregister
  111147. */
  111148. unregisterBeforeRender(func: () => void): void;
  111149. /**
  111150. * Registers a function to be called after every frame render
  111151. * @param func defines the function to register
  111152. */
  111153. registerAfterRender(func: () => void): void;
  111154. /**
  111155. * Unregisters a function called after every frame render
  111156. * @param func defines the function to unregister
  111157. */
  111158. unregisterAfterRender(func: () => void): void;
  111159. private _executeOnceBeforeRender;
  111160. /**
  111161. * The provided function will run before render once and will be disposed afterwards.
  111162. * A timeout delay can be provided so that the function will be executed in N ms.
  111163. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  111164. * @param func The function to be executed.
  111165. * @param timeout optional delay in ms
  111166. */
  111167. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  111168. /** @hidden */
  111169. _addPendingData(data: any): void;
  111170. /** @hidden */
  111171. _removePendingData(data: any): void;
  111172. /**
  111173. * Returns the number of items waiting to be loaded
  111174. * @returns the number of items waiting to be loaded
  111175. */
  111176. getWaitingItemsCount(): number;
  111177. /**
  111178. * Returns a boolean indicating if the scene is still loading data
  111179. */
  111180. get isLoading(): boolean;
  111181. /**
  111182. * Registers a function to be executed when the scene is ready
  111183. * @param {Function} func - the function to be executed
  111184. */
  111185. executeWhenReady(func: () => void): void;
  111186. /**
  111187. * Returns a promise that resolves when the scene is ready
  111188. * @returns A promise that resolves when the scene is ready
  111189. */
  111190. whenReadyAsync(): Promise<void>;
  111191. /** @hidden */
  111192. _checkIsReady(): void;
  111193. /**
  111194. * Gets all animatable attached to the scene
  111195. */
  111196. get animatables(): Animatable[];
  111197. /**
  111198. * Resets the last animation time frame.
  111199. * Useful to override when animations start running when loading a scene for the first time.
  111200. */
  111201. resetLastAnimationTimeFrame(): void;
  111202. /**
  111203. * Gets the current view matrix
  111204. * @returns a Matrix
  111205. */
  111206. getViewMatrix(): Matrix;
  111207. /**
  111208. * Gets the current projection matrix
  111209. * @returns a Matrix
  111210. */
  111211. getProjectionMatrix(): Matrix;
  111212. /**
  111213. * Gets the current transform matrix
  111214. * @returns a Matrix made of View * Projection
  111215. */
  111216. getTransformMatrix(): Matrix;
  111217. /**
  111218. * Sets the current transform matrix
  111219. * @param viewL defines the View matrix to use
  111220. * @param projectionL defines the Projection matrix to use
  111221. * @param viewR defines the right View matrix to use (if provided)
  111222. * @param projectionR defines the right Projection matrix to use (if provided)
  111223. */
  111224. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  111225. /**
  111226. * Gets the uniform buffer used to store scene data
  111227. * @returns a UniformBuffer
  111228. */
  111229. getSceneUniformBuffer(): UniformBuffer;
  111230. /**
  111231. * Gets an unique (relatively to the current scene) Id
  111232. * @returns an unique number for the scene
  111233. */
  111234. getUniqueId(): number;
  111235. /**
  111236. * Add a mesh to the list of scene's meshes
  111237. * @param newMesh defines the mesh to add
  111238. * @param recursive if all child meshes should also be added to the scene
  111239. */
  111240. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  111241. /**
  111242. * Remove a mesh for the list of scene's meshes
  111243. * @param toRemove defines the mesh to remove
  111244. * @param recursive if all child meshes should also be removed from the scene
  111245. * @returns the index where the mesh was in the mesh list
  111246. */
  111247. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  111248. /**
  111249. * Add a transform node to the list of scene's transform nodes
  111250. * @param newTransformNode defines the transform node to add
  111251. */
  111252. addTransformNode(newTransformNode: TransformNode): void;
  111253. /**
  111254. * Remove a transform node for the list of scene's transform nodes
  111255. * @param toRemove defines the transform node to remove
  111256. * @returns the index where the transform node was in the transform node list
  111257. */
  111258. removeTransformNode(toRemove: TransformNode): number;
  111259. /**
  111260. * Remove a skeleton for the list of scene's skeletons
  111261. * @param toRemove defines the skeleton to remove
  111262. * @returns the index where the skeleton was in the skeleton list
  111263. */
  111264. removeSkeleton(toRemove: Skeleton): number;
  111265. /**
  111266. * Remove a morph target for the list of scene's morph targets
  111267. * @param toRemove defines the morph target to remove
  111268. * @returns the index where the morph target was in the morph target list
  111269. */
  111270. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  111271. /**
  111272. * Remove a light for the list of scene's lights
  111273. * @param toRemove defines the light to remove
  111274. * @returns the index where the light was in the light list
  111275. */
  111276. removeLight(toRemove: Light): number;
  111277. /**
  111278. * Remove a camera for the list of scene's cameras
  111279. * @param toRemove defines the camera to remove
  111280. * @returns the index where the camera was in the camera list
  111281. */
  111282. removeCamera(toRemove: Camera): number;
  111283. /**
  111284. * Remove a particle system for the list of scene's particle systems
  111285. * @param toRemove defines the particle system to remove
  111286. * @returns the index where the particle system was in the particle system list
  111287. */
  111288. removeParticleSystem(toRemove: IParticleSystem): number;
  111289. /**
  111290. * Remove a animation for the list of scene's animations
  111291. * @param toRemove defines the animation to remove
  111292. * @returns the index where the animation was in the animation list
  111293. */
  111294. removeAnimation(toRemove: Animation): number;
  111295. /**
  111296. * Will stop the animation of the given target
  111297. * @param target - the target
  111298. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  111299. * @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)
  111300. */
  111301. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  111302. /**
  111303. * Removes the given animation group from this scene.
  111304. * @param toRemove The animation group to remove
  111305. * @returns The index of the removed animation group
  111306. */
  111307. removeAnimationGroup(toRemove: AnimationGroup): number;
  111308. /**
  111309. * Removes the given multi-material from this scene.
  111310. * @param toRemove The multi-material to remove
  111311. * @returns The index of the removed multi-material
  111312. */
  111313. removeMultiMaterial(toRemove: MultiMaterial): number;
  111314. /**
  111315. * Removes the given material from this scene.
  111316. * @param toRemove The material to remove
  111317. * @returns The index of the removed material
  111318. */
  111319. removeMaterial(toRemove: Material): number;
  111320. /**
  111321. * Removes the given action manager from this scene.
  111322. * @param toRemove The action manager to remove
  111323. * @returns The index of the removed action manager
  111324. */
  111325. removeActionManager(toRemove: AbstractActionManager): number;
  111326. /**
  111327. * Removes the given texture from this scene.
  111328. * @param toRemove The texture to remove
  111329. * @returns The index of the removed texture
  111330. */
  111331. removeTexture(toRemove: BaseTexture): number;
  111332. /**
  111333. * Adds the given light to this scene
  111334. * @param newLight The light to add
  111335. */
  111336. addLight(newLight: Light): void;
  111337. /**
  111338. * Sorts the list list based on light priorities
  111339. */
  111340. sortLightsByPriority(): void;
  111341. /**
  111342. * Adds the given camera to this scene
  111343. * @param newCamera The camera to add
  111344. */
  111345. addCamera(newCamera: Camera): void;
  111346. /**
  111347. * Adds the given skeleton to this scene
  111348. * @param newSkeleton The skeleton to add
  111349. */
  111350. addSkeleton(newSkeleton: Skeleton): void;
  111351. /**
  111352. * Adds the given particle system to this scene
  111353. * @param newParticleSystem The particle system to add
  111354. */
  111355. addParticleSystem(newParticleSystem: IParticleSystem): void;
  111356. /**
  111357. * Adds the given animation to this scene
  111358. * @param newAnimation The animation to add
  111359. */
  111360. addAnimation(newAnimation: Animation): void;
  111361. /**
  111362. * Adds the given animation group to this scene.
  111363. * @param newAnimationGroup The animation group to add
  111364. */
  111365. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  111366. /**
  111367. * Adds the given multi-material to this scene
  111368. * @param newMultiMaterial The multi-material to add
  111369. */
  111370. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  111371. /**
  111372. * Adds the given material to this scene
  111373. * @param newMaterial The material to add
  111374. */
  111375. addMaterial(newMaterial: Material): void;
  111376. /**
  111377. * Adds the given morph target to this scene
  111378. * @param newMorphTargetManager The morph target to add
  111379. */
  111380. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  111381. /**
  111382. * Adds the given geometry to this scene
  111383. * @param newGeometry The geometry to add
  111384. */
  111385. addGeometry(newGeometry: Geometry): void;
  111386. /**
  111387. * Adds the given action manager to this scene
  111388. * @param newActionManager The action manager to add
  111389. */
  111390. addActionManager(newActionManager: AbstractActionManager): void;
  111391. /**
  111392. * Adds the given texture to this scene.
  111393. * @param newTexture The texture to add
  111394. */
  111395. addTexture(newTexture: BaseTexture): void;
  111396. /**
  111397. * Switch active camera
  111398. * @param newCamera defines the new active camera
  111399. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  111400. */
  111401. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  111402. /**
  111403. * sets the active camera of the scene using its ID
  111404. * @param id defines the camera's ID
  111405. * @return the new active camera or null if none found.
  111406. */
  111407. setActiveCameraByID(id: string): Nullable<Camera>;
  111408. /**
  111409. * sets the active camera of the scene using its name
  111410. * @param name defines the camera's name
  111411. * @returns the new active camera or null if none found.
  111412. */
  111413. setActiveCameraByName(name: string): Nullable<Camera>;
  111414. /**
  111415. * get an animation group using its name
  111416. * @param name defines the material's name
  111417. * @return the animation group or null if none found.
  111418. */
  111419. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  111420. /**
  111421. * Get a material using its unique id
  111422. * @param uniqueId defines the material's unique id
  111423. * @return the material or null if none found.
  111424. */
  111425. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  111426. /**
  111427. * get a material using its id
  111428. * @param id defines the material's ID
  111429. * @return the material or null if none found.
  111430. */
  111431. getMaterialByID(id: string): Nullable<Material>;
  111432. /**
  111433. * Gets a the last added material using a given id
  111434. * @param id defines the material's ID
  111435. * @return the last material with the given id or null if none found.
  111436. */
  111437. getLastMaterialByID(id: string): Nullable<Material>;
  111438. /**
  111439. * Gets a material using its name
  111440. * @param name defines the material's name
  111441. * @return the material or null if none found.
  111442. */
  111443. getMaterialByName(name: string): Nullable<Material>;
  111444. /**
  111445. * Get a texture using its unique id
  111446. * @param uniqueId defines the texture's unique id
  111447. * @return the texture or null if none found.
  111448. */
  111449. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  111450. /**
  111451. * Gets a camera using its id
  111452. * @param id defines the id to look for
  111453. * @returns the camera or null if not found
  111454. */
  111455. getCameraByID(id: string): Nullable<Camera>;
  111456. /**
  111457. * Gets a camera using its unique id
  111458. * @param uniqueId defines the unique id to look for
  111459. * @returns the camera or null if not found
  111460. */
  111461. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  111462. /**
  111463. * Gets a camera using its name
  111464. * @param name defines the camera's name
  111465. * @return the camera or null if none found.
  111466. */
  111467. getCameraByName(name: string): Nullable<Camera>;
  111468. /**
  111469. * Gets a bone using its id
  111470. * @param id defines the bone's id
  111471. * @return the bone or null if not found
  111472. */
  111473. getBoneByID(id: string): Nullable<Bone>;
  111474. /**
  111475. * Gets a bone using its id
  111476. * @param name defines the bone's name
  111477. * @return the bone or null if not found
  111478. */
  111479. getBoneByName(name: string): Nullable<Bone>;
  111480. /**
  111481. * Gets a light node using its name
  111482. * @param name defines the the light's name
  111483. * @return the light or null if none found.
  111484. */
  111485. getLightByName(name: string): Nullable<Light>;
  111486. /**
  111487. * Gets a light node using its id
  111488. * @param id defines the light's id
  111489. * @return the light or null if none found.
  111490. */
  111491. getLightByID(id: string): Nullable<Light>;
  111492. /**
  111493. * Gets a light node using its scene-generated unique ID
  111494. * @param uniqueId defines the light's unique id
  111495. * @return the light or null if none found.
  111496. */
  111497. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  111498. /**
  111499. * Gets a particle system by id
  111500. * @param id defines the particle system id
  111501. * @return the corresponding system or null if none found
  111502. */
  111503. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  111504. /**
  111505. * Gets a geometry using its ID
  111506. * @param id defines the geometry's id
  111507. * @return the geometry or null if none found.
  111508. */
  111509. getGeometryByID(id: string): Nullable<Geometry>;
  111510. private _getGeometryByUniqueID;
  111511. /**
  111512. * Add a new geometry to this scene
  111513. * @param geometry defines the geometry to be added to the scene.
  111514. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  111515. * @return a boolean defining if the geometry was added or not
  111516. */
  111517. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  111518. /**
  111519. * Removes an existing geometry
  111520. * @param geometry defines the geometry to be removed from the scene
  111521. * @return a boolean defining if the geometry was removed or not
  111522. */
  111523. removeGeometry(geometry: Geometry): boolean;
  111524. /**
  111525. * Gets the list of geometries attached to the scene
  111526. * @returns an array of Geometry
  111527. */
  111528. getGeometries(): Geometry[];
  111529. /**
  111530. * Gets the first added mesh found of a given ID
  111531. * @param id defines the id to search for
  111532. * @return the mesh found or null if not found at all
  111533. */
  111534. getMeshByID(id: string): Nullable<AbstractMesh>;
  111535. /**
  111536. * Gets a list of meshes using their id
  111537. * @param id defines the id to search for
  111538. * @returns a list of meshes
  111539. */
  111540. getMeshesByID(id: string): Array<AbstractMesh>;
  111541. /**
  111542. * Gets the first added transform node found of a given ID
  111543. * @param id defines the id to search for
  111544. * @return the found transform node or null if not found at all.
  111545. */
  111546. getTransformNodeByID(id: string): Nullable<TransformNode>;
  111547. /**
  111548. * Gets a transform node with its auto-generated unique id
  111549. * @param uniqueId efines the unique id to search for
  111550. * @return the found transform node or null if not found at all.
  111551. */
  111552. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  111553. /**
  111554. * Gets a list of transform nodes using their id
  111555. * @param id defines the id to search for
  111556. * @returns a list of transform nodes
  111557. */
  111558. getTransformNodesByID(id: string): Array<TransformNode>;
  111559. /**
  111560. * Gets a mesh with its auto-generated unique id
  111561. * @param uniqueId defines the unique id to search for
  111562. * @return the found mesh or null if not found at all.
  111563. */
  111564. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  111565. /**
  111566. * Gets a the last added mesh using a given id
  111567. * @param id defines the id to search for
  111568. * @return the found mesh or null if not found at all.
  111569. */
  111570. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  111571. /**
  111572. * Gets a the last added node (Mesh, Camera, Light) using a given id
  111573. * @param id defines the id to search for
  111574. * @return the found node or null if not found at all
  111575. */
  111576. getLastEntryByID(id: string): Nullable<Node>;
  111577. /**
  111578. * Gets a node (Mesh, Camera, Light) using a given id
  111579. * @param id defines the id to search for
  111580. * @return the found node or null if not found at all
  111581. */
  111582. getNodeByID(id: string): Nullable<Node>;
  111583. /**
  111584. * Gets a node (Mesh, Camera, Light) using a given name
  111585. * @param name defines the name to search for
  111586. * @return the found node or null if not found at all.
  111587. */
  111588. getNodeByName(name: string): Nullable<Node>;
  111589. /**
  111590. * Gets a mesh using a given name
  111591. * @param name defines the name to search for
  111592. * @return the found mesh or null if not found at all.
  111593. */
  111594. getMeshByName(name: string): Nullable<AbstractMesh>;
  111595. /**
  111596. * Gets a transform node using a given name
  111597. * @param name defines the name to search for
  111598. * @return the found transform node or null if not found at all.
  111599. */
  111600. getTransformNodeByName(name: string): Nullable<TransformNode>;
  111601. /**
  111602. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  111603. * @param id defines the id to search for
  111604. * @return the found skeleton or null if not found at all.
  111605. */
  111606. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  111607. /**
  111608. * Gets a skeleton using a given auto generated unique id
  111609. * @param uniqueId defines the unique id to search for
  111610. * @return the found skeleton or null if not found at all.
  111611. */
  111612. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  111613. /**
  111614. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  111615. * @param id defines the id to search for
  111616. * @return the found skeleton or null if not found at all.
  111617. */
  111618. getSkeletonById(id: string): Nullable<Skeleton>;
  111619. /**
  111620. * Gets a skeleton using a given name
  111621. * @param name defines the name to search for
  111622. * @return the found skeleton or null if not found at all.
  111623. */
  111624. getSkeletonByName(name: string): Nullable<Skeleton>;
  111625. /**
  111626. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  111627. * @param id defines the id to search for
  111628. * @return the found morph target manager or null if not found at all.
  111629. */
  111630. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  111631. /**
  111632. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  111633. * @param id defines the id to search for
  111634. * @return the found morph target or null if not found at all.
  111635. */
  111636. getMorphTargetById(id: string): Nullable<MorphTarget>;
  111637. /**
  111638. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  111639. * @param name defines the name to search for
  111640. * @return the found morph target or null if not found at all.
  111641. */
  111642. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  111643. /**
  111644. * Gets a boolean indicating if the given mesh is active
  111645. * @param mesh defines the mesh to look for
  111646. * @returns true if the mesh is in the active list
  111647. */
  111648. isActiveMesh(mesh: AbstractMesh): boolean;
  111649. /**
  111650. * Return a unique id as a string which can serve as an identifier for the scene
  111651. */
  111652. get uid(): string;
  111653. /**
  111654. * Add an externaly attached data from its key.
  111655. * This method call will fail and return false, if such key already exists.
  111656. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  111657. * @param key the unique key that identifies the data
  111658. * @param data the data object to associate to the key for this Engine instance
  111659. * @return true if no such key were already present and the data was added successfully, false otherwise
  111660. */
  111661. addExternalData<T>(key: string, data: T): boolean;
  111662. /**
  111663. * Get an externaly attached data from its key
  111664. * @param key the unique key that identifies the data
  111665. * @return the associated data, if present (can be null), or undefined if not present
  111666. */
  111667. getExternalData<T>(key: string): Nullable<T>;
  111668. /**
  111669. * Get an externaly attached data from its key, create it using a factory if it's not already present
  111670. * @param key the unique key that identifies the data
  111671. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  111672. * @return the associated data, can be null if the factory returned null.
  111673. */
  111674. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  111675. /**
  111676. * Remove an externaly attached data from the Engine instance
  111677. * @param key the unique key that identifies the data
  111678. * @return true if the data was successfully removed, false if it doesn't exist
  111679. */
  111680. removeExternalData(key: string): boolean;
  111681. private _evaluateSubMesh;
  111682. /**
  111683. * Clear the processed materials smart array preventing retention point in material dispose.
  111684. */
  111685. freeProcessedMaterials(): void;
  111686. private _preventFreeActiveMeshesAndRenderingGroups;
  111687. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  111688. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  111689. * when disposing several meshes in a row or a hierarchy of meshes.
  111690. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  111691. */
  111692. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  111693. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  111694. /**
  111695. * Clear the active meshes smart array preventing retention point in mesh dispose.
  111696. */
  111697. freeActiveMeshes(): void;
  111698. /**
  111699. * Clear the info related to rendering groups preventing retention points during dispose.
  111700. */
  111701. freeRenderingGroups(): void;
  111702. /** @hidden */
  111703. _isInIntermediateRendering(): boolean;
  111704. /**
  111705. * Lambda returning the list of potentially active meshes.
  111706. */
  111707. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  111708. /**
  111709. * Lambda returning the list of potentially active sub meshes.
  111710. */
  111711. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  111712. /**
  111713. * Lambda returning the list of potentially intersecting sub meshes.
  111714. */
  111715. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  111716. /**
  111717. * Lambda returning the list of potentially colliding sub meshes.
  111718. */
  111719. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  111720. private _activeMeshesFrozen;
  111721. private _skipEvaluateActiveMeshesCompletely;
  111722. /**
  111723. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  111724. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  111725. * @returns the current scene
  111726. */
  111727. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  111728. /**
  111729. * Use this function to restart evaluating active meshes on every frame
  111730. * @returns the current scene
  111731. */
  111732. unfreezeActiveMeshes(): Scene;
  111733. private _evaluateActiveMeshes;
  111734. private _activeMesh;
  111735. /**
  111736. * Update the transform matrix to update from the current active camera
  111737. * @param force defines a boolean used to force the update even if cache is up to date
  111738. */
  111739. updateTransformMatrix(force?: boolean): void;
  111740. private _bindFrameBuffer;
  111741. /** @hidden */
  111742. _allowPostProcessClearColor: boolean;
  111743. /** @hidden */
  111744. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  111745. private _processSubCameras;
  111746. private _checkIntersections;
  111747. /** @hidden */
  111748. _advancePhysicsEngineStep(step: number): void;
  111749. /**
  111750. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  111751. */
  111752. getDeterministicFrameTime: () => number;
  111753. /** @hidden */
  111754. _animate(): void;
  111755. /** Execute all animations (for a frame) */
  111756. animate(): void;
  111757. /**
  111758. * Render the scene
  111759. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  111760. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  111761. */
  111762. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  111763. /**
  111764. * Freeze all materials
  111765. * A frozen material will not be updatable but should be faster to render
  111766. */
  111767. freezeMaterials(): void;
  111768. /**
  111769. * Unfreeze all materials
  111770. * A frozen material will not be updatable but should be faster to render
  111771. */
  111772. unfreezeMaterials(): void;
  111773. /**
  111774. * Releases all held ressources
  111775. */
  111776. dispose(): void;
  111777. /**
  111778. * Gets if the scene is already disposed
  111779. */
  111780. get isDisposed(): boolean;
  111781. /**
  111782. * Call this function to reduce memory footprint of the scene.
  111783. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  111784. */
  111785. clearCachedVertexData(): void;
  111786. /**
  111787. * This function will remove the local cached buffer data from texture.
  111788. * It will save memory but will prevent the texture from being rebuilt
  111789. */
  111790. cleanCachedTextureBuffer(): void;
  111791. /**
  111792. * Get the world extend vectors with an optional filter
  111793. *
  111794. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  111795. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  111796. */
  111797. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  111798. min: Vector3;
  111799. max: Vector3;
  111800. };
  111801. /**
  111802. * Creates a ray that can be used to pick in the scene
  111803. * @param x defines the x coordinate of the origin (on-screen)
  111804. * @param y defines the y coordinate of the origin (on-screen)
  111805. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  111806. * @param camera defines the camera to use for the picking
  111807. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  111808. * @returns a Ray
  111809. */
  111810. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  111811. /**
  111812. * Creates a ray that can be used to pick in the scene
  111813. * @param x defines the x coordinate of the origin (on-screen)
  111814. * @param y defines the y coordinate of the origin (on-screen)
  111815. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  111816. * @param result defines the ray where to store the picking ray
  111817. * @param camera defines the camera to use for the picking
  111818. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  111819. * @returns the current scene
  111820. */
  111821. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  111822. /**
  111823. * Creates a ray that can be used to pick in the scene
  111824. * @param x defines the x coordinate of the origin (on-screen)
  111825. * @param y defines the y coordinate of the origin (on-screen)
  111826. * @param camera defines the camera to use for the picking
  111827. * @returns a Ray
  111828. */
  111829. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  111830. /**
  111831. * Creates a ray that can be used to pick in the scene
  111832. * @param x defines the x coordinate of the origin (on-screen)
  111833. * @param y defines the y coordinate of the origin (on-screen)
  111834. * @param result defines the ray where to store the picking ray
  111835. * @param camera defines the camera to use for the picking
  111836. * @returns the current scene
  111837. */
  111838. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  111839. /** Launch a ray to try to pick a mesh in the scene
  111840. * @param x position on screen
  111841. * @param y position on screen
  111842. * @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
  111843. * @param fastCheck defines if the first intersection will be used (and not the closest)
  111844. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  111845. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111846. * @returns a PickingInfo
  111847. */
  111848. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  111849. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  111850. * @param x position on screen
  111851. * @param y position on screen
  111852. * @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
  111853. * @param fastCheck defines if the first intersection will be used (and not the closest)
  111854. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  111855. * @returns a PickingInfo (Please note that some info will not be set like distance, bv, bu and everything that cannot be capture by only using bounding infos)
  111856. */
  111857. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  111858. /** Use the given ray to pick a mesh in the scene
  111859. * @param ray The ray to use to pick meshes
  111860. * @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
  111861. * @param fastCheck defines if the first intersection will be used (and not the closest)
  111862. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111863. * @returns a PickingInfo
  111864. */
  111865. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  111866. /**
  111867. * Launch a ray to try to pick a mesh in the scene
  111868. * @param x X position on screen
  111869. * @param y Y position on screen
  111870. * @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
  111871. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  111872. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111873. * @returns an array of PickingInfo
  111874. */
  111875. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  111876. /**
  111877. * Launch a ray to try to pick a mesh in the scene
  111878. * @param ray Ray to use
  111879. * @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
  111880. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111881. * @returns an array of PickingInfo
  111882. */
  111883. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  111884. /**
  111885. * Force the value of meshUnderPointer
  111886. * @param mesh defines the mesh to use
  111887. */
  111888. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  111889. /**
  111890. * Gets the mesh under the pointer
  111891. * @returns a Mesh or null if no mesh is under the pointer
  111892. */
  111893. getPointerOverMesh(): Nullable<AbstractMesh>;
  111894. /** @hidden */
  111895. _rebuildGeometries(): void;
  111896. /** @hidden */
  111897. _rebuildTextures(): void;
  111898. private _getByTags;
  111899. /**
  111900. * Get a list of meshes by tags
  111901. * @param tagsQuery defines the tags query to use
  111902. * @param forEach defines a predicate used to filter results
  111903. * @returns an array of Mesh
  111904. */
  111905. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  111906. /**
  111907. * Get a list of cameras by tags
  111908. * @param tagsQuery defines the tags query to use
  111909. * @param forEach defines a predicate used to filter results
  111910. * @returns an array of Camera
  111911. */
  111912. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  111913. /**
  111914. * Get a list of lights by tags
  111915. * @param tagsQuery defines the tags query to use
  111916. * @param forEach defines a predicate used to filter results
  111917. * @returns an array of Light
  111918. */
  111919. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  111920. /**
  111921. * Get a list of materials by tags
  111922. * @param tagsQuery defines the tags query to use
  111923. * @param forEach defines a predicate used to filter results
  111924. * @returns an array of Material
  111925. */
  111926. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  111927. /**
  111928. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  111929. * This allowed control for front to back rendering or reversly depending of the special needs.
  111930. *
  111931. * @param renderingGroupId The rendering group id corresponding to its index
  111932. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  111933. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  111934. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  111935. */
  111936. 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;
  111937. /**
  111938. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  111939. *
  111940. * @param renderingGroupId The rendering group id corresponding to its index
  111941. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  111942. * @param depth Automatically clears depth between groups if true and autoClear is true.
  111943. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  111944. */
  111945. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  111946. /**
  111947. * Gets the current auto clear configuration for one rendering group of the rendering
  111948. * manager.
  111949. * @param index the rendering group index to get the information for
  111950. * @returns The auto clear setup for the requested rendering group
  111951. */
  111952. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  111953. private _blockMaterialDirtyMechanism;
  111954. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  111955. get blockMaterialDirtyMechanism(): boolean;
  111956. set blockMaterialDirtyMechanism(value: boolean);
  111957. /**
  111958. * Will flag all materials as dirty to trigger new shader compilation
  111959. * @param flag defines the flag used to specify which material part must be marked as dirty
  111960. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  111961. */
  111962. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  111963. /** @hidden */
  111964. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  111965. /** @hidden */
  111966. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  111967. /** @hidden */
  111968. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  111969. /** @hidden */
  111970. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  111971. /** @hidden */
  111972. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  111973. /** @hidden */
  111974. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  111975. }
  111976. }
  111977. declare module BABYLON {
  111978. /**
  111979. * Set of assets to keep when moving a scene into an asset container.
  111980. */
  111981. export class KeepAssets extends AbstractScene {
  111982. }
  111983. /**
  111984. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  111985. */
  111986. export class InstantiatedEntries {
  111987. /**
  111988. * List of new root nodes (eg. nodes with no parent)
  111989. */
  111990. rootNodes: TransformNode[];
  111991. /**
  111992. * List of new skeletons
  111993. */
  111994. skeletons: Skeleton[];
  111995. /**
  111996. * List of new animation groups
  111997. */
  111998. animationGroups: AnimationGroup[];
  111999. }
  112000. /**
  112001. * Container with a set of assets that can be added or removed from a scene.
  112002. */
  112003. export class AssetContainer extends AbstractScene {
  112004. private _wasAddedToScene;
  112005. /**
  112006. * The scene the AssetContainer belongs to.
  112007. */
  112008. scene: Scene;
  112009. /**
  112010. * Instantiates an AssetContainer.
  112011. * @param scene The scene the AssetContainer belongs to.
  112012. */
  112013. constructor(scene: Scene);
  112014. /**
  112015. * Instantiate or clone all meshes and add the new ones to the scene.
  112016. * Skeletons and animation groups will all be cloned
  112017. * @param nameFunction defines an optional function used to get new names for clones
  112018. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  112019. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  112020. */
  112021. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  112022. /**
  112023. * Adds all the assets from the container to the scene.
  112024. */
  112025. addAllToScene(): void;
  112026. /**
  112027. * Removes all the assets in the container from the scene
  112028. */
  112029. removeAllFromScene(): void;
  112030. /**
  112031. * Disposes all the assets in the container
  112032. */
  112033. dispose(): void;
  112034. private _moveAssets;
  112035. /**
  112036. * Removes all the assets contained in the scene and adds them to the container.
  112037. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  112038. */
  112039. moveAllFromScene(keepAssets?: KeepAssets): void;
  112040. /**
  112041. * 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.
  112042. * @returns the root mesh
  112043. */
  112044. createRootMesh(): Mesh;
  112045. /**
  112046. * Merge animations from this asset container into a scene
  112047. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  112048. * @param animatables set of animatables to retarget to a node from the scene
  112049. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  112050. */
  112051. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  112052. }
  112053. }
  112054. declare module BABYLON {
  112055. /**
  112056. * Defines how the parser contract is defined.
  112057. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  112058. */
  112059. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  112060. /**
  112061. * Defines how the individual parser contract is defined.
  112062. * These parser can parse an individual asset
  112063. */
  112064. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  112065. /**
  112066. * Base class of the scene acting as a container for the different elements composing a scene.
  112067. * This class is dynamically extended by the different components of the scene increasing
  112068. * flexibility and reducing coupling
  112069. */
  112070. export abstract class AbstractScene {
  112071. /**
  112072. * Stores the list of available parsers in the application.
  112073. */
  112074. private static _BabylonFileParsers;
  112075. /**
  112076. * Stores the list of available individual parsers in the application.
  112077. */
  112078. private static _IndividualBabylonFileParsers;
  112079. /**
  112080. * Adds a parser in the list of available ones
  112081. * @param name Defines the name of the parser
  112082. * @param parser Defines the parser to add
  112083. */
  112084. static AddParser(name: string, parser: BabylonFileParser): void;
  112085. /**
  112086. * Gets a general parser from the list of avaialble ones
  112087. * @param name Defines the name of the parser
  112088. * @returns the requested parser or null
  112089. */
  112090. static GetParser(name: string): Nullable<BabylonFileParser>;
  112091. /**
  112092. * Adds n individual parser in the list of available ones
  112093. * @param name Defines the name of the parser
  112094. * @param parser Defines the parser to add
  112095. */
  112096. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  112097. /**
  112098. * Gets an individual parser from the list of avaialble ones
  112099. * @param name Defines the name of the parser
  112100. * @returns the requested parser or null
  112101. */
  112102. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  112103. /**
  112104. * Parser json data and populate both a scene and its associated container object
  112105. * @param jsonData Defines the data to parse
  112106. * @param scene Defines the scene to parse the data for
  112107. * @param container Defines the container attached to the parsing sequence
  112108. * @param rootUrl Defines the root url of the data
  112109. */
  112110. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  112111. /**
  112112. * Gets the list of root nodes (ie. nodes with no parent)
  112113. */
  112114. rootNodes: Node[];
  112115. /** All of the cameras added to this scene
  112116. * @see http://doc.babylonjs.com/babylon101/cameras
  112117. */
  112118. cameras: Camera[];
  112119. /**
  112120. * All of the lights added to this scene
  112121. * @see http://doc.babylonjs.com/babylon101/lights
  112122. */
  112123. lights: Light[];
  112124. /**
  112125. * All of the (abstract) meshes added to this scene
  112126. */
  112127. meshes: AbstractMesh[];
  112128. /**
  112129. * The list of skeletons added to the scene
  112130. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  112131. */
  112132. skeletons: Skeleton[];
  112133. /**
  112134. * All of the particle systems added to this scene
  112135. * @see http://doc.babylonjs.com/babylon101/particles
  112136. */
  112137. particleSystems: IParticleSystem[];
  112138. /**
  112139. * Gets a list of Animations associated with the scene
  112140. */
  112141. animations: Animation[];
  112142. /**
  112143. * All of the animation groups added to this scene
  112144. * @see http://doc.babylonjs.com/how_to/group
  112145. */
  112146. animationGroups: AnimationGroup[];
  112147. /**
  112148. * All of the multi-materials added to this scene
  112149. * @see http://doc.babylonjs.com/how_to/multi_materials
  112150. */
  112151. multiMaterials: MultiMaterial[];
  112152. /**
  112153. * All of the materials added to this scene
  112154. * In the context of a Scene, it is not supposed to be modified manually.
  112155. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  112156. * Note also that the order of the Material within the array is not significant and might change.
  112157. * @see http://doc.babylonjs.com/babylon101/materials
  112158. */
  112159. materials: Material[];
  112160. /**
  112161. * The list of morph target managers added to the scene
  112162. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  112163. */
  112164. morphTargetManagers: MorphTargetManager[];
  112165. /**
  112166. * The list of geometries used in the scene.
  112167. */
  112168. geometries: Geometry[];
  112169. /**
  112170. * All of the tranform nodes added to this scene
  112171. * In the context of a Scene, it is not supposed to be modified manually.
  112172. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  112173. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  112174. * @see http://doc.babylonjs.com/how_to/transformnode
  112175. */
  112176. transformNodes: TransformNode[];
  112177. /**
  112178. * ActionManagers available on the scene.
  112179. */
  112180. actionManagers: AbstractActionManager[];
  112181. /**
  112182. * Textures to keep.
  112183. */
  112184. textures: BaseTexture[];
  112185. /**
  112186. * Environment texture for the scene
  112187. */
  112188. environmentTexture: Nullable<BaseTexture>;
  112189. /**
  112190. * @returns all meshes, lights, cameras, transformNodes and bones
  112191. */
  112192. getNodes(): Array<Node>;
  112193. }
  112194. }
  112195. declare module BABYLON {
  112196. /**
  112197. * Interface used to define options for Sound class
  112198. */
  112199. export interface ISoundOptions {
  112200. /**
  112201. * Does the sound autoplay once loaded.
  112202. */
  112203. autoplay?: boolean;
  112204. /**
  112205. * Does the sound loop after it finishes playing once.
  112206. */
  112207. loop?: boolean;
  112208. /**
  112209. * Sound's volume
  112210. */
  112211. volume?: number;
  112212. /**
  112213. * Is it a spatial sound?
  112214. */
  112215. spatialSound?: boolean;
  112216. /**
  112217. * Maximum distance to hear that sound
  112218. */
  112219. maxDistance?: number;
  112220. /**
  112221. * Uses user defined attenuation function
  112222. */
  112223. useCustomAttenuation?: boolean;
  112224. /**
  112225. * Define the roll off factor of spatial sounds.
  112226. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  112227. */
  112228. rolloffFactor?: number;
  112229. /**
  112230. * Define the reference distance the sound should be heard perfectly.
  112231. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  112232. */
  112233. refDistance?: number;
  112234. /**
  112235. * Define the distance attenuation model the sound will follow.
  112236. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  112237. */
  112238. distanceModel?: string;
  112239. /**
  112240. * Defines the playback speed (1 by default)
  112241. */
  112242. playbackRate?: number;
  112243. /**
  112244. * Defines if the sound is from a streaming source
  112245. */
  112246. streaming?: boolean;
  112247. /**
  112248. * Defines an optional length (in seconds) inside the sound file
  112249. */
  112250. length?: number;
  112251. /**
  112252. * Defines an optional offset (in seconds) inside the sound file
  112253. */
  112254. offset?: number;
  112255. /**
  112256. * If true, URLs will not be required to state the audio file codec to use.
  112257. */
  112258. skipCodecCheck?: boolean;
  112259. }
  112260. /**
  112261. * Defines a sound that can be played in the application.
  112262. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  112263. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112264. */
  112265. export class Sound {
  112266. /**
  112267. * The name of the sound in the scene.
  112268. */
  112269. name: string;
  112270. /**
  112271. * Does the sound autoplay once loaded.
  112272. */
  112273. autoplay: boolean;
  112274. /**
  112275. * Does the sound loop after it finishes playing once.
  112276. */
  112277. loop: boolean;
  112278. /**
  112279. * Does the sound use a custom attenuation curve to simulate the falloff
  112280. * happening when the source gets further away from the camera.
  112281. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  112282. */
  112283. useCustomAttenuation: boolean;
  112284. /**
  112285. * The sound track id this sound belongs to.
  112286. */
  112287. soundTrackId: number;
  112288. /**
  112289. * Is this sound currently played.
  112290. */
  112291. isPlaying: boolean;
  112292. /**
  112293. * Is this sound currently paused.
  112294. */
  112295. isPaused: boolean;
  112296. /**
  112297. * Does this sound enables spatial sound.
  112298. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  112299. */
  112300. spatialSound: boolean;
  112301. /**
  112302. * Define the reference distance the sound should be heard perfectly.
  112303. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  112304. */
  112305. refDistance: number;
  112306. /**
  112307. * Define the roll off factor of spatial sounds.
  112308. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  112309. */
  112310. rolloffFactor: number;
  112311. /**
  112312. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  112313. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  112314. */
  112315. maxDistance: number;
  112316. /**
  112317. * Define the distance attenuation model the sound will follow.
  112318. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  112319. */
  112320. distanceModel: string;
  112321. /**
  112322. * @hidden
  112323. * Back Compat
  112324. **/
  112325. onended: () => any;
  112326. /**
  112327. * Observable event when the current playing sound finishes.
  112328. */
  112329. onEndedObservable: Observable<Sound>;
  112330. private _panningModel;
  112331. private _playbackRate;
  112332. private _streaming;
  112333. private _startTime;
  112334. private _startOffset;
  112335. private _position;
  112336. /** @hidden */
  112337. _positionInEmitterSpace: boolean;
  112338. private _localDirection;
  112339. private _volume;
  112340. private _isReadyToPlay;
  112341. private _isDirectional;
  112342. private _readyToPlayCallback;
  112343. private _audioBuffer;
  112344. private _soundSource;
  112345. private _streamingSource;
  112346. private _soundPanner;
  112347. private _soundGain;
  112348. private _inputAudioNode;
  112349. private _outputAudioNode;
  112350. private _coneInnerAngle;
  112351. private _coneOuterAngle;
  112352. private _coneOuterGain;
  112353. private _scene;
  112354. private _connectedTransformNode;
  112355. private _customAttenuationFunction;
  112356. private _registerFunc;
  112357. private _isOutputConnected;
  112358. private _htmlAudioElement;
  112359. private _urlType;
  112360. private _length?;
  112361. private _offset?;
  112362. /** @hidden */
  112363. static _SceneComponentInitialization: (scene: Scene) => void;
  112364. /**
  112365. * Create a sound and attach it to a scene
  112366. * @param name Name of your sound
  112367. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  112368. * @param scene defines the scene the sound belongs to
  112369. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  112370. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  112371. */
  112372. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  112373. /**
  112374. * Release the sound and its associated resources
  112375. */
  112376. dispose(): void;
  112377. /**
  112378. * Gets if the sounds is ready to be played or not.
  112379. * @returns true if ready, otherwise false
  112380. */
  112381. isReady(): boolean;
  112382. private _soundLoaded;
  112383. /**
  112384. * Sets the data of the sound from an audiobuffer
  112385. * @param audioBuffer The audioBuffer containing the data
  112386. */
  112387. setAudioBuffer(audioBuffer: AudioBuffer): void;
  112388. /**
  112389. * Updates the current sounds options such as maxdistance, loop...
  112390. * @param options A JSON object containing values named as the object properties
  112391. */
  112392. updateOptions(options: ISoundOptions): void;
  112393. private _createSpatialParameters;
  112394. private _updateSpatialParameters;
  112395. /**
  112396. * Switch the panning model to HRTF:
  112397. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  112398. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  112399. */
  112400. switchPanningModelToHRTF(): void;
  112401. /**
  112402. * Switch the panning model to Equal Power:
  112403. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  112404. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  112405. */
  112406. switchPanningModelToEqualPower(): void;
  112407. private _switchPanningModel;
  112408. /**
  112409. * Connect this sound to a sound track audio node like gain...
  112410. * @param soundTrackAudioNode the sound track audio node to connect to
  112411. */
  112412. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  112413. /**
  112414. * Transform this sound into a directional source
  112415. * @param coneInnerAngle Size of the inner cone in degree
  112416. * @param coneOuterAngle Size of the outer cone in degree
  112417. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  112418. */
  112419. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  112420. /**
  112421. * Gets or sets the inner angle for the directional cone.
  112422. */
  112423. get directionalConeInnerAngle(): number;
  112424. /**
  112425. * Gets or sets the inner angle for the directional cone.
  112426. */
  112427. set directionalConeInnerAngle(value: number);
  112428. /**
  112429. * Gets or sets the outer angle for the directional cone.
  112430. */
  112431. get directionalConeOuterAngle(): number;
  112432. /**
  112433. * Gets or sets the outer angle for the directional cone.
  112434. */
  112435. set directionalConeOuterAngle(value: number);
  112436. /**
  112437. * Sets the position of the emitter if spatial sound is enabled
  112438. * @param newPosition Defines the new posisiton
  112439. */
  112440. setPosition(newPosition: Vector3): void;
  112441. /**
  112442. * Sets the local direction of the emitter if spatial sound is enabled
  112443. * @param newLocalDirection Defines the new local direction
  112444. */
  112445. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  112446. private _updateDirection;
  112447. /** @hidden */
  112448. updateDistanceFromListener(): void;
  112449. /**
  112450. * Sets a new custom attenuation function for the sound.
  112451. * @param callback Defines the function used for the attenuation
  112452. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  112453. */
  112454. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  112455. /**
  112456. * Play the sound
  112457. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  112458. * @param offset (optional) Start the sound at a specific time in seconds
  112459. * @param length (optional) Sound duration (in seconds)
  112460. */
  112461. play(time?: number, offset?: number, length?: number): void;
  112462. private _onended;
  112463. /**
  112464. * Stop the sound
  112465. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  112466. */
  112467. stop(time?: number): void;
  112468. /**
  112469. * Put the sound in pause
  112470. */
  112471. pause(): void;
  112472. /**
  112473. * Sets a dedicated volume for this sounds
  112474. * @param newVolume Define the new volume of the sound
  112475. * @param time Define time for gradual change to new volume
  112476. */
  112477. setVolume(newVolume: number, time?: number): void;
  112478. /**
  112479. * Set the sound play back rate
  112480. * @param newPlaybackRate Define the playback rate the sound should be played at
  112481. */
  112482. setPlaybackRate(newPlaybackRate: number): void;
  112483. /**
  112484. * Gets the volume of the sound.
  112485. * @returns the volume of the sound
  112486. */
  112487. getVolume(): number;
  112488. /**
  112489. * Attach the sound to a dedicated mesh
  112490. * @param transformNode The transform node to connect the sound with
  112491. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  112492. */
  112493. attachToMesh(transformNode: TransformNode): void;
  112494. /**
  112495. * Detach the sound from the previously attached mesh
  112496. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  112497. */
  112498. detachFromMesh(): void;
  112499. private _onRegisterAfterWorldMatrixUpdate;
  112500. /**
  112501. * Clone the current sound in the scene.
  112502. * @returns the new sound clone
  112503. */
  112504. clone(): Nullable<Sound>;
  112505. /**
  112506. * Gets the current underlying audio buffer containing the data
  112507. * @returns the audio buffer
  112508. */
  112509. getAudioBuffer(): Nullable<AudioBuffer>;
  112510. /**
  112511. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  112512. * @returns the source node
  112513. */
  112514. getSoundSource(): Nullable<AudioBufferSourceNode>;
  112515. /**
  112516. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  112517. * @returns the gain node
  112518. */
  112519. getSoundGain(): Nullable<GainNode>;
  112520. /**
  112521. * Serializes the Sound in a JSON representation
  112522. * @returns the JSON representation of the sound
  112523. */
  112524. serialize(): any;
  112525. /**
  112526. * Parse a JSON representation of a sound to innstantiate in a given scene
  112527. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  112528. * @param scene Define the scene the new parsed sound should be created in
  112529. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  112530. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  112531. * @returns the newly parsed sound
  112532. */
  112533. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  112534. }
  112535. }
  112536. declare module BABYLON {
  112537. /**
  112538. * This defines an action helpful to play a defined sound on a triggered action.
  112539. */
  112540. export class PlaySoundAction extends Action {
  112541. private _sound;
  112542. /**
  112543. * Instantiate the action
  112544. * @param triggerOptions defines the trigger options
  112545. * @param sound defines the sound to play
  112546. * @param condition defines the trigger related conditions
  112547. */
  112548. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  112549. /** @hidden */
  112550. _prepare(): void;
  112551. /**
  112552. * Execute the action and play the sound.
  112553. */
  112554. execute(): void;
  112555. /**
  112556. * Serializes the actions and its related information.
  112557. * @param parent defines the object to serialize in
  112558. * @returns the serialized object
  112559. */
  112560. serialize(parent: any): any;
  112561. }
  112562. /**
  112563. * This defines an action helpful to stop a defined sound on a triggered action.
  112564. */
  112565. export class StopSoundAction extends Action {
  112566. private _sound;
  112567. /**
  112568. * Instantiate the action
  112569. * @param triggerOptions defines the trigger options
  112570. * @param sound defines the sound to stop
  112571. * @param condition defines the trigger related conditions
  112572. */
  112573. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  112574. /** @hidden */
  112575. _prepare(): void;
  112576. /**
  112577. * Execute the action and stop the sound.
  112578. */
  112579. execute(): void;
  112580. /**
  112581. * Serializes the actions and its related information.
  112582. * @param parent defines the object to serialize in
  112583. * @returns the serialized object
  112584. */
  112585. serialize(parent: any): any;
  112586. }
  112587. }
  112588. declare module BABYLON {
  112589. /**
  112590. * This defines an action responsible to change the value of a property
  112591. * by interpolating between its current value and the newly set one once triggered.
  112592. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  112593. */
  112594. export class InterpolateValueAction extends Action {
  112595. /**
  112596. * Defines the path of the property where the value should be interpolated
  112597. */
  112598. propertyPath: string;
  112599. /**
  112600. * Defines the target value at the end of the interpolation.
  112601. */
  112602. value: any;
  112603. /**
  112604. * Defines the time it will take for the property to interpolate to the value.
  112605. */
  112606. duration: number;
  112607. /**
  112608. * Defines if the other scene animations should be stopped when the action has been triggered
  112609. */
  112610. stopOtherAnimations?: boolean;
  112611. /**
  112612. * Defines a callback raised once the interpolation animation has been done.
  112613. */
  112614. onInterpolationDone?: () => void;
  112615. /**
  112616. * Observable triggered once the interpolation animation has been done.
  112617. */
  112618. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  112619. private _target;
  112620. private _effectiveTarget;
  112621. private _property;
  112622. /**
  112623. * Instantiate the action
  112624. * @param triggerOptions defines the trigger options
  112625. * @param target defines the object containing the value to interpolate
  112626. * @param propertyPath defines the path to the property in the target object
  112627. * @param value defines the target value at the end of the interpolation
  112628. * @param duration deines the time it will take for the property to interpolate to the value.
  112629. * @param condition defines the trigger related conditions
  112630. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  112631. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  112632. */
  112633. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  112634. /** @hidden */
  112635. _prepare(): void;
  112636. /**
  112637. * Execute the action starts the value interpolation.
  112638. */
  112639. execute(): void;
  112640. /**
  112641. * Serializes the actions and its related information.
  112642. * @param parent defines the object to serialize in
  112643. * @returns the serialized object
  112644. */
  112645. serialize(parent: any): any;
  112646. }
  112647. }
  112648. declare module BABYLON {
  112649. /**
  112650. * Options allowed during the creation of a sound track.
  112651. */
  112652. export interface ISoundTrackOptions {
  112653. /**
  112654. * The volume the sound track should take during creation
  112655. */
  112656. volume?: number;
  112657. /**
  112658. * Define if the sound track is the main sound track of the scene
  112659. */
  112660. mainTrack?: boolean;
  112661. }
  112662. /**
  112663. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  112664. * It will be also used in a future release to apply effects on a specific track.
  112665. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  112666. */
  112667. export class SoundTrack {
  112668. /**
  112669. * The unique identifier of the sound track in the scene.
  112670. */
  112671. id: number;
  112672. /**
  112673. * The list of sounds included in the sound track.
  112674. */
  112675. soundCollection: Array<Sound>;
  112676. private _outputAudioNode;
  112677. private _scene;
  112678. private _connectedAnalyser;
  112679. private _options;
  112680. private _isInitialized;
  112681. /**
  112682. * Creates a new sound track.
  112683. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  112684. * @param scene Define the scene the sound track belongs to
  112685. * @param options
  112686. */
  112687. constructor(scene: Scene, options?: ISoundTrackOptions);
  112688. private _initializeSoundTrackAudioGraph;
  112689. /**
  112690. * Release the sound track and its associated resources
  112691. */
  112692. dispose(): void;
  112693. /**
  112694. * Adds a sound to this sound track
  112695. * @param sound define the cound to add
  112696. * @ignoreNaming
  112697. */
  112698. AddSound(sound: Sound): void;
  112699. /**
  112700. * Removes a sound to this sound track
  112701. * @param sound define the cound to remove
  112702. * @ignoreNaming
  112703. */
  112704. RemoveSound(sound: Sound): void;
  112705. /**
  112706. * Set a global volume for the full sound track.
  112707. * @param newVolume Define the new volume of the sound track
  112708. */
  112709. setVolume(newVolume: number): void;
  112710. /**
  112711. * Switch the panning model to HRTF:
  112712. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  112713. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  112714. */
  112715. switchPanningModelToHRTF(): void;
  112716. /**
  112717. * Switch the panning model to Equal Power:
  112718. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  112719. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  112720. */
  112721. switchPanningModelToEqualPower(): void;
  112722. /**
  112723. * Connect the sound track to an audio analyser allowing some amazing
  112724. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  112725. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  112726. * @param analyser The analyser to connect to the engine
  112727. */
  112728. connectToAnalyser(analyser: Analyser): void;
  112729. }
  112730. }
  112731. declare module BABYLON {
  112732. interface AbstractScene {
  112733. /**
  112734. * The list of sounds used in the scene.
  112735. */
  112736. sounds: Nullable<Array<Sound>>;
  112737. }
  112738. interface Scene {
  112739. /**
  112740. * @hidden
  112741. * Backing field
  112742. */
  112743. _mainSoundTrack: SoundTrack;
  112744. /**
  112745. * The main sound track played by the scene.
  112746. * It cotains your primary collection of sounds.
  112747. */
  112748. mainSoundTrack: SoundTrack;
  112749. /**
  112750. * The list of sound tracks added to the scene
  112751. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112752. */
  112753. soundTracks: Nullable<Array<SoundTrack>>;
  112754. /**
  112755. * Gets a sound using a given name
  112756. * @param name defines the name to search for
  112757. * @return the found sound or null if not found at all.
  112758. */
  112759. getSoundByName(name: string): Nullable<Sound>;
  112760. /**
  112761. * Gets or sets if audio support is enabled
  112762. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112763. */
  112764. audioEnabled: boolean;
  112765. /**
  112766. * Gets or sets if audio will be output to headphones
  112767. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112768. */
  112769. headphone: boolean;
  112770. /**
  112771. * Gets or sets custom audio listener position provider
  112772. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112773. */
  112774. audioListenerPositionProvider: Nullable<() => Vector3>;
  112775. /**
  112776. * Gets or sets a refresh rate when using 3D audio positioning
  112777. */
  112778. audioPositioningRefreshRate: number;
  112779. }
  112780. /**
  112781. * Defines the sound scene component responsible to manage any sounds
  112782. * in a given scene.
  112783. */
  112784. export class AudioSceneComponent implements ISceneSerializableComponent {
  112785. /**
  112786. * The component name helpfull to identify the component in the list of scene components.
  112787. */
  112788. readonly name: string;
  112789. /**
  112790. * The scene the component belongs to.
  112791. */
  112792. scene: Scene;
  112793. private _audioEnabled;
  112794. /**
  112795. * Gets whether audio is enabled or not.
  112796. * Please use related enable/disable method to switch state.
  112797. */
  112798. get audioEnabled(): boolean;
  112799. private _headphone;
  112800. /**
  112801. * Gets whether audio is outputing to headphone or not.
  112802. * Please use the according Switch methods to change output.
  112803. */
  112804. get headphone(): boolean;
  112805. /**
  112806. * Gets or sets a refresh rate when using 3D audio positioning
  112807. */
  112808. audioPositioningRefreshRate: number;
  112809. private _audioListenerPositionProvider;
  112810. /**
  112811. * Gets the current audio listener position provider
  112812. */
  112813. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  112814. /**
  112815. * Sets a custom listener position for all sounds in the scene
  112816. * By default, this is the position of the first active camera
  112817. */
  112818. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  112819. /**
  112820. * Creates a new instance of the component for the given scene
  112821. * @param scene Defines the scene to register the component in
  112822. */
  112823. constructor(scene: Scene);
  112824. /**
  112825. * Registers the component in a given scene
  112826. */
  112827. register(): void;
  112828. /**
  112829. * Rebuilds the elements related to this component in case of
  112830. * context lost for instance.
  112831. */
  112832. rebuild(): void;
  112833. /**
  112834. * Serializes the component data to the specified json object
  112835. * @param serializationObject The object to serialize to
  112836. */
  112837. serialize(serializationObject: any): void;
  112838. /**
  112839. * Adds all the elements from the container to the scene
  112840. * @param container the container holding the elements
  112841. */
  112842. addFromContainer(container: AbstractScene): void;
  112843. /**
  112844. * Removes all the elements in the container from the scene
  112845. * @param container contains the elements to remove
  112846. * @param dispose if the removed element should be disposed (default: false)
  112847. */
  112848. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  112849. /**
  112850. * Disposes the component and the associated ressources.
  112851. */
  112852. dispose(): void;
  112853. /**
  112854. * Disables audio in the associated scene.
  112855. */
  112856. disableAudio(): void;
  112857. /**
  112858. * Enables audio in the associated scene.
  112859. */
  112860. enableAudio(): void;
  112861. /**
  112862. * Switch audio to headphone output.
  112863. */
  112864. switchAudioModeForHeadphones(): void;
  112865. /**
  112866. * Switch audio to normal speakers.
  112867. */
  112868. switchAudioModeForNormalSpeakers(): void;
  112869. private _cachedCameraDirection;
  112870. private _cachedCameraPosition;
  112871. private _lastCheck;
  112872. private _afterRender;
  112873. }
  112874. }
  112875. declare module BABYLON {
  112876. /**
  112877. * Wraps one or more Sound objects and selects one with random weight for playback.
  112878. */
  112879. export class WeightedSound {
  112880. /** When true a Sound will be selected and played when the current playing Sound completes. */
  112881. loop: boolean;
  112882. private _coneInnerAngle;
  112883. private _coneOuterAngle;
  112884. private _volume;
  112885. /** A Sound is currently playing. */
  112886. isPlaying: boolean;
  112887. /** A Sound is currently paused. */
  112888. isPaused: boolean;
  112889. private _sounds;
  112890. private _weights;
  112891. private _currentIndex?;
  112892. /**
  112893. * Creates a new WeightedSound from the list of sounds given.
  112894. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  112895. * @param sounds Array of Sounds that will be selected from.
  112896. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  112897. */
  112898. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  112899. /**
  112900. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  112901. */
  112902. get directionalConeInnerAngle(): number;
  112903. /**
  112904. * The size of cone in degress for a directional sound in which there will be no attenuation.
  112905. */
  112906. set directionalConeInnerAngle(value: number);
  112907. /**
  112908. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  112909. * Listener angles between innerAngle and outerAngle will falloff linearly.
  112910. */
  112911. get directionalConeOuterAngle(): number;
  112912. /**
  112913. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  112914. * Listener angles between innerAngle and outerAngle will falloff linearly.
  112915. */
  112916. set directionalConeOuterAngle(value: number);
  112917. /**
  112918. * Playback volume.
  112919. */
  112920. get volume(): number;
  112921. /**
  112922. * Playback volume.
  112923. */
  112924. set volume(value: number);
  112925. private _onended;
  112926. /**
  112927. * Suspend playback
  112928. */
  112929. pause(): void;
  112930. /**
  112931. * Stop playback
  112932. */
  112933. stop(): void;
  112934. /**
  112935. * Start playback.
  112936. * @param startOffset Position the clip head at a specific time in seconds.
  112937. */
  112938. play(startOffset?: number): void;
  112939. }
  112940. }
  112941. declare module BABYLON {
  112942. /**
  112943. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  112944. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112945. */
  112946. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  112947. /**
  112948. * Gets the name of the behavior.
  112949. */
  112950. get name(): string;
  112951. /**
  112952. * The easing function used by animations
  112953. */
  112954. static EasingFunction: BackEase;
  112955. /**
  112956. * The easing mode used by animations
  112957. */
  112958. static EasingMode: number;
  112959. /**
  112960. * The duration of the animation, in milliseconds
  112961. */
  112962. transitionDuration: number;
  112963. /**
  112964. * Length of the distance animated by the transition when lower radius is reached
  112965. */
  112966. lowerRadiusTransitionRange: number;
  112967. /**
  112968. * Length of the distance animated by the transition when upper radius is reached
  112969. */
  112970. upperRadiusTransitionRange: number;
  112971. private _autoTransitionRange;
  112972. /**
  112973. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  112974. */
  112975. get autoTransitionRange(): boolean;
  112976. /**
  112977. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  112978. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  112979. */
  112980. set autoTransitionRange(value: boolean);
  112981. private _attachedCamera;
  112982. private _onAfterCheckInputsObserver;
  112983. private _onMeshTargetChangedObserver;
  112984. /**
  112985. * Initializes the behavior.
  112986. */
  112987. init(): void;
  112988. /**
  112989. * Attaches the behavior to its arc rotate camera.
  112990. * @param camera Defines the camera to attach the behavior to
  112991. */
  112992. attach(camera: ArcRotateCamera): void;
  112993. /**
  112994. * Detaches the behavior from its current arc rotate camera.
  112995. */
  112996. detach(): void;
  112997. private _radiusIsAnimating;
  112998. private _radiusBounceTransition;
  112999. private _animatables;
  113000. private _cachedWheelPrecision;
  113001. /**
  113002. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  113003. * @param radiusLimit The limit to check against.
  113004. * @return Bool to indicate if at limit.
  113005. */
  113006. private _isRadiusAtLimit;
  113007. /**
  113008. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  113009. * @param radiusDelta The delta by which to animate to. Can be negative.
  113010. */
  113011. private _applyBoundRadiusAnimation;
  113012. /**
  113013. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  113014. */
  113015. protected _clearAnimationLocks(): void;
  113016. /**
  113017. * Stops and removes all animations that have been applied to the camera
  113018. */
  113019. stopAllAnimations(): void;
  113020. }
  113021. }
  113022. declare module BABYLON {
  113023. /**
  113024. * 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.
  113025. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  113026. */
  113027. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  113028. /**
  113029. * Gets the name of the behavior.
  113030. */
  113031. get name(): string;
  113032. private _mode;
  113033. private _radiusScale;
  113034. private _positionScale;
  113035. private _defaultElevation;
  113036. private _elevationReturnTime;
  113037. private _elevationReturnWaitTime;
  113038. private _zoomStopsAnimation;
  113039. private _framingTime;
  113040. /**
  113041. * The easing function used by animations
  113042. */
  113043. static EasingFunction: ExponentialEase;
  113044. /**
  113045. * The easing mode used by animations
  113046. */
  113047. static EasingMode: number;
  113048. /**
  113049. * Sets the current mode used by the behavior
  113050. */
  113051. set mode(mode: number);
  113052. /**
  113053. * Gets current mode used by the behavior.
  113054. */
  113055. get mode(): number;
  113056. /**
  113057. * Sets the scale applied to the radius (1 by default)
  113058. */
  113059. set radiusScale(radius: number);
  113060. /**
  113061. * Gets the scale applied to the radius
  113062. */
  113063. get radiusScale(): number;
  113064. /**
  113065. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  113066. */
  113067. set positionScale(scale: number);
  113068. /**
  113069. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  113070. */
  113071. get positionScale(): number;
  113072. /**
  113073. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  113074. * behaviour is triggered, in radians.
  113075. */
  113076. set defaultElevation(elevation: number);
  113077. /**
  113078. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  113079. * behaviour is triggered, in radians.
  113080. */
  113081. get defaultElevation(): number;
  113082. /**
  113083. * Sets the time (in milliseconds) taken to return to the default beta position.
  113084. * Negative value indicates camera should not return to default.
  113085. */
  113086. set elevationReturnTime(speed: number);
  113087. /**
  113088. * Gets the time (in milliseconds) taken to return to the default beta position.
  113089. * Negative value indicates camera should not return to default.
  113090. */
  113091. get elevationReturnTime(): number;
  113092. /**
  113093. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  113094. */
  113095. set elevationReturnWaitTime(time: number);
  113096. /**
  113097. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  113098. */
  113099. get elevationReturnWaitTime(): number;
  113100. /**
  113101. * Sets the flag that indicates if user zooming should stop animation.
  113102. */
  113103. set zoomStopsAnimation(flag: boolean);
  113104. /**
  113105. * Gets the flag that indicates if user zooming should stop animation.
  113106. */
  113107. get zoomStopsAnimation(): boolean;
  113108. /**
  113109. * Sets the transition time when framing the mesh, in milliseconds
  113110. */
  113111. set framingTime(time: number);
  113112. /**
  113113. * Gets the transition time when framing the mesh, in milliseconds
  113114. */
  113115. get framingTime(): number;
  113116. /**
  113117. * Define if the behavior should automatically change the configured
  113118. * camera limits and sensibilities.
  113119. */
  113120. autoCorrectCameraLimitsAndSensibility: boolean;
  113121. private _onPrePointerObservableObserver;
  113122. private _onAfterCheckInputsObserver;
  113123. private _onMeshTargetChangedObserver;
  113124. private _attachedCamera;
  113125. private _isPointerDown;
  113126. private _lastInteractionTime;
  113127. /**
  113128. * Initializes the behavior.
  113129. */
  113130. init(): void;
  113131. /**
  113132. * Attaches the behavior to its arc rotate camera.
  113133. * @param camera Defines the camera to attach the behavior to
  113134. */
  113135. attach(camera: ArcRotateCamera): void;
  113136. /**
  113137. * Detaches the behavior from its current arc rotate camera.
  113138. */
  113139. detach(): void;
  113140. private _animatables;
  113141. private _betaIsAnimating;
  113142. private _betaTransition;
  113143. private _radiusTransition;
  113144. private _vectorTransition;
  113145. /**
  113146. * Targets the given mesh and updates zoom level accordingly.
  113147. * @param mesh The mesh to target.
  113148. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  113149. * @param onAnimationEnd Callback triggered at the end of the framing animation
  113150. */
  113151. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  113152. /**
  113153. * Targets the given mesh with its children and updates zoom level accordingly.
  113154. * @param mesh The mesh to target.
  113155. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  113156. * @param onAnimationEnd Callback triggered at the end of the framing animation
  113157. */
  113158. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  113159. /**
  113160. * Targets the given meshes with their children and updates zoom level accordingly.
  113161. * @param meshes The mesh to target.
  113162. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  113163. * @param onAnimationEnd Callback triggered at the end of the framing animation
  113164. */
  113165. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  113166. /**
  113167. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  113168. * @param minimumWorld Determines the smaller position of the bounding box extend
  113169. * @param maximumWorld Determines the bigger position of the bounding box extend
  113170. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  113171. * @param onAnimationEnd Callback triggered at the end of the framing animation
  113172. */
  113173. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  113174. /**
  113175. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  113176. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  113177. * frustum width.
  113178. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  113179. * to fully enclose the mesh in the viewing frustum.
  113180. */
  113181. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  113182. /**
  113183. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  113184. * is automatically returned to its default position (expected to be above ground plane).
  113185. */
  113186. private _maintainCameraAboveGround;
  113187. /**
  113188. * Returns the frustum slope based on the canvas ratio and camera FOV
  113189. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  113190. */
  113191. private _getFrustumSlope;
  113192. /**
  113193. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  113194. */
  113195. private _clearAnimationLocks;
  113196. /**
  113197. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  113198. */
  113199. private _applyUserInteraction;
  113200. /**
  113201. * Stops and removes all animations that have been applied to the camera
  113202. */
  113203. stopAllAnimations(): void;
  113204. /**
  113205. * Gets a value indicating if the user is moving the camera
  113206. */
  113207. get isUserIsMoving(): boolean;
  113208. /**
  113209. * The camera can move all the way towards the mesh.
  113210. */
  113211. static IgnoreBoundsSizeMode: number;
  113212. /**
  113213. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  113214. */
  113215. static FitFrustumSidesMode: number;
  113216. }
  113217. }
  113218. declare module BABYLON {
  113219. /**
  113220. * Base class for Camera Pointer Inputs.
  113221. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  113222. * for example usage.
  113223. */
  113224. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  113225. /**
  113226. * Defines the camera the input is attached to.
  113227. */
  113228. abstract camera: Camera;
  113229. /**
  113230. * Whether keyboard modifier keys are pressed at time of last mouse event.
  113231. */
  113232. protected _altKey: boolean;
  113233. protected _ctrlKey: boolean;
  113234. protected _metaKey: boolean;
  113235. protected _shiftKey: boolean;
  113236. /**
  113237. * Which mouse buttons were pressed at time of last mouse event.
  113238. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  113239. */
  113240. protected _buttonsPressed: number;
  113241. /**
  113242. * Defines the buttons associated with the input to handle camera move.
  113243. */
  113244. buttons: number[];
  113245. /**
  113246. * Attach the input controls to a specific dom element to get the input from.
  113247. * @param element Defines the element the controls should be listened from
  113248. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113249. */
  113250. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113251. /**
  113252. * Detach the current controls from the specified dom element.
  113253. * @param element Defines the element to stop listening the inputs from
  113254. */
  113255. detachControl(element: Nullable<HTMLElement>): void;
  113256. /**
  113257. * Gets the class name of the current input.
  113258. * @returns the class name
  113259. */
  113260. getClassName(): string;
  113261. /**
  113262. * Get the friendly name associated with the input class.
  113263. * @returns the input friendly name
  113264. */
  113265. getSimpleName(): string;
  113266. /**
  113267. * Called on pointer POINTERDOUBLETAP event.
  113268. * Override this method to provide functionality on POINTERDOUBLETAP event.
  113269. */
  113270. protected onDoubleTap(type: string): void;
  113271. /**
  113272. * Called on pointer POINTERMOVE event if only a single touch is active.
  113273. * Override this method to provide functionality.
  113274. */
  113275. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  113276. /**
  113277. * Called on pointer POINTERMOVE event if multiple touches are active.
  113278. * Override this method to provide functionality.
  113279. */
  113280. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  113281. /**
  113282. * Called on JS contextmenu event.
  113283. * Override this method to provide functionality.
  113284. */
  113285. protected onContextMenu(evt: PointerEvent): void;
  113286. /**
  113287. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  113288. * press.
  113289. * Override this method to provide functionality.
  113290. */
  113291. protected onButtonDown(evt: PointerEvent): void;
  113292. /**
  113293. * Called each time a new POINTERUP event occurs. Ie, for each button
  113294. * release.
  113295. * Override this method to provide functionality.
  113296. */
  113297. protected onButtonUp(evt: PointerEvent): void;
  113298. /**
  113299. * Called when window becomes inactive.
  113300. * Override this method to provide functionality.
  113301. */
  113302. protected onLostFocus(): void;
  113303. private _pointerInput;
  113304. private _observer;
  113305. private _onLostFocus;
  113306. private pointA;
  113307. private pointB;
  113308. }
  113309. }
  113310. declare module BABYLON {
  113311. /**
  113312. * Manage the pointers inputs to control an arc rotate camera.
  113313. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113314. */
  113315. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  113316. /**
  113317. * Defines the camera the input is attached to.
  113318. */
  113319. camera: ArcRotateCamera;
  113320. /**
  113321. * Gets the class name of the current input.
  113322. * @returns the class name
  113323. */
  113324. getClassName(): string;
  113325. /**
  113326. * Defines the buttons associated with the input to handle camera move.
  113327. */
  113328. buttons: number[];
  113329. /**
  113330. * Defines the pointer angular sensibility along the X axis or how fast is
  113331. * the camera rotating.
  113332. */
  113333. angularSensibilityX: number;
  113334. /**
  113335. * Defines the pointer angular sensibility along the Y axis or how fast is
  113336. * the camera rotating.
  113337. */
  113338. angularSensibilityY: number;
  113339. /**
  113340. * Defines the pointer pinch precision or how fast is the camera zooming.
  113341. */
  113342. pinchPrecision: number;
  113343. /**
  113344. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  113345. * from 0.
  113346. * It defines the percentage of current camera.radius to use as delta when
  113347. * pinch zoom is used.
  113348. */
  113349. pinchDeltaPercentage: number;
  113350. /**
  113351. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  113352. * that any object in the plane at the camera's target point will scale
  113353. * perfectly with finger motion.
  113354. * Overrides pinchDeltaPercentage and pinchPrecision.
  113355. */
  113356. useNaturalPinchZoom: boolean;
  113357. /**
  113358. * Defines the pointer panning sensibility or how fast is the camera moving.
  113359. */
  113360. panningSensibility: number;
  113361. /**
  113362. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  113363. */
  113364. multiTouchPanning: boolean;
  113365. /**
  113366. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  113367. * zoom (pinch) through multitouch.
  113368. */
  113369. multiTouchPanAndZoom: boolean;
  113370. /**
  113371. * Revers pinch action direction.
  113372. */
  113373. pinchInwards: boolean;
  113374. private _isPanClick;
  113375. private _twoFingerActivityCount;
  113376. private _isPinching;
  113377. /**
  113378. * Called on pointer POINTERMOVE event if only a single touch is active.
  113379. */
  113380. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  113381. /**
  113382. * Called on pointer POINTERDOUBLETAP event.
  113383. */
  113384. protected onDoubleTap(type: string): void;
  113385. /**
  113386. * Called on pointer POINTERMOVE event if multiple touches are active.
  113387. */
  113388. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  113389. /**
  113390. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  113391. * press.
  113392. */
  113393. protected onButtonDown(evt: PointerEvent): void;
  113394. /**
  113395. * Called each time a new POINTERUP event occurs. Ie, for each button
  113396. * release.
  113397. */
  113398. protected onButtonUp(evt: PointerEvent): void;
  113399. /**
  113400. * Called when window becomes inactive.
  113401. */
  113402. protected onLostFocus(): void;
  113403. }
  113404. }
  113405. declare module BABYLON {
  113406. /**
  113407. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  113408. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113409. */
  113410. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  113411. /**
  113412. * Defines the camera the input is attached to.
  113413. */
  113414. camera: ArcRotateCamera;
  113415. /**
  113416. * Defines the list of key codes associated with the up action (increase alpha)
  113417. */
  113418. keysUp: number[];
  113419. /**
  113420. * Defines the list of key codes associated with the down action (decrease alpha)
  113421. */
  113422. keysDown: number[];
  113423. /**
  113424. * Defines the list of key codes associated with the left action (increase beta)
  113425. */
  113426. keysLeft: number[];
  113427. /**
  113428. * Defines the list of key codes associated with the right action (decrease beta)
  113429. */
  113430. keysRight: number[];
  113431. /**
  113432. * Defines the list of key codes associated with the reset action.
  113433. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  113434. */
  113435. keysReset: number[];
  113436. /**
  113437. * Defines the panning sensibility of the inputs.
  113438. * (How fast is the camera panning)
  113439. */
  113440. panningSensibility: number;
  113441. /**
  113442. * Defines the zooming sensibility of the inputs.
  113443. * (How fast is the camera zooming)
  113444. */
  113445. zoomingSensibility: number;
  113446. /**
  113447. * Defines whether maintaining the alt key down switch the movement mode from
  113448. * orientation to zoom.
  113449. */
  113450. useAltToZoom: boolean;
  113451. /**
  113452. * Rotation speed of the camera
  113453. */
  113454. angularSpeed: number;
  113455. private _keys;
  113456. private _ctrlPressed;
  113457. private _altPressed;
  113458. private _onCanvasBlurObserver;
  113459. private _onKeyboardObserver;
  113460. private _engine;
  113461. private _scene;
  113462. /**
  113463. * Attach the input controls to a specific dom element to get the input from.
  113464. * @param element Defines the element the controls should be listened from
  113465. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113466. */
  113467. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113468. /**
  113469. * Detach the current controls from the specified dom element.
  113470. * @param element Defines the element to stop listening the inputs from
  113471. */
  113472. detachControl(element: Nullable<HTMLElement>): void;
  113473. /**
  113474. * Update the current camera state depending on the inputs that have been used this frame.
  113475. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113476. */
  113477. checkInputs(): void;
  113478. /**
  113479. * Gets the class name of the current intput.
  113480. * @returns the class name
  113481. */
  113482. getClassName(): string;
  113483. /**
  113484. * Get the friendly name associated with the input class.
  113485. * @returns the input friendly name
  113486. */
  113487. getSimpleName(): string;
  113488. }
  113489. }
  113490. declare module BABYLON {
  113491. /**
  113492. * Manage the mouse wheel inputs to control an arc rotate camera.
  113493. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113494. */
  113495. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  113496. /**
  113497. * Defines the camera the input is attached to.
  113498. */
  113499. camera: ArcRotateCamera;
  113500. /**
  113501. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  113502. */
  113503. wheelPrecision: number;
  113504. /**
  113505. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  113506. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  113507. */
  113508. wheelDeltaPercentage: number;
  113509. private _wheel;
  113510. private _observer;
  113511. private computeDeltaFromMouseWheelLegacyEvent;
  113512. /**
  113513. * Attach the input controls to a specific dom element to get the input from.
  113514. * @param element Defines the element the controls should be listened from
  113515. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113516. */
  113517. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113518. /**
  113519. * Detach the current controls from the specified dom element.
  113520. * @param element Defines the element to stop listening the inputs from
  113521. */
  113522. detachControl(element: Nullable<HTMLElement>): void;
  113523. /**
  113524. * Gets the class name of the current intput.
  113525. * @returns the class name
  113526. */
  113527. getClassName(): string;
  113528. /**
  113529. * Get the friendly name associated with the input class.
  113530. * @returns the input friendly name
  113531. */
  113532. getSimpleName(): string;
  113533. }
  113534. }
  113535. declare module BABYLON {
  113536. /**
  113537. * Default Inputs manager for the ArcRotateCamera.
  113538. * It groups all the default supported inputs for ease of use.
  113539. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113540. */
  113541. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  113542. /**
  113543. * Instantiates a new ArcRotateCameraInputsManager.
  113544. * @param camera Defines the camera the inputs belong to
  113545. */
  113546. constructor(camera: ArcRotateCamera);
  113547. /**
  113548. * Add mouse wheel input support to the input manager.
  113549. * @returns the current input manager
  113550. */
  113551. addMouseWheel(): ArcRotateCameraInputsManager;
  113552. /**
  113553. * Add pointers input support to the input manager.
  113554. * @returns the current input manager
  113555. */
  113556. addPointers(): ArcRotateCameraInputsManager;
  113557. /**
  113558. * Add keyboard input support to the input manager.
  113559. * @returns the current input manager
  113560. */
  113561. addKeyboard(): ArcRotateCameraInputsManager;
  113562. }
  113563. }
  113564. declare module BABYLON {
  113565. /**
  113566. * This represents an orbital type of camera.
  113567. *
  113568. * 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.
  113569. * 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.
  113570. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  113571. */
  113572. export class ArcRotateCamera extends TargetCamera {
  113573. /**
  113574. * Defines the rotation angle of the camera along the longitudinal axis.
  113575. */
  113576. alpha: number;
  113577. /**
  113578. * Defines the rotation angle of the camera along the latitudinal axis.
  113579. */
  113580. beta: number;
  113581. /**
  113582. * Defines the radius of the camera from it s target point.
  113583. */
  113584. radius: number;
  113585. protected _target: Vector3;
  113586. protected _targetHost: Nullable<AbstractMesh>;
  113587. /**
  113588. * Defines the target point of the camera.
  113589. * The camera looks towards it form the radius distance.
  113590. */
  113591. get target(): Vector3;
  113592. set target(value: Vector3);
  113593. /**
  113594. * Define the current local position of the camera in the scene
  113595. */
  113596. get position(): Vector3;
  113597. set position(newPosition: Vector3);
  113598. protected _upVector: Vector3;
  113599. protected _upToYMatrix: Matrix;
  113600. protected _YToUpMatrix: Matrix;
  113601. /**
  113602. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  113603. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  113604. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  113605. */
  113606. set upVector(vec: Vector3);
  113607. get upVector(): Vector3;
  113608. /**
  113609. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  113610. */
  113611. setMatUp(): void;
  113612. /**
  113613. * Current inertia value on the longitudinal axis.
  113614. * The bigger this number the longer it will take for the camera to stop.
  113615. */
  113616. inertialAlphaOffset: number;
  113617. /**
  113618. * Current inertia value on the latitudinal axis.
  113619. * The bigger this number the longer it will take for the camera to stop.
  113620. */
  113621. inertialBetaOffset: number;
  113622. /**
  113623. * Current inertia value on the radius axis.
  113624. * The bigger this number the longer it will take for the camera to stop.
  113625. */
  113626. inertialRadiusOffset: number;
  113627. /**
  113628. * Minimum allowed angle on the longitudinal axis.
  113629. * This can help limiting how the Camera is able to move in the scene.
  113630. */
  113631. lowerAlphaLimit: Nullable<number>;
  113632. /**
  113633. * Maximum allowed angle on the longitudinal axis.
  113634. * This can help limiting how the Camera is able to move in the scene.
  113635. */
  113636. upperAlphaLimit: Nullable<number>;
  113637. /**
  113638. * Minimum allowed angle on the latitudinal axis.
  113639. * This can help limiting how the Camera is able to move in the scene.
  113640. */
  113641. lowerBetaLimit: number;
  113642. /**
  113643. * Maximum allowed angle on the latitudinal axis.
  113644. * This can help limiting how the Camera is able to move in the scene.
  113645. */
  113646. upperBetaLimit: number;
  113647. /**
  113648. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  113649. * This can help limiting how the Camera is able to move in the scene.
  113650. */
  113651. lowerRadiusLimit: Nullable<number>;
  113652. /**
  113653. * Maximum allowed distance of the camera to the target (The camera can not get further).
  113654. * This can help limiting how the Camera is able to move in the scene.
  113655. */
  113656. upperRadiusLimit: Nullable<number>;
  113657. /**
  113658. * Defines the current inertia value used during panning of the camera along the X axis.
  113659. */
  113660. inertialPanningX: number;
  113661. /**
  113662. * Defines the current inertia value used during panning of the camera along the Y axis.
  113663. */
  113664. inertialPanningY: number;
  113665. /**
  113666. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  113667. * Basically if your fingers moves away from more than this distance you will be considered
  113668. * in pinch mode.
  113669. */
  113670. pinchToPanMaxDistance: number;
  113671. /**
  113672. * Defines the maximum distance the camera can pan.
  113673. * This could help keeping the cammera always in your scene.
  113674. */
  113675. panningDistanceLimit: Nullable<number>;
  113676. /**
  113677. * Defines the target of the camera before paning.
  113678. */
  113679. panningOriginTarget: Vector3;
  113680. /**
  113681. * Defines the value of the inertia used during panning.
  113682. * 0 would mean stop inertia and one would mean no decelleration at all.
  113683. */
  113684. panningInertia: number;
  113685. /**
  113686. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  113687. */
  113688. get angularSensibilityX(): number;
  113689. set angularSensibilityX(value: number);
  113690. /**
  113691. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  113692. */
  113693. get angularSensibilityY(): number;
  113694. set angularSensibilityY(value: number);
  113695. /**
  113696. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  113697. */
  113698. get pinchPrecision(): number;
  113699. set pinchPrecision(value: number);
  113700. /**
  113701. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  113702. * It will be used instead of pinchDeltaPrecision if different from 0.
  113703. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  113704. */
  113705. get pinchDeltaPercentage(): number;
  113706. set pinchDeltaPercentage(value: number);
  113707. /**
  113708. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  113709. * and pinch delta percentage.
  113710. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  113711. * that any object in the plane at the camera's target point will scale
  113712. * perfectly with finger motion.
  113713. */
  113714. get useNaturalPinchZoom(): boolean;
  113715. set useNaturalPinchZoom(value: boolean);
  113716. /**
  113717. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  113718. */
  113719. get panningSensibility(): number;
  113720. set panningSensibility(value: number);
  113721. /**
  113722. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  113723. */
  113724. get keysUp(): number[];
  113725. set keysUp(value: number[]);
  113726. /**
  113727. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  113728. */
  113729. get keysDown(): number[];
  113730. set keysDown(value: number[]);
  113731. /**
  113732. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  113733. */
  113734. get keysLeft(): number[];
  113735. set keysLeft(value: number[]);
  113736. /**
  113737. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  113738. */
  113739. get keysRight(): number[];
  113740. set keysRight(value: number[]);
  113741. /**
  113742. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  113743. */
  113744. get wheelPrecision(): number;
  113745. set wheelPrecision(value: number);
  113746. /**
  113747. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  113748. * It will be used instead of pinchDeltaPrecision if different from 0.
  113749. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  113750. */
  113751. get wheelDeltaPercentage(): number;
  113752. set wheelDeltaPercentage(value: number);
  113753. /**
  113754. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  113755. */
  113756. zoomOnFactor: number;
  113757. /**
  113758. * Defines a screen offset for the camera position.
  113759. */
  113760. targetScreenOffset: Vector2;
  113761. /**
  113762. * Allows the camera to be completely reversed.
  113763. * If false the camera can not arrive upside down.
  113764. */
  113765. allowUpsideDown: boolean;
  113766. /**
  113767. * Define if double tap/click is used to restore the previously saved state of the camera.
  113768. */
  113769. useInputToRestoreState: boolean;
  113770. /** @hidden */
  113771. _viewMatrix: Matrix;
  113772. /** @hidden */
  113773. _useCtrlForPanning: boolean;
  113774. /** @hidden */
  113775. _panningMouseButton: number;
  113776. /**
  113777. * Defines the input associated to the camera.
  113778. */
  113779. inputs: ArcRotateCameraInputsManager;
  113780. /** @hidden */
  113781. _reset: () => void;
  113782. /**
  113783. * Defines the allowed panning axis.
  113784. */
  113785. panningAxis: Vector3;
  113786. protected _localDirection: Vector3;
  113787. protected _transformedDirection: Vector3;
  113788. private _bouncingBehavior;
  113789. /**
  113790. * Gets the bouncing behavior of the camera if it has been enabled.
  113791. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  113792. */
  113793. get bouncingBehavior(): Nullable<BouncingBehavior>;
  113794. /**
  113795. * Defines if the bouncing behavior of the camera is enabled on the camera.
  113796. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  113797. */
  113798. get useBouncingBehavior(): boolean;
  113799. set useBouncingBehavior(value: boolean);
  113800. private _framingBehavior;
  113801. /**
  113802. * Gets the framing behavior of the camera if it has been enabled.
  113803. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  113804. */
  113805. get framingBehavior(): Nullable<FramingBehavior>;
  113806. /**
  113807. * Defines if the framing behavior of the camera is enabled on the camera.
  113808. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  113809. */
  113810. get useFramingBehavior(): boolean;
  113811. set useFramingBehavior(value: boolean);
  113812. private _autoRotationBehavior;
  113813. /**
  113814. * Gets the auto rotation behavior of the camera if it has been enabled.
  113815. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  113816. */
  113817. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  113818. /**
  113819. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  113820. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  113821. */
  113822. get useAutoRotationBehavior(): boolean;
  113823. set useAutoRotationBehavior(value: boolean);
  113824. /**
  113825. * Observable triggered when the mesh target has been changed on the camera.
  113826. */
  113827. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  113828. /**
  113829. * Event raised when the camera is colliding with a mesh.
  113830. */
  113831. onCollide: (collidedMesh: AbstractMesh) => void;
  113832. /**
  113833. * Defines whether the camera should check collision with the objects oh the scene.
  113834. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  113835. */
  113836. checkCollisions: boolean;
  113837. /**
  113838. * Defines the collision radius of the camera.
  113839. * This simulates a sphere around the camera.
  113840. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  113841. */
  113842. collisionRadius: Vector3;
  113843. protected _collider: Collider;
  113844. protected _previousPosition: Vector3;
  113845. protected _collisionVelocity: Vector3;
  113846. protected _newPosition: Vector3;
  113847. protected _previousAlpha: number;
  113848. protected _previousBeta: number;
  113849. protected _previousRadius: number;
  113850. protected _collisionTriggered: boolean;
  113851. protected _targetBoundingCenter: Nullable<Vector3>;
  113852. private _computationVector;
  113853. /**
  113854. * Instantiates a new ArcRotateCamera in a given scene
  113855. * @param name Defines the name of the camera
  113856. * @param alpha Defines the camera rotation along the logitudinal axis
  113857. * @param beta Defines the camera rotation along the latitudinal axis
  113858. * @param radius Defines the camera distance from its target
  113859. * @param target Defines the camera target
  113860. * @param scene Defines the scene the camera belongs to
  113861. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  113862. */
  113863. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  113864. /** @hidden */
  113865. _initCache(): void;
  113866. /** @hidden */
  113867. _updateCache(ignoreParentClass?: boolean): void;
  113868. protected _getTargetPosition(): Vector3;
  113869. private _storedAlpha;
  113870. private _storedBeta;
  113871. private _storedRadius;
  113872. private _storedTarget;
  113873. private _storedTargetScreenOffset;
  113874. /**
  113875. * Stores the current state of the camera (alpha, beta, radius and target)
  113876. * @returns the camera itself
  113877. */
  113878. storeState(): Camera;
  113879. /**
  113880. * @hidden
  113881. * Restored camera state. You must call storeState() first
  113882. */
  113883. _restoreStateValues(): boolean;
  113884. /** @hidden */
  113885. _isSynchronizedViewMatrix(): boolean;
  113886. /**
  113887. * Attached controls to the current camera.
  113888. * @param element Defines the element the controls should be listened from
  113889. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113890. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  113891. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  113892. */
  113893. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  113894. /**
  113895. * Detach the current controls from the camera.
  113896. * The camera will stop reacting to inputs.
  113897. * @param element Defines the element to stop listening the inputs from
  113898. */
  113899. detachControl(element: HTMLElement): void;
  113900. /** @hidden */
  113901. _checkInputs(): void;
  113902. protected _checkLimits(): void;
  113903. /**
  113904. * Rebuilds angles (alpha, beta) and radius from the give position and target
  113905. */
  113906. rebuildAnglesAndRadius(): void;
  113907. /**
  113908. * Use a position to define the current camera related information like alpha, beta and radius
  113909. * @param position Defines the position to set the camera at
  113910. */
  113911. setPosition(position: Vector3): void;
  113912. /**
  113913. * Defines the target the camera should look at.
  113914. * This will automatically adapt alpha beta and radius to fit within the new target.
  113915. * @param target Defines the new target as a Vector or a mesh
  113916. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  113917. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  113918. */
  113919. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  113920. /** @hidden */
  113921. _getViewMatrix(): Matrix;
  113922. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  113923. /**
  113924. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  113925. * @param meshes Defines the mesh to zoom on
  113926. * @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)
  113927. */
  113928. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  113929. /**
  113930. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  113931. * The target will be changed but the radius
  113932. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  113933. * @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)
  113934. */
  113935. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  113936. min: Vector3;
  113937. max: Vector3;
  113938. distance: number;
  113939. }, doNotUpdateMaxZ?: boolean): void;
  113940. /**
  113941. * @override
  113942. * Override Camera.createRigCamera
  113943. */
  113944. createRigCamera(name: string, cameraIndex: number): Camera;
  113945. /**
  113946. * @hidden
  113947. * @override
  113948. * Override Camera._updateRigCameras
  113949. */
  113950. _updateRigCameras(): void;
  113951. /**
  113952. * Destroy the camera and release the current resources hold by it.
  113953. */
  113954. dispose(): void;
  113955. /**
  113956. * Gets the current object class name.
  113957. * @return the class name
  113958. */
  113959. getClassName(): string;
  113960. }
  113961. }
  113962. declare module BABYLON {
  113963. /**
  113964. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  113965. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  113966. */
  113967. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  113968. /**
  113969. * Gets the name of the behavior.
  113970. */
  113971. get name(): string;
  113972. private _zoomStopsAnimation;
  113973. private _idleRotationSpeed;
  113974. private _idleRotationWaitTime;
  113975. private _idleRotationSpinupTime;
  113976. /**
  113977. * Sets the flag that indicates if user zooming should stop animation.
  113978. */
  113979. set zoomStopsAnimation(flag: boolean);
  113980. /**
  113981. * Gets the flag that indicates if user zooming should stop animation.
  113982. */
  113983. get zoomStopsAnimation(): boolean;
  113984. /**
  113985. * Sets the default speed at which the camera rotates around the model.
  113986. */
  113987. set idleRotationSpeed(speed: number);
  113988. /**
  113989. * Gets the default speed at which the camera rotates around the model.
  113990. */
  113991. get idleRotationSpeed(): number;
  113992. /**
  113993. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  113994. */
  113995. set idleRotationWaitTime(time: number);
  113996. /**
  113997. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  113998. */
  113999. get idleRotationWaitTime(): number;
  114000. /**
  114001. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  114002. */
  114003. set idleRotationSpinupTime(time: number);
  114004. /**
  114005. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  114006. */
  114007. get idleRotationSpinupTime(): number;
  114008. /**
  114009. * Gets a value indicating if the camera is currently rotating because of this behavior
  114010. */
  114011. get rotationInProgress(): boolean;
  114012. private _onPrePointerObservableObserver;
  114013. private _onAfterCheckInputsObserver;
  114014. private _attachedCamera;
  114015. private _isPointerDown;
  114016. private _lastFrameTime;
  114017. private _lastInteractionTime;
  114018. private _cameraRotationSpeed;
  114019. /**
  114020. * Initializes the behavior.
  114021. */
  114022. init(): void;
  114023. /**
  114024. * Attaches the behavior to its arc rotate camera.
  114025. * @param camera Defines the camera to attach the behavior to
  114026. */
  114027. attach(camera: ArcRotateCamera): void;
  114028. /**
  114029. * Detaches the behavior from its current arc rotate camera.
  114030. */
  114031. detach(): void;
  114032. /**
  114033. * Returns true if user is scrolling.
  114034. * @return true if user is scrolling.
  114035. */
  114036. private _userIsZooming;
  114037. private _lastFrameRadius;
  114038. private _shouldAnimationStopForInteraction;
  114039. /**
  114040. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  114041. */
  114042. private _applyUserInteraction;
  114043. private _userIsMoving;
  114044. }
  114045. }
  114046. declare module BABYLON {
  114047. /**
  114048. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  114049. */
  114050. export class AttachToBoxBehavior implements Behavior<Mesh> {
  114051. private ui;
  114052. /**
  114053. * The name of the behavior
  114054. */
  114055. name: string;
  114056. /**
  114057. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  114058. */
  114059. distanceAwayFromFace: number;
  114060. /**
  114061. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  114062. */
  114063. distanceAwayFromBottomOfFace: number;
  114064. private _faceVectors;
  114065. private _target;
  114066. private _scene;
  114067. private _onRenderObserver;
  114068. private _tmpMatrix;
  114069. private _tmpVector;
  114070. /**
  114071. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  114072. * @param ui The transform node that should be attched to the mesh
  114073. */
  114074. constructor(ui: TransformNode);
  114075. /**
  114076. * Initializes the behavior
  114077. */
  114078. init(): void;
  114079. private _closestFace;
  114080. private _zeroVector;
  114081. private _lookAtTmpMatrix;
  114082. private _lookAtToRef;
  114083. /**
  114084. * Attaches the AttachToBoxBehavior to the passed in mesh
  114085. * @param target The mesh that the specified node will be attached to
  114086. */
  114087. attach(target: Mesh): void;
  114088. /**
  114089. * Detaches the behavior from the mesh
  114090. */
  114091. detach(): void;
  114092. }
  114093. }
  114094. declare module BABYLON {
  114095. /**
  114096. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  114097. */
  114098. export class FadeInOutBehavior implements Behavior<Mesh> {
  114099. /**
  114100. * Time in milliseconds to delay before fading in (Default: 0)
  114101. */
  114102. delay: number;
  114103. /**
  114104. * Time in milliseconds for the mesh to fade in (Default: 300)
  114105. */
  114106. fadeInTime: number;
  114107. private _millisecondsPerFrame;
  114108. private _hovered;
  114109. private _hoverValue;
  114110. private _ownerNode;
  114111. /**
  114112. * Instatiates the FadeInOutBehavior
  114113. */
  114114. constructor();
  114115. /**
  114116. * The name of the behavior
  114117. */
  114118. get name(): string;
  114119. /**
  114120. * Initializes the behavior
  114121. */
  114122. init(): void;
  114123. /**
  114124. * Attaches the fade behavior on the passed in mesh
  114125. * @param ownerNode The mesh that will be faded in/out once attached
  114126. */
  114127. attach(ownerNode: Mesh): void;
  114128. /**
  114129. * Detaches the behavior from the mesh
  114130. */
  114131. detach(): void;
  114132. /**
  114133. * Triggers the mesh to begin fading in or out
  114134. * @param value if the object should fade in or out (true to fade in)
  114135. */
  114136. fadeIn(value: boolean): void;
  114137. private _update;
  114138. private _setAllVisibility;
  114139. }
  114140. }
  114141. declare module BABYLON {
  114142. /**
  114143. * Class containing a set of static utilities functions for managing Pivots
  114144. * @hidden
  114145. */
  114146. export class PivotTools {
  114147. private static _PivotCached;
  114148. private static _OldPivotPoint;
  114149. private static _PivotTranslation;
  114150. private static _PivotTmpVector;
  114151. /** @hidden */
  114152. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  114153. /** @hidden */
  114154. static _RestorePivotPoint(mesh: AbstractMesh): void;
  114155. }
  114156. }
  114157. declare module BABYLON {
  114158. /**
  114159. * Class containing static functions to help procedurally build meshes
  114160. */
  114161. export class PlaneBuilder {
  114162. /**
  114163. * Creates a plane mesh
  114164. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  114165. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  114166. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  114167. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114168. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114169. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114170. * @param name defines the name of the mesh
  114171. * @param options defines the options used to create the mesh
  114172. * @param scene defines the hosting scene
  114173. * @returns the plane mesh
  114174. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  114175. */
  114176. static CreatePlane(name: string, options: {
  114177. size?: number;
  114178. width?: number;
  114179. height?: number;
  114180. sideOrientation?: number;
  114181. frontUVs?: Vector4;
  114182. backUVs?: Vector4;
  114183. updatable?: boolean;
  114184. sourcePlane?: Plane;
  114185. }, scene?: Nullable<Scene>): Mesh;
  114186. }
  114187. }
  114188. declare module BABYLON {
  114189. /**
  114190. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  114191. */
  114192. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  114193. private static _AnyMouseID;
  114194. /**
  114195. * Abstract mesh the behavior is set on
  114196. */
  114197. attachedNode: AbstractMesh;
  114198. private _dragPlane;
  114199. private _scene;
  114200. private _pointerObserver;
  114201. private _beforeRenderObserver;
  114202. private static _planeScene;
  114203. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  114204. /**
  114205. * 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)
  114206. */
  114207. maxDragAngle: number;
  114208. /**
  114209. * @hidden
  114210. */
  114211. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  114212. /**
  114213. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  114214. */
  114215. currentDraggingPointerID: number;
  114216. /**
  114217. * The last position where the pointer hit the drag plane in world space
  114218. */
  114219. lastDragPosition: Vector3;
  114220. /**
  114221. * If the behavior is currently in a dragging state
  114222. */
  114223. dragging: boolean;
  114224. /**
  114225. * 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)
  114226. */
  114227. dragDeltaRatio: number;
  114228. /**
  114229. * If the drag plane orientation should be updated during the dragging (Default: true)
  114230. */
  114231. updateDragPlane: boolean;
  114232. private _debugMode;
  114233. private _moving;
  114234. /**
  114235. * Fires each time the attached mesh is dragged with the pointer
  114236. * * delta between last drag position and current drag position in world space
  114237. * * dragDistance along the drag axis
  114238. * * dragPlaneNormal normal of the current drag plane used during the drag
  114239. * * dragPlanePoint in world space where the drag intersects the drag plane
  114240. */
  114241. onDragObservable: Observable<{
  114242. delta: Vector3;
  114243. dragPlanePoint: Vector3;
  114244. dragPlaneNormal: Vector3;
  114245. dragDistance: number;
  114246. pointerId: number;
  114247. }>;
  114248. /**
  114249. * Fires each time a drag begins (eg. mouse down on mesh)
  114250. */
  114251. onDragStartObservable: Observable<{
  114252. dragPlanePoint: Vector3;
  114253. pointerId: number;
  114254. }>;
  114255. /**
  114256. * Fires each time a drag ends (eg. mouse release after drag)
  114257. */
  114258. onDragEndObservable: Observable<{
  114259. dragPlanePoint: Vector3;
  114260. pointerId: number;
  114261. }>;
  114262. /**
  114263. * If the attached mesh should be moved when dragged
  114264. */
  114265. moveAttached: boolean;
  114266. /**
  114267. * If the drag behavior will react to drag events (Default: true)
  114268. */
  114269. enabled: boolean;
  114270. /**
  114271. * If pointer events should start and release the drag (Default: true)
  114272. */
  114273. startAndReleaseDragOnPointerEvents: boolean;
  114274. /**
  114275. * If camera controls should be detached during the drag
  114276. */
  114277. detachCameraControls: boolean;
  114278. /**
  114279. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  114280. */
  114281. useObjectOrientationForDragging: boolean;
  114282. private _options;
  114283. /**
  114284. * Gets the options used by the behavior
  114285. */
  114286. get options(): {
  114287. dragAxis?: Vector3;
  114288. dragPlaneNormal?: Vector3;
  114289. };
  114290. /**
  114291. * Sets the options used by the behavior
  114292. */
  114293. set options(options: {
  114294. dragAxis?: Vector3;
  114295. dragPlaneNormal?: Vector3;
  114296. });
  114297. /**
  114298. * Creates a pointer drag behavior that can be attached to a mesh
  114299. * @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)
  114300. */
  114301. constructor(options?: {
  114302. dragAxis?: Vector3;
  114303. dragPlaneNormal?: Vector3;
  114304. });
  114305. /**
  114306. * Predicate to determine if it is valid to move the object to a new position when it is moved
  114307. */
  114308. validateDrag: (targetPosition: Vector3) => boolean;
  114309. /**
  114310. * The name of the behavior
  114311. */
  114312. get name(): string;
  114313. /**
  114314. * Initializes the behavior
  114315. */
  114316. init(): void;
  114317. private _tmpVector;
  114318. private _alternatePickedPoint;
  114319. private _worldDragAxis;
  114320. private _targetPosition;
  114321. private _attachedElement;
  114322. /**
  114323. * Attaches the drag behavior the passed in mesh
  114324. * @param ownerNode The mesh that will be dragged around once attached
  114325. * @param predicate Predicate to use for pick filtering
  114326. */
  114327. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  114328. /**
  114329. * Force relase the drag action by code.
  114330. */
  114331. releaseDrag(): void;
  114332. private _startDragRay;
  114333. private _lastPointerRay;
  114334. /**
  114335. * Simulates the start of a pointer drag event on the behavior
  114336. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  114337. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  114338. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  114339. */
  114340. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  114341. private _startDrag;
  114342. private _dragDelta;
  114343. private _moveDrag;
  114344. private _pickWithRayOnDragPlane;
  114345. private _pointA;
  114346. private _pointB;
  114347. private _pointC;
  114348. private _lineA;
  114349. private _lineB;
  114350. private _localAxis;
  114351. private _lookAt;
  114352. private _updateDragPlanePosition;
  114353. /**
  114354. * Detaches the behavior from the mesh
  114355. */
  114356. detach(): void;
  114357. }
  114358. }
  114359. declare module BABYLON {
  114360. /**
  114361. * A behavior that when attached to a mesh will allow the mesh to be scaled
  114362. */
  114363. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  114364. private _dragBehaviorA;
  114365. private _dragBehaviorB;
  114366. private _startDistance;
  114367. private _initialScale;
  114368. private _targetScale;
  114369. private _ownerNode;
  114370. private _sceneRenderObserver;
  114371. /**
  114372. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  114373. */
  114374. constructor();
  114375. /**
  114376. * The name of the behavior
  114377. */
  114378. get name(): string;
  114379. /**
  114380. * Initializes the behavior
  114381. */
  114382. init(): void;
  114383. private _getCurrentDistance;
  114384. /**
  114385. * Attaches the scale behavior the passed in mesh
  114386. * @param ownerNode The mesh that will be scaled around once attached
  114387. */
  114388. attach(ownerNode: Mesh): void;
  114389. /**
  114390. * Detaches the behavior from the mesh
  114391. */
  114392. detach(): void;
  114393. }
  114394. }
  114395. declare module BABYLON {
  114396. /**
  114397. * 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
  114398. */
  114399. export class SixDofDragBehavior implements Behavior<Mesh> {
  114400. private static _virtualScene;
  114401. private _ownerNode;
  114402. private _sceneRenderObserver;
  114403. private _scene;
  114404. private _targetPosition;
  114405. private _virtualOriginMesh;
  114406. private _virtualDragMesh;
  114407. private _pointerObserver;
  114408. private _moving;
  114409. private _startingOrientation;
  114410. private _attachedElement;
  114411. /**
  114412. * 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)
  114413. */
  114414. private zDragFactor;
  114415. /**
  114416. * If the object should rotate to face the drag origin
  114417. */
  114418. rotateDraggedObject: boolean;
  114419. /**
  114420. * If the behavior is currently in a dragging state
  114421. */
  114422. dragging: boolean;
  114423. /**
  114424. * 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)
  114425. */
  114426. dragDeltaRatio: number;
  114427. /**
  114428. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  114429. */
  114430. currentDraggingPointerID: number;
  114431. /**
  114432. * If camera controls should be detached during the drag
  114433. */
  114434. detachCameraControls: boolean;
  114435. /**
  114436. * Fires each time a drag starts
  114437. */
  114438. onDragStartObservable: Observable<{}>;
  114439. /**
  114440. * Fires each time a drag ends (eg. mouse release after drag)
  114441. */
  114442. onDragEndObservable: Observable<{}>;
  114443. /**
  114444. * 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
  114445. */
  114446. constructor();
  114447. /**
  114448. * The name of the behavior
  114449. */
  114450. get name(): string;
  114451. /**
  114452. * Initializes the behavior
  114453. */
  114454. init(): void;
  114455. /**
  114456. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  114457. */
  114458. private get _pointerCamera();
  114459. /**
  114460. * Attaches the scale behavior the passed in mesh
  114461. * @param ownerNode The mesh that will be scaled around once attached
  114462. */
  114463. attach(ownerNode: Mesh): void;
  114464. /**
  114465. * Detaches the behavior from the mesh
  114466. */
  114467. detach(): void;
  114468. }
  114469. }
  114470. declare module BABYLON {
  114471. /**
  114472. * Class used to apply inverse kinematics to bones
  114473. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  114474. */
  114475. export class BoneIKController {
  114476. private static _tmpVecs;
  114477. private static _tmpQuat;
  114478. private static _tmpMats;
  114479. /**
  114480. * Gets or sets the target mesh
  114481. */
  114482. targetMesh: AbstractMesh;
  114483. /** Gets or sets the mesh used as pole */
  114484. poleTargetMesh: AbstractMesh;
  114485. /**
  114486. * Gets or sets the bone used as pole
  114487. */
  114488. poleTargetBone: Nullable<Bone>;
  114489. /**
  114490. * Gets or sets the target position
  114491. */
  114492. targetPosition: Vector3;
  114493. /**
  114494. * Gets or sets the pole target position
  114495. */
  114496. poleTargetPosition: Vector3;
  114497. /**
  114498. * Gets or sets the pole target local offset
  114499. */
  114500. poleTargetLocalOffset: Vector3;
  114501. /**
  114502. * Gets or sets the pole angle
  114503. */
  114504. poleAngle: number;
  114505. /**
  114506. * Gets or sets the mesh associated with the controller
  114507. */
  114508. mesh: AbstractMesh;
  114509. /**
  114510. * 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)
  114511. */
  114512. slerpAmount: number;
  114513. private _bone1Quat;
  114514. private _bone1Mat;
  114515. private _bone2Ang;
  114516. private _bone1;
  114517. private _bone2;
  114518. private _bone1Length;
  114519. private _bone2Length;
  114520. private _maxAngle;
  114521. private _maxReach;
  114522. private _rightHandedSystem;
  114523. private _bendAxis;
  114524. private _slerping;
  114525. private _adjustRoll;
  114526. /**
  114527. * Gets or sets maximum allowed angle
  114528. */
  114529. get maxAngle(): number;
  114530. set maxAngle(value: number);
  114531. /**
  114532. * Creates a new BoneIKController
  114533. * @param mesh defines the mesh to control
  114534. * @param bone defines the bone to control
  114535. * @param options defines options to set up the controller
  114536. */
  114537. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  114538. targetMesh?: AbstractMesh;
  114539. poleTargetMesh?: AbstractMesh;
  114540. poleTargetBone?: Bone;
  114541. poleTargetLocalOffset?: Vector3;
  114542. poleAngle?: number;
  114543. bendAxis?: Vector3;
  114544. maxAngle?: number;
  114545. slerpAmount?: number;
  114546. });
  114547. private _setMaxAngle;
  114548. /**
  114549. * Force the controller to update the bones
  114550. */
  114551. update(): void;
  114552. }
  114553. }
  114554. declare module BABYLON {
  114555. /**
  114556. * Class used to make a bone look toward a point in space
  114557. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  114558. */
  114559. export class BoneLookController {
  114560. private static _tmpVecs;
  114561. private static _tmpQuat;
  114562. private static _tmpMats;
  114563. /**
  114564. * The target Vector3 that the bone will look at
  114565. */
  114566. target: Vector3;
  114567. /**
  114568. * The mesh that the bone is attached to
  114569. */
  114570. mesh: AbstractMesh;
  114571. /**
  114572. * The bone that will be looking to the target
  114573. */
  114574. bone: Bone;
  114575. /**
  114576. * The up axis of the coordinate system that is used when the bone is rotated
  114577. */
  114578. upAxis: Vector3;
  114579. /**
  114580. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  114581. */
  114582. upAxisSpace: Space;
  114583. /**
  114584. * Used to make an adjustment to the yaw of the bone
  114585. */
  114586. adjustYaw: number;
  114587. /**
  114588. * Used to make an adjustment to the pitch of the bone
  114589. */
  114590. adjustPitch: number;
  114591. /**
  114592. * Used to make an adjustment to the roll of the bone
  114593. */
  114594. adjustRoll: number;
  114595. /**
  114596. * 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)
  114597. */
  114598. slerpAmount: number;
  114599. private _minYaw;
  114600. private _maxYaw;
  114601. private _minPitch;
  114602. private _maxPitch;
  114603. private _minYawSin;
  114604. private _minYawCos;
  114605. private _maxYawSin;
  114606. private _maxYawCos;
  114607. private _midYawConstraint;
  114608. private _minPitchTan;
  114609. private _maxPitchTan;
  114610. private _boneQuat;
  114611. private _slerping;
  114612. private _transformYawPitch;
  114613. private _transformYawPitchInv;
  114614. private _firstFrameSkipped;
  114615. private _yawRange;
  114616. private _fowardAxis;
  114617. /**
  114618. * Gets or sets the minimum yaw angle that the bone can look to
  114619. */
  114620. get minYaw(): number;
  114621. set minYaw(value: number);
  114622. /**
  114623. * Gets or sets the maximum yaw angle that the bone can look to
  114624. */
  114625. get maxYaw(): number;
  114626. set maxYaw(value: number);
  114627. /**
  114628. * Gets or sets the minimum pitch angle that the bone can look to
  114629. */
  114630. get minPitch(): number;
  114631. set minPitch(value: number);
  114632. /**
  114633. * Gets or sets the maximum pitch angle that the bone can look to
  114634. */
  114635. get maxPitch(): number;
  114636. set maxPitch(value: number);
  114637. /**
  114638. * Create a BoneLookController
  114639. * @param mesh the mesh that the bone belongs to
  114640. * @param bone the bone that will be looking to the target
  114641. * @param target the target Vector3 to look at
  114642. * @param options optional settings:
  114643. * * maxYaw: the maximum angle the bone will yaw to
  114644. * * minYaw: the minimum angle the bone will yaw to
  114645. * * maxPitch: the maximum angle the bone will pitch to
  114646. * * minPitch: the minimum angle the bone will yaw to
  114647. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  114648. * * upAxis: the up axis of the coordinate system
  114649. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  114650. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  114651. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  114652. * * adjustYaw: used to make an adjustment to the yaw of the bone
  114653. * * adjustPitch: used to make an adjustment to the pitch of the bone
  114654. * * adjustRoll: used to make an adjustment to the roll of the bone
  114655. **/
  114656. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  114657. maxYaw?: number;
  114658. minYaw?: number;
  114659. maxPitch?: number;
  114660. minPitch?: number;
  114661. slerpAmount?: number;
  114662. upAxis?: Vector3;
  114663. upAxisSpace?: Space;
  114664. yawAxis?: Vector3;
  114665. pitchAxis?: Vector3;
  114666. adjustYaw?: number;
  114667. adjustPitch?: number;
  114668. adjustRoll?: number;
  114669. });
  114670. /**
  114671. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  114672. */
  114673. update(): void;
  114674. private _getAngleDiff;
  114675. private _getAngleBetween;
  114676. private _isAngleBetween;
  114677. }
  114678. }
  114679. declare module BABYLON {
  114680. /**
  114681. * Manage the gamepad inputs to control an arc rotate camera.
  114682. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114683. */
  114684. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  114685. /**
  114686. * Defines the camera the input is attached to.
  114687. */
  114688. camera: ArcRotateCamera;
  114689. /**
  114690. * Defines the gamepad the input is gathering event from.
  114691. */
  114692. gamepad: Nullable<Gamepad>;
  114693. /**
  114694. * Defines the gamepad rotation sensiblity.
  114695. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  114696. */
  114697. gamepadRotationSensibility: number;
  114698. /**
  114699. * Defines the gamepad move sensiblity.
  114700. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  114701. */
  114702. gamepadMoveSensibility: number;
  114703. private _yAxisScale;
  114704. /**
  114705. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  114706. */
  114707. get invertYAxis(): boolean;
  114708. set invertYAxis(value: boolean);
  114709. private _onGamepadConnectedObserver;
  114710. private _onGamepadDisconnectedObserver;
  114711. /**
  114712. * Attach the input controls to a specific dom element to get the input from.
  114713. * @param element Defines the element the controls should be listened from
  114714. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114715. */
  114716. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114717. /**
  114718. * Detach the current controls from the specified dom element.
  114719. * @param element Defines the element to stop listening the inputs from
  114720. */
  114721. detachControl(element: Nullable<HTMLElement>): void;
  114722. /**
  114723. * Update the current camera state depending on the inputs that have been used this frame.
  114724. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114725. */
  114726. checkInputs(): void;
  114727. /**
  114728. * Gets the class name of the current intput.
  114729. * @returns the class name
  114730. */
  114731. getClassName(): string;
  114732. /**
  114733. * Get the friendly name associated with the input class.
  114734. * @returns the input friendly name
  114735. */
  114736. getSimpleName(): string;
  114737. }
  114738. }
  114739. declare module BABYLON {
  114740. interface ArcRotateCameraInputsManager {
  114741. /**
  114742. * Add orientation input support to the input manager.
  114743. * @returns the current input manager
  114744. */
  114745. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  114746. }
  114747. /**
  114748. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  114749. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114750. */
  114751. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  114752. /**
  114753. * Defines the camera the input is attached to.
  114754. */
  114755. camera: ArcRotateCamera;
  114756. /**
  114757. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  114758. */
  114759. alphaCorrection: number;
  114760. /**
  114761. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  114762. */
  114763. gammaCorrection: number;
  114764. private _alpha;
  114765. private _gamma;
  114766. private _dirty;
  114767. private _deviceOrientationHandler;
  114768. /**
  114769. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  114770. */
  114771. constructor();
  114772. /**
  114773. * Attach the input controls to a specific dom element to get the input from.
  114774. * @param element Defines the element the controls should be listened from
  114775. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114776. */
  114777. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114778. /** @hidden */
  114779. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  114780. /**
  114781. * Update the current camera state depending on the inputs that have been used this frame.
  114782. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114783. */
  114784. checkInputs(): void;
  114785. /**
  114786. * Detach the current controls from the specified dom element.
  114787. * @param element Defines the element to stop listening the inputs from
  114788. */
  114789. detachControl(element: Nullable<HTMLElement>): void;
  114790. /**
  114791. * Gets the class name of the current intput.
  114792. * @returns the class name
  114793. */
  114794. getClassName(): string;
  114795. /**
  114796. * Get the friendly name associated with the input class.
  114797. * @returns the input friendly name
  114798. */
  114799. getSimpleName(): string;
  114800. }
  114801. }
  114802. declare module BABYLON {
  114803. /**
  114804. * Listen to mouse events to control the camera.
  114805. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114806. */
  114807. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  114808. /**
  114809. * Defines the camera the input is attached to.
  114810. */
  114811. camera: FlyCamera;
  114812. /**
  114813. * Defines if touch is enabled. (Default is true.)
  114814. */
  114815. touchEnabled: boolean;
  114816. /**
  114817. * Defines the buttons associated with the input to handle camera rotation.
  114818. */
  114819. buttons: number[];
  114820. /**
  114821. * Assign buttons for Yaw control.
  114822. */
  114823. buttonsYaw: number[];
  114824. /**
  114825. * Assign buttons for Pitch control.
  114826. */
  114827. buttonsPitch: number[];
  114828. /**
  114829. * Assign buttons for Roll control.
  114830. */
  114831. buttonsRoll: number[];
  114832. /**
  114833. * Detect if any button is being pressed while mouse is moved.
  114834. * -1 = Mouse locked.
  114835. * 0 = Left button.
  114836. * 1 = Middle Button.
  114837. * 2 = Right Button.
  114838. */
  114839. activeButton: number;
  114840. /**
  114841. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  114842. * Higher values reduce its sensitivity.
  114843. */
  114844. angularSensibility: number;
  114845. private _mousemoveCallback;
  114846. private _observer;
  114847. private _rollObserver;
  114848. private previousPosition;
  114849. private noPreventDefault;
  114850. private element;
  114851. /**
  114852. * Listen to mouse events to control the camera.
  114853. * @param touchEnabled Define if touch is enabled. (Default is true.)
  114854. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114855. */
  114856. constructor(touchEnabled?: boolean);
  114857. /**
  114858. * Attach the mouse control to the HTML DOM element.
  114859. * @param element Defines the element that listens to the input events.
  114860. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  114861. */
  114862. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114863. /**
  114864. * Detach the current controls from the specified dom element.
  114865. * @param element Defines the element to stop listening the inputs from
  114866. */
  114867. detachControl(element: Nullable<HTMLElement>): void;
  114868. /**
  114869. * Gets the class name of the current input.
  114870. * @returns the class name.
  114871. */
  114872. getClassName(): string;
  114873. /**
  114874. * Get the friendly name associated with the input class.
  114875. * @returns the input's friendly name.
  114876. */
  114877. getSimpleName(): string;
  114878. private _pointerInput;
  114879. private _onMouseMove;
  114880. /**
  114881. * Rotate camera by mouse offset.
  114882. */
  114883. private rotateCamera;
  114884. }
  114885. }
  114886. declare module BABYLON {
  114887. /**
  114888. * Default Inputs manager for the FlyCamera.
  114889. * It groups all the default supported inputs for ease of use.
  114890. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114891. */
  114892. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  114893. /**
  114894. * Instantiates a new FlyCameraInputsManager.
  114895. * @param camera Defines the camera the inputs belong to.
  114896. */
  114897. constructor(camera: FlyCamera);
  114898. /**
  114899. * Add keyboard input support to the input manager.
  114900. * @returns the new FlyCameraKeyboardMoveInput().
  114901. */
  114902. addKeyboard(): FlyCameraInputsManager;
  114903. /**
  114904. * Add mouse input support to the input manager.
  114905. * @param touchEnabled Enable touch screen support.
  114906. * @returns the new FlyCameraMouseInput().
  114907. */
  114908. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  114909. }
  114910. }
  114911. declare module BABYLON {
  114912. /**
  114913. * This is a flying camera, designed for 3D movement and rotation in all directions,
  114914. * such as in a 3D Space Shooter or a Flight Simulator.
  114915. */
  114916. export class FlyCamera extends TargetCamera {
  114917. /**
  114918. * Define the collision ellipsoid of the camera.
  114919. * This is helpful for simulating a camera body, like a player's body.
  114920. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  114921. */
  114922. ellipsoid: Vector3;
  114923. /**
  114924. * Define an offset for the position of the ellipsoid around the camera.
  114925. * This can be helpful if the camera is attached away from the player's body center,
  114926. * such as at its head.
  114927. */
  114928. ellipsoidOffset: Vector3;
  114929. /**
  114930. * Enable or disable collisions of the camera with the rest of the scene objects.
  114931. */
  114932. checkCollisions: boolean;
  114933. /**
  114934. * Enable or disable gravity on the camera.
  114935. */
  114936. applyGravity: boolean;
  114937. /**
  114938. * Define the current direction the camera is moving to.
  114939. */
  114940. cameraDirection: Vector3;
  114941. /**
  114942. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  114943. * This overrides and empties cameraRotation.
  114944. */
  114945. rotationQuaternion: Quaternion;
  114946. /**
  114947. * Track Roll to maintain the wanted Rolling when looking around.
  114948. */
  114949. _trackRoll: number;
  114950. /**
  114951. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  114952. */
  114953. rollCorrect: number;
  114954. /**
  114955. * Mimic a banked turn, Rolling the camera when Yawing.
  114956. * It's recommended to use rollCorrect = 10 for faster banking correction.
  114957. */
  114958. bankedTurn: boolean;
  114959. /**
  114960. * Limit in radians for how much Roll banking will add. (Default: 90°)
  114961. */
  114962. bankedTurnLimit: number;
  114963. /**
  114964. * Value of 0 disables the banked Roll.
  114965. * Value of 1 is equal to the Yaw angle in radians.
  114966. */
  114967. bankedTurnMultiplier: number;
  114968. /**
  114969. * The inputs manager loads all the input sources, such as keyboard and mouse.
  114970. */
  114971. inputs: FlyCameraInputsManager;
  114972. /**
  114973. * Gets the input sensibility for mouse input.
  114974. * Higher values reduce sensitivity.
  114975. */
  114976. get angularSensibility(): number;
  114977. /**
  114978. * Sets the input sensibility for a mouse input.
  114979. * Higher values reduce sensitivity.
  114980. */
  114981. set angularSensibility(value: number);
  114982. /**
  114983. * Get the keys for camera movement forward.
  114984. */
  114985. get keysForward(): number[];
  114986. /**
  114987. * Set the keys for camera movement forward.
  114988. */
  114989. set keysForward(value: number[]);
  114990. /**
  114991. * Get the keys for camera movement backward.
  114992. */
  114993. get keysBackward(): number[];
  114994. set keysBackward(value: number[]);
  114995. /**
  114996. * Get the keys for camera movement up.
  114997. */
  114998. get keysUp(): number[];
  114999. /**
  115000. * Set the keys for camera movement up.
  115001. */
  115002. set keysUp(value: number[]);
  115003. /**
  115004. * Get the keys for camera movement down.
  115005. */
  115006. get keysDown(): number[];
  115007. /**
  115008. * Set the keys for camera movement down.
  115009. */
  115010. set keysDown(value: number[]);
  115011. /**
  115012. * Get the keys for camera movement left.
  115013. */
  115014. get keysLeft(): number[];
  115015. /**
  115016. * Set the keys for camera movement left.
  115017. */
  115018. set keysLeft(value: number[]);
  115019. /**
  115020. * Set the keys for camera movement right.
  115021. */
  115022. get keysRight(): number[];
  115023. /**
  115024. * Set the keys for camera movement right.
  115025. */
  115026. set keysRight(value: number[]);
  115027. /**
  115028. * Event raised when the camera collides with a mesh in the scene.
  115029. */
  115030. onCollide: (collidedMesh: AbstractMesh) => void;
  115031. private _collider;
  115032. private _needMoveForGravity;
  115033. private _oldPosition;
  115034. private _diffPosition;
  115035. private _newPosition;
  115036. /** @hidden */
  115037. _localDirection: Vector3;
  115038. /** @hidden */
  115039. _transformedDirection: Vector3;
  115040. /**
  115041. * Instantiates a FlyCamera.
  115042. * This is a flying camera, designed for 3D movement and rotation in all directions,
  115043. * such as in a 3D Space Shooter or a Flight Simulator.
  115044. * @param name Define the name of the camera in the scene.
  115045. * @param position Define the starting position of the camera in the scene.
  115046. * @param scene Define the scene the camera belongs to.
  115047. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  115048. */
  115049. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  115050. /**
  115051. * Attach a control to the HTML DOM element.
  115052. * @param element Defines the element that listens to the input events.
  115053. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  115054. */
  115055. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115056. /**
  115057. * Detach a control from the HTML DOM element.
  115058. * The camera will stop reacting to that input.
  115059. * @param element Defines the element that listens to the input events.
  115060. */
  115061. detachControl(element: HTMLElement): void;
  115062. private _collisionMask;
  115063. /**
  115064. * Get the mask that the camera ignores in collision events.
  115065. */
  115066. get collisionMask(): number;
  115067. /**
  115068. * Set the mask that the camera ignores in collision events.
  115069. */
  115070. set collisionMask(mask: number);
  115071. /** @hidden */
  115072. _collideWithWorld(displacement: Vector3): void;
  115073. /** @hidden */
  115074. private _onCollisionPositionChange;
  115075. /** @hidden */
  115076. _checkInputs(): void;
  115077. /** @hidden */
  115078. _decideIfNeedsToMove(): boolean;
  115079. /** @hidden */
  115080. _updatePosition(): void;
  115081. /**
  115082. * Restore the Roll to its target value at the rate specified.
  115083. * @param rate - Higher means slower restoring.
  115084. * @hidden
  115085. */
  115086. restoreRoll(rate: number): void;
  115087. /**
  115088. * Destroy the camera and release the current resources held by it.
  115089. */
  115090. dispose(): void;
  115091. /**
  115092. * Get the current object class name.
  115093. * @returns the class name.
  115094. */
  115095. getClassName(): string;
  115096. }
  115097. }
  115098. declare module BABYLON {
  115099. /**
  115100. * Listen to keyboard events to control the camera.
  115101. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115102. */
  115103. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  115104. /**
  115105. * Defines the camera the input is attached to.
  115106. */
  115107. camera: FlyCamera;
  115108. /**
  115109. * The list of keyboard keys used to control the forward move of the camera.
  115110. */
  115111. keysForward: number[];
  115112. /**
  115113. * The list of keyboard keys used to control the backward move of the camera.
  115114. */
  115115. keysBackward: number[];
  115116. /**
  115117. * The list of keyboard keys used to control the forward move of the camera.
  115118. */
  115119. keysUp: number[];
  115120. /**
  115121. * The list of keyboard keys used to control the backward move of the camera.
  115122. */
  115123. keysDown: number[];
  115124. /**
  115125. * The list of keyboard keys used to control the right strafe move of the camera.
  115126. */
  115127. keysRight: number[];
  115128. /**
  115129. * The list of keyboard keys used to control the left strafe move of the camera.
  115130. */
  115131. keysLeft: number[];
  115132. private _keys;
  115133. private _onCanvasBlurObserver;
  115134. private _onKeyboardObserver;
  115135. private _engine;
  115136. private _scene;
  115137. /**
  115138. * Attach the input controls to a specific dom element to get the input from.
  115139. * @param element Defines the element the controls should be listened from
  115140. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115141. */
  115142. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115143. /**
  115144. * Detach the current controls from the specified dom element.
  115145. * @param element Defines the element to stop listening the inputs from
  115146. */
  115147. detachControl(element: Nullable<HTMLElement>): void;
  115148. /**
  115149. * Gets the class name of the current intput.
  115150. * @returns the class name
  115151. */
  115152. getClassName(): string;
  115153. /** @hidden */
  115154. _onLostFocus(e: FocusEvent): void;
  115155. /**
  115156. * Get the friendly name associated with the input class.
  115157. * @returns the input friendly name
  115158. */
  115159. getSimpleName(): string;
  115160. /**
  115161. * Update the current camera state depending on the inputs that have been used this frame.
  115162. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115163. */
  115164. checkInputs(): void;
  115165. }
  115166. }
  115167. declare module BABYLON {
  115168. /**
  115169. * Manage the mouse wheel inputs to control a follow camera.
  115170. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115171. */
  115172. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  115173. /**
  115174. * Defines the camera the input is attached to.
  115175. */
  115176. camera: FollowCamera;
  115177. /**
  115178. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  115179. */
  115180. axisControlRadius: boolean;
  115181. /**
  115182. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  115183. */
  115184. axisControlHeight: boolean;
  115185. /**
  115186. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  115187. */
  115188. axisControlRotation: boolean;
  115189. /**
  115190. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  115191. * relation to mouseWheel events.
  115192. */
  115193. wheelPrecision: number;
  115194. /**
  115195. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  115196. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  115197. */
  115198. wheelDeltaPercentage: number;
  115199. private _wheel;
  115200. private _observer;
  115201. /**
  115202. * Attach the input controls to a specific dom element to get the input from.
  115203. * @param element Defines the element the controls should be listened from
  115204. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115205. */
  115206. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115207. /**
  115208. * Detach the current controls from the specified dom element.
  115209. * @param element Defines the element to stop listening the inputs from
  115210. */
  115211. detachControl(element: Nullable<HTMLElement>): void;
  115212. /**
  115213. * Gets the class name of the current intput.
  115214. * @returns the class name
  115215. */
  115216. getClassName(): string;
  115217. /**
  115218. * Get the friendly name associated with the input class.
  115219. * @returns the input friendly name
  115220. */
  115221. getSimpleName(): string;
  115222. }
  115223. }
  115224. declare module BABYLON {
  115225. /**
  115226. * Manage the pointers inputs to control an follow camera.
  115227. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115228. */
  115229. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  115230. /**
  115231. * Defines the camera the input is attached to.
  115232. */
  115233. camera: FollowCamera;
  115234. /**
  115235. * Gets the class name of the current input.
  115236. * @returns the class name
  115237. */
  115238. getClassName(): string;
  115239. /**
  115240. * Defines the pointer angular sensibility along the X axis or how fast is
  115241. * the camera rotating.
  115242. * A negative number will reverse the axis direction.
  115243. */
  115244. angularSensibilityX: number;
  115245. /**
  115246. * Defines the pointer angular sensibility along the Y axis or how fast is
  115247. * the camera rotating.
  115248. * A negative number will reverse the axis direction.
  115249. */
  115250. angularSensibilityY: number;
  115251. /**
  115252. * Defines the pointer pinch precision or how fast is the camera zooming.
  115253. * A negative number will reverse the axis direction.
  115254. */
  115255. pinchPrecision: number;
  115256. /**
  115257. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  115258. * from 0.
  115259. * It defines the percentage of current camera.radius to use as delta when
  115260. * pinch zoom is used.
  115261. */
  115262. pinchDeltaPercentage: number;
  115263. /**
  115264. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  115265. */
  115266. axisXControlRadius: boolean;
  115267. /**
  115268. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  115269. */
  115270. axisXControlHeight: boolean;
  115271. /**
  115272. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  115273. */
  115274. axisXControlRotation: boolean;
  115275. /**
  115276. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  115277. */
  115278. axisYControlRadius: boolean;
  115279. /**
  115280. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  115281. */
  115282. axisYControlHeight: boolean;
  115283. /**
  115284. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  115285. */
  115286. axisYControlRotation: boolean;
  115287. /**
  115288. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  115289. */
  115290. axisPinchControlRadius: boolean;
  115291. /**
  115292. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  115293. */
  115294. axisPinchControlHeight: boolean;
  115295. /**
  115296. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  115297. */
  115298. axisPinchControlRotation: boolean;
  115299. /**
  115300. * Log error messages if basic misconfiguration has occurred.
  115301. */
  115302. warningEnable: boolean;
  115303. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  115304. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  115305. private _warningCounter;
  115306. private _warning;
  115307. }
  115308. }
  115309. declare module BABYLON {
  115310. /**
  115311. * Default Inputs manager for the FollowCamera.
  115312. * It groups all the default supported inputs for ease of use.
  115313. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115314. */
  115315. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  115316. /**
  115317. * Instantiates a new FollowCameraInputsManager.
  115318. * @param camera Defines the camera the inputs belong to
  115319. */
  115320. constructor(camera: FollowCamera);
  115321. /**
  115322. * Add keyboard input support to the input manager.
  115323. * @returns the current input manager
  115324. */
  115325. addKeyboard(): FollowCameraInputsManager;
  115326. /**
  115327. * Add mouse wheel input support to the input manager.
  115328. * @returns the current input manager
  115329. */
  115330. addMouseWheel(): FollowCameraInputsManager;
  115331. /**
  115332. * Add pointers input support to the input manager.
  115333. * @returns the current input manager
  115334. */
  115335. addPointers(): FollowCameraInputsManager;
  115336. /**
  115337. * Add orientation input support to the input manager.
  115338. * @returns the current input manager
  115339. */
  115340. addVRDeviceOrientation(): FollowCameraInputsManager;
  115341. }
  115342. }
  115343. declare module BABYLON {
  115344. /**
  115345. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  115346. * an arc rotate version arcFollowCamera are available.
  115347. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  115348. */
  115349. export class FollowCamera extends TargetCamera {
  115350. /**
  115351. * Distance the follow camera should follow an object at
  115352. */
  115353. radius: number;
  115354. /**
  115355. * Minimum allowed distance of the camera to the axis of rotation
  115356. * (The camera can not get closer).
  115357. * This can help limiting how the Camera is able to move in the scene.
  115358. */
  115359. lowerRadiusLimit: Nullable<number>;
  115360. /**
  115361. * Maximum allowed distance of the camera to the axis of rotation
  115362. * (The camera can not get further).
  115363. * This can help limiting how the Camera is able to move in the scene.
  115364. */
  115365. upperRadiusLimit: Nullable<number>;
  115366. /**
  115367. * Define a rotation offset between the camera and the object it follows
  115368. */
  115369. rotationOffset: number;
  115370. /**
  115371. * Minimum allowed angle to camera position relative to target object.
  115372. * This can help limiting how the Camera is able to move in the scene.
  115373. */
  115374. lowerRotationOffsetLimit: Nullable<number>;
  115375. /**
  115376. * Maximum allowed angle to camera position relative to target object.
  115377. * This can help limiting how the Camera is able to move in the scene.
  115378. */
  115379. upperRotationOffsetLimit: Nullable<number>;
  115380. /**
  115381. * Define a height offset between the camera and the object it follows.
  115382. * It can help following an object from the top (like a car chaing a plane)
  115383. */
  115384. heightOffset: number;
  115385. /**
  115386. * Minimum allowed height of camera position relative to target object.
  115387. * This can help limiting how the Camera is able to move in the scene.
  115388. */
  115389. lowerHeightOffsetLimit: Nullable<number>;
  115390. /**
  115391. * Maximum allowed height of camera position relative to target object.
  115392. * This can help limiting how the Camera is able to move in the scene.
  115393. */
  115394. upperHeightOffsetLimit: Nullable<number>;
  115395. /**
  115396. * Define how fast the camera can accelerate to follow it s target.
  115397. */
  115398. cameraAcceleration: number;
  115399. /**
  115400. * Define the speed limit of the camera following an object.
  115401. */
  115402. maxCameraSpeed: number;
  115403. /**
  115404. * Define the target of the camera.
  115405. */
  115406. lockedTarget: Nullable<AbstractMesh>;
  115407. /**
  115408. * Defines the input associated with the camera.
  115409. */
  115410. inputs: FollowCameraInputsManager;
  115411. /**
  115412. * Instantiates the follow camera.
  115413. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  115414. * @param name Define the name of the camera in the scene
  115415. * @param position Define the position of the camera
  115416. * @param scene Define the scene the camera belong to
  115417. * @param lockedTarget Define the target of the camera
  115418. */
  115419. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  115420. private _follow;
  115421. /**
  115422. * Attached controls to the current camera.
  115423. * @param element Defines the element the controls should be listened from
  115424. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115425. */
  115426. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115427. /**
  115428. * Detach the current controls from the camera.
  115429. * The camera will stop reacting to inputs.
  115430. * @param element Defines the element to stop listening the inputs from
  115431. */
  115432. detachControl(element: HTMLElement): void;
  115433. /** @hidden */
  115434. _checkInputs(): void;
  115435. private _checkLimits;
  115436. /**
  115437. * Gets the camera class name.
  115438. * @returns the class name
  115439. */
  115440. getClassName(): string;
  115441. }
  115442. /**
  115443. * Arc Rotate version of the follow camera.
  115444. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  115445. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  115446. */
  115447. export class ArcFollowCamera extends TargetCamera {
  115448. /** The longitudinal angle of the camera */
  115449. alpha: number;
  115450. /** The latitudinal angle of the camera */
  115451. beta: number;
  115452. /** The radius of the camera from its target */
  115453. radius: number;
  115454. /** Define the camera target (the messh it should follow) */
  115455. target: Nullable<AbstractMesh>;
  115456. private _cartesianCoordinates;
  115457. /**
  115458. * Instantiates a new ArcFollowCamera
  115459. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  115460. * @param name Define the name of the camera
  115461. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  115462. * @param beta Define the rotation angle of the camera around the elevation axis
  115463. * @param radius Define the radius of the camera from its target point
  115464. * @param target Define the target of the camera
  115465. * @param scene Define the scene the camera belongs to
  115466. */
  115467. constructor(name: string,
  115468. /** The longitudinal angle of the camera */
  115469. alpha: number,
  115470. /** The latitudinal angle of the camera */
  115471. beta: number,
  115472. /** The radius of the camera from its target */
  115473. radius: number,
  115474. /** Define the camera target (the messh it should follow) */
  115475. target: Nullable<AbstractMesh>, scene: Scene);
  115476. private _follow;
  115477. /** @hidden */
  115478. _checkInputs(): void;
  115479. /**
  115480. * Returns the class name of the object.
  115481. * It is mostly used internally for serialization purposes.
  115482. */
  115483. getClassName(): string;
  115484. }
  115485. }
  115486. declare module BABYLON {
  115487. /**
  115488. * Manage the keyboard inputs to control the movement of a follow camera.
  115489. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115490. */
  115491. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  115492. /**
  115493. * Defines the camera the input is attached to.
  115494. */
  115495. camera: FollowCamera;
  115496. /**
  115497. * Defines the list of key codes associated with the up action (increase heightOffset)
  115498. */
  115499. keysHeightOffsetIncr: number[];
  115500. /**
  115501. * Defines the list of key codes associated with the down action (decrease heightOffset)
  115502. */
  115503. keysHeightOffsetDecr: number[];
  115504. /**
  115505. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  115506. */
  115507. keysHeightOffsetModifierAlt: boolean;
  115508. /**
  115509. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  115510. */
  115511. keysHeightOffsetModifierCtrl: boolean;
  115512. /**
  115513. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  115514. */
  115515. keysHeightOffsetModifierShift: boolean;
  115516. /**
  115517. * Defines the list of key codes associated with the left action (increase rotationOffset)
  115518. */
  115519. keysRotationOffsetIncr: number[];
  115520. /**
  115521. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  115522. */
  115523. keysRotationOffsetDecr: number[];
  115524. /**
  115525. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  115526. */
  115527. keysRotationOffsetModifierAlt: boolean;
  115528. /**
  115529. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  115530. */
  115531. keysRotationOffsetModifierCtrl: boolean;
  115532. /**
  115533. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  115534. */
  115535. keysRotationOffsetModifierShift: boolean;
  115536. /**
  115537. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  115538. */
  115539. keysRadiusIncr: number[];
  115540. /**
  115541. * Defines the list of key codes associated with the zoom-out action (increase radius)
  115542. */
  115543. keysRadiusDecr: number[];
  115544. /**
  115545. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  115546. */
  115547. keysRadiusModifierAlt: boolean;
  115548. /**
  115549. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  115550. */
  115551. keysRadiusModifierCtrl: boolean;
  115552. /**
  115553. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  115554. */
  115555. keysRadiusModifierShift: boolean;
  115556. /**
  115557. * Defines the rate of change of heightOffset.
  115558. */
  115559. heightSensibility: number;
  115560. /**
  115561. * Defines the rate of change of rotationOffset.
  115562. */
  115563. rotationSensibility: number;
  115564. /**
  115565. * Defines the rate of change of radius.
  115566. */
  115567. radiusSensibility: number;
  115568. private _keys;
  115569. private _ctrlPressed;
  115570. private _altPressed;
  115571. private _shiftPressed;
  115572. private _onCanvasBlurObserver;
  115573. private _onKeyboardObserver;
  115574. private _engine;
  115575. private _scene;
  115576. /**
  115577. * Attach the input controls to a specific dom element to get the input from.
  115578. * @param element Defines the element the controls should be listened from
  115579. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115580. */
  115581. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115582. /**
  115583. * Detach the current controls from the specified dom element.
  115584. * @param element Defines the element to stop listening the inputs from
  115585. */
  115586. detachControl(element: Nullable<HTMLElement>): void;
  115587. /**
  115588. * Update the current camera state depending on the inputs that have been used this frame.
  115589. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115590. */
  115591. checkInputs(): void;
  115592. /**
  115593. * Gets the class name of the current input.
  115594. * @returns the class name
  115595. */
  115596. getClassName(): string;
  115597. /**
  115598. * Get the friendly name associated with the input class.
  115599. * @returns the input friendly name
  115600. */
  115601. getSimpleName(): string;
  115602. /**
  115603. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  115604. * allow modification of the heightOffset value.
  115605. */
  115606. private _modifierHeightOffset;
  115607. /**
  115608. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  115609. * allow modification of the rotationOffset value.
  115610. */
  115611. private _modifierRotationOffset;
  115612. /**
  115613. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  115614. * allow modification of the radius value.
  115615. */
  115616. private _modifierRadius;
  115617. }
  115618. }
  115619. declare module BABYLON {
  115620. interface FreeCameraInputsManager {
  115621. /**
  115622. * @hidden
  115623. */
  115624. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  115625. /**
  115626. * Add orientation input support to the input manager.
  115627. * @returns the current input manager
  115628. */
  115629. addDeviceOrientation(): FreeCameraInputsManager;
  115630. }
  115631. /**
  115632. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  115633. * Screen rotation is taken into account.
  115634. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115635. */
  115636. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  115637. private _camera;
  115638. private _screenOrientationAngle;
  115639. private _constantTranform;
  115640. private _screenQuaternion;
  115641. private _alpha;
  115642. private _beta;
  115643. private _gamma;
  115644. /**
  115645. * Can be used to detect if a device orientation sensor is available on a device
  115646. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  115647. * @returns a promise that will resolve on orientation change
  115648. */
  115649. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  115650. /**
  115651. * @hidden
  115652. */
  115653. _onDeviceOrientationChangedObservable: Observable<void>;
  115654. /**
  115655. * Instantiates a new input
  115656. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115657. */
  115658. constructor();
  115659. /**
  115660. * Define the camera controlled by the input.
  115661. */
  115662. get camera(): FreeCamera;
  115663. set camera(camera: FreeCamera);
  115664. /**
  115665. * Attach the input controls to a specific dom element to get the input from.
  115666. * @param element Defines the element the controls should be listened from
  115667. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115668. */
  115669. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115670. private _orientationChanged;
  115671. private _deviceOrientation;
  115672. /**
  115673. * Detach the current controls from the specified dom element.
  115674. * @param element Defines the element to stop listening the inputs from
  115675. */
  115676. detachControl(element: Nullable<HTMLElement>): void;
  115677. /**
  115678. * Update the current camera state depending on the inputs that have been used this frame.
  115679. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115680. */
  115681. checkInputs(): void;
  115682. /**
  115683. * Gets the class name of the current intput.
  115684. * @returns the class name
  115685. */
  115686. getClassName(): string;
  115687. /**
  115688. * Get the friendly name associated with the input class.
  115689. * @returns the input friendly name
  115690. */
  115691. getSimpleName(): string;
  115692. }
  115693. }
  115694. declare module BABYLON {
  115695. /**
  115696. * Manage the gamepad inputs to control a free camera.
  115697. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115698. */
  115699. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  115700. /**
  115701. * Define the camera the input is attached to.
  115702. */
  115703. camera: FreeCamera;
  115704. /**
  115705. * Define the Gamepad controlling the input
  115706. */
  115707. gamepad: Nullable<Gamepad>;
  115708. /**
  115709. * Defines the gamepad rotation sensiblity.
  115710. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  115711. */
  115712. gamepadAngularSensibility: number;
  115713. /**
  115714. * Defines the gamepad move sensiblity.
  115715. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  115716. */
  115717. gamepadMoveSensibility: number;
  115718. private _yAxisScale;
  115719. /**
  115720. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  115721. */
  115722. get invertYAxis(): boolean;
  115723. set invertYAxis(value: boolean);
  115724. private _onGamepadConnectedObserver;
  115725. private _onGamepadDisconnectedObserver;
  115726. private _cameraTransform;
  115727. private _deltaTransform;
  115728. private _vector3;
  115729. private _vector2;
  115730. /**
  115731. * Attach the input controls to a specific dom element to get the input from.
  115732. * @param element Defines the element the controls should be listened from
  115733. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115734. */
  115735. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115736. /**
  115737. * Detach the current controls from the specified dom element.
  115738. * @param element Defines the element to stop listening the inputs from
  115739. */
  115740. detachControl(element: Nullable<HTMLElement>): void;
  115741. /**
  115742. * Update the current camera state depending on the inputs that have been used this frame.
  115743. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115744. */
  115745. checkInputs(): void;
  115746. /**
  115747. * Gets the class name of the current intput.
  115748. * @returns the class name
  115749. */
  115750. getClassName(): string;
  115751. /**
  115752. * Get the friendly name associated with the input class.
  115753. * @returns the input friendly name
  115754. */
  115755. getSimpleName(): string;
  115756. }
  115757. }
  115758. declare module BABYLON {
  115759. /**
  115760. * Defines the potential axis of a Joystick
  115761. */
  115762. export enum JoystickAxis {
  115763. /** X axis */
  115764. X = 0,
  115765. /** Y axis */
  115766. Y = 1,
  115767. /** Z axis */
  115768. Z = 2
  115769. }
  115770. /**
  115771. * Class used to define virtual joystick (used in touch mode)
  115772. */
  115773. export class VirtualJoystick {
  115774. /**
  115775. * Gets or sets a boolean indicating that left and right values must be inverted
  115776. */
  115777. reverseLeftRight: boolean;
  115778. /**
  115779. * Gets or sets a boolean indicating that up and down values must be inverted
  115780. */
  115781. reverseUpDown: boolean;
  115782. /**
  115783. * Gets the offset value for the position (ie. the change of the position value)
  115784. */
  115785. deltaPosition: Vector3;
  115786. /**
  115787. * Gets a boolean indicating if the virtual joystick was pressed
  115788. */
  115789. pressed: boolean;
  115790. /**
  115791. * Canvas the virtual joystick will render onto, default z-index of this is 5
  115792. */
  115793. static Canvas: Nullable<HTMLCanvasElement>;
  115794. private static _globalJoystickIndex;
  115795. private static vjCanvasContext;
  115796. private static vjCanvasWidth;
  115797. private static vjCanvasHeight;
  115798. private static halfWidth;
  115799. private _action;
  115800. private _axisTargetedByLeftAndRight;
  115801. private _axisTargetedByUpAndDown;
  115802. private _joystickSensibility;
  115803. private _inversedSensibility;
  115804. private _joystickPointerID;
  115805. private _joystickColor;
  115806. private _joystickPointerPos;
  115807. private _joystickPreviousPointerPos;
  115808. private _joystickPointerStartPos;
  115809. private _deltaJoystickVector;
  115810. private _leftJoystick;
  115811. private _touches;
  115812. private _onPointerDownHandlerRef;
  115813. private _onPointerMoveHandlerRef;
  115814. private _onPointerUpHandlerRef;
  115815. private _onResize;
  115816. /**
  115817. * Creates a new virtual joystick
  115818. * @param leftJoystick defines that the joystick is for left hand (false by default)
  115819. */
  115820. constructor(leftJoystick?: boolean);
  115821. /**
  115822. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  115823. * @param newJoystickSensibility defines the new sensibility
  115824. */
  115825. setJoystickSensibility(newJoystickSensibility: number): void;
  115826. private _onPointerDown;
  115827. private _onPointerMove;
  115828. private _onPointerUp;
  115829. /**
  115830. * Change the color of the virtual joystick
  115831. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  115832. */
  115833. setJoystickColor(newColor: string): void;
  115834. /**
  115835. * Defines a callback to call when the joystick is touched
  115836. * @param action defines the callback
  115837. */
  115838. setActionOnTouch(action: () => any): void;
  115839. /**
  115840. * Defines which axis you'd like to control for left & right
  115841. * @param axis defines the axis to use
  115842. */
  115843. setAxisForLeftRight(axis: JoystickAxis): void;
  115844. /**
  115845. * Defines which axis you'd like to control for up & down
  115846. * @param axis defines the axis to use
  115847. */
  115848. setAxisForUpDown(axis: JoystickAxis): void;
  115849. private _drawVirtualJoystick;
  115850. /**
  115851. * Release internal HTML canvas
  115852. */
  115853. releaseCanvas(): void;
  115854. }
  115855. }
  115856. declare module BABYLON {
  115857. interface FreeCameraInputsManager {
  115858. /**
  115859. * Add virtual joystick input support to the input manager.
  115860. * @returns the current input manager
  115861. */
  115862. addVirtualJoystick(): FreeCameraInputsManager;
  115863. }
  115864. /**
  115865. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  115866. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115867. */
  115868. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  115869. /**
  115870. * Defines the camera the input is attached to.
  115871. */
  115872. camera: FreeCamera;
  115873. private _leftjoystick;
  115874. private _rightjoystick;
  115875. /**
  115876. * Gets the left stick of the virtual joystick.
  115877. * @returns The virtual Joystick
  115878. */
  115879. getLeftJoystick(): VirtualJoystick;
  115880. /**
  115881. * Gets the right stick of the virtual joystick.
  115882. * @returns The virtual Joystick
  115883. */
  115884. getRightJoystick(): VirtualJoystick;
  115885. /**
  115886. * Update the current camera state depending on the inputs that have been used this frame.
  115887. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115888. */
  115889. checkInputs(): void;
  115890. /**
  115891. * Attach the input controls to a specific dom element to get the input from.
  115892. * @param element Defines the element the controls should be listened from
  115893. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115894. */
  115895. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115896. /**
  115897. * Detach the current controls from the specified dom element.
  115898. * @param element Defines the element to stop listening the inputs from
  115899. */
  115900. detachControl(element: Nullable<HTMLElement>): void;
  115901. /**
  115902. * Gets the class name of the current intput.
  115903. * @returns the class name
  115904. */
  115905. getClassName(): string;
  115906. /**
  115907. * Get the friendly name associated with the input class.
  115908. * @returns the input friendly name
  115909. */
  115910. getSimpleName(): string;
  115911. }
  115912. }
  115913. declare module BABYLON {
  115914. /**
  115915. * This represents a FPS type of camera controlled by touch.
  115916. * This is like a universal camera minus the Gamepad controls.
  115917. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115918. */
  115919. export class TouchCamera extends FreeCamera {
  115920. /**
  115921. * Defines the touch sensibility for rotation.
  115922. * The higher the faster.
  115923. */
  115924. get touchAngularSensibility(): number;
  115925. set touchAngularSensibility(value: number);
  115926. /**
  115927. * Defines the touch sensibility for move.
  115928. * The higher the faster.
  115929. */
  115930. get touchMoveSensibility(): number;
  115931. set touchMoveSensibility(value: number);
  115932. /**
  115933. * Instantiates a new touch camera.
  115934. * This represents a FPS type of camera controlled by touch.
  115935. * This is like a universal camera minus the Gamepad controls.
  115936. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115937. * @param name Define the name of the camera in the scene
  115938. * @param position Define the start position of the camera in the scene
  115939. * @param scene Define the scene the camera belongs to
  115940. */
  115941. constructor(name: string, position: Vector3, scene: Scene);
  115942. /**
  115943. * Gets the current object class name.
  115944. * @return the class name
  115945. */
  115946. getClassName(): string;
  115947. /** @hidden */
  115948. _setupInputs(): void;
  115949. }
  115950. }
  115951. declare module BABYLON {
  115952. /**
  115953. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  115954. * being tilted forward or back and left or right.
  115955. */
  115956. export class DeviceOrientationCamera extends FreeCamera {
  115957. private _initialQuaternion;
  115958. private _quaternionCache;
  115959. private _tmpDragQuaternion;
  115960. private _disablePointerInputWhenUsingDeviceOrientation;
  115961. /**
  115962. * Creates a new device orientation camera
  115963. * @param name The name of the camera
  115964. * @param position The start position camera
  115965. * @param scene The scene the camera belongs to
  115966. */
  115967. constructor(name: string, position: Vector3, scene: Scene);
  115968. /**
  115969. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  115970. */
  115971. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  115972. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  115973. private _dragFactor;
  115974. /**
  115975. * Enabled turning on the y axis when the orientation sensor is active
  115976. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  115977. */
  115978. enableHorizontalDragging(dragFactor?: number): void;
  115979. /**
  115980. * Gets the current instance class name ("DeviceOrientationCamera").
  115981. * This helps avoiding instanceof at run time.
  115982. * @returns the class name
  115983. */
  115984. getClassName(): string;
  115985. /**
  115986. * @hidden
  115987. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  115988. */
  115989. _checkInputs(): void;
  115990. /**
  115991. * Reset the camera to its default orientation on the specified axis only.
  115992. * @param axis The axis to reset
  115993. */
  115994. resetToCurrentRotation(axis?: Axis): void;
  115995. }
  115996. }
  115997. declare module BABYLON {
  115998. /**
  115999. * Defines supported buttons for XBox360 compatible gamepads
  116000. */
  116001. export enum Xbox360Button {
  116002. /** A */
  116003. A = 0,
  116004. /** B */
  116005. B = 1,
  116006. /** X */
  116007. X = 2,
  116008. /** Y */
  116009. Y = 3,
  116010. /** Left button */
  116011. LB = 4,
  116012. /** Right button */
  116013. RB = 5,
  116014. /** Back */
  116015. Back = 8,
  116016. /** Start */
  116017. Start = 9,
  116018. /** Left stick */
  116019. LeftStick = 10,
  116020. /** Right stick */
  116021. RightStick = 11
  116022. }
  116023. /** Defines values for XBox360 DPad */
  116024. export enum Xbox360Dpad {
  116025. /** Up */
  116026. Up = 12,
  116027. /** Down */
  116028. Down = 13,
  116029. /** Left */
  116030. Left = 14,
  116031. /** Right */
  116032. Right = 15
  116033. }
  116034. /**
  116035. * Defines a XBox360 gamepad
  116036. */
  116037. export class Xbox360Pad extends Gamepad {
  116038. private _leftTrigger;
  116039. private _rightTrigger;
  116040. private _onlefttriggerchanged;
  116041. private _onrighttriggerchanged;
  116042. private _onbuttondown;
  116043. private _onbuttonup;
  116044. private _ondpaddown;
  116045. private _ondpadup;
  116046. /** Observable raised when a button is pressed */
  116047. onButtonDownObservable: Observable<Xbox360Button>;
  116048. /** Observable raised when a button is released */
  116049. onButtonUpObservable: Observable<Xbox360Button>;
  116050. /** Observable raised when a pad is pressed */
  116051. onPadDownObservable: Observable<Xbox360Dpad>;
  116052. /** Observable raised when a pad is released */
  116053. onPadUpObservable: Observable<Xbox360Dpad>;
  116054. private _buttonA;
  116055. private _buttonB;
  116056. private _buttonX;
  116057. private _buttonY;
  116058. private _buttonBack;
  116059. private _buttonStart;
  116060. private _buttonLB;
  116061. private _buttonRB;
  116062. private _buttonLeftStick;
  116063. private _buttonRightStick;
  116064. private _dPadUp;
  116065. private _dPadDown;
  116066. private _dPadLeft;
  116067. private _dPadRight;
  116068. private _isXboxOnePad;
  116069. /**
  116070. * Creates a new XBox360 gamepad object
  116071. * @param id defines the id of this gamepad
  116072. * @param index defines its index
  116073. * @param gamepad defines the internal HTML gamepad object
  116074. * @param xboxOne defines if it is a XBox One gamepad
  116075. */
  116076. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  116077. /**
  116078. * Defines the callback to call when left trigger is pressed
  116079. * @param callback defines the callback to use
  116080. */
  116081. onlefttriggerchanged(callback: (value: number) => void): void;
  116082. /**
  116083. * Defines the callback to call when right trigger is pressed
  116084. * @param callback defines the callback to use
  116085. */
  116086. onrighttriggerchanged(callback: (value: number) => void): void;
  116087. /**
  116088. * Gets the left trigger value
  116089. */
  116090. get leftTrigger(): number;
  116091. /**
  116092. * Sets the left trigger value
  116093. */
  116094. set leftTrigger(newValue: number);
  116095. /**
  116096. * Gets the right trigger value
  116097. */
  116098. get rightTrigger(): number;
  116099. /**
  116100. * Sets the right trigger value
  116101. */
  116102. set rightTrigger(newValue: number);
  116103. /**
  116104. * Defines the callback to call when a button is pressed
  116105. * @param callback defines the callback to use
  116106. */
  116107. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  116108. /**
  116109. * Defines the callback to call when a button is released
  116110. * @param callback defines the callback to use
  116111. */
  116112. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  116113. /**
  116114. * Defines the callback to call when a pad is pressed
  116115. * @param callback defines the callback to use
  116116. */
  116117. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  116118. /**
  116119. * Defines the callback to call when a pad is released
  116120. * @param callback defines the callback to use
  116121. */
  116122. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  116123. private _setButtonValue;
  116124. private _setDPadValue;
  116125. /**
  116126. * Gets the value of the `A` button
  116127. */
  116128. get buttonA(): number;
  116129. /**
  116130. * Sets the value of the `A` button
  116131. */
  116132. set buttonA(value: number);
  116133. /**
  116134. * Gets the value of the `B` button
  116135. */
  116136. get buttonB(): number;
  116137. /**
  116138. * Sets the value of the `B` button
  116139. */
  116140. set buttonB(value: number);
  116141. /**
  116142. * Gets the value of the `X` button
  116143. */
  116144. get buttonX(): number;
  116145. /**
  116146. * Sets the value of the `X` button
  116147. */
  116148. set buttonX(value: number);
  116149. /**
  116150. * Gets the value of the `Y` button
  116151. */
  116152. get buttonY(): number;
  116153. /**
  116154. * Sets the value of the `Y` button
  116155. */
  116156. set buttonY(value: number);
  116157. /**
  116158. * Gets the value of the `Start` button
  116159. */
  116160. get buttonStart(): number;
  116161. /**
  116162. * Sets the value of the `Start` button
  116163. */
  116164. set buttonStart(value: number);
  116165. /**
  116166. * Gets the value of the `Back` button
  116167. */
  116168. get buttonBack(): number;
  116169. /**
  116170. * Sets the value of the `Back` button
  116171. */
  116172. set buttonBack(value: number);
  116173. /**
  116174. * Gets the value of the `Left` button
  116175. */
  116176. get buttonLB(): number;
  116177. /**
  116178. * Sets the value of the `Left` button
  116179. */
  116180. set buttonLB(value: number);
  116181. /**
  116182. * Gets the value of the `Right` button
  116183. */
  116184. get buttonRB(): number;
  116185. /**
  116186. * Sets the value of the `Right` button
  116187. */
  116188. set buttonRB(value: number);
  116189. /**
  116190. * Gets the value of the Left joystick
  116191. */
  116192. get buttonLeftStick(): number;
  116193. /**
  116194. * Sets the value of the Left joystick
  116195. */
  116196. set buttonLeftStick(value: number);
  116197. /**
  116198. * Gets the value of the Right joystick
  116199. */
  116200. get buttonRightStick(): number;
  116201. /**
  116202. * Sets the value of the Right joystick
  116203. */
  116204. set buttonRightStick(value: number);
  116205. /**
  116206. * Gets the value of D-pad up
  116207. */
  116208. get dPadUp(): number;
  116209. /**
  116210. * Sets the value of D-pad up
  116211. */
  116212. set dPadUp(value: number);
  116213. /**
  116214. * Gets the value of D-pad down
  116215. */
  116216. get dPadDown(): number;
  116217. /**
  116218. * Sets the value of D-pad down
  116219. */
  116220. set dPadDown(value: number);
  116221. /**
  116222. * Gets the value of D-pad left
  116223. */
  116224. get dPadLeft(): number;
  116225. /**
  116226. * Sets the value of D-pad left
  116227. */
  116228. set dPadLeft(value: number);
  116229. /**
  116230. * Gets the value of D-pad right
  116231. */
  116232. get dPadRight(): number;
  116233. /**
  116234. * Sets the value of D-pad right
  116235. */
  116236. set dPadRight(value: number);
  116237. /**
  116238. * Force the gamepad to synchronize with device values
  116239. */
  116240. update(): void;
  116241. /**
  116242. * Disposes the gamepad
  116243. */
  116244. dispose(): void;
  116245. }
  116246. }
  116247. declare module BABYLON {
  116248. /**
  116249. * Defines supported buttons for DualShock compatible gamepads
  116250. */
  116251. export enum DualShockButton {
  116252. /** Cross */
  116253. Cross = 0,
  116254. /** Circle */
  116255. Circle = 1,
  116256. /** Square */
  116257. Square = 2,
  116258. /** Triangle */
  116259. Triangle = 3,
  116260. /** L1 */
  116261. L1 = 4,
  116262. /** R1 */
  116263. R1 = 5,
  116264. /** Share */
  116265. Share = 8,
  116266. /** Options */
  116267. Options = 9,
  116268. /** Left stick */
  116269. LeftStick = 10,
  116270. /** Right stick */
  116271. RightStick = 11
  116272. }
  116273. /** Defines values for DualShock DPad */
  116274. export enum DualShockDpad {
  116275. /** Up */
  116276. Up = 12,
  116277. /** Down */
  116278. Down = 13,
  116279. /** Left */
  116280. Left = 14,
  116281. /** Right */
  116282. Right = 15
  116283. }
  116284. /**
  116285. * Defines a DualShock gamepad
  116286. */
  116287. export class DualShockPad extends Gamepad {
  116288. private _leftTrigger;
  116289. private _rightTrigger;
  116290. private _onlefttriggerchanged;
  116291. private _onrighttriggerchanged;
  116292. private _onbuttondown;
  116293. private _onbuttonup;
  116294. private _ondpaddown;
  116295. private _ondpadup;
  116296. /** Observable raised when a button is pressed */
  116297. onButtonDownObservable: Observable<DualShockButton>;
  116298. /** Observable raised when a button is released */
  116299. onButtonUpObservable: Observable<DualShockButton>;
  116300. /** Observable raised when a pad is pressed */
  116301. onPadDownObservable: Observable<DualShockDpad>;
  116302. /** Observable raised when a pad is released */
  116303. onPadUpObservable: Observable<DualShockDpad>;
  116304. private _buttonCross;
  116305. private _buttonCircle;
  116306. private _buttonSquare;
  116307. private _buttonTriangle;
  116308. private _buttonShare;
  116309. private _buttonOptions;
  116310. private _buttonL1;
  116311. private _buttonR1;
  116312. private _buttonLeftStick;
  116313. private _buttonRightStick;
  116314. private _dPadUp;
  116315. private _dPadDown;
  116316. private _dPadLeft;
  116317. private _dPadRight;
  116318. /**
  116319. * Creates a new DualShock gamepad object
  116320. * @param id defines the id of this gamepad
  116321. * @param index defines its index
  116322. * @param gamepad defines the internal HTML gamepad object
  116323. */
  116324. constructor(id: string, index: number, gamepad: any);
  116325. /**
  116326. * Defines the callback to call when left trigger is pressed
  116327. * @param callback defines the callback to use
  116328. */
  116329. onlefttriggerchanged(callback: (value: number) => void): void;
  116330. /**
  116331. * Defines the callback to call when right trigger is pressed
  116332. * @param callback defines the callback to use
  116333. */
  116334. onrighttriggerchanged(callback: (value: number) => void): void;
  116335. /**
  116336. * Gets the left trigger value
  116337. */
  116338. get leftTrigger(): number;
  116339. /**
  116340. * Sets the left trigger value
  116341. */
  116342. set leftTrigger(newValue: number);
  116343. /**
  116344. * Gets the right trigger value
  116345. */
  116346. get rightTrigger(): number;
  116347. /**
  116348. * Sets the right trigger value
  116349. */
  116350. set rightTrigger(newValue: number);
  116351. /**
  116352. * Defines the callback to call when a button is pressed
  116353. * @param callback defines the callback to use
  116354. */
  116355. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  116356. /**
  116357. * Defines the callback to call when a button is released
  116358. * @param callback defines the callback to use
  116359. */
  116360. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  116361. /**
  116362. * Defines the callback to call when a pad is pressed
  116363. * @param callback defines the callback to use
  116364. */
  116365. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  116366. /**
  116367. * Defines the callback to call when a pad is released
  116368. * @param callback defines the callback to use
  116369. */
  116370. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  116371. private _setButtonValue;
  116372. private _setDPadValue;
  116373. /**
  116374. * Gets the value of the `Cross` button
  116375. */
  116376. get buttonCross(): number;
  116377. /**
  116378. * Sets the value of the `Cross` button
  116379. */
  116380. set buttonCross(value: number);
  116381. /**
  116382. * Gets the value of the `Circle` button
  116383. */
  116384. get buttonCircle(): number;
  116385. /**
  116386. * Sets the value of the `Circle` button
  116387. */
  116388. set buttonCircle(value: number);
  116389. /**
  116390. * Gets the value of the `Square` button
  116391. */
  116392. get buttonSquare(): number;
  116393. /**
  116394. * Sets the value of the `Square` button
  116395. */
  116396. set buttonSquare(value: number);
  116397. /**
  116398. * Gets the value of the `Triangle` button
  116399. */
  116400. get buttonTriangle(): number;
  116401. /**
  116402. * Sets the value of the `Triangle` button
  116403. */
  116404. set buttonTriangle(value: number);
  116405. /**
  116406. * Gets the value of the `Options` button
  116407. */
  116408. get buttonOptions(): number;
  116409. /**
  116410. * Sets the value of the `Options` button
  116411. */
  116412. set buttonOptions(value: number);
  116413. /**
  116414. * Gets the value of the `Share` button
  116415. */
  116416. get buttonShare(): number;
  116417. /**
  116418. * Sets the value of the `Share` button
  116419. */
  116420. set buttonShare(value: number);
  116421. /**
  116422. * Gets the value of the `L1` button
  116423. */
  116424. get buttonL1(): number;
  116425. /**
  116426. * Sets the value of the `L1` button
  116427. */
  116428. set buttonL1(value: number);
  116429. /**
  116430. * Gets the value of the `R1` button
  116431. */
  116432. get buttonR1(): number;
  116433. /**
  116434. * Sets the value of the `R1` button
  116435. */
  116436. set buttonR1(value: number);
  116437. /**
  116438. * Gets the value of the Left joystick
  116439. */
  116440. get buttonLeftStick(): number;
  116441. /**
  116442. * Sets the value of the Left joystick
  116443. */
  116444. set buttonLeftStick(value: number);
  116445. /**
  116446. * Gets the value of the Right joystick
  116447. */
  116448. get buttonRightStick(): number;
  116449. /**
  116450. * Sets the value of the Right joystick
  116451. */
  116452. set buttonRightStick(value: number);
  116453. /**
  116454. * Gets the value of D-pad up
  116455. */
  116456. get dPadUp(): number;
  116457. /**
  116458. * Sets the value of D-pad up
  116459. */
  116460. set dPadUp(value: number);
  116461. /**
  116462. * Gets the value of D-pad down
  116463. */
  116464. get dPadDown(): number;
  116465. /**
  116466. * Sets the value of D-pad down
  116467. */
  116468. set dPadDown(value: number);
  116469. /**
  116470. * Gets the value of D-pad left
  116471. */
  116472. get dPadLeft(): number;
  116473. /**
  116474. * Sets the value of D-pad left
  116475. */
  116476. set dPadLeft(value: number);
  116477. /**
  116478. * Gets the value of D-pad right
  116479. */
  116480. get dPadRight(): number;
  116481. /**
  116482. * Sets the value of D-pad right
  116483. */
  116484. set dPadRight(value: number);
  116485. /**
  116486. * Force the gamepad to synchronize with device values
  116487. */
  116488. update(): void;
  116489. /**
  116490. * Disposes the gamepad
  116491. */
  116492. dispose(): void;
  116493. }
  116494. }
  116495. declare module BABYLON {
  116496. /**
  116497. * Manager for handling gamepads
  116498. */
  116499. export class GamepadManager {
  116500. private _scene?;
  116501. private _babylonGamepads;
  116502. private _oneGamepadConnected;
  116503. /** @hidden */
  116504. _isMonitoring: boolean;
  116505. private _gamepadEventSupported;
  116506. private _gamepadSupport?;
  116507. /**
  116508. * observable to be triggered when the gamepad controller has been connected
  116509. */
  116510. onGamepadConnectedObservable: Observable<Gamepad>;
  116511. /**
  116512. * observable to be triggered when the gamepad controller has been disconnected
  116513. */
  116514. onGamepadDisconnectedObservable: Observable<Gamepad>;
  116515. private _onGamepadConnectedEvent;
  116516. private _onGamepadDisconnectedEvent;
  116517. /**
  116518. * Initializes the gamepad manager
  116519. * @param _scene BabylonJS scene
  116520. */
  116521. constructor(_scene?: Scene | undefined);
  116522. /**
  116523. * The gamepads in the game pad manager
  116524. */
  116525. get gamepads(): Gamepad[];
  116526. /**
  116527. * Get the gamepad controllers based on type
  116528. * @param type The type of gamepad controller
  116529. * @returns Nullable gamepad
  116530. */
  116531. getGamepadByType(type?: number): Nullable<Gamepad>;
  116532. /**
  116533. * Disposes the gamepad manager
  116534. */
  116535. dispose(): void;
  116536. private _addNewGamepad;
  116537. private _startMonitoringGamepads;
  116538. private _stopMonitoringGamepads;
  116539. /** @hidden */
  116540. _checkGamepadsStatus(): void;
  116541. private _updateGamepadObjects;
  116542. }
  116543. }
  116544. declare module BABYLON {
  116545. interface Scene {
  116546. /** @hidden */
  116547. _gamepadManager: Nullable<GamepadManager>;
  116548. /**
  116549. * Gets the gamepad manager associated with the scene
  116550. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  116551. */
  116552. gamepadManager: GamepadManager;
  116553. }
  116554. /**
  116555. * Interface representing a free camera inputs manager
  116556. */
  116557. interface FreeCameraInputsManager {
  116558. /**
  116559. * Adds gamepad input support to the FreeCameraInputsManager.
  116560. * @returns the FreeCameraInputsManager
  116561. */
  116562. addGamepad(): FreeCameraInputsManager;
  116563. }
  116564. /**
  116565. * Interface representing an arc rotate camera inputs manager
  116566. */
  116567. interface ArcRotateCameraInputsManager {
  116568. /**
  116569. * Adds gamepad input support to the ArcRotateCamera InputManager.
  116570. * @returns the camera inputs manager
  116571. */
  116572. addGamepad(): ArcRotateCameraInputsManager;
  116573. }
  116574. /**
  116575. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  116576. */
  116577. export class GamepadSystemSceneComponent implements ISceneComponent {
  116578. /**
  116579. * The component name helpfull to identify the component in the list of scene components.
  116580. */
  116581. readonly name: string;
  116582. /**
  116583. * The scene the component belongs to.
  116584. */
  116585. scene: Scene;
  116586. /**
  116587. * Creates a new instance of the component for the given scene
  116588. * @param scene Defines the scene to register the component in
  116589. */
  116590. constructor(scene: Scene);
  116591. /**
  116592. * Registers the component in a given scene
  116593. */
  116594. register(): void;
  116595. /**
  116596. * Rebuilds the elements related to this component in case of
  116597. * context lost for instance.
  116598. */
  116599. rebuild(): void;
  116600. /**
  116601. * Disposes the component and the associated ressources
  116602. */
  116603. dispose(): void;
  116604. private _beforeCameraUpdate;
  116605. }
  116606. }
  116607. declare module BABYLON {
  116608. /**
  116609. * 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,
  116610. * which still works and will still be found in many Playgrounds.
  116611. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  116612. */
  116613. export class UniversalCamera extends TouchCamera {
  116614. /**
  116615. * Defines the gamepad rotation sensiblity.
  116616. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  116617. */
  116618. get gamepadAngularSensibility(): number;
  116619. set gamepadAngularSensibility(value: number);
  116620. /**
  116621. * Defines the gamepad move sensiblity.
  116622. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  116623. */
  116624. get gamepadMoveSensibility(): number;
  116625. set gamepadMoveSensibility(value: number);
  116626. /**
  116627. * 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,
  116628. * which still works and will still be found in many Playgrounds.
  116629. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  116630. * @param name Define the name of the camera in the scene
  116631. * @param position Define the start position of the camera in the scene
  116632. * @param scene Define the scene the camera belongs to
  116633. */
  116634. constructor(name: string, position: Vector3, scene: Scene);
  116635. /**
  116636. * Gets the current object class name.
  116637. * @return the class name
  116638. */
  116639. getClassName(): string;
  116640. }
  116641. }
  116642. declare module BABYLON {
  116643. /**
  116644. * This represents a FPS type of camera. This is only here for back compat purpose.
  116645. * Please use the UniversalCamera instead as both are identical.
  116646. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  116647. */
  116648. export class GamepadCamera extends UniversalCamera {
  116649. /**
  116650. * Instantiates a new Gamepad Camera
  116651. * This represents a FPS type of camera. This is only here for back compat purpose.
  116652. * Please use the UniversalCamera instead as both are identical.
  116653. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  116654. * @param name Define the name of the camera in the scene
  116655. * @param position Define the start position of the camera in the scene
  116656. * @param scene Define the scene the camera belongs to
  116657. */
  116658. constructor(name: string, position: Vector3, scene: Scene);
  116659. /**
  116660. * Gets the current object class name.
  116661. * @return the class name
  116662. */
  116663. getClassName(): string;
  116664. }
  116665. }
  116666. declare module BABYLON {
  116667. /** @hidden */
  116668. export var passPixelShader: {
  116669. name: string;
  116670. shader: string;
  116671. };
  116672. }
  116673. declare module BABYLON {
  116674. /** @hidden */
  116675. export var passCubePixelShader: {
  116676. name: string;
  116677. shader: string;
  116678. };
  116679. }
  116680. declare module BABYLON {
  116681. /**
  116682. * PassPostProcess which produces an output the same as it's input
  116683. */
  116684. export class PassPostProcess extends PostProcess {
  116685. /**
  116686. * Creates the PassPostProcess
  116687. * @param name The name of the effect.
  116688. * @param options The required width/height ratio to downsize to before computing the render pass.
  116689. * @param camera The camera to apply the render pass to.
  116690. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116691. * @param engine The engine which the post process will be applied. (default: current engine)
  116692. * @param reusable If the post process can be reused on the same frame. (default: false)
  116693. * @param textureType The type of texture to be used when performing the post processing.
  116694. * @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)
  116695. */
  116696. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  116697. }
  116698. /**
  116699. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  116700. */
  116701. export class PassCubePostProcess extends PostProcess {
  116702. private _face;
  116703. /**
  116704. * Gets or sets the cube face to display.
  116705. * * 0 is +X
  116706. * * 1 is -X
  116707. * * 2 is +Y
  116708. * * 3 is -Y
  116709. * * 4 is +Z
  116710. * * 5 is -Z
  116711. */
  116712. get face(): number;
  116713. set face(value: number);
  116714. /**
  116715. * Creates the PassCubePostProcess
  116716. * @param name The name of the effect.
  116717. * @param options The required width/height ratio to downsize to before computing the render pass.
  116718. * @param camera The camera to apply the render pass to.
  116719. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116720. * @param engine The engine which the post process will be applied. (default: current engine)
  116721. * @param reusable If the post process can be reused on the same frame. (default: false)
  116722. * @param textureType The type of texture to be used when performing the post processing.
  116723. * @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)
  116724. */
  116725. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  116726. }
  116727. }
  116728. declare module BABYLON {
  116729. /** @hidden */
  116730. export var anaglyphPixelShader: {
  116731. name: string;
  116732. shader: string;
  116733. };
  116734. }
  116735. declare module BABYLON {
  116736. /**
  116737. * Postprocess used to generate anaglyphic rendering
  116738. */
  116739. export class AnaglyphPostProcess extends PostProcess {
  116740. private _passedProcess;
  116741. /**
  116742. * Creates a new AnaglyphPostProcess
  116743. * @param name defines postprocess name
  116744. * @param options defines creation options or target ratio scale
  116745. * @param rigCameras defines cameras using this postprocess
  116746. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  116747. * @param engine defines hosting engine
  116748. * @param reusable defines if the postprocess will be reused multiple times per frame
  116749. */
  116750. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  116751. }
  116752. }
  116753. declare module BABYLON {
  116754. /**
  116755. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  116756. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  116757. */
  116758. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  116759. /**
  116760. * Creates a new AnaglyphArcRotateCamera
  116761. * @param name defines camera name
  116762. * @param alpha defines alpha angle (in radians)
  116763. * @param beta defines beta angle (in radians)
  116764. * @param radius defines radius
  116765. * @param target defines camera target
  116766. * @param interaxialDistance defines distance between each color axis
  116767. * @param scene defines the hosting scene
  116768. */
  116769. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  116770. /**
  116771. * Gets camera class name
  116772. * @returns AnaglyphArcRotateCamera
  116773. */
  116774. getClassName(): string;
  116775. }
  116776. }
  116777. declare module BABYLON {
  116778. /**
  116779. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  116780. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  116781. */
  116782. export class AnaglyphFreeCamera extends FreeCamera {
  116783. /**
  116784. * Creates a new AnaglyphFreeCamera
  116785. * @param name defines camera name
  116786. * @param position defines initial position
  116787. * @param interaxialDistance defines distance between each color axis
  116788. * @param scene defines the hosting scene
  116789. */
  116790. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  116791. /**
  116792. * Gets camera class name
  116793. * @returns AnaglyphFreeCamera
  116794. */
  116795. getClassName(): string;
  116796. }
  116797. }
  116798. declare module BABYLON {
  116799. /**
  116800. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  116801. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  116802. */
  116803. export class AnaglyphGamepadCamera extends GamepadCamera {
  116804. /**
  116805. * Creates a new AnaglyphGamepadCamera
  116806. * @param name defines camera name
  116807. * @param position defines initial position
  116808. * @param interaxialDistance defines distance between each color axis
  116809. * @param scene defines the hosting scene
  116810. */
  116811. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  116812. /**
  116813. * Gets camera class name
  116814. * @returns AnaglyphGamepadCamera
  116815. */
  116816. getClassName(): string;
  116817. }
  116818. }
  116819. declare module BABYLON {
  116820. /**
  116821. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  116822. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  116823. */
  116824. export class AnaglyphUniversalCamera extends UniversalCamera {
  116825. /**
  116826. * Creates a new AnaglyphUniversalCamera
  116827. * @param name defines camera name
  116828. * @param position defines initial position
  116829. * @param interaxialDistance defines distance between each color axis
  116830. * @param scene defines the hosting scene
  116831. */
  116832. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  116833. /**
  116834. * Gets camera class name
  116835. * @returns AnaglyphUniversalCamera
  116836. */
  116837. getClassName(): string;
  116838. }
  116839. }
  116840. declare module BABYLON {
  116841. /**
  116842. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  116843. * @see http://doc.babylonjs.com/features/cameras
  116844. */
  116845. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  116846. /**
  116847. * Creates a new StereoscopicArcRotateCamera
  116848. * @param name defines camera name
  116849. * @param alpha defines alpha angle (in radians)
  116850. * @param beta defines beta angle (in radians)
  116851. * @param radius defines radius
  116852. * @param target defines camera target
  116853. * @param interaxialDistance defines distance between each color axis
  116854. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  116855. * @param scene defines the hosting scene
  116856. */
  116857. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  116858. /**
  116859. * Gets camera class name
  116860. * @returns StereoscopicArcRotateCamera
  116861. */
  116862. getClassName(): string;
  116863. }
  116864. }
  116865. declare module BABYLON {
  116866. /**
  116867. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  116868. * @see http://doc.babylonjs.com/features/cameras
  116869. */
  116870. export class StereoscopicFreeCamera extends FreeCamera {
  116871. /**
  116872. * Creates a new StereoscopicFreeCamera
  116873. * @param name defines camera name
  116874. * @param position defines initial position
  116875. * @param interaxialDistance defines distance between each color axis
  116876. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  116877. * @param scene defines the hosting scene
  116878. */
  116879. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  116880. /**
  116881. * Gets camera class name
  116882. * @returns StereoscopicFreeCamera
  116883. */
  116884. getClassName(): string;
  116885. }
  116886. }
  116887. declare module BABYLON {
  116888. /**
  116889. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  116890. * @see http://doc.babylonjs.com/features/cameras
  116891. */
  116892. export class StereoscopicGamepadCamera extends GamepadCamera {
  116893. /**
  116894. * Creates a new StereoscopicGamepadCamera
  116895. * @param name defines camera name
  116896. * @param position defines initial position
  116897. * @param interaxialDistance defines distance between each color axis
  116898. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  116899. * @param scene defines the hosting scene
  116900. */
  116901. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  116902. /**
  116903. * Gets camera class name
  116904. * @returns StereoscopicGamepadCamera
  116905. */
  116906. getClassName(): string;
  116907. }
  116908. }
  116909. declare module BABYLON {
  116910. /**
  116911. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  116912. * @see http://doc.babylonjs.com/features/cameras
  116913. */
  116914. export class StereoscopicUniversalCamera extends UniversalCamera {
  116915. /**
  116916. * Creates a new StereoscopicUniversalCamera
  116917. * @param name defines camera name
  116918. * @param position defines initial position
  116919. * @param interaxialDistance defines distance between each color axis
  116920. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  116921. * @param scene defines the hosting scene
  116922. */
  116923. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  116924. /**
  116925. * Gets camera class name
  116926. * @returns StereoscopicUniversalCamera
  116927. */
  116928. getClassName(): string;
  116929. }
  116930. }
  116931. declare module BABYLON {
  116932. /**
  116933. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  116934. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  116935. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  116936. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  116937. */
  116938. export class VirtualJoysticksCamera extends FreeCamera {
  116939. /**
  116940. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  116941. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  116942. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  116943. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  116944. * @param name Define the name of the camera in the scene
  116945. * @param position Define the start position of the camera in the scene
  116946. * @param scene Define the scene the camera belongs to
  116947. */
  116948. constructor(name: string, position: Vector3, scene: Scene);
  116949. /**
  116950. * Gets the current object class name.
  116951. * @return the class name
  116952. */
  116953. getClassName(): string;
  116954. }
  116955. }
  116956. declare module BABYLON {
  116957. /**
  116958. * This represents all the required metrics to create a VR camera.
  116959. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  116960. */
  116961. export class VRCameraMetrics {
  116962. /**
  116963. * Define the horizontal resolution off the screen.
  116964. */
  116965. hResolution: number;
  116966. /**
  116967. * Define the vertical resolution off the screen.
  116968. */
  116969. vResolution: number;
  116970. /**
  116971. * Define the horizontal screen size.
  116972. */
  116973. hScreenSize: number;
  116974. /**
  116975. * Define the vertical screen size.
  116976. */
  116977. vScreenSize: number;
  116978. /**
  116979. * Define the vertical screen center position.
  116980. */
  116981. vScreenCenter: number;
  116982. /**
  116983. * Define the distance of the eyes to the screen.
  116984. */
  116985. eyeToScreenDistance: number;
  116986. /**
  116987. * Define the distance between both lenses
  116988. */
  116989. lensSeparationDistance: number;
  116990. /**
  116991. * Define the distance between both viewer's eyes.
  116992. */
  116993. interpupillaryDistance: number;
  116994. /**
  116995. * Define the distortion factor of the VR postprocess.
  116996. * Please, touch with care.
  116997. */
  116998. distortionK: number[];
  116999. /**
  117000. * Define the chromatic aberration correction factors for the VR post process.
  117001. */
  117002. chromaAbCorrection: number[];
  117003. /**
  117004. * Define the scale factor of the post process.
  117005. * The smaller the better but the slower.
  117006. */
  117007. postProcessScaleFactor: number;
  117008. /**
  117009. * Define an offset for the lens center.
  117010. */
  117011. lensCenterOffset: number;
  117012. /**
  117013. * Define if the current vr camera should compensate the distortion of the lense or not.
  117014. */
  117015. compensateDistortion: boolean;
  117016. /**
  117017. * Defines if multiview should be enabled when rendering (Default: false)
  117018. */
  117019. multiviewEnabled: boolean;
  117020. /**
  117021. * Gets the rendering aspect ratio based on the provided resolutions.
  117022. */
  117023. get aspectRatio(): number;
  117024. /**
  117025. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  117026. */
  117027. get aspectRatioFov(): number;
  117028. /**
  117029. * @hidden
  117030. */
  117031. get leftHMatrix(): Matrix;
  117032. /**
  117033. * @hidden
  117034. */
  117035. get rightHMatrix(): Matrix;
  117036. /**
  117037. * @hidden
  117038. */
  117039. get leftPreViewMatrix(): Matrix;
  117040. /**
  117041. * @hidden
  117042. */
  117043. get rightPreViewMatrix(): Matrix;
  117044. /**
  117045. * Get the default VRMetrics based on the most generic setup.
  117046. * @returns the default vr metrics
  117047. */
  117048. static GetDefault(): VRCameraMetrics;
  117049. }
  117050. }
  117051. declare module BABYLON {
  117052. /** @hidden */
  117053. export var vrDistortionCorrectionPixelShader: {
  117054. name: string;
  117055. shader: string;
  117056. };
  117057. }
  117058. declare module BABYLON {
  117059. /**
  117060. * VRDistortionCorrectionPostProcess used for mobile VR
  117061. */
  117062. export class VRDistortionCorrectionPostProcess extends PostProcess {
  117063. private _isRightEye;
  117064. private _distortionFactors;
  117065. private _postProcessScaleFactor;
  117066. private _lensCenterOffset;
  117067. private _scaleIn;
  117068. private _scaleFactor;
  117069. private _lensCenter;
  117070. /**
  117071. * Initializes the VRDistortionCorrectionPostProcess
  117072. * @param name The name of the effect.
  117073. * @param camera The camera to apply the render pass to.
  117074. * @param isRightEye If this is for the right eye distortion
  117075. * @param vrMetrics All the required metrics for the VR camera
  117076. */
  117077. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  117078. }
  117079. }
  117080. declare module BABYLON {
  117081. /**
  117082. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  117083. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  117084. */
  117085. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  117086. /**
  117087. * Creates a new VRDeviceOrientationArcRotateCamera
  117088. * @param name defines camera name
  117089. * @param alpha defines the camera rotation along the logitudinal axis
  117090. * @param beta defines the camera rotation along the latitudinal axis
  117091. * @param radius defines the camera distance from its target
  117092. * @param target defines the camera target
  117093. * @param scene defines the scene the camera belongs to
  117094. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  117095. * @param vrCameraMetrics defines the vr metrics associated to the camera
  117096. */
  117097. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  117098. /**
  117099. * Gets camera class name
  117100. * @returns VRDeviceOrientationArcRotateCamera
  117101. */
  117102. getClassName(): string;
  117103. }
  117104. }
  117105. declare module BABYLON {
  117106. /**
  117107. * Camera used to simulate VR rendering (based on FreeCamera)
  117108. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  117109. */
  117110. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  117111. /**
  117112. * Creates a new VRDeviceOrientationFreeCamera
  117113. * @param name defines camera name
  117114. * @param position defines the start position of the camera
  117115. * @param scene defines the scene the camera belongs to
  117116. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  117117. * @param vrCameraMetrics defines the vr metrics associated to the camera
  117118. */
  117119. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  117120. /**
  117121. * Gets camera class name
  117122. * @returns VRDeviceOrientationFreeCamera
  117123. */
  117124. getClassName(): string;
  117125. }
  117126. }
  117127. declare module BABYLON {
  117128. /**
  117129. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  117130. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  117131. */
  117132. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  117133. /**
  117134. * Creates a new VRDeviceOrientationGamepadCamera
  117135. * @param name defines camera name
  117136. * @param position defines the start position of the camera
  117137. * @param scene defines the scene the camera belongs to
  117138. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  117139. * @param vrCameraMetrics defines the vr metrics associated to the camera
  117140. */
  117141. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  117142. /**
  117143. * Gets camera class name
  117144. * @returns VRDeviceOrientationGamepadCamera
  117145. */
  117146. getClassName(): string;
  117147. }
  117148. }
  117149. declare module BABYLON {
  117150. /** @hidden */
  117151. export var imageProcessingPixelShader: {
  117152. name: string;
  117153. shader: string;
  117154. };
  117155. }
  117156. declare module BABYLON {
  117157. /**
  117158. * ImageProcessingPostProcess
  117159. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  117160. */
  117161. export class ImageProcessingPostProcess extends PostProcess {
  117162. /**
  117163. * Default configuration related to image processing available in the PBR Material.
  117164. */
  117165. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  117166. /**
  117167. * Gets the image processing configuration used either in this material.
  117168. */
  117169. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  117170. /**
  117171. * Sets the Default image processing configuration used either in the this material.
  117172. *
  117173. * If sets to null, the scene one is in use.
  117174. */
  117175. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  117176. /**
  117177. * Keep track of the image processing observer to allow dispose and replace.
  117178. */
  117179. private _imageProcessingObserver;
  117180. /**
  117181. * Attaches a new image processing configuration to the PBR Material.
  117182. * @param configuration
  117183. */
  117184. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  117185. /**
  117186. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  117187. */
  117188. get colorCurves(): Nullable<ColorCurves>;
  117189. /**
  117190. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  117191. */
  117192. set colorCurves(value: Nullable<ColorCurves>);
  117193. /**
  117194. * Gets wether the color curves effect is enabled.
  117195. */
  117196. get colorCurvesEnabled(): boolean;
  117197. /**
  117198. * Sets wether the color curves effect is enabled.
  117199. */
  117200. set colorCurvesEnabled(value: boolean);
  117201. /**
  117202. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  117203. */
  117204. get colorGradingTexture(): Nullable<BaseTexture>;
  117205. /**
  117206. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  117207. */
  117208. set colorGradingTexture(value: Nullable<BaseTexture>);
  117209. /**
  117210. * Gets wether the color grading effect is enabled.
  117211. */
  117212. get colorGradingEnabled(): boolean;
  117213. /**
  117214. * Gets wether the color grading effect is enabled.
  117215. */
  117216. set colorGradingEnabled(value: boolean);
  117217. /**
  117218. * Gets exposure used in the effect.
  117219. */
  117220. get exposure(): number;
  117221. /**
  117222. * Sets exposure used in the effect.
  117223. */
  117224. set exposure(value: number);
  117225. /**
  117226. * Gets wether tonemapping is enabled or not.
  117227. */
  117228. get toneMappingEnabled(): boolean;
  117229. /**
  117230. * Sets wether tonemapping is enabled or not
  117231. */
  117232. set toneMappingEnabled(value: boolean);
  117233. /**
  117234. * Gets the type of tone mapping effect.
  117235. */
  117236. get toneMappingType(): number;
  117237. /**
  117238. * Sets the type of tone mapping effect.
  117239. */
  117240. set toneMappingType(value: number);
  117241. /**
  117242. * Gets contrast used in the effect.
  117243. */
  117244. get contrast(): number;
  117245. /**
  117246. * Sets contrast used in the effect.
  117247. */
  117248. set contrast(value: number);
  117249. /**
  117250. * Gets Vignette stretch size.
  117251. */
  117252. get vignetteStretch(): number;
  117253. /**
  117254. * Sets Vignette stretch size.
  117255. */
  117256. set vignetteStretch(value: number);
  117257. /**
  117258. * Gets Vignette centre X Offset.
  117259. */
  117260. get vignetteCentreX(): number;
  117261. /**
  117262. * Sets Vignette centre X Offset.
  117263. */
  117264. set vignetteCentreX(value: number);
  117265. /**
  117266. * Gets Vignette centre Y Offset.
  117267. */
  117268. get vignetteCentreY(): number;
  117269. /**
  117270. * Sets Vignette centre Y Offset.
  117271. */
  117272. set vignetteCentreY(value: number);
  117273. /**
  117274. * Gets Vignette weight or intensity of the vignette effect.
  117275. */
  117276. get vignetteWeight(): number;
  117277. /**
  117278. * Sets Vignette weight or intensity of the vignette effect.
  117279. */
  117280. set vignetteWeight(value: number);
  117281. /**
  117282. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  117283. * if vignetteEnabled is set to true.
  117284. */
  117285. get vignetteColor(): Color4;
  117286. /**
  117287. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  117288. * if vignetteEnabled is set to true.
  117289. */
  117290. set vignetteColor(value: Color4);
  117291. /**
  117292. * Gets Camera field of view used by the Vignette effect.
  117293. */
  117294. get vignetteCameraFov(): number;
  117295. /**
  117296. * Sets Camera field of view used by the Vignette effect.
  117297. */
  117298. set vignetteCameraFov(value: number);
  117299. /**
  117300. * Gets the vignette blend mode allowing different kind of effect.
  117301. */
  117302. get vignetteBlendMode(): number;
  117303. /**
  117304. * Sets the vignette blend mode allowing different kind of effect.
  117305. */
  117306. set vignetteBlendMode(value: number);
  117307. /**
  117308. * Gets wether the vignette effect is enabled.
  117309. */
  117310. get vignetteEnabled(): boolean;
  117311. /**
  117312. * Sets wether the vignette effect is enabled.
  117313. */
  117314. set vignetteEnabled(value: boolean);
  117315. private _fromLinearSpace;
  117316. /**
  117317. * Gets wether the input of the processing is in Gamma or Linear Space.
  117318. */
  117319. get fromLinearSpace(): boolean;
  117320. /**
  117321. * Sets wether the input of the processing is in Gamma or Linear Space.
  117322. */
  117323. set fromLinearSpace(value: boolean);
  117324. /**
  117325. * Defines cache preventing GC.
  117326. */
  117327. private _defines;
  117328. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  117329. /**
  117330. * "ImageProcessingPostProcess"
  117331. * @returns "ImageProcessingPostProcess"
  117332. */
  117333. getClassName(): string;
  117334. protected _updateParameters(): void;
  117335. dispose(camera?: Camera): void;
  117336. }
  117337. }
  117338. declare module BABYLON {
  117339. /**
  117340. * Class containing static functions to help procedurally build meshes
  117341. */
  117342. export class GroundBuilder {
  117343. /**
  117344. * Creates a ground mesh
  117345. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  117346. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  117347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117348. * @param name defines the name of the mesh
  117349. * @param options defines the options used to create the mesh
  117350. * @param scene defines the hosting scene
  117351. * @returns the ground mesh
  117352. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  117353. */
  117354. static CreateGround(name: string, options: {
  117355. width?: number;
  117356. height?: number;
  117357. subdivisions?: number;
  117358. subdivisionsX?: number;
  117359. subdivisionsY?: number;
  117360. updatable?: boolean;
  117361. }, scene: any): Mesh;
  117362. /**
  117363. * Creates a tiled ground mesh
  117364. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  117365. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  117366. * * 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
  117367. * * 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
  117368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117369. * @param name defines the name of the mesh
  117370. * @param options defines the options used to create the mesh
  117371. * @param scene defines the hosting scene
  117372. * @returns the tiled ground mesh
  117373. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  117374. */
  117375. static CreateTiledGround(name: string, options: {
  117376. xmin: number;
  117377. zmin: number;
  117378. xmax: number;
  117379. zmax: number;
  117380. subdivisions?: {
  117381. w: number;
  117382. h: number;
  117383. };
  117384. precision?: {
  117385. w: number;
  117386. h: number;
  117387. };
  117388. updatable?: boolean;
  117389. }, scene?: Nullable<Scene>): Mesh;
  117390. /**
  117391. * Creates a ground mesh from a height map
  117392. * * The parameter `url` sets the URL of the height map image resource.
  117393. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  117394. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  117395. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  117396. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  117397. * * 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.
  117398. * * 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).
  117399. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  117400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117401. * @param name defines the name of the mesh
  117402. * @param url defines the url to the height map
  117403. * @param options defines the options used to create the mesh
  117404. * @param scene defines the hosting scene
  117405. * @returns the ground mesh
  117406. * @see https://doc.babylonjs.com/babylon101/height_map
  117407. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  117408. */
  117409. static CreateGroundFromHeightMap(name: string, url: string, options: {
  117410. width?: number;
  117411. height?: number;
  117412. subdivisions?: number;
  117413. minHeight?: number;
  117414. maxHeight?: number;
  117415. colorFilter?: Color3;
  117416. alphaFilter?: number;
  117417. updatable?: boolean;
  117418. onReady?: (mesh: GroundMesh) => void;
  117419. }, scene?: Nullable<Scene>): GroundMesh;
  117420. }
  117421. }
  117422. declare module BABYLON {
  117423. /**
  117424. * Class containing static functions to help procedurally build meshes
  117425. */
  117426. export class TorusBuilder {
  117427. /**
  117428. * Creates a torus mesh
  117429. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  117430. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  117431. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  117432. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117433. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117435. * @param name defines the name of the mesh
  117436. * @param options defines the options used to create the mesh
  117437. * @param scene defines the hosting scene
  117438. * @returns the torus mesh
  117439. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  117440. */
  117441. static CreateTorus(name: string, options: {
  117442. diameter?: number;
  117443. thickness?: number;
  117444. tessellation?: number;
  117445. updatable?: boolean;
  117446. sideOrientation?: number;
  117447. frontUVs?: Vector4;
  117448. backUVs?: Vector4;
  117449. }, scene: any): Mesh;
  117450. }
  117451. }
  117452. declare module BABYLON {
  117453. /**
  117454. * Class containing static functions to help procedurally build meshes
  117455. */
  117456. export class CylinderBuilder {
  117457. /**
  117458. * Creates a cylinder or a cone mesh
  117459. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  117460. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  117461. * * 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.
  117462. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  117463. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  117464. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  117465. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  117466. * * 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).
  117467. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  117468. * * 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).
  117469. * * 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
  117470. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  117471. * * 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
  117472. * * 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.
  117473. * * If `enclose` is false, a ring surface is one element.
  117474. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  117475. * * 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
  117476. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117477. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117479. * @param name defines the name of the mesh
  117480. * @param options defines the options used to create the mesh
  117481. * @param scene defines the hosting scene
  117482. * @returns the cylinder mesh
  117483. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  117484. */
  117485. static CreateCylinder(name: string, options: {
  117486. height?: number;
  117487. diameterTop?: number;
  117488. diameterBottom?: number;
  117489. diameter?: number;
  117490. tessellation?: number;
  117491. subdivisions?: number;
  117492. arc?: number;
  117493. faceColors?: Color4[];
  117494. faceUV?: Vector4[];
  117495. updatable?: boolean;
  117496. hasRings?: boolean;
  117497. enclose?: boolean;
  117498. cap?: number;
  117499. sideOrientation?: number;
  117500. frontUVs?: Vector4;
  117501. backUVs?: Vector4;
  117502. }, scene: any): Mesh;
  117503. }
  117504. }
  117505. declare module BABYLON {
  117506. /**
  117507. * States of the webXR experience
  117508. */
  117509. export enum WebXRState {
  117510. /**
  117511. * Transitioning to being in XR mode
  117512. */
  117513. ENTERING_XR = 0,
  117514. /**
  117515. * Transitioning to non XR mode
  117516. */
  117517. EXITING_XR = 1,
  117518. /**
  117519. * In XR mode and presenting
  117520. */
  117521. IN_XR = 2,
  117522. /**
  117523. * Not entered XR mode
  117524. */
  117525. NOT_IN_XR = 3
  117526. }
  117527. /**
  117528. * Abstraction of the XR render target
  117529. */
  117530. export interface WebXRRenderTarget extends IDisposable {
  117531. /**
  117532. * xrpresent context of the canvas which can be used to display/mirror xr content
  117533. */
  117534. canvasContext: WebGLRenderingContext;
  117535. /**
  117536. * xr layer for the canvas
  117537. */
  117538. xrLayer: Nullable<XRWebGLLayer>;
  117539. /**
  117540. * Initializes the xr layer for the session
  117541. * @param xrSession xr session
  117542. * @returns a promise that will resolve once the XR Layer has been created
  117543. */
  117544. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  117545. }
  117546. }
  117547. declare module BABYLON {
  117548. /**
  117549. * COnfiguration object for WebXR output canvas
  117550. */
  117551. export class WebXRManagedOutputCanvasOptions {
  117552. /**
  117553. * An optional canvas in case you wish to create it yourself and provide it here.
  117554. * If not provided, a new canvas will be created
  117555. */
  117556. canvasElement?: HTMLCanvasElement;
  117557. /**
  117558. * Options for this XR Layer output
  117559. */
  117560. canvasOptions?: XRWebGLLayerOptions;
  117561. /**
  117562. * CSS styling for a newly created canvas (if not provided)
  117563. */
  117564. newCanvasCssStyle?: string;
  117565. /**
  117566. * Get the default values of the configuration object
  117567. * @returns default values of this configuration object
  117568. */
  117569. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  117570. }
  117571. /**
  117572. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  117573. */
  117574. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  117575. private _options;
  117576. private _canvas;
  117577. private _engine;
  117578. /**
  117579. * Rendering context of the canvas which can be used to display/mirror xr content
  117580. */
  117581. canvasContext: WebGLRenderingContext;
  117582. /**
  117583. * xr layer for the canvas
  117584. */
  117585. xrLayer: Nullable<XRWebGLLayer>;
  117586. /**
  117587. * Initializes the canvas to be added/removed upon entering/exiting xr
  117588. * @param _xrSessionManager The XR Session manager
  117589. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  117590. */
  117591. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  117592. /**
  117593. * Disposes of the object
  117594. */
  117595. dispose(): void;
  117596. /**
  117597. * Initializes the xr layer for the session
  117598. * @param xrSession xr session
  117599. * @returns a promise that will resolve once the XR Layer has been created
  117600. */
  117601. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  117602. private _addCanvas;
  117603. private _removeCanvas;
  117604. private _setManagedOutputCanvas;
  117605. }
  117606. }
  117607. declare module BABYLON {
  117608. /**
  117609. * Manages an XRSession to work with Babylon's engine
  117610. * @see https://doc.babylonjs.com/how_to/webxr
  117611. */
  117612. export class WebXRSessionManager implements IDisposable {
  117613. /** The scene which the session should be created for */
  117614. scene: Scene;
  117615. private _referenceSpace;
  117616. private _rttProvider;
  117617. private _sessionEnded;
  117618. private _xrNavigator;
  117619. private baseLayer;
  117620. /**
  117621. * The base reference space from which the session started. good if you want to reset your
  117622. * reference space
  117623. */
  117624. baseReferenceSpace: XRReferenceSpace;
  117625. /**
  117626. * Current XR frame
  117627. */
  117628. currentFrame: Nullable<XRFrame>;
  117629. /** WebXR timestamp updated every frame */
  117630. currentTimestamp: number;
  117631. /**
  117632. * Used just in case of a failure to initialize an immersive session.
  117633. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  117634. */
  117635. defaultHeightCompensation: number;
  117636. /**
  117637. * Fires every time a new xrFrame arrives which can be used to update the camera
  117638. */
  117639. onXRFrameObservable: Observable<XRFrame>;
  117640. /**
  117641. * Fires when the reference space changed
  117642. */
  117643. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  117644. /**
  117645. * Fires when the xr session is ended either by the device or manually done
  117646. */
  117647. onXRSessionEnded: Observable<any>;
  117648. /**
  117649. * Fires when the xr session is ended either by the device or manually done
  117650. */
  117651. onXRSessionInit: Observable<XRSession>;
  117652. /**
  117653. * Underlying xr session
  117654. */
  117655. session: XRSession;
  117656. /**
  117657. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  117658. * or get the offset the player is currently at.
  117659. */
  117660. viewerReferenceSpace: XRReferenceSpace;
  117661. /**
  117662. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  117663. * @param scene The scene which the session should be created for
  117664. */
  117665. constructor(
  117666. /** The scene which the session should be created for */
  117667. scene: Scene);
  117668. /**
  117669. * The current reference space used in this session. This reference space can constantly change!
  117670. * It is mainly used to offset the camera's position.
  117671. */
  117672. get referenceSpace(): XRReferenceSpace;
  117673. /**
  117674. * Set a new reference space and triggers the observable
  117675. */
  117676. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  117677. /**
  117678. * Disposes of the session manager
  117679. */
  117680. dispose(): void;
  117681. /**
  117682. * Stops the xrSession and restores the render loop
  117683. * @returns Promise which resolves after it exits XR
  117684. */
  117685. exitXRAsync(): Promise<void>;
  117686. /**
  117687. * Gets the correct render target texture to be rendered this frame for this eye
  117688. * @param eye the eye for which to get the render target
  117689. * @returns the render target for the specified eye
  117690. */
  117691. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  117692. /**
  117693. * Creates a WebXRRenderTarget object for the XR session
  117694. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  117695. * @param options optional options to provide when creating a new render target
  117696. * @returns a WebXR render target to which the session can render
  117697. */
  117698. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  117699. /**
  117700. * Initializes the manager
  117701. * After initialization enterXR can be called to start an XR session
  117702. * @returns Promise which resolves after it is initialized
  117703. */
  117704. initializeAsync(): Promise<void>;
  117705. /**
  117706. * Initializes an xr session
  117707. * @param xrSessionMode mode to initialize
  117708. * @param xrSessionInit defines optional and required values to pass to the session builder
  117709. * @returns a promise which will resolve once the session has been initialized
  117710. */
  117711. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  117712. /**
  117713. * Checks if a session would be supported for the creation options specified
  117714. * @param sessionMode session mode to check if supported eg. immersive-vr
  117715. * @returns A Promise that resolves to true if supported and false if not
  117716. */
  117717. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  117718. /**
  117719. * Resets the reference space to the one started the session
  117720. */
  117721. resetReferenceSpace(): void;
  117722. /**
  117723. * Starts rendering to the xr layer
  117724. */
  117725. runXRRenderLoop(): void;
  117726. /**
  117727. * Sets the reference space on the xr session
  117728. * @param referenceSpaceType space to set
  117729. * @returns a promise that will resolve once the reference space has been set
  117730. */
  117731. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  117732. /**
  117733. * Updates the render state of the session
  117734. * @param state state to set
  117735. * @returns a promise that resolves once the render state has been updated
  117736. */
  117737. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  117738. /**
  117739. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  117740. * @param sessionMode defines the session to test
  117741. * @returns a promise with boolean as final value
  117742. */
  117743. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  117744. private _createRenderTargetTexture;
  117745. }
  117746. }
  117747. declare module BABYLON {
  117748. /**
  117749. * WebXR Camera which holds the views for the xrSession
  117750. * @see https://doc.babylonjs.com/how_to/webxr_camera
  117751. */
  117752. export class WebXRCamera extends FreeCamera {
  117753. private _xrSessionManager;
  117754. private _firstFrame;
  117755. private _referenceQuaternion;
  117756. private _referencedPosition;
  117757. private _xrInvPositionCache;
  117758. private _xrInvQuaternionCache;
  117759. /**
  117760. * Should position compensation execute on first frame.
  117761. * This is used when copying the position from a native (non XR) camera
  117762. */
  117763. compensateOnFirstFrame: boolean;
  117764. /**
  117765. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  117766. * @param name the name of the camera
  117767. * @param scene the scene to add the camera to
  117768. * @param _xrSessionManager a constructed xr session manager
  117769. */
  117770. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  117771. /**
  117772. * Return the user's height, unrelated to the current ground.
  117773. * This will be the y position of this camera, when ground level is 0.
  117774. */
  117775. get realWorldHeight(): number;
  117776. /** @hidden */
  117777. _updateForDualEyeDebugging(): void;
  117778. /**
  117779. * Sets this camera's transformation based on a non-vr camera
  117780. * @param otherCamera the non-vr camera to copy the transformation from
  117781. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  117782. */
  117783. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  117784. /**
  117785. * Gets the current instance class name ("WebXRCamera").
  117786. * @returns the class name
  117787. */
  117788. getClassName(): string;
  117789. private _updateFromXRSession;
  117790. private _updateNumberOfRigCameras;
  117791. private _updateReferenceSpace;
  117792. private _updateReferenceSpaceOffset;
  117793. }
  117794. }
  117795. declare module BABYLON {
  117796. /**
  117797. * Defining the interface required for a (webxr) feature
  117798. */
  117799. export interface IWebXRFeature extends IDisposable {
  117800. /**
  117801. * Is this feature attached
  117802. */
  117803. attached: boolean;
  117804. /**
  117805. * Should auto-attach be disabled?
  117806. */
  117807. disableAutoAttach: boolean;
  117808. /**
  117809. * Attach the feature to the session
  117810. * Will usually be called by the features manager
  117811. *
  117812. * @param force should attachment be forced (even when already attached)
  117813. * @returns true if successful.
  117814. */
  117815. attach(force?: boolean): boolean;
  117816. /**
  117817. * Detach the feature from the session
  117818. * Will usually be called by the features manager
  117819. *
  117820. * @returns true if successful.
  117821. */
  117822. detach(): boolean;
  117823. }
  117824. /**
  117825. * A list of the currently available features without referencing them
  117826. */
  117827. export class WebXRFeatureName {
  117828. /**
  117829. * The name of the anchor system feature
  117830. */
  117831. static ANCHOR_SYSTEM: string;
  117832. /**
  117833. * The name of the background remover feature
  117834. */
  117835. static BACKGROUND_REMOVER: string;
  117836. /**
  117837. * The name of the hit test feature
  117838. */
  117839. static HIT_TEST: string;
  117840. /**
  117841. * physics impostors for xr controllers feature
  117842. */
  117843. static PHYSICS_CONTROLLERS: string;
  117844. /**
  117845. * The name of the plane detection feature
  117846. */
  117847. static PLANE_DETECTION: string;
  117848. /**
  117849. * The name of the pointer selection feature
  117850. */
  117851. static POINTER_SELECTION: string;
  117852. /**
  117853. * The name of the teleportation feature
  117854. */
  117855. static TELEPORTATION: string;
  117856. }
  117857. /**
  117858. * Defining the constructor of a feature. Used to register the modules.
  117859. */
  117860. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  117861. /**
  117862. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  117863. * It is mainly used in AR sessions.
  117864. *
  117865. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  117866. */
  117867. export class WebXRFeaturesManager implements IDisposable {
  117868. private _xrSessionManager;
  117869. private static readonly _AvailableFeatures;
  117870. private _features;
  117871. /**
  117872. * constructs a new features manages.
  117873. *
  117874. * @param _xrSessionManager an instance of WebXRSessionManager
  117875. */
  117876. constructor(_xrSessionManager: WebXRSessionManager);
  117877. /**
  117878. * Used to register a module. After calling this function a developer can use this feature in the scene.
  117879. * Mainly used internally.
  117880. *
  117881. * @param featureName the name of the feature to register
  117882. * @param constructorFunction the function used to construct the module
  117883. * @param version the (babylon) version of the module
  117884. * @param stable is that a stable version of this module
  117885. */
  117886. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  117887. /**
  117888. * Returns a constructor of a specific feature.
  117889. *
  117890. * @param featureName the name of the feature to construct
  117891. * @param version the version of the feature to load
  117892. * @param xrSessionManager the xrSessionManager. Used to construct the module
  117893. * @param options optional options provided to the module.
  117894. * @returns a function that, when called, will return a new instance of this feature
  117895. */
  117896. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  117897. /**
  117898. * Can be used to return the list of features currently registered
  117899. *
  117900. * @returns an Array of available features
  117901. */
  117902. static GetAvailableFeatures(): string[];
  117903. /**
  117904. * Gets the versions available for a specific feature
  117905. * @param featureName the name of the feature
  117906. * @returns an array with the available versions
  117907. */
  117908. static GetAvailableVersions(featureName: string): string[];
  117909. /**
  117910. * Return the latest unstable version of this feature
  117911. * @param featureName the name of the feature to search
  117912. * @returns the version number. if not found will return -1
  117913. */
  117914. static GetLatestVersionOfFeature(featureName: string): number;
  117915. /**
  117916. * Return the latest stable version of this feature
  117917. * @param featureName the name of the feature to search
  117918. * @returns the version number. if not found will return -1
  117919. */
  117920. static GetStableVersionOfFeature(featureName: string): number;
  117921. /**
  117922. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  117923. * Can be used during a session to start a feature
  117924. * @param featureName the name of feature to attach
  117925. */
  117926. attachFeature(featureName: string): void;
  117927. /**
  117928. * Can be used inside a session or when the session ends to detach a specific feature
  117929. * @param featureName the name of the feature to detach
  117930. */
  117931. detachFeature(featureName: string): void;
  117932. /**
  117933. * Used to disable an already-enabled feature
  117934. * The feature will be disposed and will be recreated once enabled.
  117935. * @param featureName the feature to disable
  117936. * @returns true if disable was successful
  117937. */
  117938. disableFeature(featureName: string | {
  117939. Name: string;
  117940. }): boolean;
  117941. /**
  117942. * dispose this features manager
  117943. */
  117944. dispose(): void;
  117945. /**
  117946. * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.
  117947. * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.
  117948. *
  117949. * @param featureName the name of the feature to load or the class of the feature
  117950. * @param version optional version to load. if not provided the latest version will be enabled
  117951. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  117952. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  117953. * @returns a new constructed feature or throws an error if feature not found.
  117954. */
  117955. enableFeature(featureName: string | {
  117956. Name: string;
  117957. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  117958. /**
  117959. * get the implementation of an enabled feature.
  117960. * @param featureName the name of the feature to load
  117961. * @returns the feature class, if found
  117962. */
  117963. getEnabledFeature(featureName: string): IWebXRFeature;
  117964. /**
  117965. * Get the list of enabled features
  117966. * @returns an array of enabled features
  117967. */
  117968. getEnabledFeatures(): string[];
  117969. }
  117970. }
  117971. declare module BABYLON {
  117972. /**
  117973. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  117974. * @see https://doc.babylonjs.com/how_to/webxr
  117975. */
  117976. export class WebXRExperienceHelper implements IDisposable {
  117977. private scene;
  117978. private _nonVRCamera;
  117979. private _originalSceneAutoClear;
  117980. private _supported;
  117981. /**
  117982. * Camera used to render xr content
  117983. */
  117984. camera: WebXRCamera;
  117985. /** A features manager for this xr session */
  117986. featuresManager: WebXRFeaturesManager;
  117987. /**
  117988. * Observers registered here will be triggered after the camera's initial transformation is set
  117989. * This can be used to set a different ground level or an extra rotation.
  117990. *
  117991. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  117992. * to the position set after this observable is done executing.
  117993. */
  117994. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  117995. /**
  117996. * Fires when the state of the experience helper has changed
  117997. */
  117998. onStateChangedObservable: Observable<WebXRState>;
  117999. /** Session manager used to keep track of xr session */
  118000. sessionManager: WebXRSessionManager;
  118001. /**
  118002. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  118003. */
  118004. state: WebXRState;
  118005. /**
  118006. * Creates a WebXRExperienceHelper
  118007. * @param scene The scene the helper should be created in
  118008. */
  118009. private constructor();
  118010. /**
  118011. * Creates the experience helper
  118012. * @param scene the scene to attach the experience helper to
  118013. * @returns a promise for the experience helper
  118014. */
  118015. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  118016. /**
  118017. * Disposes of the experience helper
  118018. */
  118019. dispose(): void;
  118020. /**
  118021. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  118022. * @param sessionMode options for the XR session
  118023. * @param referenceSpaceType frame of reference of the XR session
  118024. * @param renderTarget the output canvas that will be used to enter XR mode
  118025. * @returns promise that resolves after xr mode has entered
  118026. */
  118027. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  118028. /**
  118029. * Exits XR mode and returns the scene to its original state
  118030. * @returns promise that resolves after xr mode has exited
  118031. */
  118032. exitXRAsync(): Promise<void>;
  118033. private _nonXRToXRCamera;
  118034. private _setState;
  118035. }
  118036. }
  118037. declare module BABYLON {
  118038. /**
  118039. * X-Y values for axes in WebXR
  118040. */
  118041. export interface IWebXRMotionControllerAxesValue {
  118042. /**
  118043. * The value of the x axis
  118044. */
  118045. x: number;
  118046. /**
  118047. * The value of the y-axis
  118048. */
  118049. y: number;
  118050. }
  118051. /**
  118052. * changed / previous values for the values of this component
  118053. */
  118054. export interface IWebXRMotionControllerComponentChangesValues<T> {
  118055. /**
  118056. * current (this frame) value
  118057. */
  118058. current: T;
  118059. /**
  118060. * previous (last change) value
  118061. */
  118062. previous: T;
  118063. }
  118064. /**
  118065. * Represents changes in the component between current frame and last values recorded
  118066. */
  118067. export interface IWebXRMotionControllerComponentChanges {
  118068. /**
  118069. * will be populated with previous and current values if axes changed
  118070. */
  118071. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  118072. /**
  118073. * will be populated with previous and current values if pressed changed
  118074. */
  118075. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  118076. /**
  118077. * will be populated with previous and current values if touched changed
  118078. */
  118079. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  118080. /**
  118081. * will be populated with previous and current values if value changed
  118082. */
  118083. value?: IWebXRMotionControllerComponentChangesValues<number>;
  118084. }
  118085. /**
  118086. * This class represents a single component (for example button or thumbstick) of a motion controller
  118087. */
  118088. export class WebXRControllerComponent implements IDisposable {
  118089. /**
  118090. * the id of this component
  118091. */
  118092. id: string;
  118093. /**
  118094. * the type of the component
  118095. */
  118096. type: MotionControllerComponentType;
  118097. private _buttonIndex;
  118098. private _axesIndices;
  118099. private _axes;
  118100. private _changes;
  118101. private _currentValue;
  118102. private _hasChanges;
  118103. private _pressed;
  118104. private _touched;
  118105. /**
  118106. * button component type
  118107. */
  118108. static BUTTON_TYPE: MotionControllerComponentType;
  118109. /**
  118110. * squeeze component type
  118111. */
  118112. static SQUEEZE_TYPE: MotionControllerComponentType;
  118113. /**
  118114. * Thumbstick component type
  118115. */
  118116. static THUMBSTICK_TYPE: MotionControllerComponentType;
  118117. /**
  118118. * Touchpad component type
  118119. */
  118120. static TOUCHPAD_TYPE: MotionControllerComponentType;
  118121. /**
  118122. * trigger component type
  118123. */
  118124. static TRIGGER_TYPE: MotionControllerComponentType;
  118125. /**
  118126. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  118127. * the axes data changes
  118128. */
  118129. onAxisValueChangedObservable: Observable<{
  118130. x: number;
  118131. y: number;
  118132. }>;
  118133. /**
  118134. * Observers registered here will be triggered when the state of a button changes
  118135. * State change is either pressed / touched / value
  118136. */
  118137. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  118138. /**
  118139. * Creates a new component for a motion controller.
  118140. * It is created by the motion controller itself
  118141. *
  118142. * @param id the id of this component
  118143. * @param type the type of the component
  118144. * @param _buttonIndex index in the buttons array of the gamepad
  118145. * @param _axesIndices indices of the values in the axes array of the gamepad
  118146. */
  118147. constructor(
  118148. /**
  118149. * the id of this component
  118150. */
  118151. id: string,
  118152. /**
  118153. * the type of the component
  118154. */
  118155. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  118156. /**
  118157. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  118158. */
  118159. get axes(): IWebXRMotionControllerAxesValue;
  118160. /**
  118161. * Get the changes. Elements will be populated only if they changed with their previous and current value
  118162. */
  118163. get changes(): IWebXRMotionControllerComponentChanges;
  118164. /**
  118165. * Return whether or not the component changed the last frame
  118166. */
  118167. get hasChanges(): boolean;
  118168. /**
  118169. * is the button currently pressed
  118170. */
  118171. get pressed(): boolean;
  118172. /**
  118173. * is the button currently touched
  118174. */
  118175. get touched(): boolean;
  118176. /**
  118177. * Get the current value of this component
  118178. */
  118179. get value(): number;
  118180. /**
  118181. * Dispose this component
  118182. */
  118183. dispose(): void;
  118184. /**
  118185. * Are there axes correlating to this component
  118186. * @return true is axes data is available
  118187. */
  118188. isAxes(): boolean;
  118189. /**
  118190. * Is this component a button (hence - pressable)
  118191. * @returns true if can be pressed
  118192. */
  118193. isButton(): boolean;
  118194. /**
  118195. * update this component using the gamepad object it is in. Called on every frame
  118196. * @param nativeController the native gamepad controller object
  118197. */
  118198. update(nativeController: IMinimalMotionControllerObject): void;
  118199. }
  118200. }
  118201. declare module BABYLON {
  118202. /**
  118203. * Class used to represent data loading progression
  118204. */
  118205. export class SceneLoaderProgressEvent {
  118206. /** defines if data length to load can be evaluated */
  118207. readonly lengthComputable: boolean;
  118208. /** defines the loaded data length */
  118209. readonly loaded: number;
  118210. /** defines the data length to load */
  118211. readonly total: number;
  118212. /**
  118213. * Create a new progress event
  118214. * @param lengthComputable defines if data length to load can be evaluated
  118215. * @param loaded defines the loaded data length
  118216. * @param total defines the data length to load
  118217. */
  118218. constructor(
  118219. /** defines if data length to load can be evaluated */
  118220. lengthComputable: boolean,
  118221. /** defines the loaded data length */
  118222. loaded: number,
  118223. /** defines the data length to load */
  118224. total: number);
  118225. /**
  118226. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  118227. * @param event defines the source event
  118228. * @returns a new SceneLoaderProgressEvent
  118229. */
  118230. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  118231. }
  118232. /**
  118233. * Interface used by SceneLoader plugins to define supported file extensions
  118234. */
  118235. export interface ISceneLoaderPluginExtensions {
  118236. /**
  118237. * Defines the list of supported extensions
  118238. */
  118239. [extension: string]: {
  118240. isBinary: boolean;
  118241. };
  118242. }
  118243. /**
  118244. * Interface used by SceneLoader plugin factory
  118245. */
  118246. export interface ISceneLoaderPluginFactory {
  118247. /**
  118248. * Defines the name of the factory
  118249. */
  118250. name: string;
  118251. /**
  118252. * Function called to create a new plugin
  118253. * @return the new plugin
  118254. */
  118255. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  118256. /**
  118257. * The callback that returns true if the data can be directly loaded.
  118258. * @param data string containing the file data
  118259. * @returns if the data can be loaded directly
  118260. */
  118261. canDirectLoad?(data: string): boolean;
  118262. }
  118263. /**
  118264. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  118265. */
  118266. export interface ISceneLoaderPluginBase {
  118267. /**
  118268. * The friendly name of this plugin.
  118269. */
  118270. name: string;
  118271. /**
  118272. * The file extensions supported by this plugin.
  118273. */
  118274. extensions: string | ISceneLoaderPluginExtensions;
  118275. /**
  118276. * The callback called when loading from a url.
  118277. * @param scene scene loading this url
  118278. * @param url url to load
  118279. * @param onSuccess callback called when the file successfully loads
  118280. * @param onProgress callback called while file is loading (if the server supports this mode)
  118281. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  118282. * @param onError callback called when the file fails to load
  118283. * @returns a file request object
  118284. */
  118285. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  118286. /**
  118287. * The callback called when loading from a file object.
  118288. * @param scene scene loading this file
  118289. * @param file defines the file to load
  118290. * @param onSuccess defines the callback to call when data is loaded
  118291. * @param onProgress defines the callback to call during loading process
  118292. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  118293. * @param onError defines the callback to call when an error occurs
  118294. * @returns a file request object
  118295. */
  118296. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  118297. /**
  118298. * The callback that returns true if the data can be directly loaded.
  118299. * @param data string containing the file data
  118300. * @returns if the data can be loaded directly
  118301. */
  118302. canDirectLoad?(data: string): boolean;
  118303. /**
  118304. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  118305. * @param scene scene loading this data
  118306. * @param data string containing the data
  118307. * @returns data to pass to the plugin
  118308. */
  118309. directLoad?(scene: Scene, data: string): any;
  118310. /**
  118311. * The callback that allows custom handling of the root url based on the response url.
  118312. * @param rootUrl the original root url
  118313. * @param responseURL the response url if available
  118314. * @returns the new root url
  118315. */
  118316. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  118317. }
  118318. /**
  118319. * Interface used to define a SceneLoader plugin
  118320. */
  118321. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  118322. /**
  118323. * Import meshes into a scene.
  118324. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  118325. * @param scene The scene to import into
  118326. * @param data The data to import
  118327. * @param rootUrl The root url for scene and resources
  118328. * @param meshes The meshes array to import into
  118329. * @param particleSystems The particle systems array to import into
  118330. * @param skeletons The skeletons array to import into
  118331. * @param onError The callback when import fails
  118332. * @returns True if successful or false otherwise
  118333. */
  118334. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  118335. /**
  118336. * Load into a scene.
  118337. * @param scene The scene to load into
  118338. * @param data The data to import
  118339. * @param rootUrl The root url for scene and resources
  118340. * @param onError The callback when import fails
  118341. * @returns True if successful or false otherwise
  118342. */
  118343. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  118344. /**
  118345. * Load into an asset container.
  118346. * @param scene The scene to load into
  118347. * @param data The data to import
  118348. * @param rootUrl The root url for scene and resources
  118349. * @param onError The callback when import fails
  118350. * @returns The loaded asset container
  118351. */
  118352. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  118353. }
  118354. /**
  118355. * Interface used to define an async SceneLoader plugin
  118356. */
  118357. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  118358. /**
  118359. * Import meshes into a scene.
  118360. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  118361. * @param scene The scene to import into
  118362. * @param data The data to import
  118363. * @param rootUrl The root url for scene and resources
  118364. * @param onProgress The callback when the load progresses
  118365. * @param fileName Defines the name of the file to load
  118366. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  118367. */
  118368. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  118369. meshes: AbstractMesh[];
  118370. particleSystems: IParticleSystem[];
  118371. skeletons: Skeleton[];
  118372. animationGroups: AnimationGroup[];
  118373. }>;
  118374. /**
  118375. * Load into a scene.
  118376. * @param scene The scene to load into
  118377. * @param data The data to import
  118378. * @param rootUrl The root url for scene and resources
  118379. * @param onProgress The callback when the load progresses
  118380. * @param fileName Defines the name of the file to load
  118381. * @returns Nothing
  118382. */
  118383. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  118384. /**
  118385. * Load into an asset container.
  118386. * @param scene The scene to load into
  118387. * @param data The data to import
  118388. * @param rootUrl The root url for scene and resources
  118389. * @param onProgress The callback when the load progresses
  118390. * @param fileName Defines the name of the file to load
  118391. * @returns The loaded asset container
  118392. */
  118393. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  118394. }
  118395. /**
  118396. * Mode that determines how to handle old animation groups before loading new ones.
  118397. */
  118398. export enum SceneLoaderAnimationGroupLoadingMode {
  118399. /**
  118400. * Reset all old animations to initial state then dispose them.
  118401. */
  118402. Clean = 0,
  118403. /**
  118404. * Stop all old animations.
  118405. */
  118406. Stop = 1,
  118407. /**
  118408. * Restart old animations from first frame.
  118409. */
  118410. Sync = 2,
  118411. /**
  118412. * Old animations remains untouched.
  118413. */
  118414. NoSync = 3
  118415. }
  118416. /**
  118417. * Class used to load scene from various file formats using registered plugins
  118418. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  118419. */
  118420. export class SceneLoader {
  118421. /**
  118422. * No logging while loading
  118423. */
  118424. static readonly NO_LOGGING: number;
  118425. /**
  118426. * Minimal logging while loading
  118427. */
  118428. static readonly MINIMAL_LOGGING: number;
  118429. /**
  118430. * Summary logging while loading
  118431. */
  118432. static readonly SUMMARY_LOGGING: number;
  118433. /**
  118434. * Detailled logging while loading
  118435. */
  118436. static readonly DETAILED_LOGGING: number;
  118437. /**
  118438. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  118439. */
  118440. static get ForceFullSceneLoadingForIncremental(): boolean;
  118441. static set ForceFullSceneLoadingForIncremental(value: boolean);
  118442. /**
  118443. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  118444. */
  118445. static get ShowLoadingScreen(): boolean;
  118446. static set ShowLoadingScreen(value: boolean);
  118447. /**
  118448. * Defines the current logging level (while loading the scene)
  118449. * @ignorenaming
  118450. */
  118451. static get loggingLevel(): number;
  118452. static set loggingLevel(value: number);
  118453. /**
  118454. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  118455. */
  118456. static get CleanBoneMatrixWeights(): boolean;
  118457. static set CleanBoneMatrixWeights(value: boolean);
  118458. /**
  118459. * Event raised when a plugin is used to load a scene
  118460. */
  118461. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  118462. private static _registeredPlugins;
  118463. private static _getDefaultPlugin;
  118464. private static _getPluginForExtension;
  118465. private static _getPluginForDirectLoad;
  118466. private static _getPluginForFilename;
  118467. private static _getDirectLoad;
  118468. private static _loadData;
  118469. private static _getFileInfo;
  118470. /**
  118471. * Gets a plugin that can load the given extension
  118472. * @param extension defines the extension to load
  118473. * @returns a plugin or null if none works
  118474. */
  118475. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  118476. /**
  118477. * Gets a boolean indicating that the given extension can be loaded
  118478. * @param extension defines the extension to load
  118479. * @returns true if the extension is supported
  118480. */
  118481. static IsPluginForExtensionAvailable(extension: string): boolean;
  118482. /**
  118483. * Adds a new plugin to the list of registered plugins
  118484. * @param plugin defines the plugin to add
  118485. */
  118486. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  118487. /**
  118488. * Import meshes into a scene
  118489. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  118490. * @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)
  118491. * @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)
  118492. * @param scene the instance of BABYLON.Scene to append to
  118493. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  118494. * @param onProgress a callback with a progress event for each file being loaded
  118495. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118496. * @param pluginExtension the extension used to determine the plugin
  118497. * @returns The loaded plugin
  118498. */
  118499. 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>;
  118500. /**
  118501. * Import meshes into a scene
  118502. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  118503. * @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)
  118504. * @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)
  118505. * @param scene the instance of BABYLON.Scene to append to
  118506. * @param onProgress a callback with a progress event for each file being loaded
  118507. * @param pluginExtension the extension used to determine the plugin
  118508. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  118509. */
  118510. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  118511. meshes: AbstractMesh[];
  118512. particleSystems: IParticleSystem[];
  118513. skeletons: Skeleton[];
  118514. animationGroups: AnimationGroup[];
  118515. }>;
  118516. /**
  118517. * Load a scene
  118518. * @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)
  118519. * @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)
  118520. * @param engine is the instance of BABYLON.Engine to use to create the scene
  118521. * @param onSuccess a callback with the scene when import succeeds
  118522. * @param onProgress a callback with a progress event for each file being loaded
  118523. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118524. * @param pluginExtension the extension used to determine the plugin
  118525. * @returns The loaded plugin
  118526. */
  118527. 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>;
  118528. /**
  118529. * Load a scene
  118530. * @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)
  118531. * @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)
  118532. * @param engine is the instance of BABYLON.Engine to use to create the scene
  118533. * @param onProgress a callback with a progress event for each file being loaded
  118534. * @param pluginExtension the extension used to determine the plugin
  118535. * @returns The loaded scene
  118536. */
  118537. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  118538. /**
  118539. * Append a scene
  118540. * @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)
  118541. * @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)
  118542. * @param scene is the instance of BABYLON.Scene to append to
  118543. * @param onSuccess a callback with the scene when import succeeds
  118544. * @param onProgress a callback with a progress event for each file being loaded
  118545. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118546. * @param pluginExtension the extension used to determine the plugin
  118547. * @returns The loaded plugin
  118548. */
  118549. 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>;
  118550. /**
  118551. * Append a scene
  118552. * @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)
  118553. * @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)
  118554. * @param scene is the instance of BABYLON.Scene to append to
  118555. * @param onProgress a callback with a progress event for each file being loaded
  118556. * @param pluginExtension the extension used to determine the plugin
  118557. * @returns The given scene
  118558. */
  118559. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  118560. /**
  118561. * Load a scene into an asset container
  118562. * @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)
  118563. * @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)
  118564. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  118565. * @param onSuccess a callback with the scene when import succeeds
  118566. * @param onProgress a callback with a progress event for each file being loaded
  118567. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118568. * @param pluginExtension the extension used to determine the plugin
  118569. * @returns The loaded plugin
  118570. */
  118571. 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>;
  118572. /**
  118573. * Load a scene into an asset container
  118574. * @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)
  118575. * @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)
  118576. * @param scene is the instance of Scene to append to
  118577. * @param onProgress a callback with a progress event for each file being loaded
  118578. * @param pluginExtension the extension used to determine the plugin
  118579. * @returns The loaded asset container
  118580. */
  118581. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  118582. /**
  118583. * Import animations from a file into a scene
  118584. * @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)
  118585. * @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)
  118586. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  118587. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  118588. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  118589. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  118590. * @param onSuccess a callback with the scene when import succeeds
  118591. * @param onProgress a callback with a progress event for each file being loaded
  118592. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118593. */
  118594. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  118595. /**
  118596. * Import animations from a file into a scene
  118597. * @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)
  118598. * @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)
  118599. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  118600. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  118601. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  118602. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  118603. * @param onSuccess a callback with the scene when import succeeds
  118604. * @param onProgress a callback with a progress event for each file being loaded
  118605. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118606. * @returns the updated scene with imported animations
  118607. */
  118608. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  118609. }
  118610. }
  118611. declare module BABYLON {
  118612. /**
  118613. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  118614. */
  118615. export type MotionControllerHandness = "none" | "left" | "right";
  118616. /**
  118617. * The type of components available in motion controllers.
  118618. * This is not the name of the component.
  118619. */
  118620. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  118621. /**
  118622. * The state of a controller component
  118623. */
  118624. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  118625. /**
  118626. * The schema of motion controller layout.
  118627. * No object will be initialized using this interface
  118628. * This is used just to define the profile.
  118629. */
  118630. export interface IMotionControllerLayout {
  118631. /**
  118632. * Path to load the assets. Usually relative to the base path
  118633. */
  118634. assetPath: string;
  118635. /**
  118636. * Available components (unsorted)
  118637. */
  118638. components: {
  118639. /**
  118640. * A map of component Ids
  118641. */
  118642. [componentId: string]: {
  118643. /**
  118644. * The type of input the component outputs
  118645. */
  118646. type: MotionControllerComponentType;
  118647. /**
  118648. * The indices of this component in the gamepad object
  118649. */
  118650. gamepadIndices: {
  118651. /**
  118652. * Index of button
  118653. */
  118654. button?: number;
  118655. /**
  118656. * If available, index of x-axis
  118657. */
  118658. xAxis?: number;
  118659. /**
  118660. * If available, index of y-axis
  118661. */
  118662. yAxis?: number;
  118663. };
  118664. /**
  118665. * The mesh's root node name
  118666. */
  118667. rootNodeName: string;
  118668. /**
  118669. * Animation definitions for this model
  118670. */
  118671. visualResponses: {
  118672. [stateKey: string]: {
  118673. /**
  118674. * What property will be animated
  118675. */
  118676. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  118677. /**
  118678. * What states influence this visual response
  118679. */
  118680. states: MotionControllerComponentStateType[];
  118681. /**
  118682. * Type of animation - movement or visibility
  118683. */
  118684. valueNodeProperty: "transform" | "visibility";
  118685. /**
  118686. * Base node name to move. Its position will be calculated according to the min and max nodes
  118687. */
  118688. valueNodeName?: string;
  118689. /**
  118690. * Minimum movement node
  118691. */
  118692. minNodeName?: string;
  118693. /**
  118694. * Max movement node
  118695. */
  118696. maxNodeName?: string;
  118697. };
  118698. };
  118699. /**
  118700. * If touch enabled, what is the name of node to display user feedback
  118701. */
  118702. touchPointNodeName?: string;
  118703. };
  118704. };
  118705. /**
  118706. * Is it xr standard mapping or not
  118707. */
  118708. gamepadMapping: "" | "xr-standard";
  118709. /**
  118710. * Base root node of this entire model
  118711. */
  118712. rootNodeName: string;
  118713. /**
  118714. * Defines the main button component id
  118715. */
  118716. selectComponentId: string;
  118717. }
  118718. /**
  118719. * A definition for the layout map in the input profile
  118720. */
  118721. export interface IMotionControllerLayoutMap {
  118722. /**
  118723. * Layouts with handness type as a key
  118724. */
  118725. [handness: string]: IMotionControllerLayout;
  118726. }
  118727. /**
  118728. * The XR Input profile schema
  118729. * Profiles can be found here:
  118730. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  118731. */
  118732. export interface IMotionControllerProfile {
  118733. /**
  118734. * fallback profiles for this profileId
  118735. */
  118736. fallbackProfileIds: string[];
  118737. /**
  118738. * The layout map, with handness as key
  118739. */
  118740. layouts: IMotionControllerLayoutMap;
  118741. /**
  118742. * The id of this profile
  118743. * correlates to the profile(s) in the xrInput.profiles array
  118744. */
  118745. profileId: string;
  118746. }
  118747. /**
  118748. * A helper-interface for the 3 meshes needed for controller button animation
  118749. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  118750. */
  118751. export interface IMotionControllerButtonMeshMap {
  118752. /**
  118753. * the mesh that defines the pressed value mesh position.
  118754. * This is used to find the max-position of this button
  118755. */
  118756. pressedMesh: AbstractMesh;
  118757. /**
  118758. * the mesh that defines the unpressed value mesh position.
  118759. * This is used to find the min (or initial) position of this button
  118760. */
  118761. unpressedMesh: AbstractMesh;
  118762. /**
  118763. * The mesh that will be changed when value changes
  118764. */
  118765. valueMesh: AbstractMesh;
  118766. }
  118767. /**
  118768. * A helper-interface for the 3 meshes needed for controller axis animation.
  118769. * This will be expanded when touchpad animations are fully supported
  118770. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  118771. */
  118772. export interface IMotionControllerMeshMap {
  118773. /**
  118774. * the mesh that defines the maximum value mesh position.
  118775. */
  118776. maxMesh?: AbstractMesh;
  118777. /**
  118778. * the mesh that defines the minimum value mesh position.
  118779. */
  118780. minMesh?: AbstractMesh;
  118781. /**
  118782. * The mesh that will be changed when axis value changes
  118783. */
  118784. valueMesh: AbstractMesh;
  118785. }
  118786. /**
  118787. * The elements needed for change-detection of the gamepad objects in motion controllers
  118788. */
  118789. export interface IMinimalMotionControllerObject {
  118790. /**
  118791. * Available axes of this controller
  118792. */
  118793. axes: number[];
  118794. /**
  118795. * An array of available buttons
  118796. */
  118797. buttons: Array<{
  118798. /**
  118799. * Value of the button/trigger
  118800. */
  118801. value: number;
  118802. /**
  118803. * If the button/trigger is currently touched
  118804. */
  118805. touched: boolean;
  118806. /**
  118807. * If the button/trigger is currently pressed
  118808. */
  118809. pressed: boolean;
  118810. }>;
  118811. }
  118812. /**
  118813. * An Abstract Motion controller
  118814. * This class receives an xrInput and a profile layout and uses those to initialize the components
  118815. * Each component has an observable to check for changes in value and state
  118816. */
  118817. export abstract class WebXRAbstractMotionController implements IDisposable {
  118818. protected scene: Scene;
  118819. protected layout: IMotionControllerLayout;
  118820. /**
  118821. * The gamepad object correlating to this controller
  118822. */
  118823. gamepadObject: IMinimalMotionControllerObject;
  118824. /**
  118825. * handness (left/right/none) of this controller
  118826. */
  118827. handness: MotionControllerHandness;
  118828. private _initComponent;
  118829. private _modelReady;
  118830. /**
  118831. * A map of components (WebXRControllerComponent) in this motion controller
  118832. * Components have a ComponentType and can also have both button and axis definitions
  118833. */
  118834. readonly components: {
  118835. [id: string]: WebXRControllerComponent;
  118836. };
  118837. /**
  118838. * Disable the model's animation. Can be set at any time.
  118839. */
  118840. disableAnimation: boolean;
  118841. /**
  118842. * Observers registered here will be triggered when the model of this controller is done loading
  118843. */
  118844. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  118845. /**
  118846. * The profile id of this motion controller
  118847. */
  118848. abstract profileId: string;
  118849. /**
  118850. * The root mesh of the model. It is null if the model was not yet initialized
  118851. */
  118852. rootMesh: Nullable<AbstractMesh>;
  118853. /**
  118854. * constructs a new abstract motion controller
  118855. * @param scene the scene to which the model of the controller will be added
  118856. * @param layout The profile layout to load
  118857. * @param gamepadObject The gamepad object correlating to this controller
  118858. * @param handness handness (left/right/none) of this controller
  118859. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  118860. */
  118861. constructor(scene: Scene, layout: IMotionControllerLayout,
  118862. /**
  118863. * The gamepad object correlating to this controller
  118864. */
  118865. gamepadObject: IMinimalMotionControllerObject,
  118866. /**
  118867. * handness (left/right/none) of this controller
  118868. */
  118869. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  118870. /**
  118871. * Dispose this controller, the model mesh and all its components
  118872. */
  118873. dispose(): void;
  118874. /**
  118875. * Returns all components of specific type
  118876. * @param type the type to search for
  118877. * @return an array of components with this type
  118878. */
  118879. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  118880. /**
  118881. * get a component based an its component id as defined in layout.components
  118882. * @param id the id of the component
  118883. * @returns the component correlates to the id or undefined if not found
  118884. */
  118885. getComponent(id: string): WebXRControllerComponent;
  118886. /**
  118887. * Get the list of components available in this motion controller
  118888. * @returns an array of strings correlating to available components
  118889. */
  118890. getComponentIds(): string[];
  118891. /**
  118892. * Get the first component of specific type
  118893. * @param type type of component to find
  118894. * @return a controller component or null if not found
  118895. */
  118896. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  118897. /**
  118898. * Get the main (Select) component of this controller as defined in the layout
  118899. * @returns the main component of this controller
  118900. */
  118901. getMainComponent(): WebXRControllerComponent;
  118902. /**
  118903. * Loads the model correlating to this controller
  118904. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  118905. * @returns A promise fulfilled with the result of the model loading
  118906. */
  118907. loadModel(): Promise<boolean>;
  118908. /**
  118909. * Update this model using the current XRFrame
  118910. * @param xrFrame the current xr frame to use and update the model
  118911. */
  118912. updateFromXRFrame(xrFrame: XRFrame): void;
  118913. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  118914. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  118915. /**
  118916. * Moves the axis on the controller mesh based on its current state
  118917. * @param axis the index of the axis
  118918. * @param axisValue the value of the axis which determines the meshes new position
  118919. * @hidden
  118920. */
  118921. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  118922. /**
  118923. * Update the model itself with the current frame data
  118924. * @param xrFrame the frame to use for updating the model mesh
  118925. */
  118926. protected updateModel(xrFrame: XRFrame): void;
  118927. /**
  118928. * Get the filename and path for this controller's model
  118929. * @returns a map of filename and path
  118930. */
  118931. protected abstract _getFilenameAndPath(): {
  118932. filename: string;
  118933. path: string;
  118934. };
  118935. /**
  118936. * This function is called before the mesh is loaded. It checks for loading constraints.
  118937. * For example, this function can check if the GLB loader is available
  118938. * If this function returns false, the generic controller will be loaded instead
  118939. * @returns Is the client ready to load the mesh
  118940. */
  118941. protected abstract _getModelLoadingConstraints(): boolean;
  118942. /**
  118943. * This function will be called after the model was successfully loaded and can be used
  118944. * for mesh transformations before it is available for the user
  118945. * @param meshes the loaded meshes
  118946. */
  118947. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  118948. /**
  118949. * Set the root mesh for this controller. Important for the WebXR controller class
  118950. * @param meshes the loaded meshes
  118951. */
  118952. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  118953. /**
  118954. * A function executed each frame that updates the mesh (if needed)
  118955. * @param xrFrame the current xrFrame
  118956. */
  118957. protected abstract _updateModel(xrFrame: XRFrame): void;
  118958. private _getGenericFilenameAndPath;
  118959. private _getGenericParentMesh;
  118960. }
  118961. }
  118962. declare module BABYLON {
  118963. /**
  118964. * A generic trigger-only motion controller for WebXR
  118965. */
  118966. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  118967. /**
  118968. * Static version of the profile id of this controller
  118969. */
  118970. static ProfileId: string;
  118971. profileId: string;
  118972. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  118973. protected _getFilenameAndPath(): {
  118974. filename: string;
  118975. path: string;
  118976. };
  118977. protected _getModelLoadingConstraints(): boolean;
  118978. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  118979. protected _setRootMesh(meshes: AbstractMesh[]): void;
  118980. protected _updateModel(): void;
  118981. }
  118982. }
  118983. declare module BABYLON {
  118984. /**
  118985. * Class containing static functions to help procedurally build meshes
  118986. */
  118987. export class SphereBuilder {
  118988. /**
  118989. * Creates a sphere mesh
  118990. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  118991. * * 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`)
  118992. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  118993. * * 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
  118994. * * 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)
  118995. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118996. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118998. * @param name defines the name of the mesh
  118999. * @param options defines the options used to create the mesh
  119000. * @param scene defines the hosting scene
  119001. * @returns the sphere mesh
  119002. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  119003. */
  119004. static CreateSphere(name: string, options: {
  119005. segments?: number;
  119006. diameter?: number;
  119007. diameterX?: number;
  119008. diameterY?: number;
  119009. diameterZ?: number;
  119010. arc?: number;
  119011. slice?: number;
  119012. sideOrientation?: number;
  119013. frontUVs?: Vector4;
  119014. backUVs?: Vector4;
  119015. updatable?: boolean;
  119016. }, scene?: Nullable<Scene>): Mesh;
  119017. }
  119018. }
  119019. declare module BABYLON {
  119020. /**
  119021. * A profiled motion controller has its profile loaded from an online repository.
  119022. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  119023. */
  119024. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  119025. private _repositoryUrl;
  119026. private _buttonMeshMapping;
  119027. private _touchDots;
  119028. /**
  119029. * The profile ID of this controller. Will be populated when the controller initializes.
  119030. */
  119031. profileId: string;
  119032. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  119033. dispose(): void;
  119034. protected _getFilenameAndPath(): {
  119035. filename: string;
  119036. path: string;
  119037. };
  119038. protected _getModelLoadingConstraints(): boolean;
  119039. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  119040. protected _setRootMesh(meshes: AbstractMesh[]): void;
  119041. protected _updateModel(_xrFrame: XRFrame): void;
  119042. }
  119043. }
  119044. declare module BABYLON {
  119045. /**
  119046. * A construction function type to create a new controller based on an xrInput object
  119047. */
  119048. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  119049. /**
  119050. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  119051. *
  119052. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  119053. * it should be replaced with auto-loaded controllers.
  119054. *
  119055. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  119056. */
  119057. export class WebXRMotionControllerManager {
  119058. private static _AvailableControllers;
  119059. private static _Fallbacks;
  119060. private static _ProfileLoadingPromises;
  119061. private static _ProfilesList;
  119062. /**
  119063. * The base URL of the online controller repository. Can be changed at any time.
  119064. */
  119065. static BaseRepositoryUrl: string;
  119066. /**
  119067. * Which repository gets priority - local or online
  119068. */
  119069. static PrioritizeOnlineRepository: boolean;
  119070. /**
  119071. * Use the online repository, or use only locally-defined controllers
  119072. */
  119073. static UseOnlineRepository: boolean;
  119074. /**
  119075. * Clear the cache used for profile loading and reload when requested again
  119076. */
  119077. static ClearProfilesCache(): void;
  119078. /**
  119079. * Register the default fallbacks.
  119080. * This function is called automatically when this file is imported.
  119081. */
  119082. static DefaultFallbacks(): void;
  119083. /**
  119084. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  119085. * @param profileId the profile to which a fallback needs to be found
  119086. * @return an array with corresponding fallback profiles
  119087. */
  119088. static FindFallbackWithProfileId(profileId: string): string[];
  119089. /**
  119090. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  119091. * The order of search:
  119092. *
  119093. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  119094. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  119095. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  119096. * 4) return the generic trigger controller if none were found
  119097. *
  119098. * @param xrInput the xrInput to which a new controller is initialized
  119099. * @param scene the scene to which the model will be added
  119100. * @param forceProfile force a certain profile for this controller
  119101. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  119102. */
  119103. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  119104. /**
  119105. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  119106. *
  119107. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  119108. *
  119109. * @param type the profile type to register
  119110. * @param constructFunction the function to be called when loading this profile
  119111. */
  119112. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  119113. /**
  119114. * Register a fallback to a specific profile.
  119115. * @param profileId the profileId that will receive the fallbacks
  119116. * @param fallbacks A list of fallback profiles
  119117. */
  119118. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  119119. /**
  119120. * Will update the list of profiles available in the repository
  119121. * @return a promise that resolves to a map of profiles available online
  119122. */
  119123. static UpdateProfilesList(): Promise<{
  119124. [profile: string]: string;
  119125. }>;
  119126. private static _LoadProfileFromRepository;
  119127. private static _LoadProfilesFromAvailableControllers;
  119128. }
  119129. }
  119130. declare module BABYLON {
  119131. /**
  119132. * Configuration options for the WebXR controller creation
  119133. */
  119134. export interface IWebXRControllerOptions {
  119135. /**
  119136. * Should the controller mesh be animated when a user interacts with it
  119137. * The pressed buttons / thumbstick and touchpad animations will be disabled
  119138. */
  119139. disableMotionControllerAnimation?: boolean;
  119140. /**
  119141. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  119142. */
  119143. doNotLoadControllerMesh?: boolean;
  119144. /**
  119145. * Force a specific controller type for this controller.
  119146. * This can be used when creating your own profile or when testing different controllers
  119147. */
  119148. forceControllerProfile?: string;
  119149. }
  119150. /**
  119151. * Represents an XR controller
  119152. */
  119153. export class WebXRInputSource {
  119154. private _scene;
  119155. /** The underlying input source for the controller */
  119156. inputSource: XRInputSource;
  119157. private _options;
  119158. private _tmpQuaternion;
  119159. private _tmpVector;
  119160. private _uniqueId;
  119161. /**
  119162. * 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
  119163. */
  119164. grip?: AbstractMesh;
  119165. /**
  119166. * If available, this is the gamepad object related to this controller.
  119167. * Using this object it is possible to get click events and trackpad changes of the
  119168. * webxr controller that is currently being used.
  119169. */
  119170. motionController?: WebXRAbstractMotionController;
  119171. /**
  119172. * Event that fires when the controller is removed/disposed.
  119173. * The object provided as event data is this controller, after associated assets were disposed.
  119174. * uniqueId is still available.
  119175. */
  119176. onDisposeObservable: Observable<WebXRInputSource>;
  119177. /**
  119178. * Will be triggered when the mesh associated with the motion controller is done loading.
  119179. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  119180. * A shortened version of controller -> motion controller -> on mesh loaded.
  119181. */
  119182. onMeshLoadedObservable: Observable<AbstractMesh>;
  119183. /**
  119184. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  119185. */
  119186. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  119187. /**
  119188. * Pointer which can be used to select objects or attach a visible laser to
  119189. */
  119190. pointer: AbstractMesh;
  119191. /**
  119192. * Creates the controller
  119193. * @see https://doc.babylonjs.com/how_to/webxr
  119194. * @param _scene the scene which the controller should be associated to
  119195. * @param inputSource the underlying input source for the controller
  119196. * @param _options options for this controller creation
  119197. */
  119198. constructor(_scene: Scene,
  119199. /** The underlying input source for the controller */
  119200. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  119201. /**
  119202. * Get this controllers unique id
  119203. */
  119204. get uniqueId(): string;
  119205. /**
  119206. * Disposes of the object
  119207. */
  119208. dispose(): void;
  119209. /**
  119210. * Gets a world space ray coming from the pointer or grip
  119211. * @param result the resulting ray
  119212. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  119213. */
  119214. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  119215. /**
  119216. * Updates the controller pose based on the given XRFrame
  119217. * @param xrFrame xr frame to update the pose with
  119218. * @param referenceSpace reference space to use
  119219. */
  119220. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  119221. }
  119222. }
  119223. declare module BABYLON {
  119224. /**
  119225. * The schema for initialization options of the XR Input class
  119226. */
  119227. export interface IWebXRInputOptions {
  119228. /**
  119229. * If set to true no model will be automatically loaded
  119230. */
  119231. doNotLoadControllerMeshes?: boolean;
  119232. /**
  119233. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  119234. * If not found, the xr input profile data will be used.
  119235. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  119236. */
  119237. forceInputProfile?: string;
  119238. /**
  119239. * Do not send a request to the controller repository to load the profile.
  119240. *
  119241. * Instead, use the controllers available in babylon itself.
  119242. */
  119243. disableOnlineControllerRepository?: boolean;
  119244. /**
  119245. * A custom URL for the controllers repository
  119246. */
  119247. customControllersRepositoryURL?: string;
  119248. /**
  119249. * Should the controller model's components not move according to the user input
  119250. */
  119251. disableControllerAnimation?: boolean;
  119252. }
  119253. /**
  119254. * XR input used to track XR inputs such as controllers/rays
  119255. */
  119256. export class WebXRInput implements IDisposable {
  119257. /**
  119258. * the xr session manager for this session
  119259. */
  119260. xrSessionManager: WebXRSessionManager;
  119261. /**
  119262. * the WebXR camera for this session. Mainly used for teleportation
  119263. */
  119264. xrCamera: WebXRCamera;
  119265. private readonly options;
  119266. /**
  119267. * XR controllers being tracked
  119268. */
  119269. controllers: Array<WebXRInputSource>;
  119270. private _frameObserver;
  119271. private _sessionEndedObserver;
  119272. private _sessionInitObserver;
  119273. /**
  119274. * Event when a controller has been connected/added
  119275. */
  119276. onControllerAddedObservable: Observable<WebXRInputSource>;
  119277. /**
  119278. * Event when a controller has been removed/disconnected
  119279. */
  119280. onControllerRemovedObservable: Observable<WebXRInputSource>;
  119281. /**
  119282. * Initializes the WebXRInput
  119283. * @param xrSessionManager the xr session manager for this session
  119284. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  119285. * @param options = initialization options for this xr input
  119286. */
  119287. constructor(
  119288. /**
  119289. * the xr session manager for this session
  119290. */
  119291. xrSessionManager: WebXRSessionManager,
  119292. /**
  119293. * the WebXR camera for this session. Mainly used for teleportation
  119294. */
  119295. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  119296. private _onInputSourcesChange;
  119297. private _addAndRemoveControllers;
  119298. /**
  119299. * Disposes of the object
  119300. */
  119301. dispose(): void;
  119302. }
  119303. }
  119304. declare module BABYLON {
  119305. /**
  119306. * This is the base class for all WebXR features.
  119307. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  119308. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  119309. */
  119310. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  119311. protected _xrSessionManager: WebXRSessionManager;
  119312. private _attached;
  119313. private _removeOnDetach;
  119314. /**
  119315. * Should auto-attach be disabled?
  119316. */
  119317. disableAutoAttach: boolean;
  119318. /**
  119319. * Construct a new (abstract) WebXR feature
  119320. * @param _xrSessionManager the xr session manager for this feature
  119321. */
  119322. constructor(_xrSessionManager: WebXRSessionManager);
  119323. /**
  119324. * Is this feature attached
  119325. */
  119326. get attached(): boolean;
  119327. /**
  119328. * attach this feature
  119329. *
  119330. * @param force should attachment be forced (even when already attached)
  119331. * @returns true if successful, false is failed or already attached
  119332. */
  119333. attach(force?: boolean): boolean;
  119334. /**
  119335. * detach this feature.
  119336. *
  119337. * @returns true if successful, false if failed or already detached
  119338. */
  119339. detach(): boolean;
  119340. /**
  119341. * Dispose this feature and all of the resources attached
  119342. */
  119343. dispose(): void;
  119344. /**
  119345. * This is used to register callbacks that will automatically be removed when detach is called.
  119346. * @param observable the observable to which the observer will be attached
  119347. * @param callback the callback to register
  119348. */
  119349. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  119350. /**
  119351. * Code in this function will be executed on each xrFrame received from the browser.
  119352. * This function will not execute after the feature is detached.
  119353. * @param _xrFrame the current frame
  119354. */
  119355. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  119356. }
  119357. }
  119358. declare module BABYLON {
  119359. /**
  119360. * Renders a layer on top of an existing scene
  119361. */
  119362. export class UtilityLayerRenderer implements IDisposable {
  119363. /** the original scene that will be rendered on top of */
  119364. originalScene: Scene;
  119365. private _pointerCaptures;
  119366. private _lastPointerEvents;
  119367. private static _DefaultUtilityLayer;
  119368. private static _DefaultKeepDepthUtilityLayer;
  119369. private _sharedGizmoLight;
  119370. private _renderCamera;
  119371. /**
  119372. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  119373. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  119374. * @returns the camera that is used when rendering the utility layer
  119375. */
  119376. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  119377. /**
  119378. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  119379. * @param cam the camera that should be used when rendering the utility layer
  119380. */
  119381. setRenderCamera(cam: Nullable<Camera>): void;
  119382. /**
  119383. * @hidden
  119384. * Light which used by gizmos to get light shading
  119385. */
  119386. _getSharedGizmoLight(): HemisphericLight;
  119387. /**
  119388. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  119389. */
  119390. pickUtilitySceneFirst: boolean;
  119391. /**
  119392. * 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)
  119393. */
  119394. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  119395. /**
  119396. * 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)
  119397. */
  119398. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  119399. /**
  119400. * The scene that is rendered on top of the original scene
  119401. */
  119402. utilityLayerScene: Scene;
  119403. /**
  119404. * If the utility layer should automatically be rendered on top of existing scene
  119405. */
  119406. shouldRender: boolean;
  119407. /**
  119408. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  119409. */
  119410. onlyCheckPointerDownEvents: boolean;
  119411. /**
  119412. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  119413. */
  119414. processAllEvents: boolean;
  119415. /**
  119416. * Observable raised when the pointer move from the utility layer scene to the main scene
  119417. */
  119418. onPointerOutObservable: Observable<number>;
  119419. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  119420. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  119421. private _afterRenderObserver;
  119422. private _sceneDisposeObserver;
  119423. private _originalPointerObserver;
  119424. /**
  119425. * Instantiates a UtilityLayerRenderer
  119426. * @param originalScene the original scene that will be rendered on top of
  119427. * @param handleEvents boolean indicating if the utility layer should handle events
  119428. */
  119429. constructor(
  119430. /** the original scene that will be rendered on top of */
  119431. originalScene: Scene, handleEvents?: boolean);
  119432. private _notifyObservers;
  119433. /**
  119434. * Renders the utility layers scene on top of the original scene
  119435. */
  119436. render(): void;
  119437. /**
  119438. * Disposes of the renderer
  119439. */
  119440. dispose(): void;
  119441. private _updateCamera;
  119442. }
  119443. }
  119444. declare module BABYLON {
  119445. /**
  119446. * Options interface for the pointer selection module
  119447. */
  119448. export interface IWebXRControllerPointerSelectionOptions {
  119449. /**
  119450. * if provided, this scene will be used to render meshes.
  119451. */
  119452. customUtilityLayerScene?: Scene;
  119453. /**
  119454. * Disable the pointer up event when the xr controller in screen and gaze mode is disposed (meaning - when the user removed the finger from the screen)
  119455. * If not disabled, the last picked point will be used to execute a pointer up event
  119456. * If disabled, pointer up event will be triggered right after the pointer down event.
  119457. * Used in screen and gaze target ray mode only
  119458. */
  119459. disablePointerUpOnTouchOut: boolean;
  119460. /**
  119461. * For gaze mode (time to select instead of press)
  119462. */
  119463. forceGazeMode: boolean;
  119464. /**
  119465. * Factor to be applied to the pointer-moved function in the gaze mode. How sensitive should the gaze mode be when checking if the pointer moved
  119466. * to start a new countdown to the pointer down event.
  119467. * Defaults to 1.
  119468. */
  119469. gazeModePointerMovedFactor?: number;
  119470. /**
  119471. * Different button type to use instead of the main component
  119472. */
  119473. overrideButtonId?: string;
  119474. /**
  119475. * use this rendering group id for the meshes (optional)
  119476. */
  119477. renderingGroupId?: number;
  119478. /**
  119479. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  119480. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  119481. * 3000 means 3 seconds between pointing at something and selecting it
  119482. */
  119483. timeToSelect?: number;
  119484. /**
  119485. * Should meshes created here be added to a utility layer or the main scene
  119486. */
  119487. useUtilityLayer?: boolean;
  119488. /**
  119489. * the xr input to use with this pointer selection
  119490. */
  119491. xrInput: WebXRInput;
  119492. }
  119493. /**
  119494. * A module that will enable pointer selection for motion controllers of XR Input Sources
  119495. */
  119496. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  119497. private readonly _options;
  119498. private static _idCounter;
  119499. private _attachController;
  119500. private _controllers;
  119501. private _scene;
  119502. private _tmpVectorForPickCompare;
  119503. /**
  119504. * The module's name
  119505. */
  119506. static readonly Name: string;
  119507. /**
  119508. * The (Babylon) version of this module.
  119509. * This is an integer representing the implementation version.
  119510. * This number does not correspond to the WebXR specs version
  119511. */
  119512. static readonly Version: number;
  119513. /**
  119514. * Disable lighting on the laser pointer (so it will always be visible)
  119515. */
  119516. disablePointerLighting: boolean;
  119517. /**
  119518. * Disable lighting on the selection mesh (so it will always be visible)
  119519. */
  119520. disableSelectionMeshLighting: boolean;
  119521. /**
  119522. * Should the laser pointer be displayed
  119523. */
  119524. displayLaserPointer: boolean;
  119525. /**
  119526. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  119527. */
  119528. displaySelectionMesh: boolean;
  119529. /**
  119530. * This color will be set to the laser pointer when selection is triggered
  119531. */
  119532. laserPointerPickedColor: Color3;
  119533. /**
  119534. * Default color of the laser pointer
  119535. */
  119536. lasterPointerDefaultColor: Color3;
  119537. /**
  119538. * default color of the selection ring
  119539. */
  119540. selectionMeshDefaultColor: Color3;
  119541. /**
  119542. * This color will be applied to the selection ring when selection is triggered
  119543. */
  119544. selectionMeshPickedColor: Color3;
  119545. /**
  119546. * Optional filter to be used for ray selection. This predicate shares behavior with
  119547. * scene.pointerMovePredicate which takes priority if it is also assigned.
  119548. */
  119549. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  119550. /**
  119551. * constructs a new background remover module
  119552. * @param _xrSessionManager the session manager for this module
  119553. * @param _options read-only options to be used in this module
  119554. */
  119555. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  119556. /**
  119557. * attach this feature
  119558. * Will usually be called by the features manager
  119559. *
  119560. * @returns true if successful.
  119561. */
  119562. attach(): boolean;
  119563. /**
  119564. * detach this feature.
  119565. * Will usually be called by the features manager
  119566. *
  119567. * @returns true if successful.
  119568. */
  119569. detach(): boolean;
  119570. /**
  119571. * Will get the mesh under a specific pointer.
  119572. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  119573. * @param controllerId the controllerId to check
  119574. * @returns The mesh under pointer or null if no mesh is under the pointer
  119575. */
  119576. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  119577. /**
  119578. * Get the xr controller that correlates to the pointer id in the pointer event
  119579. *
  119580. * @param id the pointer id to search for
  119581. * @returns the controller that correlates to this id or null if not found
  119582. */
  119583. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  119584. protected _onXRFrame(_xrFrame: XRFrame): void;
  119585. private _attachGazeMode;
  119586. private _attachScreenRayMode;
  119587. private _attachTrackedPointerRayMode;
  119588. private _convertNormalToDirectionOfRay;
  119589. private _detachController;
  119590. private _generateNewMeshPair;
  119591. private _pickingMoved;
  119592. private _updatePointerDistance;
  119593. }
  119594. }
  119595. declare module BABYLON {
  119596. /**
  119597. * Button which can be used to enter a different mode of XR
  119598. */
  119599. export class WebXREnterExitUIButton {
  119600. /** button element */
  119601. element: HTMLElement;
  119602. /** XR initialization options for the button */
  119603. sessionMode: XRSessionMode;
  119604. /** Reference space type */
  119605. referenceSpaceType: XRReferenceSpaceType;
  119606. /**
  119607. * Creates a WebXREnterExitUIButton
  119608. * @param element button element
  119609. * @param sessionMode XR initialization session mode
  119610. * @param referenceSpaceType the type of reference space to be used
  119611. */
  119612. constructor(
  119613. /** button element */
  119614. element: HTMLElement,
  119615. /** XR initialization options for the button */
  119616. sessionMode: XRSessionMode,
  119617. /** Reference space type */
  119618. referenceSpaceType: XRReferenceSpaceType);
  119619. /**
  119620. * Extendable function which can be used to update the button's visuals when the state changes
  119621. * @param activeButton the current active button in the UI
  119622. */
  119623. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  119624. }
  119625. /**
  119626. * Options to create the webXR UI
  119627. */
  119628. export class WebXREnterExitUIOptions {
  119629. /**
  119630. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  119631. */
  119632. customButtons?: Array<WebXREnterExitUIButton>;
  119633. /**
  119634. * A reference space type to use when creating the default button.
  119635. * Default is local-floor
  119636. */
  119637. referenceSpaceType?: XRReferenceSpaceType;
  119638. /**
  119639. * Context to enter xr with
  119640. */
  119641. renderTarget?: Nullable<WebXRRenderTarget>;
  119642. /**
  119643. * A session mode to use when creating the default button.
  119644. * Default is immersive-vr
  119645. */
  119646. sessionMode?: XRSessionMode;
  119647. }
  119648. /**
  119649. * UI to allow the user to enter/exit XR mode
  119650. */
  119651. export class WebXREnterExitUI implements IDisposable {
  119652. private scene;
  119653. /** version of the options passed to this UI */
  119654. options: WebXREnterExitUIOptions;
  119655. private _activeButton;
  119656. private _buttons;
  119657. private _overlay;
  119658. /**
  119659. * Fired every time the active button is changed.
  119660. *
  119661. * When xr is entered via a button that launches xr that button will be the callback parameter
  119662. *
  119663. * When exiting xr the callback parameter will be null)
  119664. */
  119665. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  119666. /**
  119667. *
  119668. * @param scene babylon scene object to use
  119669. * @param options (read-only) version of the options passed to this UI
  119670. */
  119671. private constructor();
  119672. /**
  119673. * Creates UI to allow the user to enter/exit XR mode
  119674. * @param scene the scene to add the ui to
  119675. * @param helper the xr experience helper to enter/exit xr with
  119676. * @param options options to configure the UI
  119677. * @returns the created ui
  119678. */
  119679. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  119680. /**
  119681. * Disposes of the XR UI component
  119682. */
  119683. dispose(): void;
  119684. private _updateButtons;
  119685. }
  119686. }
  119687. declare module BABYLON {
  119688. /**
  119689. * Class containing static functions to help procedurally build meshes
  119690. */
  119691. export class LinesBuilder {
  119692. /**
  119693. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  119694. * * 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
  119695. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  119696. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  119697. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  119698. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  119699. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  119700. * * 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
  119701. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  119702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119703. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  119704. * @param name defines the name of the new line system
  119705. * @param options defines the options used to create the line system
  119706. * @param scene defines the hosting scene
  119707. * @returns a new line system mesh
  119708. */
  119709. static CreateLineSystem(name: string, options: {
  119710. lines: Vector3[][];
  119711. updatable?: boolean;
  119712. instance?: Nullable<LinesMesh>;
  119713. colors?: Nullable<Color4[][]>;
  119714. useVertexAlpha?: boolean;
  119715. }, scene: Nullable<Scene>): LinesMesh;
  119716. /**
  119717. * Creates a line mesh
  119718. * 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
  119719. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  119720. * * The parameter `points` is an array successive Vector3
  119721. * * 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
  119722. * * The optional parameter `colors` is an array of successive Color4, one per line point
  119723. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  119724. * * When updating an instance, remember that only point positions can change, not the number of points
  119725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119726. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  119727. * @param name defines the name of the new line system
  119728. * @param options defines the options used to create the line system
  119729. * @param scene defines the hosting scene
  119730. * @returns a new line mesh
  119731. */
  119732. static CreateLines(name: string, options: {
  119733. points: Vector3[];
  119734. updatable?: boolean;
  119735. instance?: Nullable<LinesMesh>;
  119736. colors?: Color4[];
  119737. useVertexAlpha?: boolean;
  119738. }, scene?: Nullable<Scene>): LinesMesh;
  119739. /**
  119740. * Creates a dashed line mesh
  119741. * * 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
  119742. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  119743. * * The parameter `points` is an array successive Vector3
  119744. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  119745. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  119746. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  119747. * * 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
  119748. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  119749. * * When updating an instance, remember that only point positions can change, not the number of points
  119750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119751. * @param name defines the name of the mesh
  119752. * @param options defines the options used to create the mesh
  119753. * @param scene defines the hosting scene
  119754. * @returns the dashed line mesh
  119755. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  119756. */
  119757. static CreateDashedLines(name: string, options: {
  119758. points: Vector3[];
  119759. dashSize?: number;
  119760. gapSize?: number;
  119761. dashNb?: number;
  119762. updatable?: boolean;
  119763. instance?: LinesMesh;
  119764. useVertexAlpha?: boolean;
  119765. }, scene?: Nullable<Scene>): LinesMesh;
  119766. }
  119767. }
  119768. declare module BABYLON {
  119769. /**
  119770. * The options container for the teleportation module
  119771. */
  119772. export interface IWebXRTeleportationOptions {
  119773. /**
  119774. * if provided, this scene will be used to render meshes.
  119775. */
  119776. customUtilityLayerScene?: Scene;
  119777. /**
  119778. * Values to configure the default target mesh
  119779. */
  119780. defaultTargetMeshOptions?: {
  119781. /**
  119782. * Fill color of the teleportation area
  119783. */
  119784. teleportationFillColor?: string;
  119785. /**
  119786. * Border color for the teleportation area
  119787. */
  119788. teleportationBorderColor?: string;
  119789. /**
  119790. * Disable the mesh's animation sequence
  119791. */
  119792. disableAnimation?: boolean;
  119793. /**
  119794. * Disable lighting on the material or the ring and arrow
  119795. */
  119796. disableLighting?: boolean;
  119797. /**
  119798. * Override the default material of the torus and arrow
  119799. */
  119800. torusArrowMaterial?: Material;
  119801. };
  119802. /**
  119803. * A list of meshes to use as floor meshes.
  119804. * Meshes can be added and removed after initializing the feature using the
  119805. * addFloorMesh and removeFloorMesh functions
  119806. * If empty, rotation will still work
  119807. */
  119808. floorMeshes?: AbstractMesh[];
  119809. /**
  119810. * use this rendering group id for the meshes (optional)
  119811. */
  119812. renderingGroupId?: number;
  119813. /**
  119814. * Should teleportation move only to snap points
  119815. */
  119816. snapPointsOnly?: boolean;
  119817. /**
  119818. * An array of points to which the teleportation will snap to.
  119819. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  119820. */
  119821. snapPositions?: Vector3[];
  119822. /**
  119823. * How close should the teleportation ray be in order to snap to position.
  119824. * Default to 0.8 units (meters)
  119825. */
  119826. snapToPositionRadius?: number;
  119827. /**
  119828. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  119829. * If you want to support rotation, make sure your mesh has a direction indicator.
  119830. *
  119831. * When left untouched, the default mesh will be initialized.
  119832. */
  119833. teleportationTargetMesh?: AbstractMesh;
  119834. /**
  119835. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  119836. */
  119837. timeToTeleport?: number;
  119838. /**
  119839. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  119840. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  119841. */
  119842. useMainComponentOnly?: boolean;
  119843. /**
  119844. * Should meshes created here be added to a utility layer or the main scene
  119845. */
  119846. useUtilityLayer?: boolean;
  119847. /**
  119848. * Babylon XR Input class for controller
  119849. */
  119850. xrInput: WebXRInput;
  119851. }
  119852. /**
  119853. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  119854. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  119855. * the input of the attached controllers.
  119856. */
  119857. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  119858. private _options;
  119859. private _controllers;
  119860. private _currentTeleportationControllerId;
  119861. private _floorMeshes;
  119862. private _quadraticBezierCurve;
  119863. private _selectionFeature;
  119864. private _snapToPositions;
  119865. private _snappedToPoint;
  119866. private _teleportationRingMaterial?;
  119867. private _tmpRay;
  119868. private _tmpVector;
  119869. /**
  119870. * The module's name
  119871. */
  119872. static readonly Name: string;
  119873. /**
  119874. * The (Babylon) version of this module.
  119875. * This is an integer representing the implementation version.
  119876. * This number does not correspond to the webxr specs version
  119877. */
  119878. static readonly Version: number;
  119879. /**
  119880. * Is movement backwards enabled
  119881. */
  119882. backwardsMovementEnabled: boolean;
  119883. /**
  119884. * Distance to travel when moving backwards
  119885. */
  119886. backwardsTeleportationDistance: number;
  119887. /**
  119888. * The distance from the user to the inspection point in the direction of the controller
  119889. * A higher number will allow the user to move further
  119890. * defaults to 5 (meters, in xr units)
  119891. */
  119892. parabolicCheckRadius: number;
  119893. /**
  119894. * Should the module support parabolic ray on top of direct ray
  119895. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  119896. * Very helpful when moving between floors / different heights
  119897. */
  119898. parabolicRayEnabled: boolean;
  119899. /**
  119900. * How much rotation should be applied when rotating right and left
  119901. */
  119902. rotationAngle: number;
  119903. /**
  119904. * Is rotation enabled when moving forward?
  119905. * Disabling this feature will prevent the user from deciding the direction when teleporting
  119906. */
  119907. rotationEnabled: boolean;
  119908. /**
  119909. * constructs a new anchor system
  119910. * @param _xrSessionManager an instance of WebXRSessionManager
  119911. * @param _options configuration object for this feature
  119912. */
  119913. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  119914. /**
  119915. * Get the snapPointsOnly flag
  119916. */
  119917. get snapPointsOnly(): boolean;
  119918. /**
  119919. * Sets the snapPointsOnly flag
  119920. * @param snapToPoints should teleportation be exclusively to snap points
  119921. */
  119922. set snapPointsOnly(snapToPoints: boolean);
  119923. /**
  119924. * Add a new mesh to the floor meshes array
  119925. * @param mesh the mesh to use as floor mesh
  119926. */
  119927. addFloorMesh(mesh: AbstractMesh): void;
  119928. /**
  119929. * Add a new snap-to point to fix teleportation to this position
  119930. * @param newSnapPoint The new Snap-To point
  119931. */
  119932. addSnapPoint(newSnapPoint: Vector3): void;
  119933. attach(): boolean;
  119934. detach(): boolean;
  119935. dispose(): void;
  119936. /**
  119937. * Remove a mesh from the floor meshes array
  119938. * @param mesh the mesh to remove
  119939. */
  119940. removeFloorMesh(mesh: AbstractMesh): void;
  119941. /**
  119942. * Remove a mesh from the floor meshes array using its name
  119943. * @param name the mesh name to remove
  119944. */
  119945. removeFloorMeshByName(name: string): void;
  119946. /**
  119947. * This function will iterate through the array, searching for this point or equal to it. It will then remove it from the snap-to array
  119948. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  119949. * @returns was the point found and removed or not
  119950. */
  119951. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  119952. /**
  119953. * This function sets a selection feature that will be disabled when
  119954. * the forward ray is shown and will be reattached when hidden.
  119955. * This is used to remove the selection rays when moving.
  119956. * @param selectionFeature the feature to disable when forward movement is enabled
  119957. */
  119958. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  119959. protected _onXRFrame(_xrFrame: XRFrame): void;
  119960. private _attachController;
  119961. private _createDefaultTargetMesh;
  119962. private _detachController;
  119963. private _findClosestSnapPointWithRadius;
  119964. private _setTargetMeshPosition;
  119965. private _setTargetMeshVisibility;
  119966. private _showParabolicPath;
  119967. private _teleportForward;
  119968. }
  119969. }
  119970. declare module BABYLON {
  119971. /**
  119972. * Options for the default xr helper
  119973. */
  119974. export class WebXRDefaultExperienceOptions {
  119975. /**
  119976. * Enable or disable default UI to enter XR
  119977. */
  119978. disableDefaultUI?: boolean;
  119979. /**
  119980. * Should teleportation not initialize. defaults to false.
  119981. */
  119982. disableTeleportation?: boolean;
  119983. /**
  119984. * Floor meshes that will be used for teleport
  119985. */
  119986. floorMeshes?: Array<AbstractMesh>;
  119987. /**
  119988. * If set to true, the first frame will not be used to reset position
  119989. * The first frame is mainly used when copying transformation from the old camera
  119990. * Mainly used in AR
  119991. */
  119992. ignoreNativeCameraTransformation?: boolean;
  119993. /**
  119994. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  119995. */
  119996. inputOptions?: IWebXRInputOptions;
  119997. /**
  119998. * optional configuration for the output canvas
  119999. */
  120000. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  120001. /**
  120002. * optional UI options. This can be used among other to change session mode and reference space type
  120003. */
  120004. uiOptions?: WebXREnterExitUIOptions;
  120005. /**
  120006. * When loading teleportation and pointer select, use stable versions instead of latest.
  120007. */
  120008. useStablePlugins?: boolean;
  120009. }
  120010. /**
  120011. * Default experience which provides a similar setup to the previous webVRExperience
  120012. */
  120013. export class WebXRDefaultExperience {
  120014. /**
  120015. * Base experience
  120016. */
  120017. baseExperience: WebXRExperienceHelper;
  120018. /**
  120019. * Enables ui for entering/exiting xr
  120020. */
  120021. enterExitUI: WebXREnterExitUI;
  120022. /**
  120023. * Input experience extension
  120024. */
  120025. input: WebXRInput;
  120026. /**
  120027. * Enables laser pointer and selection
  120028. */
  120029. pointerSelection: WebXRControllerPointerSelection;
  120030. /**
  120031. * Default target xr should render to
  120032. */
  120033. renderTarget: WebXRRenderTarget;
  120034. /**
  120035. * Enables teleportation
  120036. */
  120037. teleportation: WebXRMotionControllerTeleportation;
  120038. private constructor();
  120039. /**
  120040. * Creates the default xr experience
  120041. * @param scene scene
  120042. * @param options options for basic configuration
  120043. * @returns resulting WebXRDefaultExperience
  120044. */
  120045. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  120046. /**
  120047. * DIsposes of the experience helper
  120048. */
  120049. dispose(): void;
  120050. }
  120051. }
  120052. declare module BABYLON {
  120053. /**
  120054. * Options to modify the vr teleportation behavior.
  120055. */
  120056. export interface VRTeleportationOptions {
  120057. /**
  120058. * The name of the mesh which should be used as the teleportation floor. (default: null)
  120059. */
  120060. floorMeshName?: string;
  120061. /**
  120062. * A list of meshes to be used as the teleportation floor. (default: empty)
  120063. */
  120064. floorMeshes?: Mesh[];
  120065. /**
  120066. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  120067. */
  120068. teleportationMode?: number;
  120069. /**
  120070. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  120071. */
  120072. teleportationTime?: number;
  120073. /**
  120074. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  120075. */
  120076. teleportationSpeed?: number;
  120077. /**
  120078. * The easing function used in the animation or null for Linear. (default CircleEase)
  120079. */
  120080. easingFunction?: EasingFunction;
  120081. }
  120082. /**
  120083. * Options to modify the vr experience helper's behavior.
  120084. */
  120085. export interface VRExperienceHelperOptions extends WebVROptions {
  120086. /**
  120087. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  120088. */
  120089. createDeviceOrientationCamera?: boolean;
  120090. /**
  120091. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  120092. */
  120093. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  120094. /**
  120095. * Uses the main button on the controller to toggle the laser casted. (default: true)
  120096. */
  120097. laserToggle?: boolean;
  120098. /**
  120099. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  120100. */
  120101. floorMeshes?: Mesh[];
  120102. /**
  120103. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  120104. */
  120105. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  120106. /**
  120107. * Defines if WebXR should be used instead of WebVR (if available)
  120108. */
  120109. useXR?: boolean;
  120110. }
  120111. /**
  120112. * Event containing information after VR has been entered
  120113. */
  120114. export class OnAfterEnteringVRObservableEvent {
  120115. /**
  120116. * If entering vr was successful
  120117. */
  120118. success: boolean;
  120119. }
  120120. /**
  120121. * Helps to quickly add VR support to an existing scene.
  120122. * See http://doc.babylonjs.com/how_to/webvr_helper
  120123. */
  120124. export class VRExperienceHelper {
  120125. /** Options to modify the vr experience helper's behavior. */
  120126. webVROptions: VRExperienceHelperOptions;
  120127. private _scene;
  120128. private _position;
  120129. private _btnVR;
  120130. private _btnVRDisplayed;
  120131. private _webVRsupported;
  120132. private _webVRready;
  120133. private _webVRrequesting;
  120134. private _webVRpresenting;
  120135. private _hasEnteredVR;
  120136. private _fullscreenVRpresenting;
  120137. private _inputElement;
  120138. private _webVRCamera;
  120139. private _vrDeviceOrientationCamera;
  120140. private _deviceOrientationCamera;
  120141. private _existingCamera;
  120142. private _onKeyDown;
  120143. private _onVrDisplayPresentChange;
  120144. private _onVRDisplayChanged;
  120145. private _onVRRequestPresentStart;
  120146. private _onVRRequestPresentComplete;
  120147. /**
  120148. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  120149. */
  120150. enableGazeEvenWhenNoPointerLock: boolean;
  120151. /**
  120152. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  120153. */
  120154. exitVROnDoubleTap: boolean;
  120155. /**
  120156. * Observable raised right before entering VR.
  120157. */
  120158. onEnteringVRObservable: Observable<VRExperienceHelper>;
  120159. /**
  120160. * Observable raised when entering VR has completed.
  120161. */
  120162. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  120163. /**
  120164. * Observable raised when exiting VR.
  120165. */
  120166. onExitingVRObservable: Observable<VRExperienceHelper>;
  120167. /**
  120168. * Observable raised when controller mesh is loaded.
  120169. */
  120170. onControllerMeshLoadedObservable: Observable<WebVRController>;
  120171. /** Return this.onEnteringVRObservable
  120172. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  120173. */
  120174. get onEnteringVR(): Observable<VRExperienceHelper>;
  120175. /** Return this.onExitingVRObservable
  120176. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  120177. */
  120178. get onExitingVR(): Observable<VRExperienceHelper>;
  120179. /** Return this.onControllerMeshLoadedObservable
  120180. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  120181. */
  120182. get onControllerMeshLoaded(): Observable<WebVRController>;
  120183. private _rayLength;
  120184. private _useCustomVRButton;
  120185. private _teleportationRequested;
  120186. private _teleportActive;
  120187. private _floorMeshName;
  120188. private _floorMeshesCollection;
  120189. private _teleportationMode;
  120190. private _teleportationTime;
  120191. private _teleportationSpeed;
  120192. private _teleportationEasing;
  120193. private _rotationAllowed;
  120194. private _teleportBackwardsVector;
  120195. private _teleportationTarget;
  120196. private _isDefaultTeleportationTarget;
  120197. private _postProcessMove;
  120198. private _teleportationFillColor;
  120199. private _teleportationBorderColor;
  120200. private _rotationAngle;
  120201. private _haloCenter;
  120202. private _cameraGazer;
  120203. private _padSensibilityUp;
  120204. private _padSensibilityDown;
  120205. private _leftController;
  120206. private _rightController;
  120207. private _gazeColor;
  120208. private _laserColor;
  120209. private _pickedLaserColor;
  120210. private _pickedGazeColor;
  120211. /**
  120212. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  120213. */
  120214. onNewMeshSelected: Observable<AbstractMesh>;
  120215. /**
  120216. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  120217. * This observable will provide the mesh and the controller used to select the mesh
  120218. */
  120219. onMeshSelectedWithController: Observable<{
  120220. mesh: AbstractMesh;
  120221. controller: WebVRController;
  120222. }>;
  120223. /**
  120224. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  120225. */
  120226. onNewMeshPicked: Observable<PickingInfo>;
  120227. private _circleEase;
  120228. /**
  120229. * Observable raised before camera teleportation
  120230. */
  120231. onBeforeCameraTeleport: Observable<Vector3>;
  120232. /**
  120233. * Observable raised after camera teleportation
  120234. */
  120235. onAfterCameraTeleport: Observable<Vector3>;
  120236. /**
  120237. * Observable raised when current selected mesh gets unselected
  120238. */
  120239. onSelectedMeshUnselected: Observable<AbstractMesh>;
  120240. private _raySelectionPredicate;
  120241. /**
  120242. * To be optionaly changed by user to define custom ray selection
  120243. */
  120244. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  120245. /**
  120246. * To be optionaly changed by user to define custom selection logic (after ray selection)
  120247. */
  120248. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  120249. /**
  120250. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  120251. */
  120252. teleportationEnabled: boolean;
  120253. private _defaultHeight;
  120254. private _teleportationInitialized;
  120255. private _interactionsEnabled;
  120256. private _interactionsRequested;
  120257. private _displayGaze;
  120258. private _displayLaserPointer;
  120259. /**
  120260. * The mesh used to display where the user is going to teleport.
  120261. */
  120262. get teleportationTarget(): Mesh;
  120263. /**
  120264. * Sets the mesh to be used to display where the user is going to teleport.
  120265. */
  120266. set teleportationTarget(value: Mesh);
  120267. /**
  120268. * 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
  120269. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  120270. * See http://doc.babylonjs.com/resources/baking_transformations
  120271. */
  120272. get gazeTrackerMesh(): Mesh;
  120273. set gazeTrackerMesh(value: Mesh);
  120274. /**
  120275. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  120276. */
  120277. updateGazeTrackerScale: boolean;
  120278. /**
  120279. * If the gaze trackers color should be updated when selecting meshes
  120280. */
  120281. updateGazeTrackerColor: boolean;
  120282. /**
  120283. * If the controller laser color should be updated when selecting meshes
  120284. */
  120285. updateControllerLaserColor: boolean;
  120286. /**
  120287. * The gaze tracking mesh corresponding to the left controller
  120288. */
  120289. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  120290. /**
  120291. * The gaze tracking mesh corresponding to the right controller
  120292. */
  120293. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  120294. /**
  120295. * If the ray of the gaze should be displayed.
  120296. */
  120297. get displayGaze(): boolean;
  120298. /**
  120299. * Sets if the ray of the gaze should be displayed.
  120300. */
  120301. set displayGaze(value: boolean);
  120302. /**
  120303. * If the ray of the LaserPointer should be displayed.
  120304. */
  120305. get displayLaserPointer(): boolean;
  120306. /**
  120307. * Sets if the ray of the LaserPointer should be displayed.
  120308. */
  120309. set displayLaserPointer(value: boolean);
  120310. /**
  120311. * The deviceOrientationCamera used as the camera when not in VR.
  120312. */
  120313. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  120314. /**
  120315. * Based on the current WebVR support, returns the current VR camera used.
  120316. */
  120317. get currentVRCamera(): Nullable<Camera>;
  120318. /**
  120319. * The webVRCamera which is used when in VR.
  120320. */
  120321. get webVRCamera(): WebVRFreeCamera;
  120322. /**
  120323. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  120324. */
  120325. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  120326. /**
  120327. * The html button that is used to trigger entering into VR.
  120328. */
  120329. get vrButton(): Nullable<HTMLButtonElement>;
  120330. private get _teleportationRequestInitiated();
  120331. /**
  120332. * Defines whether or not Pointer lock should be requested when switching to
  120333. * full screen.
  120334. */
  120335. requestPointerLockOnFullScreen: boolean;
  120336. /**
  120337. * If asking to force XR, this will be populated with the default xr experience
  120338. */
  120339. xr: WebXRDefaultExperience;
  120340. /**
  120341. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  120342. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  120343. */
  120344. xrTestDone: boolean;
  120345. /**
  120346. * Instantiates a VRExperienceHelper.
  120347. * Helps to quickly add VR support to an existing scene.
  120348. * @param scene The scene the VRExperienceHelper belongs to.
  120349. * @param webVROptions Options to modify the vr experience helper's behavior.
  120350. */
  120351. constructor(scene: Scene,
  120352. /** Options to modify the vr experience helper's behavior. */
  120353. webVROptions?: VRExperienceHelperOptions);
  120354. private completeVRInit;
  120355. private _onDefaultMeshLoaded;
  120356. private _onResize;
  120357. private _onFullscreenChange;
  120358. /**
  120359. * Gets a value indicating if we are currently in VR mode.
  120360. */
  120361. get isInVRMode(): boolean;
  120362. private onVrDisplayPresentChange;
  120363. private onVRDisplayChanged;
  120364. private moveButtonToBottomRight;
  120365. private displayVRButton;
  120366. private updateButtonVisibility;
  120367. private _cachedAngularSensibility;
  120368. /**
  120369. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  120370. * Otherwise, will use the fullscreen API.
  120371. */
  120372. enterVR(): void;
  120373. /**
  120374. * Attempt to exit VR, or fullscreen.
  120375. */
  120376. exitVR(): void;
  120377. /**
  120378. * The position of the vr experience helper.
  120379. */
  120380. get position(): Vector3;
  120381. /**
  120382. * Sets the position of the vr experience helper.
  120383. */
  120384. set position(value: Vector3);
  120385. /**
  120386. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  120387. */
  120388. enableInteractions(): void;
  120389. private get _noControllerIsActive();
  120390. private beforeRender;
  120391. private _isTeleportationFloor;
  120392. /**
  120393. * Adds a floor mesh to be used for teleportation.
  120394. * @param floorMesh the mesh to be used for teleportation.
  120395. */
  120396. addFloorMesh(floorMesh: Mesh): void;
  120397. /**
  120398. * Removes a floor mesh from being used for teleportation.
  120399. * @param floorMesh the mesh to be removed.
  120400. */
  120401. removeFloorMesh(floorMesh: Mesh): void;
  120402. /**
  120403. * Enables interactions and teleportation using the VR controllers and gaze.
  120404. * @param vrTeleportationOptions options to modify teleportation behavior.
  120405. */
  120406. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  120407. private _onNewGamepadConnected;
  120408. private _tryEnableInteractionOnController;
  120409. private _onNewGamepadDisconnected;
  120410. private _enableInteractionOnController;
  120411. private _checkTeleportWithRay;
  120412. private _checkRotate;
  120413. private _checkTeleportBackwards;
  120414. private _enableTeleportationOnController;
  120415. private _createTeleportationCircles;
  120416. private _displayTeleportationTarget;
  120417. private _hideTeleportationTarget;
  120418. private _rotateCamera;
  120419. private _moveTeleportationSelectorTo;
  120420. private _workingVector;
  120421. private _workingQuaternion;
  120422. private _workingMatrix;
  120423. /**
  120424. * Time Constant Teleportation Mode
  120425. */
  120426. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  120427. /**
  120428. * Speed Constant Teleportation Mode
  120429. */
  120430. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  120431. /**
  120432. * Teleports the users feet to the desired location
  120433. * @param location The location where the user's feet should be placed
  120434. */
  120435. teleportCamera(location: Vector3): void;
  120436. private _convertNormalToDirectionOfRay;
  120437. private _castRayAndSelectObject;
  120438. private _notifySelectedMeshUnselected;
  120439. /**
  120440. * Permanently set new colors for the laser pointer
  120441. * @param color the new laser color
  120442. * @param pickedColor the new laser color when picked mesh detected
  120443. */
  120444. setLaserColor(color: Color3, pickedColor?: Color3): void;
  120445. /**
  120446. * Set lighting enabled / disabled on the laser pointer of both controllers
  120447. * @param enabled should the lighting be enabled on the laser pointer
  120448. */
  120449. setLaserLightingState(enabled?: boolean): void;
  120450. /**
  120451. * Permanently set new colors for the gaze pointer
  120452. * @param color the new gaze color
  120453. * @param pickedColor the new gaze color when picked mesh detected
  120454. */
  120455. setGazeColor(color: Color3, pickedColor?: Color3): void;
  120456. /**
  120457. * Sets the color of the laser ray from the vr controllers.
  120458. * @param color new color for the ray.
  120459. */
  120460. changeLaserColor(color: Color3): void;
  120461. /**
  120462. * Sets the color of the ray from the vr headsets gaze.
  120463. * @param color new color for the ray.
  120464. */
  120465. changeGazeColor(color: Color3): void;
  120466. /**
  120467. * Exits VR and disposes of the vr experience helper
  120468. */
  120469. dispose(): void;
  120470. /**
  120471. * Gets the name of the VRExperienceHelper class
  120472. * @returns "VRExperienceHelper"
  120473. */
  120474. getClassName(): string;
  120475. }
  120476. }
  120477. declare module BABYLON {
  120478. /**
  120479. * Contains an array of blocks representing the octree
  120480. */
  120481. export interface IOctreeContainer<T> {
  120482. /**
  120483. * Blocks within the octree
  120484. */
  120485. blocks: Array<OctreeBlock<T>>;
  120486. }
  120487. /**
  120488. * Class used to store a cell in an octree
  120489. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120490. */
  120491. export class OctreeBlock<T> {
  120492. /**
  120493. * Gets the content of the current block
  120494. */
  120495. entries: T[];
  120496. /**
  120497. * Gets the list of block children
  120498. */
  120499. blocks: Array<OctreeBlock<T>>;
  120500. private _depth;
  120501. private _maxDepth;
  120502. private _capacity;
  120503. private _minPoint;
  120504. private _maxPoint;
  120505. private _boundingVectors;
  120506. private _creationFunc;
  120507. /**
  120508. * Creates a new block
  120509. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  120510. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  120511. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  120512. * @param depth defines the current depth of this block in the octree
  120513. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  120514. * @param creationFunc defines a callback to call when an element is added to the block
  120515. */
  120516. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  120517. /**
  120518. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  120519. */
  120520. get capacity(): number;
  120521. /**
  120522. * Gets the minimum vector (in world space) of the block's bounding box
  120523. */
  120524. get minPoint(): Vector3;
  120525. /**
  120526. * Gets the maximum vector (in world space) of the block's bounding box
  120527. */
  120528. get maxPoint(): Vector3;
  120529. /**
  120530. * Add a new element to this block
  120531. * @param entry defines the element to add
  120532. */
  120533. addEntry(entry: T): void;
  120534. /**
  120535. * Remove an element from this block
  120536. * @param entry defines the element to remove
  120537. */
  120538. removeEntry(entry: T): void;
  120539. /**
  120540. * Add an array of elements to this block
  120541. * @param entries defines the array of elements to add
  120542. */
  120543. addEntries(entries: T[]): void;
  120544. /**
  120545. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  120546. * @param frustumPlanes defines the frustum planes to test
  120547. * @param selection defines the array to store current content if selection is positive
  120548. * @param allowDuplicate defines if the selection array can contains duplicated entries
  120549. */
  120550. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  120551. /**
  120552. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  120553. * @param sphereCenter defines the bounding sphere center
  120554. * @param sphereRadius defines the bounding sphere radius
  120555. * @param selection defines the array to store current content if selection is positive
  120556. * @param allowDuplicate defines if the selection array can contains duplicated entries
  120557. */
  120558. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  120559. /**
  120560. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  120561. * @param ray defines the ray to test with
  120562. * @param selection defines the array to store current content if selection is positive
  120563. */
  120564. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  120565. /**
  120566. * Subdivide the content into child blocks (this block will then be empty)
  120567. */
  120568. createInnerBlocks(): void;
  120569. /**
  120570. * @hidden
  120571. */
  120572. 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;
  120573. }
  120574. }
  120575. declare module BABYLON {
  120576. /**
  120577. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  120578. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120579. */
  120580. export class Octree<T> {
  120581. /** 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.) */
  120582. maxDepth: number;
  120583. /**
  120584. * Blocks within the octree containing objects
  120585. */
  120586. blocks: Array<OctreeBlock<T>>;
  120587. /**
  120588. * Content stored in the octree
  120589. */
  120590. dynamicContent: T[];
  120591. private _maxBlockCapacity;
  120592. private _selectionContent;
  120593. private _creationFunc;
  120594. /**
  120595. * Creates a octree
  120596. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120597. * @param creationFunc function to be used to instatiate the octree
  120598. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  120599. * @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.)
  120600. */
  120601. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  120602. /** 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.) */
  120603. maxDepth?: number);
  120604. /**
  120605. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  120606. * @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);
  120607. * @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);
  120608. * @param entries meshes to be added to the octree blocks
  120609. */
  120610. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  120611. /**
  120612. * Adds a mesh to the octree
  120613. * @param entry Mesh to add to the octree
  120614. */
  120615. addMesh(entry: T): void;
  120616. /**
  120617. * Remove an element from the octree
  120618. * @param entry defines the element to remove
  120619. */
  120620. removeMesh(entry: T): void;
  120621. /**
  120622. * Selects an array of meshes within the frustum
  120623. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  120624. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  120625. * @returns array of meshes within the frustum
  120626. */
  120627. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  120628. /**
  120629. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  120630. * @param sphereCenter defines the bounding sphere center
  120631. * @param sphereRadius defines the bounding sphere radius
  120632. * @param allowDuplicate defines if the selection array can contains duplicated entries
  120633. * @returns an array of objects that intersect the sphere
  120634. */
  120635. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  120636. /**
  120637. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  120638. * @param ray defines the ray to test with
  120639. * @returns array of intersected objects
  120640. */
  120641. intersectsRay(ray: Ray): SmartArray<T>;
  120642. /**
  120643. * Adds a mesh into the octree block if it intersects the block
  120644. */
  120645. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  120646. /**
  120647. * Adds a submesh into the octree block if it intersects the block
  120648. */
  120649. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  120650. }
  120651. }
  120652. declare module BABYLON {
  120653. interface Scene {
  120654. /**
  120655. * @hidden
  120656. * Backing Filed
  120657. */
  120658. _selectionOctree: Octree<AbstractMesh>;
  120659. /**
  120660. * Gets the octree used to boost mesh selection (picking)
  120661. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120662. */
  120663. selectionOctree: Octree<AbstractMesh>;
  120664. /**
  120665. * Creates or updates the octree used to boost selection (picking)
  120666. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120667. * @param maxCapacity defines the maximum capacity per leaf
  120668. * @param maxDepth defines the maximum depth of the octree
  120669. * @returns an octree of AbstractMesh
  120670. */
  120671. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  120672. }
  120673. interface AbstractMesh {
  120674. /**
  120675. * @hidden
  120676. * Backing Field
  120677. */
  120678. _submeshesOctree: Octree<SubMesh>;
  120679. /**
  120680. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  120681. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  120682. * @param maxCapacity defines the maximum size of each block (64 by default)
  120683. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  120684. * @returns the new octree
  120685. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  120686. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120687. */
  120688. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  120689. }
  120690. /**
  120691. * Defines the octree scene component responsible to manage any octrees
  120692. * in a given scene.
  120693. */
  120694. export class OctreeSceneComponent {
  120695. /**
  120696. * The component name help to identify the component in the list of scene components.
  120697. */
  120698. readonly name: string;
  120699. /**
  120700. * The scene the component belongs to.
  120701. */
  120702. scene: Scene;
  120703. /**
  120704. * Indicates if the meshes have been checked to make sure they are isEnabled()
  120705. */
  120706. readonly checksIsEnabled: boolean;
  120707. /**
  120708. * Creates a new instance of the component for the given scene
  120709. * @param scene Defines the scene to register the component in
  120710. */
  120711. constructor(scene: Scene);
  120712. /**
  120713. * Registers the component in a given scene
  120714. */
  120715. register(): void;
  120716. /**
  120717. * Return the list of active meshes
  120718. * @returns the list of active meshes
  120719. */
  120720. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  120721. /**
  120722. * Return the list of active sub meshes
  120723. * @param mesh The mesh to get the candidates sub meshes from
  120724. * @returns the list of active sub meshes
  120725. */
  120726. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  120727. private _tempRay;
  120728. /**
  120729. * Return the list of sub meshes intersecting with a given local ray
  120730. * @param mesh defines the mesh to find the submesh for
  120731. * @param localRay defines the ray in local space
  120732. * @returns the list of intersecting sub meshes
  120733. */
  120734. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  120735. /**
  120736. * Return the list of sub meshes colliding with a collider
  120737. * @param mesh defines the mesh to find the submesh for
  120738. * @param collider defines the collider to evaluate the collision against
  120739. * @returns the list of colliding sub meshes
  120740. */
  120741. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  120742. /**
  120743. * Rebuilds the elements related to this component in case of
  120744. * context lost for instance.
  120745. */
  120746. rebuild(): void;
  120747. /**
  120748. * Disposes the component and the associated ressources.
  120749. */
  120750. dispose(): void;
  120751. }
  120752. }
  120753. declare module BABYLON {
  120754. /**
  120755. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  120756. */
  120757. export class Gizmo implements IDisposable {
  120758. /** The utility layer the gizmo will be added to */
  120759. gizmoLayer: UtilityLayerRenderer;
  120760. /**
  120761. * The root mesh of the gizmo
  120762. */
  120763. _rootMesh: Mesh;
  120764. private _attachedMesh;
  120765. /**
  120766. * Ratio for the scale of the gizmo (Default: 1)
  120767. */
  120768. scaleRatio: number;
  120769. /**
  120770. * If a custom mesh has been set (Default: false)
  120771. */
  120772. protected _customMeshSet: boolean;
  120773. /**
  120774. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  120775. * * When set, interactions will be enabled
  120776. */
  120777. get attachedMesh(): Nullable<AbstractMesh>;
  120778. set attachedMesh(value: Nullable<AbstractMesh>);
  120779. /**
  120780. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  120781. * @param mesh The mesh to replace the default mesh of the gizmo
  120782. */
  120783. setCustomMesh(mesh: Mesh): void;
  120784. /**
  120785. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  120786. */
  120787. updateGizmoRotationToMatchAttachedMesh: boolean;
  120788. /**
  120789. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  120790. */
  120791. updateGizmoPositionToMatchAttachedMesh: boolean;
  120792. /**
  120793. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  120794. */
  120795. updateScale: boolean;
  120796. protected _interactionsEnabled: boolean;
  120797. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  120798. private _beforeRenderObserver;
  120799. private _tempVector;
  120800. /**
  120801. * Creates a gizmo
  120802. * @param gizmoLayer The utility layer the gizmo will be added to
  120803. */
  120804. constructor(
  120805. /** The utility layer the gizmo will be added to */
  120806. gizmoLayer?: UtilityLayerRenderer);
  120807. /**
  120808. * Updates the gizmo to match the attached mesh's position/rotation
  120809. */
  120810. protected _update(): void;
  120811. /**
  120812. * Disposes of the gizmo
  120813. */
  120814. dispose(): void;
  120815. }
  120816. }
  120817. declare module BABYLON {
  120818. /**
  120819. * Single plane drag gizmo
  120820. */
  120821. export class PlaneDragGizmo extends Gizmo {
  120822. /**
  120823. * Drag behavior responsible for the gizmos dragging interactions
  120824. */
  120825. dragBehavior: PointerDragBehavior;
  120826. private _pointerObserver;
  120827. /**
  120828. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  120829. */
  120830. snapDistance: number;
  120831. /**
  120832. * Event that fires each time the gizmo snaps to a new location.
  120833. * * snapDistance is the the change in distance
  120834. */
  120835. onSnapObservable: Observable<{
  120836. snapDistance: number;
  120837. }>;
  120838. private _plane;
  120839. private _coloredMaterial;
  120840. private _hoverMaterial;
  120841. private _isEnabled;
  120842. private _parent;
  120843. /** @hidden */
  120844. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  120845. /** @hidden */
  120846. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  120847. /**
  120848. * Creates a PlaneDragGizmo
  120849. * @param gizmoLayer The utility layer the gizmo will be added to
  120850. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  120851. * @param color The color of the gizmo
  120852. */
  120853. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  120854. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  120855. /**
  120856. * If the gizmo is enabled
  120857. */
  120858. set isEnabled(value: boolean);
  120859. get isEnabled(): boolean;
  120860. /**
  120861. * Disposes of the gizmo
  120862. */
  120863. dispose(): void;
  120864. }
  120865. }
  120866. declare module BABYLON {
  120867. /**
  120868. * Gizmo that enables dragging a mesh along 3 axis
  120869. */
  120870. export class PositionGizmo extends Gizmo {
  120871. /**
  120872. * Internal gizmo used for interactions on the x axis
  120873. */
  120874. xGizmo: AxisDragGizmo;
  120875. /**
  120876. * Internal gizmo used for interactions on the y axis
  120877. */
  120878. yGizmo: AxisDragGizmo;
  120879. /**
  120880. * Internal gizmo used for interactions on the z axis
  120881. */
  120882. zGizmo: AxisDragGizmo;
  120883. /**
  120884. * Internal gizmo used for interactions on the yz plane
  120885. */
  120886. xPlaneGizmo: PlaneDragGizmo;
  120887. /**
  120888. * Internal gizmo used for interactions on the xz plane
  120889. */
  120890. yPlaneGizmo: PlaneDragGizmo;
  120891. /**
  120892. * Internal gizmo used for interactions on the xy plane
  120893. */
  120894. zPlaneGizmo: PlaneDragGizmo;
  120895. /**
  120896. * private variables
  120897. */
  120898. private _meshAttached;
  120899. private _updateGizmoRotationToMatchAttachedMesh;
  120900. private _snapDistance;
  120901. private _scaleRatio;
  120902. /** Fires an event when any of it's sub gizmos are dragged */
  120903. onDragStartObservable: Observable<unknown>;
  120904. /** Fires an event when any of it's sub gizmos are released from dragging */
  120905. onDragEndObservable: Observable<unknown>;
  120906. /**
  120907. * If set to true, planar drag is enabled
  120908. */
  120909. private _planarGizmoEnabled;
  120910. get attachedMesh(): Nullable<AbstractMesh>;
  120911. set attachedMesh(mesh: Nullable<AbstractMesh>);
  120912. /**
  120913. * Creates a PositionGizmo
  120914. * @param gizmoLayer The utility layer the gizmo will be added to
  120915. */
  120916. constructor(gizmoLayer?: UtilityLayerRenderer);
  120917. /**
  120918. * If the planar drag gizmo is enabled
  120919. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  120920. */
  120921. set planarGizmoEnabled(value: boolean);
  120922. get planarGizmoEnabled(): boolean;
  120923. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  120924. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  120925. /**
  120926. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  120927. */
  120928. set snapDistance(value: number);
  120929. get snapDistance(): number;
  120930. /**
  120931. * Ratio for the scale of the gizmo (Default: 1)
  120932. */
  120933. set scaleRatio(value: number);
  120934. get scaleRatio(): number;
  120935. /**
  120936. * Disposes of the gizmo
  120937. */
  120938. dispose(): void;
  120939. /**
  120940. * CustomMeshes are not supported by this gizmo
  120941. * @param mesh The mesh to replace the default mesh of the gizmo
  120942. */
  120943. setCustomMesh(mesh: Mesh): void;
  120944. }
  120945. }
  120946. declare module BABYLON {
  120947. /**
  120948. * Single axis drag gizmo
  120949. */
  120950. export class AxisDragGizmo extends Gizmo {
  120951. /**
  120952. * Drag behavior responsible for the gizmos dragging interactions
  120953. */
  120954. dragBehavior: PointerDragBehavior;
  120955. private _pointerObserver;
  120956. /**
  120957. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  120958. */
  120959. snapDistance: number;
  120960. /**
  120961. * Event that fires each time the gizmo snaps to a new location.
  120962. * * snapDistance is the the change in distance
  120963. */
  120964. onSnapObservable: Observable<{
  120965. snapDistance: number;
  120966. }>;
  120967. private _isEnabled;
  120968. private _parent;
  120969. private _arrow;
  120970. private _coloredMaterial;
  120971. private _hoverMaterial;
  120972. /** @hidden */
  120973. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  120974. /** @hidden */
  120975. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  120976. /**
  120977. * Creates an AxisDragGizmo
  120978. * @param gizmoLayer The utility layer the gizmo will be added to
  120979. * @param dragAxis The axis which the gizmo will be able to drag on
  120980. * @param color The color of the gizmo
  120981. */
  120982. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  120983. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  120984. /**
  120985. * If the gizmo is enabled
  120986. */
  120987. set isEnabled(value: boolean);
  120988. get isEnabled(): boolean;
  120989. /**
  120990. * Disposes of the gizmo
  120991. */
  120992. dispose(): void;
  120993. }
  120994. }
  120995. declare module BABYLON.Debug {
  120996. /**
  120997. * The Axes viewer will show 3 axes in a specific point in space
  120998. */
  120999. export class AxesViewer {
  121000. private _xAxis;
  121001. private _yAxis;
  121002. private _zAxis;
  121003. private _scaleLinesFactor;
  121004. private _instanced;
  121005. /**
  121006. * Gets the hosting scene
  121007. */
  121008. scene: Scene;
  121009. /**
  121010. * Gets or sets a number used to scale line length
  121011. */
  121012. scaleLines: number;
  121013. /** Gets the node hierarchy used to render x-axis */
  121014. get xAxis(): TransformNode;
  121015. /** Gets the node hierarchy used to render y-axis */
  121016. get yAxis(): TransformNode;
  121017. /** Gets the node hierarchy used to render z-axis */
  121018. get zAxis(): TransformNode;
  121019. /**
  121020. * Creates a new AxesViewer
  121021. * @param scene defines the hosting scene
  121022. * @param scaleLines defines a number used to scale line length (1 by default)
  121023. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  121024. * @param xAxis defines the node hierarchy used to render the x-axis
  121025. * @param yAxis defines the node hierarchy used to render the y-axis
  121026. * @param zAxis defines the node hierarchy used to render the z-axis
  121027. */
  121028. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  121029. /**
  121030. * Force the viewer to update
  121031. * @param position defines the position of the viewer
  121032. * @param xaxis defines the x axis of the viewer
  121033. * @param yaxis defines the y axis of the viewer
  121034. * @param zaxis defines the z axis of the viewer
  121035. */
  121036. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  121037. /**
  121038. * Creates an instance of this axes viewer.
  121039. * @returns a new axes viewer with instanced meshes
  121040. */
  121041. createInstance(): AxesViewer;
  121042. /** Releases resources */
  121043. dispose(): void;
  121044. private static _SetRenderingGroupId;
  121045. }
  121046. }
  121047. declare module BABYLON.Debug {
  121048. /**
  121049. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  121050. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  121051. */
  121052. export class BoneAxesViewer extends AxesViewer {
  121053. /**
  121054. * Gets or sets the target mesh where to display the axes viewer
  121055. */
  121056. mesh: Nullable<Mesh>;
  121057. /**
  121058. * Gets or sets the target bone where to display the axes viewer
  121059. */
  121060. bone: Nullable<Bone>;
  121061. /** Gets current position */
  121062. pos: Vector3;
  121063. /** Gets direction of X axis */
  121064. xaxis: Vector3;
  121065. /** Gets direction of Y axis */
  121066. yaxis: Vector3;
  121067. /** Gets direction of Z axis */
  121068. zaxis: Vector3;
  121069. /**
  121070. * Creates a new BoneAxesViewer
  121071. * @param scene defines the hosting scene
  121072. * @param bone defines the target bone
  121073. * @param mesh defines the target mesh
  121074. * @param scaleLines defines a scaling factor for line length (1 by default)
  121075. */
  121076. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  121077. /**
  121078. * Force the viewer to update
  121079. */
  121080. update(): void;
  121081. /** Releases resources */
  121082. dispose(): void;
  121083. }
  121084. }
  121085. declare module BABYLON {
  121086. /**
  121087. * Interface used to define scene explorer extensibility option
  121088. */
  121089. export interface IExplorerExtensibilityOption {
  121090. /**
  121091. * Define the option label
  121092. */
  121093. label: string;
  121094. /**
  121095. * Defines the action to execute on click
  121096. */
  121097. action: (entity: any) => void;
  121098. }
  121099. /**
  121100. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  121101. */
  121102. export interface IExplorerExtensibilityGroup {
  121103. /**
  121104. * Defines a predicate to test if a given type mut be extended
  121105. */
  121106. predicate: (entity: any) => boolean;
  121107. /**
  121108. * Gets the list of options added to a type
  121109. */
  121110. entries: IExplorerExtensibilityOption[];
  121111. }
  121112. /**
  121113. * Interface used to define the options to use to create the Inspector
  121114. */
  121115. export interface IInspectorOptions {
  121116. /**
  121117. * Display in overlay mode (default: false)
  121118. */
  121119. overlay?: boolean;
  121120. /**
  121121. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  121122. */
  121123. globalRoot?: HTMLElement;
  121124. /**
  121125. * Display the Scene explorer
  121126. */
  121127. showExplorer?: boolean;
  121128. /**
  121129. * Display the property inspector
  121130. */
  121131. showInspector?: boolean;
  121132. /**
  121133. * Display in embed mode (both panes on the right)
  121134. */
  121135. embedMode?: boolean;
  121136. /**
  121137. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  121138. */
  121139. handleResize?: boolean;
  121140. /**
  121141. * Allow the panes to popup (default: true)
  121142. */
  121143. enablePopup?: boolean;
  121144. /**
  121145. * Allow the panes to be closed by users (default: true)
  121146. */
  121147. enableClose?: boolean;
  121148. /**
  121149. * Optional list of extensibility entries
  121150. */
  121151. explorerExtensibility?: IExplorerExtensibilityGroup[];
  121152. /**
  121153. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  121154. */
  121155. inspectorURL?: string;
  121156. /**
  121157. * Optional initial tab (default to DebugLayerTab.Properties)
  121158. */
  121159. initialTab?: DebugLayerTab;
  121160. }
  121161. interface Scene {
  121162. /**
  121163. * @hidden
  121164. * Backing field
  121165. */
  121166. _debugLayer: DebugLayer;
  121167. /**
  121168. * Gets the debug layer (aka Inspector) associated with the scene
  121169. * @see http://doc.babylonjs.com/features/playground_debuglayer
  121170. */
  121171. debugLayer: DebugLayer;
  121172. }
  121173. /**
  121174. * Enum of inspector action tab
  121175. */
  121176. export enum DebugLayerTab {
  121177. /**
  121178. * Properties tag (default)
  121179. */
  121180. Properties = 0,
  121181. /**
  121182. * Debug tab
  121183. */
  121184. Debug = 1,
  121185. /**
  121186. * Statistics tab
  121187. */
  121188. Statistics = 2,
  121189. /**
  121190. * Tools tab
  121191. */
  121192. Tools = 3,
  121193. /**
  121194. * Settings tab
  121195. */
  121196. Settings = 4
  121197. }
  121198. /**
  121199. * The debug layer (aka Inspector) is the go to tool in order to better understand
  121200. * what is happening in your scene
  121201. * @see http://doc.babylonjs.com/features/playground_debuglayer
  121202. */
  121203. export class DebugLayer {
  121204. /**
  121205. * Define the url to get the inspector script from.
  121206. * By default it uses the babylonjs CDN.
  121207. * @ignoreNaming
  121208. */
  121209. static InspectorURL: string;
  121210. private _scene;
  121211. private BJSINSPECTOR;
  121212. private _onPropertyChangedObservable?;
  121213. /**
  121214. * Observable triggered when a property is changed through the inspector.
  121215. */
  121216. get onPropertyChangedObservable(): any;
  121217. /**
  121218. * Instantiates a new debug layer.
  121219. * The debug layer (aka Inspector) is the go to tool in order to better understand
  121220. * what is happening in your scene
  121221. * @see http://doc.babylonjs.com/features/playground_debuglayer
  121222. * @param scene Defines the scene to inspect
  121223. */
  121224. constructor(scene: Scene);
  121225. /** Creates the inspector window. */
  121226. private _createInspector;
  121227. /**
  121228. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  121229. * @param entity defines the entity to select
  121230. * @param lineContainerTitle defines the specific block to highlight
  121231. */
  121232. select(entity: any, lineContainerTitle?: string): void;
  121233. /** Get the inspector from bundle or global */
  121234. private _getGlobalInspector;
  121235. /**
  121236. * Get if the inspector is visible or not.
  121237. * @returns true if visible otherwise, false
  121238. */
  121239. isVisible(): boolean;
  121240. /**
  121241. * Hide the inspector and close its window.
  121242. */
  121243. hide(): void;
  121244. /**
  121245. * Launch the debugLayer.
  121246. * @param config Define the configuration of the inspector
  121247. * @return a promise fulfilled when the debug layer is visible
  121248. */
  121249. show(config?: IInspectorOptions): Promise<DebugLayer>;
  121250. }
  121251. }
  121252. declare module BABYLON {
  121253. /**
  121254. * Class containing static functions to help procedurally build meshes
  121255. */
  121256. export class BoxBuilder {
  121257. /**
  121258. * Creates a box mesh
  121259. * * The parameter `size` sets the size (float) of each box side (default 1)
  121260. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  121261. * * 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)
  121262. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121263. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121264. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121266. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  121267. * @param name defines the name of the mesh
  121268. * @param options defines the options used to create the mesh
  121269. * @param scene defines the hosting scene
  121270. * @returns the box mesh
  121271. */
  121272. static CreateBox(name: string, options: {
  121273. size?: number;
  121274. width?: number;
  121275. height?: number;
  121276. depth?: number;
  121277. faceUV?: Vector4[];
  121278. faceColors?: Color4[];
  121279. sideOrientation?: number;
  121280. frontUVs?: Vector4;
  121281. backUVs?: Vector4;
  121282. wrap?: boolean;
  121283. topBaseAt?: number;
  121284. bottomBaseAt?: number;
  121285. updatable?: boolean;
  121286. }, scene?: Nullable<Scene>): Mesh;
  121287. }
  121288. }
  121289. declare module BABYLON.Debug {
  121290. /**
  121291. * Used to show the physics impostor around the specific mesh
  121292. */
  121293. export class PhysicsViewer {
  121294. /** @hidden */
  121295. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  121296. /** @hidden */
  121297. protected _meshes: Array<Nullable<AbstractMesh>>;
  121298. /** @hidden */
  121299. protected _scene: Nullable<Scene>;
  121300. /** @hidden */
  121301. protected _numMeshes: number;
  121302. /** @hidden */
  121303. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  121304. private _renderFunction;
  121305. private _utilityLayer;
  121306. private _debugBoxMesh;
  121307. private _debugSphereMesh;
  121308. private _debugCylinderMesh;
  121309. private _debugMaterial;
  121310. private _debugMeshMeshes;
  121311. /**
  121312. * Creates a new PhysicsViewer
  121313. * @param scene defines the hosting scene
  121314. */
  121315. constructor(scene: Scene);
  121316. /** @hidden */
  121317. protected _updateDebugMeshes(): void;
  121318. /**
  121319. * Renders a specified physic impostor
  121320. * @param impostor defines the impostor to render
  121321. * @param targetMesh defines the mesh represented by the impostor
  121322. * @returns the new debug mesh used to render the impostor
  121323. */
  121324. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  121325. /**
  121326. * Hides a specified physic impostor
  121327. * @param impostor defines the impostor to hide
  121328. */
  121329. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  121330. private _getDebugMaterial;
  121331. private _getDebugBoxMesh;
  121332. private _getDebugSphereMesh;
  121333. private _getDebugCylinderMesh;
  121334. private _getDebugMeshMesh;
  121335. private _getDebugMesh;
  121336. /** Releases all resources */
  121337. dispose(): void;
  121338. }
  121339. }
  121340. declare module BABYLON {
  121341. /**
  121342. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  121343. * in order to better appreciate the issue one might have.
  121344. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  121345. */
  121346. export class RayHelper {
  121347. /**
  121348. * Defines the ray we are currently tryin to visualize.
  121349. */
  121350. ray: Nullable<Ray>;
  121351. private _renderPoints;
  121352. private _renderLine;
  121353. private _renderFunction;
  121354. private _scene;
  121355. private _updateToMeshFunction;
  121356. private _attachedToMesh;
  121357. private _meshSpaceDirection;
  121358. private _meshSpaceOrigin;
  121359. /**
  121360. * Helper function to create a colored helper in a scene in one line.
  121361. * @param ray Defines the ray we are currently tryin to visualize
  121362. * @param scene Defines the scene the ray is used in
  121363. * @param color Defines the color we want to see the ray in
  121364. * @returns The newly created ray helper.
  121365. */
  121366. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  121367. /**
  121368. * Instantiate a new ray helper.
  121369. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  121370. * in order to better appreciate the issue one might have.
  121371. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  121372. * @param ray Defines the ray we are currently tryin to visualize
  121373. */
  121374. constructor(ray: Ray);
  121375. /**
  121376. * Shows the ray we are willing to debug.
  121377. * @param scene Defines the scene the ray needs to be rendered in
  121378. * @param color Defines the color the ray needs to be rendered in
  121379. */
  121380. show(scene: Scene, color?: Color3): void;
  121381. /**
  121382. * Hides the ray we are debugging.
  121383. */
  121384. hide(): void;
  121385. private _render;
  121386. /**
  121387. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  121388. * @param mesh Defines the mesh we want the helper attached to
  121389. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  121390. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  121391. * @param length Defines the length of the ray
  121392. */
  121393. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  121394. /**
  121395. * Detach the ray helper from the mesh it has previously been attached to.
  121396. */
  121397. detachFromMesh(): void;
  121398. private _updateToMesh;
  121399. /**
  121400. * Dispose the helper and release its associated resources.
  121401. */
  121402. dispose(): void;
  121403. }
  121404. }
  121405. declare module BABYLON.Debug {
  121406. /**
  121407. * Class used to render a debug view of a given skeleton
  121408. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  121409. */
  121410. export class SkeletonViewer {
  121411. /** defines the skeleton to render */
  121412. skeleton: Skeleton;
  121413. /** defines the mesh attached to the skeleton */
  121414. mesh: AbstractMesh;
  121415. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  121416. autoUpdateBonesMatrices: boolean;
  121417. /** defines the rendering group id to use with the viewer */
  121418. renderingGroupId: number;
  121419. /** Gets or sets the color used to render the skeleton */
  121420. color: Color3;
  121421. private _scene;
  121422. private _debugLines;
  121423. private _debugMesh;
  121424. private _isEnabled;
  121425. private _renderFunction;
  121426. private _utilityLayer;
  121427. /**
  121428. * Returns the mesh used to render the bones
  121429. */
  121430. get debugMesh(): Nullable<LinesMesh>;
  121431. /**
  121432. * Creates a new SkeletonViewer
  121433. * @param skeleton defines the skeleton to render
  121434. * @param mesh defines the mesh attached to the skeleton
  121435. * @param scene defines the hosting scene
  121436. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  121437. * @param renderingGroupId defines the rendering group id to use with the viewer
  121438. */
  121439. constructor(
  121440. /** defines the skeleton to render */
  121441. skeleton: Skeleton,
  121442. /** defines the mesh attached to the skeleton */
  121443. mesh: AbstractMesh, scene: Scene,
  121444. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  121445. autoUpdateBonesMatrices?: boolean,
  121446. /** defines the rendering group id to use with the viewer */
  121447. renderingGroupId?: number);
  121448. /** Gets or sets a boolean indicating if the viewer is enabled */
  121449. set isEnabled(value: boolean);
  121450. get isEnabled(): boolean;
  121451. private _getBonePosition;
  121452. private _getLinesForBonesWithLength;
  121453. private _getLinesForBonesNoLength;
  121454. /** Update the viewer to sync with current skeleton state */
  121455. update(): void;
  121456. /** Release associated resources */
  121457. dispose(): void;
  121458. }
  121459. }
  121460. declare module BABYLON {
  121461. /**
  121462. * This class will take all inputs from Keyboard, Pointer, and
  121463. * any Gamepads and provide a polling system that all devices
  121464. * will use. This class assumes that there will only be one
  121465. * pointer device and one keyboard.
  121466. */
  121467. export class DeviceInputSystem implements IDisposable {
  121468. /** POINTER_DEVICE */
  121469. static readonly POINTER_DEVICE: string;
  121470. /** KEYBOARD_DEVICE */
  121471. static readonly KEYBOARD_DEVICE: string;
  121472. /**
  121473. * Observable to be triggered when a device is connected
  121474. */
  121475. onDeviceConnectedObservable: Observable<string>;
  121476. /**
  121477. * Observable to be triggered when a device is disconnected
  121478. */
  121479. onDeviceDisconnectedObservable: Observable<string>;
  121480. private _inputs;
  121481. private _gamepads;
  121482. private _keyboardActive;
  121483. private _pointerActive;
  121484. private _elementToAttachTo;
  121485. private _keyboardDownEvent;
  121486. private _keyboardUpEvent;
  121487. private _pointerMoveEvent;
  121488. private _pointerDownEvent;
  121489. private _pointerUpEvent;
  121490. private _gamepadConnectedEvent;
  121491. private _gamepadDisconnectedEvent;
  121492. private static _MAX_KEYCODES;
  121493. private static _MAX_POINTER_INPUTS;
  121494. /**
  121495. * Default Constructor
  121496. * @param engine - engine to pull input element from
  121497. */
  121498. constructor(engine: Engine);
  121499. /**
  121500. * Checks for current device input value, given an id and input index
  121501. * @param deviceName Id of connected device
  121502. * @param inputIndex Index of device input
  121503. * @returns Current value of input
  121504. */
  121505. pollInput(deviceName: string, inputIndex: number): Nullable<number>;
  121506. /**
  121507. * Dispose of all the eventlisteners and clears the observables
  121508. */
  121509. dispose(): void;
  121510. /**
  121511. * Add device and inputs to device map
  121512. * @param deviceName Assigned name of device (may be SN)
  121513. * @param numberOfInputs Number of input entries to create for given device
  121514. */
  121515. private _registerDevice;
  121516. /**
  121517. * Given a specific device name, remove that device from the device map
  121518. * @param deviceName Name of device to be removed
  121519. */
  121520. private _unregisterDevice;
  121521. /**
  121522. * Handle all actions that come from keyboard interaction
  121523. */
  121524. private _handleKeyActions;
  121525. /**
  121526. * Handle all actions that come from pointer interaction
  121527. */
  121528. private _handlePointerActions;
  121529. /**
  121530. * Handle all actions that come from gamepad interaction
  121531. */
  121532. private _handleGamepadActions;
  121533. /**
  121534. * Update all non-event based devices with each frame
  121535. */
  121536. private _updateDevice;
  121537. }
  121538. }
  121539. declare module BABYLON {
  121540. /**
  121541. * Options to create the null engine
  121542. */
  121543. export class NullEngineOptions {
  121544. /**
  121545. * Render width (Default: 512)
  121546. */
  121547. renderWidth: number;
  121548. /**
  121549. * Render height (Default: 256)
  121550. */
  121551. renderHeight: number;
  121552. /**
  121553. * Texture size (Default: 512)
  121554. */
  121555. textureSize: number;
  121556. /**
  121557. * If delta time between frames should be constant
  121558. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121559. */
  121560. deterministicLockstep: boolean;
  121561. /**
  121562. * Maximum about of steps between frames (Default: 4)
  121563. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121564. */
  121565. lockstepMaxSteps: number;
  121566. }
  121567. /**
  121568. * The null engine class provides support for headless version of babylon.js.
  121569. * This can be used in server side scenario or for testing purposes
  121570. */
  121571. export class NullEngine extends Engine {
  121572. private _options;
  121573. /**
  121574. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  121575. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121576. * @returns true if engine is in deterministic lock step mode
  121577. */
  121578. isDeterministicLockStep(): boolean;
  121579. /**
  121580. * Gets the max steps when engine is running in deterministic lock step
  121581. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121582. * @returns the max steps
  121583. */
  121584. getLockstepMaxSteps(): number;
  121585. /**
  121586. * Gets the current hardware scaling level.
  121587. * By default the hardware scaling level is computed from the window device ratio.
  121588. * 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.
  121589. * @returns a number indicating the current hardware scaling level
  121590. */
  121591. getHardwareScalingLevel(): number;
  121592. constructor(options?: NullEngineOptions);
  121593. /**
  121594. * Creates a vertex buffer
  121595. * @param vertices the data for the vertex buffer
  121596. * @returns the new WebGL static buffer
  121597. */
  121598. createVertexBuffer(vertices: FloatArray): DataBuffer;
  121599. /**
  121600. * Creates a new index buffer
  121601. * @param indices defines the content of the index buffer
  121602. * @param updatable defines if the index buffer must be updatable
  121603. * @returns a new webGL buffer
  121604. */
  121605. createIndexBuffer(indices: IndicesArray): DataBuffer;
  121606. /**
  121607. * Clear the current render buffer or the current render target (if any is set up)
  121608. * @param color defines the color to use
  121609. * @param backBuffer defines if the back buffer must be cleared
  121610. * @param depth defines if the depth buffer must be cleared
  121611. * @param stencil defines if the stencil buffer must be cleared
  121612. */
  121613. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  121614. /**
  121615. * Gets the current render width
  121616. * @param useScreen defines if screen size must be used (or the current render target if any)
  121617. * @returns a number defining the current render width
  121618. */
  121619. getRenderWidth(useScreen?: boolean): number;
  121620. /**
  121621. * Gets the current render height
  121622. * @param useScreen defines if screen size must be used (or the current render target if any)
  121623. * @returns a number defining the current render height
  121624. */
  121625. getRenderHeight(useScreen?: boolean): number;
  121626. /**
  121627. * Set the WebGL's viewport
  121628. * @param viewport defines the viewport element to be used
  121629. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  121630. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  121631. */
  121632. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  121633. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  121634. /**
  121635. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  121636. * @param pipelineContext defines the pipeline context to use
  121637. * @param uniformsNames defines the list of uniform names
  121638. * @returns an array of webGL uniform locations
  121639. */
  121640. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  121641. /**
  121642. * Gets the lsit of active attributes for a given webGL program
  121643. * @param pipelineContext defines the pipeline context to use
  121644. * @param attributesNames defines the list of attribute names to get
  121645. * @returns an array of indices indicating the offset of each attribute
  121646. */
  121647. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  121648. /**
  121649. * Binds an effect to the webGL context
  121650. * @param effect defines the effect to bind
  121651. */
  121652. bindSamplers(effect: Effect): void;
  121653. /**
  121654. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  121655. * @param effect defines the effect to activate
  121656. */
  121657. enableEffect(effect: Effect): void;
  121658. /**
  121659. * Set various states to the webGL context
  121660. * @param culling defines backface culling state
  121661. * @param zOffset defines the value to apply to zOffset (0 by default)
  121662. * @param force defines if states must be applied even if cache is up to date
  121663. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  121664. */
  121665. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  121666. /**
  121667. * Set the value of an uniform to an array of int32
  121668. * @param uniform defines the webGL uniform location where to store the value
  121669. * @param array defines the array of int32 to store
  121670. */
  121671. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  121672. /**
  121673. * Set the value of an uniform to an array of int32 (stored as vec2)
  121674. * @param uniform defines the webGL uniform location where to store the value
  121675. * @param array defines the array of int32 to store
  121676. */
  121677. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  121678. /**
  121679. * Set the value of an uniform to an array of int32 (stored as vec3)
  121680. * @param uniform defines the webGL uniform location where to store the value
  121681. * @param array defines the array of int32 to store
  121682. */
  121683. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  121684. /**
  121685. * Set the value of an uniform to an array of int32 (stored as vec4)
  121686. * @param uniform defines the webGL uniform location where to store the value
  121687. * @param array defines the array of int32 to store
  121688. */
  121689. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  121690. /**
  121691. * Set the value of an uniform to an array of float32
  121692. * @param uniform defines the webGL uniform location where to store the value
  121693. * @param array defines the array of float32 to store
  121694. */
  121695. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  121696. /**
  121697. * Set the value of an uniform to an array of float32 (stored as vec2)
  121698. * @param uniform defines the webGL uniform location where to store the value
  121699. * @param array defines the array of float32 to store
  121700. */
  121701. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  121702. /**
  121703. * Set the value of an uniform to an array of float32 (stored as vec3)
  121704. * @param uniform defines the webGL uniform location where to store the value
  121705. * @param array defines the array of float32 to store
  121706. */
  121707. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  121708. /**
  121709. * Set the value of an uniform to an array of float32 (stored as vec4)
  121710. * @param uniform defines the webGL uniform location where to store the value
  121711. * @param array defines the array of float32 to store
  121712. */
  121713. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  121714. /**
  121715. * Set the value of an uniform to an array of number
  121716. * @param uniform defines the webGL uniform location where to store the value
  121717. * @param array defines the array of number to store
  121718. */
  121719. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  121720. /**
  121721. * Set the value of an uniform to an array of number (stored as vec2)
  121722. * @param uniform defines the webGL uniform location where to store the value
  121723. * @param array defines the array of number to store
  121724. */
  121725. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  121726. /**
  121727. * Set the value of an uniform to an array of number (stored as vec3)
  121728. * @param uniform defines the webGL uniform location where to store the value
  121729. * @param array defines the array of number to store
  121730. */
  121731. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  121732. /**
  121733. * Set the value of an uniform to an array of number (stored as vec4)
  121734. * @param uniform defines the webGL uniform location where to store the value
  121735. * @param array defines the array of number to store
  121736. */
  121737. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  121738. /**
  121739. * Set the value of an uniform to an array of float32 (stored as matrices)
  121740. * @param uniform defines the webGL uniform location where to store the value
  121741. * @param matrices defines the array of float32 to store
  121742. */
  121743. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  121744. /**
  121745. * Set the value of an uniform to a matrix (3x3)
  121746. * @param uniform defines the webGL uniform location where to store the value
  121747. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  121748. */
  121749. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121750. /**
  121751. * Set the value of an uniform to a matrix (2x2)
  121752. * @param uniform defines the webGL uniform location where to store the value
  121753. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  121754. */
  121755. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121756. /**
  121757. * Set the value of an uniform to a number (float)
  121758. * @param uniform defines the webGL uniform location where to store the value
  121759. * @param value defines the float number to store
  121760. */
  121761. setFloat(uniform: WebGLUniformLocation, value: number): void;
  121762. /**
  121763. * Set the value of an uniform to a vec2
  121764. * @param uniform defines the webGL uniform location where to store the value
  121765. * @param x defines the 1st component of the value
  121766. * @param y defines the 2nd component of the value
  121767. */
  121768. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  121769. /**
  121770. * Set the value of an uniform to a vec3
  121771. * @param uniform defines the webGL uniform location where to store the value
  121772. * @param x defines the 1st component of the value
  121773. * @param y defines the 2nd component of the value
  121774. * @param z defines the 3rd component of the value
  121775. */
  121776. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  121777. /**
  121778. * Set the value of an uniform to a boolean
  121779. * @param uniform defines the webGL uniform location where to store the value
  121780. * @param bool defines the boolean to store
  121781. */
  121782. setBool(uniform: WebGLUniformLocation, bool: number): void;
  121783. /**
  121784. * Set the value of an uniform to a vec4
  121785. * @param uniform defines the webGL uniform location where to store the value
  121786. * @param x defines the 1st component of the value
  121787. * @param y defines the 2nd component of the value
  121788. * @param z defines the 3rd component of the value
  121789. * @param w defines the 4th component of the value
  121790. */
  121791. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  121792. /**
  121793. * Sets the current alpha mode
  121794. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  121795. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  121796. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  121797. */
  121798. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  121799. /**
  121800. * Bind webGl buffers directly to the webGL context
  121801. * @param vertexBuffers defines the vertex buffer to bind
  121802. * @param indexBuffer defines the index buffer to bind
  121803. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  121804. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  121805. * @param effect defines the effect associated with the vertex buffer
  121806. */
  121807. bindBuffers(vertexBuffers: {
  121808. [key: string]: VertexBuffer;
  121809. }, indexBuffer: DataBuffer, effect: Effect): void;
  121810. /**
  121811. * Force the entire cache to be cleared
  121812. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  121813. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  121814. */
  121815. wipeCaches(bruteForce?: boolean): void;
  121816. /**
  121817. * Send a draw order
  121818. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  121819. * @param indexStart defines the starting index
  121820. * @param indexCount defines the number of index to draw
  121821. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121822. */
  121823. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  121824. /**
  121825. * Draw a list of indexed primitives
  121826. * @param fillMode defines the primitive to use
  121827. * @param indexStart defines the starting index
  121828. * @param indexCount defines the number of index to draw
  121829. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121830. */
  121831. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  121832. /**
  121833. * Draw a list of unindexed primitives
  121834. * @param fillMode defines the primitive to use
  121835. * @param verticesStart defines the index of first vertex to draw
  121836. * @param verticesCount defines the count of vertices to draw
  121837. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121838. */
  121839. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  121840. /** @hidden */
  121841. _createTexture(): WebGLTexture;
  121842. /** @hidden */
  121843. _releaseTexture(texture: InternalTexture): void;
  121844. /**
  121845. * Usually called from Texture.ts.
  121846. * Passed information to create a WebGLTexture
  121847. * @param urlArg defines a value which contains one of the following:
  121848. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  121849. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  121850. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  121851. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  121852. * @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)
  121853. * @param scene needed for loading to the correct scene
  121854. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  121855. * @param onLoad optional callback to be called upon successful completion
  121856. * @param onError optional callback to be called upon failure
  121857. * @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
  121858. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  121859. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  121860. * @param forcedExtension defines the extension to use to pick the right loader
  121861. * @param mimeType defines an optional mime type
  121862. * @returns a InternalTexture for assignment back into BABYLON.Texture
  121863. */
  121864. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  121865. /**
  121866. * Creates a new render target texture
  121867. * @param size defines the size of the texture
  121868. * @param options defines the options used to create the texture
  121869. * @returns a new render target texture stored in an InternalTexture
  121870. */
  121871. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  121872. /**
  121873. * Update the sampling mode of a given texture
  121874. * @param samplingMode defines the required sampling mode
  121875. * @param texture defines the texture to update
  121876. */
  121877. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  121878. /**
  121879. * Binds the frame buffer to the specified texture.
  121880. * @param texture The texture to render to or null for the default canvas
  121881. * @param faceIndex The face of the texture to render to in case of cube texture
  121882. * @param requiredWidth The width of the target to render to
  121883. * @param requiredHeight The height of the target to render to
  121884. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  121885. * @param lodLevel defines le lod level to bind to the frame buffer
  121886. */
  121887. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  121888. /**
  121889. * Unbind the current render target texture from the webGL context
  121890. * @param texture defines the render target texture to unbind
  121891. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  121892. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  121893. */
  121894. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  121895. /**
  121896. * Creates a dynamic vertex buffer
  121897. * @param vertices the data for the dynamic vertex buffer
  121898. * @returns the new WebGL dynamic buffer
  121899. */
  121900. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  121901. /**
  121902. * Update the content of a dynamic texture
  121903. * @param texture defines the texture to update
  121904. * @param canvas defines the canvas containing the source
  121905. * @param invertY defines if data must be stored with Y axis inverted
  121906. * @param premulAlpha defines if alpha is stored as premultiplied
  121907. * @param format defines the format of the data
  121908. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  121909. */
  121910. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  121911. /**
  121912. * Gets a boolean indicating if all created effects are ready
  121913. * @returns true if all effects are ready
  121914. */
  121915. areAllEffectsReady(): boolean;
  121916. /**
  121917. * @hidden
  121918. * Get the current error code of the webGL context
  121919. * @returns the error code
  121920. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  121921. */
  121922. getError(): number;
  121923. /** @hidden */
  121924. _getUnpackAlignement(): number;
  121925. /** @hidden */
  121926. _unpackFlipY(value: boolean): void;
  121927. /**
  121928. * Update a dynamic index buffer
  121929. * @param indexBuffer defines the target index buffer
  121930. * @param indices defines the data to update
  121931. * @param offset defines the offset in the target index buffer where update should start
  121932. */
  121933. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  121934. /**
  121935. * Updates a dynamic vertex buffer.
  121936. * @param vertexBuffer the vertex buffer to update
  121937. * @param vertices the data used to update the vertex buffer
  121938. * @param byteOffset the byte offset of the data (optional)
  121939. * @param byteLength the byte length of the data (optional)
  121940. */
  121941. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  121942. /** @hidden */
  121943. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  121944. /** @hidden */
  121945. _bindTexture(channel: number, texture: InternalTexture): void;
  121946. protected _deleteBuffer(buffer: WebGLBuffer): void;
  121947. /**
  121948. * 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
  121949. */
  121950. releaseEffects(): void;
  121951. displayLoadingUI(): void;
  121952. hideLoadingUI(): void;
  121953. /** @hidden */
  121954. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121955. /** @hidden */
  121956. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121957. /** @hidden */
  121958. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121959. /** @hidden */
  121960. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  121961. }
  121962. }
  121963. declare module BABYLON {
  121964. /**
  121965. * @hidden
  121966. **/
  121967. export class _TimeToken {
  121968. _startTimeQuery: Nullable<WebGLQuery>;
  121969. _endTimeQuery: Nullable<WebGLQuery>;
  121970. _timeElapsedQuery: Nullable<WebGLQuery>;
  121971. _timeElapsedQueryEnded: boolean;
  121972. }
  121973. }
  121974. declare module BABYLON {
  121975. /** @hidden */
  121976. export class _OcclusionDataStorage {
  121977. /** @hidden */
  121978. occlusionInternalRetryCounter: number;
  121979. /** @hidden */
  121980. isOcclusionQueryInProgress: boolean;
  121981. /** @hidden */
  121982. isOccluded: boolean;
  121983. /** @hidden */
  121984. occlusionRetryCount: number;
  121985. /** @hidden */
  121986. occlusionType: number;
  121987. /** @hidden */
  121988. occlusionQueryAlgorithmType: number;
  121989. }
  121990. interface Engine {
  121991. /**
  121992. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  121993. * @return the new query
  121994. */
  121995. createQuery(): WebGLQuery;
  121996. /**
  121997. * Delete and release a webGL query
  121998. * @param query defines the query to delete
  121999. * @return the current engine
  122000. */
  122001. deleteQuery(query: WebGLQuery): Engine;
  122002. /**
  122003. * Check if a given query has resolved and got its value
  122004. * @param query defines the query to check
  122005. * @returns true if the query got its value
  122006. */
  122007. isQueryResultAvailable(query: WebGLQuery): boolean;
  122008. /**
  122009. * Gets the value of a given query
  122010. * @param query defines the query to check
  122011. * @returns the value of the query
  122012. */
  122013. getQueryResult(query: WebGLQuery): number;
  122014. /**
  122015. * Initiates an occlusion query
  122016. * @param algorithmType defines the algorithm to use
  122017. * @param query defines the query to use
  122018. * @returns the current engine
  122019. * @see http://doc.babylonjs.com/features/occlusionquery
  122020. */
  122021. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  122022. /**
  122023. * Ends an occlusion query
  122024. * @see http://doc.babylonjs.com/features/occlusionquery
  122025. * @param algorithmType defines the algorithm to use
  122026. * @returns the current engine
  122027. */
  122028. endOcclusionQuery(algorithmType: number): Engine;
  122029. /**
  122030. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  122031. * Please note that only one query can be issued at a time
  122032. * @returns a time token used to track the time span
  122033. */
  122034. startTimeQuery(): Nullable<_TimeToken>;
  122035. /**
  122036. * Ends a time query
  122037. * @param token defines the token used to measure the time span
  122038. * @returns the time spent (in ns)
  122039. */
  122040. endTimeQuery(token: _TimeToken): int;
  122041. /** @hidden */
  122042. _currentNonTimestampToken: Nullable<_TimeToken>;
  122043. /** @hidden */
  122044. _createTimeQuery(): WebGLQuery;
  122045. /** @hidden */
  122046. _deleteTimeQuery(query: WebGLQuery): void;
  122047. /** @hidden */
  122048. _getGlAlgorithmType(algorithmType: number): number;
  122049. /** @hidden */
  122050. _getTimeQueryResult(query: WebGLQuery): any;
  122051. /** @hidden */
  122052. _getTimeQueryAvailability(query: WebGLQuery): any;
  122053. }
  122054. interface AbstractMesh {
  122055. /**
  122056. * Backing filed
  122057. * @hidden
  122058. */
  122059. __occlusionDataStorage: _OcclusionDataStorage;
  122060. /**
  122061. * Access property
  122062. * @hidden
  122063. */
  122064. _occlusionDataStorage: _OcclusionDataStorage;
  122065. /**
  122066. * 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.
  122067. * The default value is -1 which means don't break the query and wait till the result
  122068. * @see http://doc.babylonjs.com/features/occlusionquery
  122069. */
  122070. occlusionRetryCount: number;
  122071. /**
  122072. * 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:
  122073. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  122074. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  122075. * * 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.
  122076. * @see http://doc.babylonjs.com/features/occlusionquery
  122077. */
  122078. occlusionType: number;
  122079. /**
  122080. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  122081. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  122082. * * 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.
  122083. * @see http://doc.babylonjs.com/features/occlusionquery
  122084. */
  122085. occlusionQueryAlgorithmType: number;
  122086. /**
  122087. * 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
  122088. * @see http://doc.babylonjs.com/features/occlusionquery
  122089. */
  122090. isOccluded: boolean;
  122091. /**
  122092. * Flag to check the progress status of the query
  122093. * @see http://doc.babylonjs.com/features/occlusionquery
  122094. */
  122095. isOcclusionQueryInProgress: boolean;
  122096. }
  122097. }
  122098. declare module BABYLON {
  122099. /** @hidden */
  122100. export var _forceTransformFeedbackToBundle: boolean;
  122101. interface Engine {
  122102. /**
  122103. * Creates a webGL transform feedback object
  122104. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  122105. * @returns the webGL transform feedback object
  122106. */
  122107. createTransformFeedback(): WebGLTransformFeedback;
  122108. /**
  122109. * Delete a webGL transform feedback object
  122110. * @param value defines the webGL transform feedback object to delete
  122111. */
  122112. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  122113. /**
  122114. * Bind a webGL transform feedback object to the webgl context
  122115. * @param value defines the webGL transform feedback object to bind
  122116. */
  122117. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  122118. /**
  122119. * Begins a transform feedback operation
  122120. * @param usePoints defines if points or triangles must be used
  122121. */
  122122. beginTransformFeedback(usePoints: boolean): void;
  122123. /**
  122124. * Ends a transform feedback operation
  122125. */
  122126. endTransformFeedback(): void;
  122127. /**
  122128. * Specify the varyings to use with transform feedback
  122129. * @param program defines the associated webGL program
  122130. * @param value defines the list of strings representing the varying names
  122131. */
  122132. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  122133. /**
  122134. * Bind a webGL buffer for a transform feedback operation
  122135. * @param value defines the webGL buffer to bind
  122136. */
  122137. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  122138. }
  122139. }
  122140. declare module BABYLON {
  122141. /**
  122142. * Creation options of the multi render target texture.
  122143. */
  122144. export interface IMultiRenderTargetOptions {
  122145. /**
  122146. * Define if the texture needs to create mip maps after render.
  122147. */
  122148. generateMipMaps?: boolean;
  122149. /**
  122150. * Define the types of all the draw buffers we want to create
  122151. */
  122152. types?: number[];
  122153. /**
  122154. * Define the sampling modes of all the draw buffers we want to create
  122155. */
  122156. samplingModes?: number[];
  122157. /**
  122158. * Define if a depth buffer is required
  122159. */
  122160. generateDepthBuffer?: boolean;
  122161. /**
  122162. * Define if a stencil buffer is required
  122163. */
  122164. generateStencilBuffer?: boolean;
  122165. /**
  122166. * Define if a depth texture is required instead of a depth buffer
  122167. */
  122168. generateDepthTexture?: boolean;
  122169. /**
  122170. * Define the number of desired draw buffers
  122171. */
  122172. textureCount?: number;
  122173. /**
  122174. * Define if aspect ratio should be adapted to the texture or stay the scene one
  122175. */
  122176. doNotChangeAspectRatio?: boolean;
  122177. /**
  122178. * Define the default type of the buffers we are creating
  122179. */
  122180. defaultType?: number;
  122181. }
  122182. /**
  122183. * A multi render target, like a render target provides the ability to render to a texture.
  122184. * Unlike the render target, it can render to several draw buffers in one draw.
  122185. * This is specially interesting in deferred rendering or for any effects requiring more than
  122186. * just one color from a single pass.
  122187. */
  122188. export class MultiRenderTarget extends RenderTargetTexture {
  122189. private _internalTextures;
  122190. private _textures;
  122191. private _multiRenderTargetOptions;
  122192. /**
  122193. * Get if draw buffers are currently supported by the used hardware and browser.
  122194. */
  122195. get isSupported(): boolean;
  122196. /**
  122197. * Get the list of textures generated by the multi render target.
  122198. */
  122199. get textures(): Texture[];
  122200. /**
  122201. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  122202. */
  122203. get depthTexture(): Texture;
  122204. /**
  122205. * Set the wrapping mode on U of all the textures we are rendering to.
  122206. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  122207. */
  122208. set wrapU(wrap: number);
  122209. /**
  122210. * Set the wrapping mode on V of all the textures we are rendering to.
  122211. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  122212. */
  122213. set wrapV(wrap: number);
  122214. /**
  122215. * Instantiate a new multi render target texture.
  122216. * A multi render target, like a render target provides the ability to render to a texture.
  122217. * Unlike the render target, it can render to several draw buffers in one draw.
  122218. * This is specially interesting in deferred rendering or for any effects requiring more than
  122219. * just one color from a single pass.
  122220. * @param name Define the name of the texture
  122221. * @param size Define the size of the buffers to render to
  122222. * @param count Define the number of target we are rendering into
  122223. * @param scene Define the scene the texture belongs to
  122224. * @param options Define the options used to create the multi render target
  122225. */
  122226. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  122227. /** @hidden */
  122228. _rebuild(): void;
  122229. private _createInternalTextures;
  122230. private _createTextures;
  122231. /**
  122232. * Define the number of samples used if MSAA is enabled.
  122233. */
  122234. get samples(): number;
  122235. set samples(value: number);
  122236. /**
  122237. * Resize all the textures in the multi render target.
  122238. * Be carrefull as it will recreate all the data in the new texture.
  122239. * @param size Define the new size
  122240. */
  122241. resize(size: any): void;
  122242. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  122243. /**
  122244. * Dispose the render targets and their associated resources
  122245. */
  122246. dispose(): void;
  122247. /**
  122248. * Release all the underlying texture used as draw buffers.
  122249. */
  122250. releaseInternalTextures(): void;
  122251. }
  122252. }
  122253. declare module BABYLON {
  122254. interface ThinEngine {
  122255. /**
  122256. * Unbind a list of render target textures from the webGL context
  122257. * This is used only when drawBuffer extension or webGL2 are active
  122258. * @param textures defines the render target textures to unbind
  122259. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  122260. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  122261. */
  122262. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  122263. /**
  122264. * Create a multi render target texture
  122265. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  122266. * @param size defines the size of the texture
  122267. * @param options defines the creation options
  122268. * @returns the cube texture as an InternalTexture
  122269. */
  122270. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  122271. /**
  122272. * Update the sample count for a given multiple render target texture
  122273. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  122274. * @param textures defines the textures to update
  122275. * @param samples defines the sample count to set
  122276. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  122277. */
  122278. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  122279. }
  122280. }
  122281. declare module BABYLON {
  122282. /**
  122283. * Class used to define an additional view for the engine
  122284. * @see https://doc.babylonjs.com/how_to/multi_canvases
  122285. */
  122286. export class EngineView {
  122287. /** Defines the canvas where to render the view */
  122288. target: HTMLCanvasElement;
  122289. /** Defines an optional camera used to render the view (will use active camera else) */
  122290. camera?: Camera;
  122291. }
  122292. interface Engine {
  122293. /**
  122294. * Gets or sets the HTML element to use for attaching events
  122295. */
  122296. inputElement: Nullable<HTMLElement>;
  122297. /**
  122298. * Gets the current engine view
  122299. * @see https://doc.babylonjs.com/how_to/multi_canvases
  122300. */
  122301. activeView: Nullable<EngineView>;
  122302. /** Gets or sets the list of views */
  122303. views: EngineView[];
  122304. /**
  122305. * Register a new child canvas
  122306. * @param canvas defines the canvas to register
  122307. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  122308. * @returns the associated view
  122309. */
  122310. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  122311. /**
  122312. * Remove a registered child canvas
  122313. * @param canvas defines the canvas to remove
  122314. * @returns the current engine
  122315. */
  122316. unRegisterView(canvas: HTMLCanvasElement): Engine;
  122317. }
  122318. }
  122319. declare module BABYLON {
  122320. interface Engine {
  122321. /** @hidden */
  122322. _excludedCompressedTextures: string[];
  122323. /** @hidden */
  122324. _textureFormatInUse: string;
  122325. /**
  122326. * Gets the list of texture formats supported
  122327. */
  122328. readonly texturesSupported: Array<string>;
  122329. /**
  122330. * Gets the texture format in use
  122331. */
  122332. readonly textureFormatInUse: Nullable<string>;
  122333. /**
  122334. * Set the compressed texture extensions or file names to skip.
  122335. *
  122336. * @param skippedFiles defines the list of those texture files you want to skip
  122337. * Example: [".dds", ".env", "myfile.png"]
  122338. */
  122339. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  122340. /**
  122341. * Set the compressed texture format to use, based on the formats you have, and the formats
  122342. * supported by the hardware / browser.
  122343. *
  122344. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  122345. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  122346. * to API arguments needed to compressed textures. This puts the burden on the container
  122347. * generator to house the arcane code for determining these for current & future formats.
  122348. *
  122349. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  122350. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  122351. *
  122352. * Note: The result of this call is not taken into account when a texture is base64.
  122353. *
  122354. * @param formatsAvailable defines the list of those format families you have created
  122355. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  122356. *
  122357. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  122358. * @returns The extension selected.
  122359. */
  122360. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  122361. }
  122362. }
  122363. declare module BABYLON {
  122364. /**
  122365. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  122366. */
  122367. export interface CubeMapInfo {
  122368. /**
  122369. * The pixel array for the front face.
  122370. * This is stored in format, left to right, up to down format.
  122371. */
  122372. front: Nullable<ArrayBufferView>;
  122373. /**
  122374. * The pixel array for the back face.
  122375. * This is stored in format, left to right, up to down format.
  122376. */
  122377. back: Nullable<ArrayBufferView>;
  122378. /**
  122379. * The pixel array for the left face.
  122380. * This is stored in format, left to right, up to down format.
  122381. */
  122382. left: Nullable<ArrayBufferView>;
  122383. /**
  122384. * The pixel array for the right face.
  122385. * This is stored in format, left to right, up to down format.
  122386. */
  122387. right: Nullable<ArrayBufferView>;
  122388. /**
  122389. * The pixel array for the up face.
  122390. * This is stored in format, left to right, up to down format.
  122391. */
  122392. up: Nullable<ArrayBufferView>;
  122393. /**
  122394. * The pixel array for the down face.
  122395. * This is stored in format, left to right, up to down format.
  122396. */
  122397. down: Nullable<ArrayBufferView>;
  122398. /**
  122399. * The size of the cubemap stored.
  122400. *
  122401. * Each faces will be size * size pixels.
  122402. */
  122403. size: number;
  122404. /**
  122405. * The format of the texture.
  122406. *
  122407. * RGBA, RGB.
  122408. */
  122409. format: number;
  122410. /**
  122411. * The type of the texture data.
  122412. *
  122413. * UNSIGNED_INT, FLOAT.
  122414. */
  122415. type: number;
  122416. /**
  122417. * Specifies whether the texture is in gamma space.
  122418. */
  122419. gammaSpace: boolean;
  122420. }
  122421. /**
  122422. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  122423. */
  122424. export class PanoramaToCubeMapTools {
  122425. private static FACE_FRONT;
  122426. private static FACE_BACK;
  122427. private static FACE_RIGHT;
  122428. private static FACE_LEFT;
  122429. private static FACE_DOWN;
  122430. private static FACE_UP;
  122431. /**
  122432. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  122433. *
  122434. * @param float32Array The source data.
  122435. * @param inputWidth The width of the input panorama.
  122436. * @param inputHeight The height of the input panorama.
  122437. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  122438. * @return The cubemap data
  122439. */
  122440. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  122441. private static CreateCubemapTexture;
  122442. private static CalcProjectionSpherical;
  122443. }
  122444. }
  122445. declare module BABYLON {
  122446. /**
  122447. * Helper class dealing with the extraction of spherical polynomial dataArray
  122448. * from a cube map.
  122449. */
  122450. export class CubeMapToSphericalPolynomialTools {
  122451. private static FileFaces;
  122452. /**
  122453. * Converts a texture to the according Spherical Polynomial data.
  122454. * This extracts the first 3 orders only as they are the only one used in the lighting.
  122455. *
  122456. * @param texture The texture to extract the information from.
  122457. * @return The Spherical Polynomial data.
  122458. */
  122459. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  122460. /**
  122461. * Converts a cubemap to the according Spherical Polynomial data.
  122462. * This extracts the first 3 orders only as they are the only one used in the lighting.
  122463. *
  122464. * @param cubeInfo The Cube map to extract the information from.
  122465. * @return The Spherical Polynomial data.
  122466. */
  122467. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  122468. }
  122469. }
  122470. declare module BABYLON {
  122471. interface BaseTexture {
  122472. /**
  122473. * Get the polynomial representation of the texture data.
  122474. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  122475. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  122476. */
  122477. sphericalPolynomial: Nullable<SphericalPolynomial>;
  122478. }
  122479. }
  122480. declare module BABYLON {
  122481. /** @hidden */
  122482. export var rgbdEncodePixelShader: {
  122483. name: string;
  122484. shader: string;
  122485. };
  122486. }
  122487. declare module BABYLON {
  122488. /** @hidden */
  122489. export var rgbdDecodePixelShader: {
  122490. name: string;
  122491. shader: string;
  122492. };
  122493. }
  122494. declare module BABYLON {
  122495. /**
  122496. * Raw texture data and descriptor sufficient for WebGL texture upload
  122497. */
  122498. export interface EnvironmentTextureInfo {
  122499. /**
  122500. * Version of the environment map
  122501. */
  122502. version: number;
  122503. /**
  122504. * Width of image
  122505. */
  122506. width: number;
  122507. /**
  122508. * Irradiance information stored in the file.
  122509. */
  122510. irradiance: any;
  122511. /**
  122512. * Specular information stored in the file.
  122513. */
  122514. specular: any;
  122515. }
  122516. /**
  122517. * Defines One Image in the file. It requires only the position in the file
  122518. * as well as the length.
  122519. */
  122520. interface BufferImageData {
  122521. /**
  122522. * Length of the image data.
  122523. */
  122524. length: number;
  122525. /**
  122526. * Position of the data from the null terminator delimiting the end of the JSON.
  122527. */
  122528. position: number;
  122529. }
  122530. /**
  122531. * Defines the specular data enclosed in the file.
  122532. * This corresponds to the version 1 of the data.
  122533. */
  122534. export interface EnvironmentTextureSpecularInfoV1 {
  122535. /**
  122536. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  122537. */
  122538. specularDataPosition?: number;
  122539. /**
  122540. * This contains all the images data needed to reconstruct the cubemap.
  122541. */
  122542. mipmaps: Array<BufferImageData>;
  122543. /**
  122544. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  122545. */
  122546. lodGenerationScale: number;
  122547. }
  122548. /**
  122549. * Sets of helpers addressing the serialization and deserialization of environment texture
  122550. * stored in a BabylonJS env file.
  122551. * Those files are usually stored as .env files.
  122552. */
  122553. export class EnvironmentTextureTools {
  122554. /**
  122555. * Magic number identifying the env file.
  122556. */
  122557. private static _MagicBytes;
  122558. /**
  122559. * Gets the environment info from an env file.
  122560. * @param data The array buffer containing the .env bytes.
  122561. * @returns the environment file info (the json header) if successfully parsed.
  122562. */
  122563. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  122564. /**
  122565. * Creates an environment texture from a loaded cube texture.
  122566. * @param texture defines the cube texture to convert in env file
  122567. * @return a promise containing the environment data if succesfull.
  122568. */
  122569. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  122570. /**
  122571. * Creates a JSON representation of the spherical data.
  122572. * @param texture defines the texture containing the polynomials
  122573. * @return the JSON representation of the spherical info
  122574. */
  122575. private static _CreateEnvTextureIrradiance;
  122576. /**
  122577. * Creates the ArrayBufferViews used for initializing environment texture image data.
  122578. * @param data the image data
  122579. * @param info parameters that determine what views will be created for accessing the underlying buffer
  122580. * @return the views described by info providing access to the underlying buffer
  122581. */
  122582. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  122583. /**
  122584. * Uploads the texture info contained in the env file to the GPU.
  122585. * @param texture defines the internal texture to upload to
  122586. * @param data defines the data to load
  122587. * @param info defines the texture info retrieved through the GetEnvInfo method
  122588. * @returns a promise
  122589. */
  122590. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  122591. private static _OnImageReadyAsync;
  122592. /**
  122593. * Uploads the levels of image data to the GPU.
  122594. * @param texture defines the internal texture to upload to
  122595. * @param imageData defines the array buffer views of image data [mipmap][face]
  122596. * @returns a promise
  122597. */
  122598. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  122599. /**
  122600. * Uploads spherical polynomials information to the texture.
  122601. * @param texture defines the texture we are trying to upload the information to
  122602. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  122603. */
  122604. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  122605. /** @hidden */
  122606. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  122607. }
  122608. }
  122609. declare module BABYLON {
  122610. /**
  122611. * Contains position and normal vectors for a vertex
  122612. */
  122613. export class PositionNormalVertex {
  122614. /** the position of the vertex (defaut: 0,0,0) */
  122615. position: Vector3;
  122616. /** the normal of the vertex (defaut: 0,1,0) */
  122617. normal: Vector3;
  122618. /**
  122619. * Creates a PositionNormalVertex
  122620. * @param position the position of the vertex (defaut: 0,0,0)
  122621. * @param normal the normal of the vertex (defaut: 0,1,0)
  122622. */
  122623. constructor(
  122624. /** the position of the vertex (defaut: 0,0,0) */
  122625. position?: Vector3,
  122626. /** the normal of the vertex (defaut: 0,1,0) */
  122627. normal?: Vector3);
  122628. /**
  122629. * Clones the PositionNormalVertex
  122630. * @returns the cloned PositionNormalVertex
  122631. */
  122632. clone(): PositionNormalVertex;
  122633. }
  122634. /**
  122635. * Contains position, normal and uv vectors for a vertex
  122636. */
  122637. export class PositionNormalTextureVertex {
  122638. /** the position of the vertex (defaut: 0,0,0) */
  122639. position: Vector3;
  122640. /** the normal of the vertex (defaut: 0,1,0) */
  122641. normal: Vector3;
  122642. /** the uv of the vertex (default: 0,0) */
  122643. uv: Vector2;
  122644. /**
  122645. * Creates a PositionNormalTextureVertex
  122646. * @param position the position of the vertex (defaut: 0,0,0)
  122647. * @param normal the normal of the vertex (defaut: 0,1,0)
  122648. * @param uv the uv of the vertex (default: 0,0)
  122649. */
  122650. constructor(
  122651. /** the position of the vertex (defaut: 0,0,0) */
  122652. position?: Vector3,
  122653. /** the normal of the vertex (defaut: 0,1,0) */
  122654. normal?: Vector3,
  122655. /** the uv of the vertex (default: 0,0) */
  122656. uv?: Vector2);
  122657. /**
  122658. * Clones the PositionNormalTextureVertex
  122659. * @returns the cloned PositionNormalTextureVertex
  122660. */
  122661. clone(): PositionNormalTextureVertex;
  122662. }
  122663. }
  122664. declare module BABYLON {
  122665. /** @hidden */
  122666. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  122667. private _genericAttributeLocation;
  122668. private _varyingLocationCount;
  122669. private _varyingLocationMap;
  122670. private _replacements;
  122671. private _textureCount;
  122672. private _uniforms;
  122673. lineProcessor(line: string): string;
  122674. attributeProcessor(attribute: string): string;
  122675. varyingProcessor(varying: string, isFragment: boolean): string;
  122676. uniformProcessor(uniform: string): string;
  122677. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  122678. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  122679. }
  122680. }
  122681. declare module BABYLON {
  122682. /**
  122683. * Container for accessors for natively-stored mesh data buffers.
  122684. */
  122685. class NativeDataBuffer extends DataBuffer {
  122686. /**
  122687. * Accessor value used to identify/retrieve a natively-stored index buffer.
  122688. */
  122689. nativeIndexBuffer?: any;
  122690. /**
  122691. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  122692. */
  122693. nativeVertexBuffer?: any;
  122694. }
  122695. /** @hidden */
  122696. class NativeTexture extends InternalTexture {
  122697. getInternalTexture(): InternalTexture;
  122698. getViewCount(): number;
  122699. }
  122700. /** @hidden */
  122701. export class NativeEngine extends Engine {
  122702. private readonly _native;
  122703. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  122704. private readonly INVALID_HANDLE;
  122705. getHardwareScalingLevel(): number;
  122706. constructor();
  122707. dispose(): void;
  122708. /**
  122709. * Can be used to override the current requestAnimationFrame requester.
  122710. * @hidden
  122711. */
  122712. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  122713. /**
  122714. * Override default engine behavior.
  122715. * @param color
  122716. * @param backBuffer
  122717. * @param depth
  122718. * @param stencil
  122719. */
  122720. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  122721. /**
  122722. * Gets host document
  122723. * @returns the host document object
  122724. */
  122725. getHostDocument(): Nullable<Document>;
  122726. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  122727. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  122728. createVertexBuffer(data: DataArray): NativeDataBuffer;
  122729. recordVertexArrayObject(vertexBuffers: {
  122730. [key: string]: VertexBuffer;
  122731. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  122732. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  122733. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  122734. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  122735. /**
  122736. * Draw a list of indexed primitives
  122737. * @param fillMode defines the primitive to use
  122738. * @param indexStart defines the starting index
  122739. * @param indexCount defines the number of index to draw
  122740. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  122741. */
  122742. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  122743. /**
  122744. * Draw a list of unindexed primitives
  122745. * @param fillMode defines the primitive to use
  122746. * @param verticesStart defines the index of first vertex to draw
  122747. * @param verticesCount defines the count of vertices to draw
  122748. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  122749. */
  122750. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  122751. createPipelineContext(): IPipelineContext;
  122752. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  122753. /** @hidden */
  122754. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  122755. /** @hidden */
  122756. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  122757. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  122758. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  122759. protected _setProgram(program: WebGLProgram): void;
  122760. _releaseEffect(effect: Effect): void;
  122761. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  122762. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  122763. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  122764. bindSamplers(effect: Effect): void;
  122765. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  122766. getRenderWidth(useScreen?: boolean): number;
  122767. getRenderHeight(useScreen?: boolean): number;
  122768. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  122769. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  122770. /**
  122771. * Set the z offset to apply to current rendering
  122772. * @param value defines the offset to apply
  122773. */
  122774. setZOffset(value: number): void;
  122775. /**
  122776. * Gets the current value of the zOffset
  122777. * @returns the current zOffset state
  122778. */
  122779. getZOffset(): number;
  122780. /**
  122781. * Enable or disable depth buffering
  122782. * @param enable defines the state to set
  122783. */
  122784. setDepthBuffer(enable: boolean): void;
  122785. /**
  122786. * Gets a boolean indicating if depth writing is enabled
  122787. * @returns the current depth writing state
  122788. */
  122789. getDepthWrite(): boolean;
  122790. /**
  122791. * Enable or disable depth writing
  122792. * @param enable defines the state to set
  122793. */
  122794. setDepthWrite(enable: boolean): void;
  122795. /**
  122796. * Enable or disable color writing
  122797. * @param enable defines the state to set
  122798. */
  122799. setColorWrite(enable: boolean): void;
  122800. /**
  122801. * Gets a boolean indicating if color writing is enabled
  122802. * @returns the current color writing state
  122803. */
  122804. getColorWrite(): boolean;
  122805. /**
  122806. * Sets alpha constants used by some alpha blending modes
  122807. * @param r defines the red component
  122808. * @param g defines the green component
  122809. * @param b defines the blue component
  122810. * @param a defines the alpha component
  122811. */
  122812. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  122813. /**
  122814. * Sets the current alpha mode
  122815. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  122816. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  122817. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  122818. */
  122819. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  122820. /**
  122821. * Gets the current alpha mode
  122822. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  122823. * @returns the current alpha mode
  122824. */
  122825. getAlphaMode(): number;
  122826. setInt(uniform: WebGLUniformLocation, int: number): void;
  122827. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  122828. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  122829. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  122830. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  122831. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  122832. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  122833. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  122834. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  122835. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  122836. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  122837. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  122838. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  122839. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  122840. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  122841. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  122842. setFloat(uniform: WebGLUniformLocation, value: number): void;
  122843. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  122844. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  122845. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  122846. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  122847. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  122848. wipeCaches(bruteForce?: boolean): void;
  122849. _createTexture(): WebGLTexture;
  122850. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  122851. /**
  122852. * Usually called from Texture.ts.
  122853. * Passed information to create a WebGLTexture
  122854. * @param url defines a value which contains one of the following:
  122855. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  122856. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  122857. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  122858. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  122859. * @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)
  122860. * @param scene needed for loading to the correct scene
  122861. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  122862. * @param onLoad optional callback to be called upon successful completion
  122863. * @param onError optional callback to be called upon failure
  122864. * @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
  122865. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  122866. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  122867. * @param forcedExtension defines the extension to use to pick the right loader
  122868. * @param mimeType defines an optional mime type
  122869. * @returns a InternalTexture for assignment back into BABYLON.Texture
  122870. */
  122871. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  122872. /**
  122873. * Creates a cube texture
  122874. * @param rootUrl defines the url where the files to load is located
  122875. * @param scene defines the current scene
  122876. * @param files defines the list of files to load (1 per face)
  122877. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  122878. * @param onLoad defines an optional callback raised when the texture is loaded
  122879. * @param onError defines an optional callback raised if there is an issue to load the texture
  122880. * @param format defines the format of the data
  122881. * @param forcedExtension defines the extension to use to pick the right loader
  122882. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  122883. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  122884. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  122885. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  122886. * @returns the cube texture as an InternalTexture
  122887. */
  122888. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  122889. private _getSamplingFilter;
  122890. private static _GetNativeTextureFormat;
  122891. createRenderTargetTexture(size: number | {
  122892. width: number;
  122893. height: number;
  122894. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  122895. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  122896. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  122897. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  122898. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  122899. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  122900. /**
  122901. * Updates a dynamic vertex buffer.
  122902. * @param vertexBuffer the vertex buffer to update
  122903. * @param data the data used to update the vertex buffer
  122904. * @param byteOffset the byte offset of the data (optional)
  122905. * @param byteLength the byte length of the data (optional)
  122906. */
  122907. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  122908. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  122909. private _updateAnisotropicLevel;
  122910. private _getAddressMode;
  122911. /** @hidden */
  122912. _bindTexture(channel: number, texture: InternalTexture): void;
  122913. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  122914. releaseEffects(): void;
  122915. /** @hidden */
  122916. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  122917. /** @hidden */
  122918. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  122919. /** @hidden */
  122920. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  122921. /** @hidden */
  122922. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  122923. }
  122924. }
  122925. declare module BABYLON {
  122926. /**
  122927. * Gather the list of clipboard event types as constants.
  122928. */
  122929. export class ClipboardEventTypes {
  122930. /**
  122931. * The clipboard event is fired when a copy command is active (pressed).
  122932. */
  122933. static readonly COPY: number;
  122934. /**
  122935. * The clipboard event is fired when a cut command is active (pressed).
  122936. */
  122937. static readonly CUT: number;
  122938. /**
  122939. * The clipboard event is fired when a paste command is active (pressed).
  122940. */
  122941. static readonly PASTE: number;
  122942. }
  122943. /**
  122944. * This class is used to store clipboard related info for the onClipboardObservable event.
  122945. */
  122946. export class ClipboardInfo {
  122947. /**
  122948. * Defines the type of event (BABYLON.ClipboardEventTypes)
  122949. */
  122950. type: number;
  122951. /**
  122952. * Defines the related dom event
  122953. */
  122954. event: ClipboardEvent;
  122955. /**
  122956. *Creates an instance of ClipboardInfo.
  122957. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  122958. * @param event Defines the related dom event
  122959. */
  122960. constructor(
  122961. /**
  122962. * Defines the type of event (BABYLON.ClipboardEventTypes)
  122963. */
  122964. type: number,
  122965. /**
  122966. * Defines the related dom event
  122967. */
  122968. event: ClipboardEvent);
  122969. /**
  122970. * Get the clipboard event's type from the keycode.
  122971. * @param keyCode Defines the keyCode for the current keyboard event.
  122972. * @return {number}
  122973. */
  122974. static GetTypeFromCharacter(keyCode: number): number;
  122975. }
  122976. }
  122977. declare module BABYLON {
  122978. /**
  122979. * Google Daydream controller
  122980. */
  122981. export class DaydreamController extends WebVRController {
  122982. /**
  122983. * Base Url for the controller model.
  122984. */
  122985. static MODEL_BASE_URL: string;
  122986. /**
  122987. * File name for the controller model.
  122988. */
  122989. static MODEL_FILENAME: string;
  122990. /**
  122991. * Gamepad Id prefix used to identify Daydream Controller.
  122992. */
  122993. static readonly GAMEPAD_ID_PREFIX: string;
  122994. /**
  122995. * Creates a new DaydreamController from a gamepad
  122996. * @param vrGamepad the gamepad that the controller should be created from
  122997. */
  122998. constructor(vrGamepad: any);
  122999. /**
  123000. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  123001. * @param scene scene in which to add meshes
  123002. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  123003. */
  123004. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  123005. /**
  123006. * Called once for each button that changed state since the last frame
  123007. * @param buttonIdx Which button index changed
  123008. * @param state New state of the button
  123009. * @param changes Which properties on the state changed since last frame
  123010. */
  123011. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  123012. }
  123013. }
  123014. declare module BABYLON {
  123015. /**
  123016. * Gear VR Controller
  123017. */
  123018. export class GearVRController extends WebVRController {
  123019. /**
  123020. * Base Url for the controller model.
  123021. */
  123022. static MODEL_BASE_URL: string;
  123023. /**
  123024. * File name for the controller model.
  123025. */
  123026. static MODEL_FILENAME: string;
  123027. /**
  123028. * Gamepad Id prefix used to identify this controller.
  123029. */
  123030. static readonly GAMEPAD_ID_PREFIX: string;
  123031. private readonly _buttonIndexToObservableNameMap;
  123032. /**
  123033. * Creates a new GearVRController from a gamepad
  123034. * @param vrGamepad the gamepad that the controller should be created from
  123035. */
  123036. constructor(vrGamepad: any);
  123037. /**
  123038. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  123039. * @param scene scene in which to add meshes
  123040. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  123041. */
  123042. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  123043. /**
  123044. * Called once for each button that changed state since the last frame
  123045. * @param buttonIdx Which button index changed
  123046. * @param state New state of the button
  123047. * @param changes Which properties on the state changed since last frame
  123048. */
  123049. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  123050. }
  123051. }
  123052. declare module BABYLON {
  123053. /**
  123054. * Generic Controller
  123055. */
  123056. export class GenericController extends WebVRController {
  123057. /**
  123058. * Base Url for the controller model.
  123059. */
  123060. static readonly MODEL_BASE_URL: string;
  123061. /**
  123062. * File name for the controller model.
  123063. */
  123064. static readonly MODEL_FILENAME: string;
  123065. /**
  123066. * Creates a new GenericController from a gamepad
  123067. * @param vrGamepad the gamepad that the controller should be created from
  123068. */
  123069. constructor(vrGamepad: any);
  123070. /**
  123071. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  123072. * @param scene scene in which to add meshes
  123073. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  123074. */
  123075. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  123076. /**
  123077. * Called once for each button that changed state since the last frame
  123078. * @param buttonIdx Which button index changed
  123079. * @param state New state of the button
  123080. * @param changes Which properties on the state changed since last frame
  123081. */
  123082. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  123083. }
  123084. }
  123085. declare module BABYLON {
  123086. /**
  123087. * Oculus Touch Controller
  123088. */
  123089. export class OculusTouchController extends WebVRController {
  123090. /**
  123091. * Base Url for the controller model.
  123092. */
  123093. static MODEL_BASE_URL: string;
  123094. /**
  123095. * File name for the left controller model.
  123096. */
  123097. static MODEL_LEFT_FILENAME: string;
  123098. /**
  123099. * File name for the right controller model.
  123100. */
  123101. static MODEL_RIGHT_FILENAME: string;
  123102. /**
  123103. * Base Url for the Quest controller model.
  123104. */
  123105. static QUEST_MODEL_BASE_URL: string;
  123106. /**
  123107. * @hidden
  123108. * If the controllers are running on a device that needs the updated Quest controller models
  123109. */
  123110. static _IsQuest: boolean;
  123111. /**
  123112. * Fired when the secondary trigger on this controller is modified
  123113. */
  123114. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  123115. /**
  123116. * Fired when the thumb rest on this controller is modified
  123117. */
  123118. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  123119. /**
  123120. * Creates a new OculusTouchController from a gamepad
  123121. * @param vrGamepad the gamepad that the controller should be created from
  123122. */
  123123. constructor(vrGamepad: any);
  123124. /**
  123125. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  123126. * @param scene scene in which to add meshes
  123127. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  123128. */
  123129. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  123130. /**
  123131. * Fired when the A button on this controller is modified
  123132. */
  123133. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  123134. /**
  123135. * Fired when the B button on this controller is modified
  123136. */
  123137. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  123138. /**
  123139. * Fired when the X button on this controller is modified
  123140. */
  123141. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  123142. /**
  123143. * Fired when the Y button on this controller is modified
  123144. */
  123145. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  123146. /**
  123147. * Called once for each button that changed state since the last frame
  123148. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  123149. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  123150. * 2) secondary trigger (same)
  123151. * 3) A (right) X (left), touch, pressed = value
  123152. * 4) B / Y
  123153. * 5) thumb rest
  123154. * @param buttonIdx Which button index changed
  123155. * @param state New state of the button
  123156. * @param changes Which properties on the state changed since last frame
  123157. */
  123158. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  123159. }
  123160. }
  123161. declare module BABYLON {
  123162. /**
  123163. * Vive Controller
  123164. */
  123165. export class ViveController extends WebVRController {
  123166. /**
  123167. * Base Url for the controller model.
  123168. */
  123169. static MODEL_BASE_URL: string;
  123170. /**
  123171. * File name for the controller model.
  123172. */
  123173. static MODEL_FILENAME: string;
  123174. /**
  123175. * Creates a new ViveController from a gamepad
  123176. * @param vrGamepad the gamepad that the controller should be created from
  123177. */
  123178. constructor(vrGamepad: any);
  123179. /**
  123180. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  123181. * @param scene scene in which to add meshes
  123182. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  123183. */
  123184. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  123185. /**
  123186. * Fired when the left button on this controller is modified
  123187. */
  123188. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  123189. /**
  123190. * Fired when the right button on this controller is modified
  123191. */
  123192. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  123193. /**
  123194. * Fired when the menu button on this controller is modified
  123195. */
  123196. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  123197. /**
  123198. * Called once for each button that changed state since the last frame
  123199. * Vive mapping:
  123200. * 0: touchpad
  123201. * 1: trigger
  123202. * 2: left AND right buttons
  123203. * 3: menu button
  123204. * @param buttonIdx Which button index changed
  123205. * @param state New state of the button
  123206. * @param changes Which properties on the state changed since last frame
  123207. */
  123208. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  123209. }
  123210. }
  123211. declare module BABYLON {
  123212. /**
  123213. * Defines the WindowsMotionController object that the state of the windows motion controller
  123214. */
  123215. export class WindowsMotionController extends WebVRController {
  123216. /**
  123217. * The base url used to load the left and right controller models
  123218. */
  123219. static MODEL_BASE_URL: string;
  123220. /**
  123221. * The name of the left controller model file
  123222. */
  123223. static MODEL_LEFT_FILENAME: string;
  123224. /**
  123225. * The name of the right controller model file
  123226. */
  123227. static MODEL_RIGHT_FILENAME: string;
  123228. /**
  123229. * The controller name prefix for this controller type
  123230. */
  123231. static readonly GAMEPAD_ID_PREFIX: string;
  123232. /**
  123233. * The controller id pattern for this controller type
  123234. */
  123235. private static readonly GAMEPAD_ID_PATTERN;
  123236. private _loadedMeshInfo;
  123237. protected readonly _mapping: {
  123238. buttons: string[];
  123239. buttonMeshNames: {
  123240. trigger: string;
  123241. menu: string;
  123242. grip: string;
  123243. thumbstick: string;
  123244. trackpad: string;
  123245. };
  123246. buttonObservableNames: {
  123247. trigger: string;
  123248. menu: string;
  123249. grip: string;
  123250. thumbstick: string;
  123251. trackpad: string;
  123252. };
  123253. axisMeshNames: string[];
  123254. pointingPoseMeshName: string;
  123255. };
  123256. /**
  123257. * Fired when the trackpad on this controller is clicked
  123258. */
  123259. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  123260. /**
  123261. * Fired when the trackpad on this controller is modified
  123262. */
  123263. onTrackpadValuesChangedObservable: Observable<StickValues>;
  123264. /**
  123265. * The current x and y values of this controller's trackpad
  123266. */
  123267. trackpad: StickValues;
  123268. /**
  123269. * Creates a new WindowsMotionController from a gamepad
  123270. * @param vrGamepad the gamepad that the controller should be created from
  123271. */
  123272. constructor(vrGamepad: any);
  123273. /**
  123274. * Fired when the trigger on this controller is modified
  123275. */
  123276. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  123277. /**
  123278. * Fired when the menu button on this controller is modified
  123279. */
  123280. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  123281. /**
  123282. * Fired when the grip button on this controller is modified
  123283. */
  123284. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  123285. /**
  123286. * Fired when the thumbstick button on this controller is modified
  123287. */
  123288. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  123289. /**
  123290. * Fired when the touchpad button on this controller is modified
  123291. */
  123292. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  123293. /**
  123294. * Fired when the touchpad values on this controller are modified
  123295. */
  123296. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  123297. protected _updateTrackpad(): void;
  123298. /**
  123299. * Called once per frame by the engine.
  123300. */
  123301. update(): void;
  123302. /**
  123303. * Called once for each button that changed state since the last frame
  123304. * @param buttonIdx Which button index changed
  123305. * @param state New state of the button
  123306. * @param changes Which properties on the state changed since last frame
  123307. */
  123308. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  123309. /**
  123310. * Moves the buttons on the controller mesh based on their current state
  123311. * @param buttonName the name of the button to move
  123312. * @param buttonValue the value of the button which determines the buttons new position
  123313. */
  123314. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  123315. /**
  123316. * Moves the axis on the controller mesh based on its current state
  123317. * @param axis the index of the axis
  123318. * @param axisValue the value of the axis which determines the meshes new position
  123319. * @hidden
  123320. */
  123321. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  123322. /**
  123323. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  123324. * @param scene scene in which to add meshes
  123325. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  123326. */
  123327. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  123328. /**
  123329. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  123330. * can be transformed by button presses and axes values, based on this._mapping.
  123331. *
  123332. * @param scene scene in which the meshes exist
  123333. * @param meshes list of meshes that make up the controller model to process
  123334. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  123335. */
  123336. private processModel;
  123337. private createMeshInfo;
  123338. /**
  123339. * Gets the ray of the controller in the direction the controller is pointing
  123340. * @param length the length the resulting ray should be
  123341. * @returns a ray in the direction the controller is pointing
  123342. */
  123343. getForwardRay(length?: number): Ray;
  123344. /**
  123345. * Disposes of the controller
  123346. */
  123347. dispose(): void;
  123348. }
  123349. /**
  123350. * This class represents a new windows motion controller in XR.
  123351. */
  123352. export class XRWindowsMotionController extends WindowsMotionController {
  123353. /**
  123354. * Changing the original WIndowsMotionController mapping to fir the new mapping
  123355. */
  123356. protected readonly _mapping: {
  123357. buttons: string[];
  123358. buttonMeshNames: {
  123359. trigger: string;
  123360. menu: string;
  123361. grip: string;
  123362. thumbstick: string;
  123363. trackpad: string;
  123364. };
  123365. buttonObservableNames: {
  123366. trigger: string;
  123367. menu: string;
  123368. grip: string;
  123369. thumbstick: string;
  123370. trackpad: string;
  123371. };
  123372. axisMeshNames: string[];
  123373. pointingPoseMeshName: string;
  123374. };
  123375. /**
  123376. * Construct a new XR-Based windows motion controller
  123377. *
  123378. * @param gamepadInfo the gamepad object from the browser
  123379. */
  123380. constructor(gamepadInfo: any);
  123381. /**
  123382. * holds the thumbstick values (X,Y)
  123383. */
  123384. thumbstickValues: StickValues;
  123385. /**
  123386. * Fired when the thumbstick on this controller is clicked
  123387. */
  123388. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  123389. /**
  123390. * Fired when the thumbstick on this controller is modified
  123391. */
  123392. onThumbstickValuesChangedObservable: Observable<StickValues>;
  123393. /**
  123394. * Fired when the touchpad button on this controller is modified
  123395. */
  123396. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  123397. /**
  123398. * Fired when the touchpad values on this controller are modified
  123399. */
  123400. onTrackpadValuesChangedObservable: Observable<StickValues>;
  123401. /**
  123402. * Fired when the thumbstick button on this controller is modified
  123403. * here to prevent breaking changes
  123404. */
  123405. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  123406. /**
  123407. * updating the thumbstick(!) and not the trackpad.
  123408. * This is named this way due to the difference between WebVR and XR and to avoid
  123409. * changing the parent class.
  123410. */
  123411. protected _updateTrackpad(): void;
  123412. /**
  123413. * Disposes the class with joy
  123414. */
  123415. dispose(): void;
  123416. }
  123417. }
  123418. declare module BABYLON {
  123419. /**
  123420. * Class containing static functions to help procedurally build meshes
  123421. */
  123422. export class PolyhedronBuilder {
  123423. /**
  123424. * Creates a polyhedron mesh
  123425. * * 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
  123426. * * The parameter `size` (positive float, default 1) sets the polygon size
  123427. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  123428. * * 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`
  123429. * * 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
  123430. * * 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)`)
  123431. * * 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
  123432. * * 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
  123433. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123434. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123436. * @param name defines the name of the mesh
  123437. * @param options defines the options used to create the mesh
  123438. * @param scene defines the hosting scene
  123439. * @returns the polyhedron mesh
  123440. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  123441. */
  123442. static CreatePolyhedron(name: string, options: {
  123443. type?: number;
  123444. size?: number;
  123445. sizeX?: number;
  123446. sizeY?: number;
  123447. sizeZ?: number;
  123448. custom?: any;
  123449. faceUV?: Vector4[];
  123450. faceColors?: Color4[];
  123451. flat?: boolean;
  123452. updatable?: boolean;
  123453. sideOrientation?: number;
  123454. frontUVs?: Vector4;
  123455. backUVs?: Vector4;
  123456. }, scene?: Nullable<Scene>): Mesh;
  123457. }
  123458. }
  123459. declare module BABYLON {
  123460. /**
  123461. * Gizmo that enables scaling a mesh along 3 axis
  123462. */
  123463. export class ScaleGizmo extends Gizmo {
  123464. /**
  123465. * Internal gizmo used for interactions on the x axis
  123466. */
  123467. xGizmo: AxisScaleGizmo;
  123468. /**
  123469. * Internal gizmo used for interactions on the y axis
  123470. */
  123471. yGizmo: AxisScaleGizmo;
  123472. /**
  123473. * Internal gizmo used for interactions on the z axis
  123474. */
  123475. zGizmo: AxisScaleGizmo;
  123476. /**
  123477. * Internal gizmo used to scale all axis equally
  123478. */
  123479. uniformScaleGizmo: AxisScaleGizmo;
  123480. private _meshAttached;
  123481. private _updateGizmoRotationToMatchAttachedMesh;
  123482. private _snapDistance;
  123483. private _scaleRatio;
  123484. private _uniformScalingMesh;
  123485. private _octahedron;
  123486. private _sensitivity;
  123487. /** Fires an event when any of it's sub gizmos are dragged */
  123488. onDragStartObservable: Observable<unknown>;
  123489. /** Fires an event when any of it's sub gizmos are released from dragging */
  123490. onDragEndObservable: Observable<unknown>;
  123491. get attachedMesh(): Nullable<AbstractMesh>;
  123492. set attachedMesh(mesh: Nullable<AbstractMesh>);
  123493. /**
  123494. * Creates a ScaleGizmo
  123495. * @param gizmoLayer The utility layer the gizmo will be added to
  123496. */
  123497. constructor(gizmoLayer?: UtilityLayerRenderer);
  123498. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  123499. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  123500. /**
  123501. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  123502. */
  123503. set snapDistance(value: number);
  123504. get snapDistance(): number;
  123505. /**
  123506. * Ratio for the scale of the gizmo (Default: 1)
  123507. */
  123508. set scaleRatio(value: number);
  123509. get scaleRatio(): number;
  123510. /**
  123511. * Sensitivity factor for dragging (Default: 1)
  123512. */
  123513. set sensitivity(value: number);
  123514. get sensitivity(): number;
  123515. /**
  123516. * Disposes of the gizmo
  123517. */
  123518. dispose(): void;
  123519. }
  123520. }
  123521. declare module BABYLON {
  123522. /**
  123523. * Single axis scale gizmo
  123524. */
  123525. export class AxisScaleGizmo extends Gizmo {
  123526. /**
  123527. * Drag behavior responsible for the gizmos dragging interactions
  123528. */
  123529. dragBehavior: PointerDragBehavior;
  123530. private _pointerObserver;
  123531. /**
  123532. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  123533. */
  123534. snapDistance: number;
  123535. /**
  123536. * Event that fires each time the gizmo snaps to a new location.
  123537. * * snapDistance is the the change in distance
  123538. */
  123539. onSnapObservable: Observable<{
  123540. snapDistance: number;
  123541. }>;
  123542. /**
  123543. * If the scaling operation should be done on all axis (default: false)
  123544. */
  123545. uniformScaling: boolean;
  123546. /**
  123547. * Custom sensitivity value for the drag strength
  123548. */
  123549. sensitivity: number;
  123550. private _isEnabled;
  123551. private _parent;
  123552. private _arrow;
  123553. private _coloredMaterial;
  123554. private _hoverMaterial;
  123555. /**
  123556. * Creates an AxisScaleGizmo
  123557. * @param gizmoLayer The utility layer the gizmo will be added to
  123558. * @param dragAxis The axis which the gizmo will be able to scale on
  123559. * @param color The color of the gizmo
  123560. */
  123561. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  123562. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  123563. /**
  123564. * If the gizmo is enabled
  123565. */
  123566. set isEnabled(value: boolean);
  123567. get isEnabled(): boolean;
  123568. /**
  123569. * Disposes of the gizmo
  123570. */
  123571. dispose(): void;
  123572. /**
  123573. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  123574. * @param mesh The mesh to replace the default mesh of the gizmo
  123575. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  123576. */
  123577. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  123578. }
  123579. }
  123580. declare module BABYLON {
  123581. /**
  123582. * Bounding box gizmo
  123583. */
  123584. export class BoundingBoxGizmo extends Gizmo {
  123585. private _lineBoundingBox;
  123586. private _rotateSpheresParent;
  123587. private _scaleBoxesParent;
  123588. private _boundingDimensions;
  123589. private _renderObserver;
  123590. private _pointerObserver;
  123591. private _scaleDragSpeed;
  123592. private _tmpQuaternion;
  123593. private _tmpVector;
  123594. private _tmpRotationMatrix;
  123595. /**
  123596. * 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)
  123597. */
  123598. ignoreChildren: boolean;
  123599. /**
  123600. * 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)
  123601. */
  123602. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  123603. /**
  123604. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  123605. */
  123606. rotationSphereSize: number;
  123607. /**
  123608. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  123609. */
  123610. scaleBoxSize: number;
  123611. /**
  123612. * 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)
  123613. */
  123614. fixedDragMeshScreenSize: boolean;
  123615. /**
  123616. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  123617. */
  123618. fixedDragMeshScreenSizeDistanceFactor: number;
  123619. /**
  123620. * Fired when a rotation sphere or scale box is dragged
  123621. */
  123622. onDragStartObservable: Observable<{}>;
  123623. /**
  123624. * Fired when a scale box is dragged
  123625. */
  123626. onScaleBoxDragObservable: Observable<{}>;
  123627. /**
  123628. * Fired when a scale box drag is ended
  123629. */
  123630. onScaleBoxDragEndObservable: Observable<{}>;
  123631. /**
  123632. * Fired when a rotation sphere is dragged
  123633. */
  123634. onRotationSphereDragObservable: Observable<{}>;
  123635. /**
  123636. * Fired when a rotation sphere drag is ended
  123637. */
  123638. onRotationSphereDragEndObservable: Observable<{}>;
  123639. /**
  123640. * 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)
  123641. */
  123642. scalePivot: Nullable<Vector3>;
  123643. /**
  123644. * Mesh used as a pivot to rotate the attached mesh
  123645. */
  123646. private _anchorMesh;
  123647. private _existingMeshScale;
  123648. private _dragMesh;
  123649. private pointerDragBehavior;
  123650. private coloredMaterial;
  123651. private hoverColoredMaterial;
  123652. /**
  123653. * Sets the color of the bounding box gizmo
  123654. * @param color the color to set
  123655. */
  123656. setColor(color: Color3): void;
  123657. /**
  123658. * Creates an BoundingBoxGizmo
  123659. * @param gizmoLayer The utility layer the gizmo will be added to
  123660. * @param color The color of the gizmo
  123661. */
  123662. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  123663. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  123664. private _selectNode;
  123665. /**
  123666. * Updates the bounding box information for the Gizmo
  123667. */
  123668. updateBoundingBox(): void;
  123669. private _updateRotationSpheres;
  123670. private _updateScaleBoxes;
  123671. /**
  123672. * Enables rotation on the specified axis and disables rotation on the others
  123673. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  123674. */
  123675. setEnabledRotationAxis(axis: string): void;
  123676. /**
  123677. * Enables/disables scaling
  123678. * @param enable if scaling should be enabled
  123679. * @param homogeneousScaling defines if scaling should only be homogeneous
  123680. */
  123681. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  123682. private _updateDummy;
  123683. /**
  123684. * Enables a pointer drag behavior on the bounding box of the gizmo
  123685. */
  123686. enableDragBehavior(): void;
  123687. /**
  123688. * Disposes of the gizmo
  123689. */
  123690. dispose(): void;
  123691. /**
  123692. * 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)
  123693. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  123694. * @returns the bounding box mesh with the passed in mesh as a child
  123695. */
  123696. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  123697. /**
  123698. * CustomMeshes are not supported by this gizmo
  123699. * @param mesh The mesh to replace the default mesh of the gizmo
  123700. */
  123701. setCustomMesh(mesh: Mesh): void;
  123702. }
  123703. }
  123704. declare module BABYLON {
  123705. /**
  123706. * Single plane rotation gizmo
  123707. */
  123708. export class PlaneRotationGizmo extends Gizmo {
  123709. /**
  123710. * Drag behavior responsible for the gizmos dragging interactions
  123711. */
  123712. dragBehavior: PointerDragBehavior;
  123713. private _pointerObserver;
  123714. /**
  123715. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  123716. */
  123717. snapDistance: number;
  123718. /**
  123719. * Event that fires each time the gizmo snaps to a new location.
  123720. * * snapDistance is the the change in distance
  123721. */
  123722. onSnapObservable: Observable<{
  123723. snapDistance: number;
  123724. }>;
  123725. private _isEnabled;
  123726. private _parent;
  123727. /**
  123728. * Creates a PlaneRotationGizmo
  123729. * @param gizmoLayer The utility layer the gizmo will be added to
  123730. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  123731. * @param color The color of the gizmo
  123732. * @param tessellation Amount of tessellation to be used when creating rotation circles
  123733. * @param useEulerRotation Use and update Euler angle instead of quaternion
  123734. */
  123735. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  123736. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  123737. /**
  123738. * If the gizmo is enabled
  123739. */
  123740. set isEnabled(value: boolean);
  123741. get isEnabled(): boolean;
  123742. /**
  123743. * Disposes of the gizmo
  123744. */
  123745. dispose(): void;
  123746. }
  123747. }
  123748. declare module BABYLON {
  123749. /**
  123750. * Gizmo that enables rotating a mesh along 3 axis
  123751. */
  123752. export class RotationGizmo extends Gizmo {
  123753. /**
  123754. * Internal gizmo used for interactions on the x axis
  123755. */
  123756. xGizmo: PlaneRotationGizmo;
  123757. /**
  123758. * Internal gizmo used for interactions on the y axis
  123759. */
  123760. yGizmo: PlaneRotationGizmo;
  123761. /**
  123762. * Internal gizmo used for interactions on the z axis
  123763. */
  123764. zGizmo: PlaneRotationGizmo;
  123765. /** Fires an event when any of it's sub gizmos are dragged */
  123766. onDragStartObservable: Observable<unknown>;
  123767. /** Fires an event when any of it's sub gizmos are released from dragging */
  123768. onDragEndObservable: Observable<unknown>;
  123769. private _meshAttached;
  123770. get attachedMesh(): Nullable<AbstractMesh>;
  123771. set attachedMesh(mesh: Nullable<AbstractMesh>);
  123772. /**
  123773. * Creates a RotationGizmo
  123774. * @param gizmoLayer The utility layer the gizmo will be added to
  123775. * @param tessellation Amount of tessellation to be used when creating rotation circles
  123776. * @param useEulerRotation Use and update Euler angle instead of quaternion
  123777. */
  123778. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  123779. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  123780. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  123781. /**
  123782. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  123783. */
  123784. set snapDistance(value: number);
  123785. get snapDistance(): number;
  123786. /**
  123787. * Ratio for the scale of the gizmo (Default: 1)
  123788. */
  123789. set scaleRatio(value: number);
  123790. get scaleRatio(): number;
  123791. /**
  123792. * Disposes of the gizmo
  123793. */
  123794. dispose(): void;
  123795. /**
  123796. * CustomMeshes are not supported by this gizmo
  123797. * @param mesh The mesh to replace the default mesh of the gizmo
  123798. */
  123799. setCustomMesh(mesh: Mesh): void;
  123800. }
  123801. }
  123802. declare module BABYLON {
  123803. /**
  123804. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  123805. */
  123806. export class GizmoManager implements IDisposable {
  123807. private scene;
  123808. /**
  123809. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  123810. */
  123811. gizmos: {
  123812. positionGizmo: Nullable<PositionGizmo>;
  123813. rotationGizmo: Nullable<RotationGizmo>;
  123814. scaleGizmo: Nullable<ScaleGizmo>;
  123815. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  123816. };
  123817. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  123818. clearGizmoOnEmptyPointerEvent: boolean;
  123819. /** Fires an event when the manager is attached to a mesh */
  123820. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  123821. private _gizmosEnabled;
  123822. private _pointerObserver;
  123823. private _attachedMesh;
  123824. private _boundingBoxColor;
  123825. private _defaultUtilityLayer;
  123826. private _defaultKeepDepthUtilityLayer;
  123827. /**
  123828. * When bounding box gizmo is enabled, this can be used to track drag/end events
  123829. */
  123830. boundingBoxDragBehavior: SixDofDragBehavior;
  123831. /**
  123832. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  123833. */
  123834. attachableMeshes: Nullable<Array<AbstractMesh>>;
  123835. /**
  123836. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  123837. */
  123838. usePointerToAttachGizmos: boolean;
  123839. /**
  123840. * Utility layer that the bounding box gizmo belongs to
  123841. */
  123842. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  123843. /**
  123844. * Utility layer that all gizmos besides bounding box belong to
  123845. */
  123846. get utilityLayer(): UtilityLayerRenderer;
  123847. /**
  123848. * Instatiates a gizmo manager
  123849. * @param scene the scene to overlay the gizmos on top of
  123850. */
  123851. constructor(scene: Scene);
  123852. /**
  123853. * Attaches a set of gizmos to the specified mesh
  123854. * @param mesh The mesh the gizmo's should be attached to
  123855. */
  123856. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  123857. /**
  123858. * If the position gizmo is enabled
  123859. */
  123860. set positionGizmoEnabled(value: boolean);
  123861. get positionGizmoEnabled(): boolean;
  123862. /**
  123863. * If the rotation gizmo is enabled
  123864. */
  123865. set rotationGizmoEnabled(value: boolean);
  123866. get rotationGizmoEnabled(): boolean;
  123867. /**
  123868. * If the scale gizmo is enabled
  123869. */
  123870. set scaleGizmoEnabled(value: boolean);
  123871. get scaleGizmoEnabled(): boolean;
  123872. /**
  123873. * If the boundingBox gizmo is enabled
  123874. */
  123875. set boundingBoxGizmoEnabled(value: boolean);
  123876. get boundingBoxGizmoEnabled(): boolean;
  123877. /**
  123878. * Disposes of the gizmo manager
  123879. */
  123880. dispose(): void;
  123881. }
  123882. }
  123883. declare module BABYLON {
  123884. /**
  123885. * A directional light is defined by a direction (what a surprise!).
  123886. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  123887. * 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.
  123888. * Documentation: https://doc.babylonjs.com/babylon101/lights
  123889. */
  123890. export class DirectionalLight extends ShadowLight {
  123891. private _shadowFrustumSize;
  123892. /**
  123893. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  123894. */
  123895. get shadowFrustumSize(): number;
  123896. /**
  123897. * Specifies a fix frustum size for the shadow generation.
  123898. */
  123899. set shadowFrustumSize(value: number);
  123900. private _shadowOrthoScale;
  123901. /**
  123902. * Gets the shadow projection scale against the optimal computed one.
  123903. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  123904. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  123905. */
  123906. get shadowOrthoScale(): number;
  123907. /**
  123908. * Sets the shadow projection scale against the optimal computed one.
  123909. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  123910. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  123911. */
  123912. set shadowOrthoScale(value: number);
  123913. /**
  123914. * Automatically compute the projection matrix to best fit (including all the casters)
  123915. * on each frame.
  123916. */
  123917. autoUpdateExtends: boolean;
  123918. /**
  123919. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  123920. * on each frame. autoUpdateExtends must be set to true for this to work
  123921. */
  123922. autoCalcShadowZBounds: boolean;
  123923. private _orthoLeft;
  123924. private _orthoRight;
  123925. private _orthoTop;
  123926. private _orthoBottom;
  123927. /**
  123928. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  123929. * The directional light is emitted from everywhere in the given direction.
  123930. * It can cast shadows.
  123931. * Documentation : https://doc.babylonjs.com/babylon101/lights
  123932. * @param name The friendly name of the light
  123933. * @param direction The direction of the light
  123934. * @param scene The scene the light belongs to
  123935. */
  123936. constructor(name: string, direction: Vector3, scene: Scene);
  123937. /**
  123938. * Returns the string "DirectionalLight".
  123939. * @return The class name
  123940. */
  123941. getClassName(): string;
  123942. /**
  123943. * Returns the integer 1.
  123944. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  123945. */
  123946. getTypeID(): number;
  123947. /**
  123948. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  123949. * Returns the DirectionalLight Shadow projection matrix.
  123950. */
  123951. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  123952. /**
  123953. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  123954. * Returns the DirectionalLight Shadow projection matrix.
  123955. */
  123956. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  123957. /**
  123958. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  123959. * Returns the DirectionalLight Shadow projection matrix.
  123960. */
  123961. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  123962. protected _buildUniformLayout(): void;
  123963. /**
  123964. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  123965. * @param effect The effect to update
  123966. * @param lightIndex The index of the light in the effect to update
  123967. * @returns The directional light
  123968. */
  123969. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  123970. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  123971. /**
  123972. * Gets the minZ used for shadow according to both the scene and the light.
  123973. *
  123974. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  123975. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  123976. * @param activeCamera The camera we are returning the min for
  123977. * @returns the depth min z
  123978. */
  123979. getDepthMinZ(activeCamera: Camera): number;
  123980. /**
  123981. * Gets the maxZ used for shadow according to both the scene and the light.
  123982. *
  123983. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  123984. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  123985. * @param activeCamera The camera we are returning the max for
  123986. * @returns the depth max z
  123987. */
  123988. getDepthMaxZ(activeCamera: Camera): number;
  123989. /**
  123990. * Prepares the list of defines specific to the light type.
  123991. * @param defines the list of defines
  123992. * @param lightIndex defines the index of the light for the effect
  123993. */
  123994. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  123995. }
  123996. }
  123997. declare module BABYLON {
  123998. /**
  123999. * Class containing static functions to help procedurally build meshes
  124000. */
  124001. export class HemisphereBuilder {
  124002. /**
  124003. * Creates a hemisphere mesh
  124004. * @param name defines the name of the mesh
  124005. * @param options defines the options used to create the mesh
  124006. * @param scene defines the hosting scene
  124007. * @returns the hemisphere mesh
  124008. */
  124009. static CreateHemisphere(name: string, options: {
  124010. segments?: number;
  124011. diameter?: number;
  124012. sideOrientation?: number;
  124013. }, scene: any): Mesh;
  124014. }
  124015. }
  124016. declare module BABYLON {
  124017. /**
  124018. * A spot light is defined by a position, a direction, an angle, and an exponent.
  124019. * These values define a cone of light starting from the position, emitting toward the direction.
  124020. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  124021. * and the exponent defines the speed of the decay of the light with distance (reach).
  124022. * Documentation: https://doc.babylonjs.com/babylon101/lights
  124023. */
  124024. export class SpotLight extends ShadowLight {
  124025. private _angle;
  124026. private _innerAngle;
  124027. private _cosHalfAngle;
  124028. private _lightAngleScale;
  124029. private _lightAngleOffset;
  124030. /**
  124031. * Gets the cone angle of the spot light in Radians.
  124032. */
  124033. get angle(): number;
  124034. /**
  124035. * Sets the cone angle of the spot light in Radians.
  124036. */
  124037. set angle(value: number);
  124038. /**
  124039. * Only used in gltf falloff mode, this defines the angle where
  124040. * the directional falloff will start before cutting at angle which could be seen
  124041. * as outer angle.
  124042. */
  124043. get innerAngle(): number;
  124044. /**
  124045. * Only used in gltf falloff mode, this defines the angle where
  124046. * the directional falloff will start before cutting at angle which could be seen
  124047. * as outer angle.
  124048. */
  124049. set innerAngle(value: number);
  124050. private _shadowAngleScale;
  124051. /**
  124052. * Allows scaling the angle of the light for shadow generation only.
  124053. */
  124054. get shadowAngleScale(): number;
  124055. /**
  124056. * Allows scaling the angle of the light for shadow generation only.
  124057. */
  124058. set shadowAngleScale(value: number);
  124059. /**
  124060. * The light decay speed with the distance from the emission spot.
  124061. */
  124062. exponent: number;
  124063. private _projectionTextureMatrix;
  124064. /**
  124065. * Allows reading the projecton texture
  124066. */
  124067. get projectionTextureMatrix(): Matrix;
  124068. protected _projectionTextureLightNear: number;
  124069. /**
  124070. * Gets the near clip of the Spotlight for texture projection.
  124071. */
  124072. get projectionTextureLightNear(): number;
  124073. /**
  124074. * Sets the near clip of the Spotlight for texture projection.
  124075. */
  124076. set projectionTextureLightNear(value: number);
  124077. protected _projectionTextureLightFar: number;
  124078. /**
  124079. * Gets the far clip of the Spotlight for texture projection.
  124080. */
  124081. get projectionTextureLightFar(): number;
  124082. /**
  124083. * Sets the far clip of the Spotlight for texture projection.
  124084. */
  124085. set projectionTextureLightFar(value: number);
  124086. protected _projectionTextureUpDirection: Vector3;
  124087. /**
  124088. * Gets the Up vector of the Spotlight for texture projection.
  124089. */
  124090. get projectionTextureUpDirection(): Vector3;
  124091. /**
  124092. * Sets the Up vector of the Spotlight for texture projection.
  124093. */
  124094. set projectionTextureUpDirection(value: Vector3);
  124095. private _projectionTexture;
  124096. /**
  124097. * Gets the projection texture of the light.
  124098. */
  124099. get projectionTexture(): Nullable<BaseTexture>;
  124100. /**
  124101. * Sets the projection texture of the light.
  124102. */
  124103. set projectionTexture(value: Nullable<BaseTexture>);
  124104. private _projectionTextureViewLightDirty;
  124105. private _projectionTextureProjectionLightDirty;
  124106. private _projectionTextureDirty;
  124107. private _projectionTextureViewTargetVector;
  124108. private _projectionTextureViewLightMatrix;
  124109. private _projectionTextureProjectionLightMatrix;
  124110. private _projectionTextureScalingMatrix;
  124111. /**
  124112. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  124113. * It can cast shadows.
  124114. * Documentation : https://doc.babylonjs.com/babylon101/lights
  124115. * @param name The light friendly name
  124116. * @param position The position of the spot light in the scene
  124117. * @param direction The direction of the light in the scene
  124118. * @param angle The cone angle of the light in Radians
  124119. * @param exponent The light decay speed with the distance from the emission spot
  124120. * @param scene The scene the lights belongs to
  124121. */
  124122. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  124123. /**
  124124. * Returns the string "SpotLight".
  124125. * @returns the class name
  124126. */
  124127. getClassName(): string;
  124128. /**
  124129. * Returns the integer 2.
  124130. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  124131. */
  124132. getTypeID(): number;
  124133. /**
  124134. * Overrides the direction setter to recompute the projection texture view light Matrix.
  124135. */
  124136. protected _setDirection(value: Vector3): void;
  124137. /**
  124138. * Overrides the position setter to recompute the projection texture view light Matrix.
  124139. */
  124140. protected _setPosition(value: Vector3): void;
  124141. /**
  124142. * 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.
  124143. * Returns the SpotLight.
  124144. */
  124145. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  124146. protected _computeProjectionTextureViewLightMatrix(): void;
  124147. protected _computeProjectionTextureProjectionLightMatrix(): void;
  124148. /**
  124149. * Main function for light texture projection matrix computing.
  124150. */
  124151. protected _computeProjectionTextureMatrix(): void;
  124152. protected _buildUniformLayout(): void;
  124153. private _computeAngleValues;
  124154. /**
  124155. * Sets the passed Effect "effect" with the Light textures.
  124156. * @param effect The effect to update
  124157. * @param lightIndex The index of the light in the effect to update
  124158. * @returns The light
  124159. */
  124160. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  124161. /**
  124162. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  124163. * @param effect The effect to update
  124164. * @param lightIndex The index of the light in the effect to update
  124165. * @returns The spot light
  124166. */
  124167. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  124168. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  124169. /**
  124170. * Disposes the light and the associated resources.
  124171. */
  124172. dispose(): void;
  124173. /**
  124174. * Prepares the list of defines specific to the light type.
  124175. * @param defines the list of defines
  124176. * @param lightIndex defines the index of the light for the effect
  124177. */
  124178. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  124179. }
  124180. }
  124181. declare module BABYLON {
  124182. /**
  124183. * Gizmo that enables viewing a light
  124184. */
  124185. export class LightGizmo extends Gizmo {
  124186. private _lightMesh;
  124187. private _material;
  124188. private _cachedPosition;
  124189. private _cachedForward;
  124190. private _attachedMeshParent;
  124191. /**
  124192. * Creates a LightGizmo
  124193. * @param gizmoLayer The utility layer the gizmo will be added to
  124194. */
  124195. constructor(gizmoLayer?: UtilityLayerRenderer);
  124196. private _light;
  124197. /**
  124198. * The light that the gizmo is attached to
  124199. */
  124200. set light(light: Nullable<Light>);
  124201. get light(): Nullable<Light>;
  124202. /**
  124203. * Gets the material used to render the light gizmo
  124204. */
  124205. get material(): StandardMaterial;
  124206. /**
  124207. * @hidden
  124208. * Updates the gizmo to match the attached mesh's position/rotation
  124209. */
  124210. protected _update(): void;
  124211. private static _Scale;
  124212. /**
  124213. * Creates the lines for a light mesh
  124214. */
  124215. private static _CreateLightLines;
  124216. /**
  124217. * Disposes of the light gizmo
  124218. */
  124219. dispose(): void;
  124220. private static _CreateHemisphericLightMesh;
  124221. private static _CreatePointLightMesh;
  124222. private static _CreateSpotLightMesh;
  124223. private static _CreateDirectionalLightMesh;
  124224. }
  124225. }
  124226. declare module BABYLON {
  124227. /** @hidden */
  124228. export var backgroundFragmentDeclaration: {
  124229. name: string;
  124230. shader: string;
  124231. };
  124232. }
  124233. declare module BABYLON {
  124234. /** @hidden */
  124235. export var backgroundUboDeclaration: {
  124236. name: string;
  124237. shader: string;
  124238. };
  124239. }
  124240. declare module BABYLON {
  124241. /** @hidden */
  124242. export var backgroundPixelShader: {
  124243. name: string;
  124244. shader: string;
  124245. };
  124246. }
  124247. declare module BABYLON {
  124248. /** @hidden */
  124249. export var backgroundVertexDeclaration: {
  124250. name: string;
  124251. shader: string;
  124252. };
  124253. }
  124254. declare module BABYLON {
  124255. /** @hidden */
  124256. export var backgroundVertexShader: {
  124257. name: string;
  124258. shader: string;
  124259. };
  124260. }
  124261. declare module BABYLON {
  124262. /**
  124263. * Background material used to create an efficient environement around your scene.
  124264. */
  124265. export class BackgroundMaterial extends PushMaterial {
  124266. /**
  124267. * Standard reflectance value at parallel view angle.
  124268. */
  124269. static StandardReflectance0: number;
  124270. /**
  124271. * Standard reflectance value at grazing angle.
  124272. */
  124273. static StandardReflectance90: number;
  124274. protected _primaryColor: Color3;
  124275. /**
  124276. * Key light Color (multiply against the environement texture)
  124277. */
  124278. primaryColor: Color3;
  124279. protected __perceptualColor: Nullable<Color3>;
  124280. /**
  124281. * Experimental Internal Use Only.
  124282. *
  124283. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  124284. * This acts as a helper to set the primary color to a more "human friendly" value.
  124285. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  124286. * output color as close as possible from the chosen value.
  124287. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  124288. * part of lighting setup.)
  124289. */
  124290. get _perceptualColor(): Nullable<Color3>;
  124291. set _perceptualColor(value: Nullable<Color3>);
  124292. protected _primaryColorShadowLevel: float;
  124293. /**
  124294. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  124295. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  124296. */
  124297. get primaryColorShadowLevel(): float;
  124298. set primaryColorShadowLevel(value: float);
  124299. protected _primaryColorHighlightLevel: float;
  124300. /**
  124301. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  124302. * The primary color is used at the level chosen to define what the white area would look.
  124303. */
  124304. get primaryColorHighlightLevel(): float;
  124305. set primaryColorHighlightLevel(value: float);
  124306. protected _reflectionTexture: Nullable<BaseTexture>;
  124307. /**
  124308. * Reflection Texture used in the material.
  124309. * Should be author in a specific way for the best result (refer to the documentation).
  124310. */
  124311. reflectionTexture: Nullable<BaseTexture>;
  124312. protected _reflectionBlur: float;
  124313. /**
  124314. * Reflection Texture level of blur.
  124315. *
  124316. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  124317. * texture twice.
  124318. */
  124319. reflectionBlur: float;
  124320. protected _diffuseTexture: Nullable<BaseTexture>;
  124321. /**
  124322. * Diffuse Texture used in the material.
  124323. * Should be author in a specific way for the best result (refer to the documentation).
  124324. */
  124325. diffuseTexture: Nullable<BaseTexture>;
  124326. protected _shadowLights: Nullable<IShadowLight[]>;
  124327. /**
  124328. * Specify the list of lights casting shadow on the material.
  124329. * All scene shadow lights will be included if null.
  124330. */
  124331. shadowLights: Nullable<IShadowLight[]>;
  124332. protected _shadowLevel: float;
  124333. /**
  124334. * Helps adjusting the shadow to a softer level if required.
  124335. * 0 means black shadows and 1 means no shadows.
  124336. */
  124337. shadowLevel: float;
  124338. protected _sceneCenter: Vector3;
  124339. /**
  124340. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  124341. * It is usually zero but might be interesting to modify according to your setup.
  124342. */
  124343. sceneCenter: Vector3;
  124344. protected _opacityFresnel: boolean;
  124345. /**
  124346. * This helps specifying that the material is falling off to the sky box at grazing angle.
  124347. * This helps ensuring a nice transition when the camera goes under the ground.
  124348. */
  124349. opacityFresnel: boolean;
  124350. protected _reflectionFresnel: boolean;
  124351. /**
  124352. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  124353. * This helps adding a mirror texture on the ground.
  124354. */
  124355. reflectionFresnel: boolean;
  124356. protected _reflectionFalloffDistance: number;
  124357. /**
  124358. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  124359. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  124360. */
  124361. reflectionFalloffDistance: number;
  124362. protected _reflectionAmount: number;
  124363. /**
  124364. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  124365. */
  124366. reflectionAmount: number;
  124367. protected _reflectionReflectance0: number;
  124368. /**
  124369. * This specifies the weight of the reflection at grazing angle.
  124370. */
  124371. reflectionReflectance0: number;
  124372. protected _reflectionReflectance90: number;
  124373. /**
  124374. * This specifies the weight of the reflection at a perpendicular point of view.
  124375. */
  124376. reflectionReflectance90: number;
  124377. /**
  124378. * Sets the reflection reflectance fresnel values according to the default standard
  124379. * empirically know to work well :-)
  124380. */
  124381. set reflectionStandardFresnelWeight(value: number);
  124382. protected _useRGBColor: boolean;
  124383. /**
  124384. * Helps to directly use the maps channels instead of their level.
  124385. */
  124386. useRGBColor: boolean;
  124387. protected _enableNoise: boolean;
  124388. /**
  124389. * This helps reducing the banding effect that could occur on the background.
  124390. */
  124391. enableNoise: boolean;
  124392. /**
  124393. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  124394. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  124395. * Recommended to be keep at 1.0 except for special cases.
  124396. */
  124397. get fovMultiplier(): number;
  124398. set fovMultiplier(value: number);
  124399. private _fovMultiplier;
  124400. /**
  124401. * Enable the FOV adjustment feature controlled by fovMultiplier.
  124402. */
  124403. useEquirectangularFOV: boolean;
  124404. private _maxSimultaneousLights;
  124405. /**
  124406. * Number of Simultaneous lights allowed on the material.
  124407. */
  124408. maxSimultaneousLights: int;
  124409. /**
  124410. * Default configuration related to image processing available in the Background Material.
  124411. */
  124412. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  124413. /**
  124414. * Keep track of the image processing observer to allow dispose and replace.
  124415. */
  124416. private _imageProcessingObserver;
  124417. /**
  124418. * Attaches a new image processing configuration to the PBR Material.
  124419. * @param configuration (if null the scene configuration will be use)
  124420. */
  124421. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  124422. /**
  124423. * Gets the image processing configuration used either in this material.
  124424. */
  124425. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  124426. /**
  124427. * Sets the Default image processing configuration used either in the this material.
  124428. *
  124429. * If sets to null, the scene one is in use.
  124430. */
  124431. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  124432. /**
  124433. * Gets wether the color curves effect is enabled.
  124434. */
  124435. get cameraColorCurvesEnabled(): boolean;
  124436. /**
  124437. * Sets wether the color curves effect is enabled.
  124438. */
  124439. set cameraColorCurvesEnabled(value: boolean);
  124440. /**
  124441. * Gets wether the color grading effect is enabled.
  124442. */
  124443. get cameraColorGradingEnabled(): boolean;
  124444. /**
  124445. * Gets wether the color grading effect is enabled.
  124446. */
  124447. set cameraColorGradingEnabled(value: boolean);
  124448. /**
  124449. * Gets wether tonemapping is enabled or not.
  124450. */
  124451. get cameraToneMappingEnabled(): boolean;
  124452. /**
  124453. * Sets wether tonemapping is enabled or not
  124454. */
  124455. set cameraToneMappingEnabled(value: boolean);
  124456. /**
  124457. * The camera exposure used on this material.
  124458. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  124459. * This corresponds to a photographic exposure.
  124460. */
  124461. get cameraExposure(): float;
  124462. /**
  124463. * The camera exposure used on this material.
  124464. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  124465. * This corresponds to a photographic exposure.
  124466. */
  124467. set cameraExposure(value: float);
  124468. /**
  124469. * Gets The camera contrast used on this material.
  124470. */
  124471. get cameraContrast(): float;
  124472. /**
  124473. * Sets The camera contrast used on this material.
  124474. */
  124475. set cameraContrast(value: float);
  124476. /**
  124477. * Gets the Color Grading 2D Lookup Texture.
  124478. */
  124479. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  124480. /**
  124481. * Sets the Color Grading 2D Lookup Texture.
  124482. */
  124483. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  124484. /**
  124485. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  124486. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  124487. * 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;
  124488. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  124489. */
  124490. get cameraColorCurves(): Nullable<ColorCurves>;
  124491. /**
  124492. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  124493. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  124494. * 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;
  124495. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  124496. */
  124497. set cameraColorCurves(value: Nullable<ColorCurves>);
  124498. /**
  124499. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  124500. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  124501. */
  124502. switchToBGR: boolean;
  124503. private _renderTargets;
  124504. private _reflectionControls;
  124505. private _white;
  124506. private _primaryShadowColor;
  124507. private _primaryHighlightColor;
  124508. /**
  124509. * Instantiates a Background Material in the given scene
  124510. * @param name The friendly name of the material
  124511. * @param scene The scene to add the material to
  124512. */
  124513. constructor(name: string, scene: Scene);
  124514. /**
  124515. * Gets a boolean indicating that current material needs to register RTT
  124516. */
  124517. get hasRenderTargetTextures(): boolean;
  124518. /**
  124519. * The entire material has been created in order to prevent overdraw.
  124520. * @returns false
  124521. */
  124522. needAlphaTesting(): boolean;
  124523. /**
  124524. * The entire material has been created in order to prevent overdraw.
  124525. * @returns true if blending is enable
  124526. */
  124527. needAlphaBlending(): boolean;
  124528. /**
  124529. * Checks wether the material is ready to be rendered for a given mesh.
  124530. * @param mesh The mesh to render
  124531. * @param subMesh The submesh to check against
  124532. * @param useInstances Specify wether or not the material is used with instances
  124533. * @returns true if all the dependencies are ready (Textures, Effects...)
  124534. */
  124535. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  124536. /**
  124537. * Compute the primary color according to the chosen perceptual color.
  124538. */
  124539. private _computePrimaryColorFromPerceptualColor;
  124540. /**
  124541. * Compute the highlights and shadow colors according to their chosen levels.
  124542. */
  124543. private _computePrimaryColors;
  124544. /**
  124545. * Build the uniform buffer used in the material.
  124546. */
  124547. buildUniformLayout(): void;
  124548. /**
  124549. * Unbind the material.
  124550. */
  124551. unbind(): void;
  124552. /**
  124553. * Bind only the world matrix to the material.
  124554. * @param world The world matrix to bind.
  124555. */
  124556. bindOnlyWorldMatrix(world: Matrix): void;
  124557. /**
  124558. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  124559. * @param world The world matrix to bind.
  124560. * @param subMesh The submesh to bind for.
  124561. */
  124562. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  124563. /**
  124564. * Checks to see if a texture is used in the material.
  124565. * @param texture - Base texture to use.
  124566. * @returns - Boolean specifying if a texture is used in the material.
  124567. */
  124568. hasTexture(texture: BaseTexture): boolean;
  124569. /**
  124570. * Dispose the material.
  124571. * @param forceDisposeEffect Force disposal of the associated effect.
  124572. * @param forceDisposeTextures Force disposal of the associated textures.
  124573. */
  124574. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  124575. /**
  124576. * Clones the material.
  124577. * @param name The cloned name.
  124578. * @returns The cloned material.
  124579. */
  124580. clone(name: string): BackgroundMaterial;
  124581. /**
  124582. * Serializes the current material to its JSON representation.
  124583. * @returns The JSON representation.
  124584. */
  124585. serialize(): any;
  124586. /**
  124587. * Gets the class name of the material
  124588. * @returns "BackgroundMaterial"
  124589. */
  124590. getClassName(): string;
  124591. /**
  124592. * Parse a JSON input to create back a background material.
  124593. * @param source The JSON data to parse
  124594. * @param scene The scene to create the parsed material in
  124595. * @param rootUrl The root url of the assets the material depends upon
  124596. * @returns the instantiated BackgroundMaterial.
  124597. */
  124598. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  124599. }
  124600. }
  124601. declare module BABYLON {
  124602. /**
  124603. * Represents the different options available during the creation of
  124604. * a Environment helper.
  124605. *
  124606. * This can control the default ground, skybox and image processing setup of your scene.
  124607. */
  124608. export interface IEnvironmentHelperOptions {
  124609. /**
  124610. * Specifies whether or not to create a ground.
  124611. * True by default.
  124612. */
  124613. createGround: boolean;
  124614. /**
  124615. * Specifies the ground size.
  124616. * 15 by default.
  124617. */
  124618. groundSize: number;
  124619. /**
  124620. * The texture used on the ground for the main color.
  124621. * Comes from the BabylonJS CDN by default.
  124622. *
  124623. * Remarks: Can be either a texture or a url.
  124624. */
  124625. groundTexture: string | BaseTexture;
  124626. /**
  124627. * The color mixed in the ground texture by default.
  124628. * BabylonJS clearColor by default.
  124629. */
  124630. groundColor: Color3;
  124631. /**
  124632. * Specifies the ground opacity.
  124633. * 1 by default.
  124634. */
  124635. groundOpacity: number;
  124636. /**
  124637. * Enables the ground to receive shadows.
  124638. * True by default.
  124639. */
  124640. enableGroundShadow: boolean;
  124641. /**
  124642. * Helps preventing the shadow to be fully black on the ground.
  124643. * 0.5 by default.
  124644. */
  124645. groundShadowLevel: number;
  124646. /**
  124647. * Creates a mirror texture attach to the ground.
  124648. * false by default.
  124649. */
  124650. enableGroundMirror: boolean;
  124651. /**
  124652. * Specifies the ground mirror size ratio.
  124653. * 0.3 by default as the default kernel is 64.
  124654. */
  124655. groundMirrorSizeRatio: number;
  124656. /**
  124657. * Specifies the ground mirror blur kernel size.
  124658. * 64 by default.
  124659. */
  124660. groundMirrorBlurKernel: number;
  124661. /**
  124662. * Specifies the ground mirror visibility amount.
  124663. * 1 by default
  124664. */
  124665. groundMirrorAmount: number;
  124666. /**
  124667. * Specifies the ground mirror reflectance weight.
  124668. * This uses the standard weight of the background material to setup the fresnel effect
  124669. * of the mirror.
  124670. * 1 by default.
  124671. */
  124672. groundMirrorFresnelWeight: number;
  124673. /**
  124674. * Specifies the ground mirror Falloff distance.
  124675. * This can helps reducing the size of the reflection.
  124676. * 0 by Default.
  124677. */
  124678. groundMirrorFallOffDistance: number;
  124679. /**
  124680. * Specifies the ground mirror texture type.
  124681. * Unsigned Int by Default.
  124682. */
  124683. groundMirrorTextureType: number;
  124684. /**
  124685. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  124686. * the shown objects.
  124687. */
  124688. groundYBias: number;
  124689. /**
  124690. * Specifies whether or not to create a skybox.
  124691. * True by default.
  124692. */
  124693. createSkybox: boolean;
  124694. /**
  124695. * Specifies the skybox size.
  124696. * 20 by default.
  124697. */
  124698. skyboxSize: number;
  124699. /**
  124700. * The texture used on the skybox for the main color.
  124701. * Comes from the BabylonJS CDN by default.
  124702. *
  124703. * Remarks: Can be either a texture or a url.
  124704. */
  124705. skyboxTexture: string | BaseTexture;
  124706. /**
  124707. * The color mixed in the skybox texture by default.
  124708. * BabylonJS clearColor by default.
  124709. */
  124710. skyboxColor: Color3;
  124711. /**
  124712. * The background rotation around the Y axis of the scene.
  124713. * This helps aligning the key lights of your scene with the background.
  124714. * 0 by default.
  124715. */
  124716. backgroundYRotation: number;
  124717. /**
  124718. * Compute automatically the size of the elements to best fit with the scene.
  124719. */
  124720. sizeAuto: boolean;
  124721. /**
  124722. * Default position of the rootMesh if autoSize is not true.
  124723. */
  124724. rootPosition: Vector3;
  124725. /**
  124726. * Sets up the image processing in the scene.
  124727. * true by default.
  124728. */
  124729. setupImageProcessing: boolean;
  124730. /**
  124731. * The texture used as your environment texture in the scene.
  124732. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  124733. *
  124734. * Remarks: Can be either a texture or a url.
  124735. */
  124736. environmentTexture: string | BaseTexture;
  124737. /**
  124738. * The value of the exposure to apply to the scene.
  124739. * 0.6 by default if setupImageProcessing is true.
  124740. */
  124741. cameraExposure: number;
  124742. /**
  124743. * The value of the contrast to apply to the scene.
  124744. * 1.6 by default if setupImageProcessing is true.
  124745. */
  124746. cameraContrast: number;
  124747. /**
  124748. * Specifies whether or not tonemapping should be enabled in the scene.
  124749. * true by default if setupImageProcessing is true.
  124750. */
  124751. toneMappingEnabled: boolean;
  124752. }
  124753. /**
  124754. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  124755. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  124756. * It also helps with the default setup of your imageProcessing configuration.
  124757. */
  124758. export class EnvironmentHelper {
  124759. /**
  124760. * Default ground texture URL.
  124761. */
  124762. private static _groundTextureCDNUrl;
  124763. /**
  124764. * Default skybox texture URL.
  124765. */
  124766. private static _skyboxTextureCDNUrl;
  124767. /**
  124768. * Default environment texture URL.
  124769. */
  124770. private static _environmentTextureCDNUrl;
  124771. /**
  124772. * Creates the default options for the helper.
  124773. */
  124774. private static _getDefaultOptions;
  124775. private _rootMesh;
  124776. /**
  124777. * Gets the root mesh created by the helper.
  124778. */
  124779. get rootMesh(): Mesh;
  124780. private _skybox;
  124781. /**
  124782. * Gets the skybox created by the helper.
  124783. */
  124784. get skybox(): Nullable<Mesh>;
  124785. private _skyboxTexture;
  124786. /**
  124787. * Gets the skybox texture created by the helper.
  124788. */
  124789. get skyboxTexture(): Nullable<BaseTexture>;
  124790. private _skyboxMaterial;
  124791. /**
  124792. * Gets the skybox material created by the helper.
  124793. */
  124794. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  124795. private _ground;
  124796. /**
  124797. * Gets the ground mesh created by the helper.
  124798. */
  124799. get ground(): Nullable<Mesh>;
  124800. private _groundTexture;
  124801. /**
  124802. * Gets the ground texture created by the helper.
  124803. */
  124804. get groundTexture(): Nullable<BaseTexture>;
  124805. private _groundMirror;
  124806. /**
  124807. * Gets the ground mirror created by the helper.
  124808. */
  124809. get groundMirror(): Nullable<MirrorTexture>;
  124810. /**
  124811. * Gets the ground mirror render list to helps pushing the meshes
  124812. * you wish in the ground reflection.
  124813. */
  124814. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  124815. private _groundMaterial;
  124816. /**
  124817. * Gets the ground material created by the helper.
  124818. */
  124819. get groundMaterial(): Nullable<BackgroundMaterial>;
  124820. /**
  124821. * Stores the creation options.
  124822. */
  124823. private readonly _scene;
  124824. private _options;
  124825. /**
  124826. * This observable will be notified with any error during the creation of the environment,
  124827. * mainly texture creation errors.
  124828. */
  124829. onErrorObservable: Observable<{
  124830. message?: string;
  124831. exception?: any;
  124832. }>;
  124833. /**
  124834. * constructor
  124835. * @param options Defines the options we want to customize the helper
  124836. * @param scene The scene to add the material to
  124837. */
  124838. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  124839. /**
  124840. * Updates the background according to the new options
  124841. * @param options
  124842. */
  124843. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  124844. /**
  124845. * Sets the primary color of all the available elements.
  124846. * @param color the main color to affect to the ground and the background
  124847. */
  124848. setMainColor(color: Color3): void;
  124849. /**
  124850. * Setup the image processing according to the specified options.
  124851. */
  124852. private _setupImageProcessing;
  124853. /**
  124854. * Setup the environment texture according to the specified options.
  124855. */
  124856. private _setupEnvironmentTexture;
  124857. /**
  124858. * Setup the background according to the specified options.
  124859. */
  124860. private _setupBackground;
  124861. /**
  124862. * Get the scene sizes according to the setup.
  124863. */
  124864. private _getSceneSize;
  124865. /**
  124866. * Setup the ground according to the specified options.
  124867. */
  124868. private _setupGround;
  124869. /**
  124870. * Setup the ground material according to the specified options.
  124871. */
  124872. private _setupGroundMaterial;
  124873. /**
  124874. * Setup the ground diffuse texture according to the specified options.
  124875. */
  124876. private _setupGroundDiffuseTexture;
  124877. /**
  124878. * Setup the ground mirror texture according to the specified options.
  124879. */
  124880. private _setupGroundMirrorTexture;
  124881. /**
  124882. * Setup the ground to receive the mirror texture.
  124883. */
  124884. private _setupMirrorInGroundMaterial;
  124885. /**
  124886. * Setup the skybox according to the specified options.
  124887. */
  124888. private _setupSkybox;
  124889. /**
  124890. * Setup the skybox material according to the specified options.
  124891. */
  124892. private _setupSkyboxMaterial;
  124893. /**
  124894. * Setup the skybox reflection texture according to the specified options.
  124895. */
  124896. private _setupSkyboxReflectionTexture;
  124897. private _errorHandler;
  124898. /**
  124899. * Dispose all the elements created by the Helper.
  124900. */
  124901. dispose(): void;
  124902. }
  124903. }
  124904. declare module BABYLON {
  124905. /**
  124906. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  124907. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  124908. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  124909. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  124910. */
  124911. export class PhotoDome extends TransformNode {
  124912. /**
  124913. * Define the image as a Monoscopic panoramic 360 image.
  124914. */
  124915. static readonly MODE_MONOSCOPIC: number;
  124916. /**
  124917. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  124918. */
  124919. static readonly MODE_TOPBOTTOM: number;
  124920. /**
  124921. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  124922. */
  124923. static readonly MODE_SIDEBYSIDE: number;
  124924. private _useDirectMapping;
  124925. /**
  124926. * The texture being displayed on the sphere
  124927. */
  124928. protected _photoTexture: Texture;
  124929. /**
  124930. * Gets or sets the texture being displayed on the sphere
  124931. */
  124932. get photoTexture(): Texture;
  124933. set photoTexture(value: Texture);
  124934. /**
  124935. * Observable raised when an error occured while loading the 360 image
  124936. */
  124937. onLoadErrorObservable: Observable<string>;
  124938. /**
  124939. * The skybox material
  124940. */
  124941. protected _material: BackgroundMaterial;
  124942. /**
  124943. * The surface used for the skybox
  124944. */
  124945. protected _mesh: Mesh;
  124946. /**
  124947. * Gets the mesh used for the skybox.
  124948. */
  124949. get mesh(): Mesh;
  124950. /**
  124951. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  124952. * Also see the options.resolution property.
  124953. */
  124954. get fovMultiplier(): number;
  124955. set fovMultiplier(value: number);
  124956. private _imageMode;
  124957. /**
  124958. * Gets or set the current video mode for the video. It can be:
  124959. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  124960. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  124961. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  124962. */
  124963. get imageMode(): number;
  124964. set imageMode(value: number);
  124965. /**
  124966. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  124967. * @param name Element's name, child elements will append suffixes for their own names.
  124968. * @param urlsOfPhoto defines the url of the photo to display
  124969. * @param options defines an object containing optional or exposed sub element properties
  124970. * @param onError defines a callback called when an error occured while loading the texture
  124971. */
  124972. constructor(name: string, urlOfPhoto: string, options: {
  124973. resolution?: number;
  124974. size?: number;
  124975. useDirectMapping?: boolean;
  124976. faceForward?: boolean;
  124977. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  124978. private _onBeforeCameraRenderObserver;
  124979. private _changeImageMode;
  124980. /**
  124981. * Releases resources associated with this node.
  124982. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  124983. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  124984. */
  124985. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  124986. }
  124987. }
  124988. declare module BABYLON {
  124989. /**
  124990. * Class used to host RGBD texture specific utilities
  124991. */
  124992. export class RGBDTextureTools {
  124993. /**
  124994. * Expand the RGBD Texture from RGBD to Half Float if possible.
  124995. * @param texture the texture to expand.
  124996. */
  124997. static ExpandRGBDTexture(texture: Texture): void;
  124998. }
  124999. }
  125000. declare module BABYLON {
  125001. /**
  125002. * Class used to host texture specific utilities
  125003. */
  125004. export class BRDFTextureTools {
  125005. /**
  125006. * Prevents texture cache collision
  125007. */
  125008. private static _instanceNumber;
  125009. /**
  125010. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  125011. * @param scene defines the hosting scene
  125012. * @returns the environment BRDF texture
  125013. */
  125014. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  125015. private static _environmentBRDFBase64Texture;
  125016. }
  125017. }
  125018. declare module BABYLON {
  125019. /**
  125020. * @hidden
  125021. */
  125022. export interface IMaterialClearCoatDefines {
  125023. CLEARCOAT: boolean;
  125024. CLEARCOAT_DEFAULTIOR: boolean;
  125025. CLEARCOAT_TEXTURE: boolean;
  125026. CLEARCOAT_TEXTUREDIRECTUV: number;
  125027. CLEARCOAT_BUMP: boolean;
  125028. CLEARCOAT_BUMPDIRECTUV: number;
  125029. CLEARCOAT_TINT: boolean;
  125030. CLEARCOAT_TINT_TEXTURE: boolean;
  125031. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  125032. /** @hidden */
  125033. _areTexturesDirty: boolean;
  125034. }
  125035. /**
  125036. * Define the code related to the clear coat parameters of the pbr material.
  125037. */
  125038. export class PBRClearCoatConfiguration {
  125039. /**
  125040. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  125041. * The default fits with a polyurethane material.
  125042. */
  125043. private static readonly _DefaultIndexOfRefraction;
  125044. private _isEnabled;
  125045. /**
  125046. * Defines if the clear coat is enabled in the material.
  125047. */
  125048. isEnabled: boolean;
  125049. /**
  125050. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  125051. */
  125052. intensity: number;
  125053. /**
  125054. * Defines the clear coat layer roughness.
  125055. */
  125056. roughness: number;
  125057. private _indexOfRefraction;
  125058. /**
  125059. * Defines the index of refraction of the clear coat.
  125060. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  125061. * The default fits with a polyurethane material.
  125062. * Changing the default value is more performance intensive.
  125063. */
  125064. indexOfRefraction: number;
  125065. private _texture;
  125066. /**
  125067. * Stores the clear coat values in a texture.
  125068. */
  125069. texture: Nullable<BaseTexture>;
  125070. private _bumpTexture;
  125071. /**
  125072. * Define the clear coat specific bump texture.
  125073. */
  125074. bumpTexture: Nullable<BaseTexture>;
  125075. private _isTintEnabled;
  125076. /**
  125077. * Defines if the clear coat tint is enabled in the material.
  125078. */
  125079. isTintEnabled: boolean;
  125080. /**
  125081. * Defines the clear coat tint of the material.
  125082. * This is only use if tint is enabled
  125083. */
  125084. tintColor: Color3;
  125085. /**
  125086. * Defines the distance at which the tint color should be found in the
  125087. * clear coat media.
  125088. * This is only use if tint is enabled
  125089. */
  125090. tintColorAtDistance: number;
  125091. /**
  125092. * Defines the clear coat layer thickness.
  125093. * This is only use if tint is enabled
  125094. */
  125095. tintThickness: number;
  125096. private _tintTexture;
  125097. /**
  125098. * Stores the clear tint values in a texture.
  125099. * rgb is tint
  125100. * a is a thickness factor
  125101. */
  125102. tintTexture: Nullable<BaseTexture>;
  125103. /** @hidden */
  125104. private _internalMarkAllSubMeshesAsTexturesDirty;
  125105. /** @hidden */
  125106. _markAllSubMeshesAsTexturesDirty(): void;
  125107. /**
  125108. * Instantiate a new istance of clear coat configuration.
  125109. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  125110. */
  125111. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  125112. /**
  125113. * Gets wehter the submesh is ready to be used or not.
  125114. * @param defines the list of "defines" to update.
  125115. * @param scene defines the scene the material belongs to.
  125116. * @param engine defines the engine the material belongs to.
  125117. * @param disableBumpMap defines wether the material disables bump or not.
  125118. * @returns - boolean indicating that the submesh is ready or not.
  125119. */
  125120. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  125121. /**
  125122. * Checks to see if a texture is used in the material.
  125123. * @param defines the list of "defines" to update.
  125124. * @param scene defines the scene to the material belongs to.
  125125. */
  125126. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  125127. /**
  125128. * Binds the material data.
  125129. * @param uniformBuffer defines the Uniform buffer to fill in.
  125130. * @param scene defines the scene the material belongs to.
  125131. * @param engine defines the engine the material belongs to.
  125132. * @param disableBumpMap defines wether the material disables bump or not.
  125133. * @param isFrozen defines wether the material is frozen or not.
  125134. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  125135. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  125136. */
  125137. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  125138. /**
  125139. * Checks to see if a texture is used in the material.
  125140. * @param texture - Base texture to use.
  125141. * @returns - Boolean specifying if a texture is used in the material.
  125142. */
  125143. hasTexture(texture: BaseTexture): boolean;
  125144. /**
  125145. * Returns an array of the actively used textures.
  125146. * @param activeTextures Array of BaseTextures
  125147. */
  125148. getActiveTextures(activeTextures: BaseTexture[]): void;
  125149. /**
  125150. * Returns the animatable textures.
  125151. * @param animatables Array of animatable textures.
  125152. */
  125153. getAnimatables(animatables: IAnimatable[]): void;
  125154. /**
  125155. * Disposes the resources of the material.
  125156. * @param forceDisposeTextures - Forces the disposal of all textures.
  125157. */
  125158. dispose(forceDisposeTextures?: boolean): void;
  125159. /**
  125160. * Get the current class name of the texture useful for serialization or dynamic coding.
  125161. * @returns "PBRClearCoatConfiguration"
  125162. */
  125163. getClassName(): string;
  125164. /**
  125165. * Add fallbacks to the effect fallbacks list.
  125166. * @param defines defines the Base texture to use.
  125167. * @param fallbacks defines the current fallback list.
  125168. * @param currentRank defines the current fallback rank.
  125169. * @returns the new fallback rank.
  125170. */
  125171. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  125172. /**
  125173. * Add the required uniforms to the current list.
  125174. * @param uniforms defines the current uniform list.
  125175. */
  125176. static AddUniforms(uniforms: string[]): void;
  125177. /**
  125178. * Add the required samplers to the current list.
  125179. * @param samplers defines the current sampler list.
  125180. */
  125181. static AddSamplers(samplers: string[]): void;
  125182. /**
  125183. * Add the required uniforms to the current buffer.
  125184. * @param uniformBuffer defines the current uniform buffer.
  125185. */
  125186. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  125187. /**
  125188. * Makes a duplicate of the current configuration into another one.
  125189. * @param clearCoatConfiguration define the config where to copy the info
  125190. */
  125191. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  125192. /**
  125193. * Serializes this clear coat configuration.
  125194. * @returns - An object with the serialized config.
  125195. */
  125196. serialize(): any;
  125197. /**
  125198. * Parses a anisotropy Configuration from a serialized object.
  125199. * @param source - Serialized object.
  125200. * @param scene Defines the scene we are parsing for
  125201. * @param rootUrl Defines the rootUrl to load from
  125202. */
  125203. parse(source: any, scene: Scene, rootUrl: string): void;
  125204. }
  125205. }
  125206. declare module BABYLON {
  125207. /**
  125208. * @hidden
  125209. */
  125210. export interface IMaterialAnisotropicDefines {
  125211. ANISOTROPIC: boolean;
  125212. ANISOTROPIC_TEXTURE: boolean;
  125213. ANISOTROPIC_TEXTUREDIRECTUV: number;
  125214. MAINUV1: boolean;
  125215. _areTexturesDirty: boolean;
  125216. _needUVs: boolean;
  125217. }
  125218. /**
  125219. * Define the code related to the anisotropic parameters of the pbr material.
  125220. */
  125221. export class PBRAnisotropicConfiguration {
  125222. private _isEnabled;
  125223. /**
  125224. * Defines if the anisotropy is enabled in the material.
  125225. */
  125226. isEnabled: boolean;
  125227. /**
  125228. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  125229. */
  125230. intensity: number;
  125231. /**
  125232. * Defines if the effect is along the tangents, bitangents or in between.
  125233. * By default, the effect is "strectching" the highlights along the tangents.
  125234. */
  125235. direction: Vector2;
  125236. private _texture;
  125237. /**
  125238. * Stores the anisotropy values in a texture.
  125239. * rg is direction (like normal from -1 to 1)
  125240. * b is a intensity
  125241. */
  125242. texture: Nullable<BaseTexture>;
  125243. /** @hidden */
  125244. private _internalMarkAllSubMeshesAsTexturesDirty;
  125245. /** @hidden */
  125246. _markAllSubMeshesAsTexturesDirty(): void;
  125247. /**
  125248. * Instantiate a new istance of anisotropy configuration.
  125249. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  125250. */
  125251. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  125252. /**
  125253. * Specifies that the submesh is ready to be used.
  125254. * @param defines the list of "defines" to update.
  125255. * @param scene defines the scene the material belongs to.
  125256. * @returns - boolean indicating that the submesh is ready or not.
  125257. */
  125258. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  125259. /**
  125260. * Checks to see if a texture is used in the material.
  125261. * @param defines the list of "defines" to update.
  125262. * @param mesh the mesh we are preparing the defines for.
  125263. * @param scene defines the scene the material belongs to.
  125264. */
  125265. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  125266. /**
  125267. * Binds the material data.
  125268. * @param uniformBuffer defines the Uniform buffer to fill in.
  125269. * @param scene defines the scene the material belongs to.
  125270. * @param isFrozen defines wether the material is frozen or not.
  125271. */
  125272. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  125273. /**
  125274. * Checks to see if a texture is used in the material.
  125275. * @param texture - Base texture to use.
  125276. * @returns - Boolean specifying if a texture is used in the material.
  125277. */
  125278. hasTexture(texture: BaseTexture): boolean;
  125279. /**
  125280. * Returns an array of the actively used textures.
  125281. * @param activeTextures Array of BaseTextures
  125282. */
  125283. getActiveTextures(activeTextures: BaseTexture[]): void;
  125284. /**
  125285. * Returns the animatable textures.
  125286. * @param animatables Array of animatable textures.
  125287. */
  125288. getAnimatables(animatables: IAnimatable[]): void;
  125289. /**
  125290. * Disposes the resources of the material.
  125291. * @param forceDisposeTextures - Forces the disposal of all textures.
  125292. */
  125293. dispose(forceDisposeTextures?: boolean): void;
  125294. /**
  125295. * Get the current class name of the texture useful for serialization or dynamic coding.
  125296. * @returns "PBRAnisotropicConfiguration"
  125297. */
  125298. getClassName(): string;
  125299. /**
  125300. * Add fallbacks to the effect fallbacks list.
  125301. * @param defines defines the Base texture to use.
  125302. * @param fallbacks defines the current fallback list.
  125303. * @param currentRank defines the current fallback rank.
  125304. * @returns the new fallback rank.
  125305. */
  125306. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  125307. /**
  125308. * Add the required uniforms to the current list.
  125309. * @param uniforms defines the current uniform list.
  125310. */
  125311. static AddUniforms(uniforms: string[]): void;
  125312. /**
  125313. * Add the required uniforms to the current buffer.
  125314. * @param uniformBuffer defines the current uniform buffer.
  125315. */
  125316. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  125317. /**
  125318. * Add the required samplers to the current list.
  125319. * @param samplers defines the current sampler list.
  125320. */
  125321. static AddSamplers(samplers: string[]): void;
  125322. /**
  125323. * Makes a duplicate of the current configuration into another one.
  125324. * @param anisotropicConfiguration define the config where to copy the info
  125325. */
  125326. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  125327. /**
  125328. * Serializes this anisotropy configuration.
  125329. * @returns - An object with the serialized config.
  125330. */
  125331. serialize(): any;
  125332. /**
  125333. * Parses a anisotropy Configuration from a serialized object.
  125334. * @param source - Serialized object.
  125335. * @param scene Defines the scene we are parsing for
  125336. * @param rootUrl Defines the rootUrl to load from
  125337. */
  125338. parse(source: any, scene: Scene, rootUrl: string): void;
  125339. }
  125340. }
  125341. declare module BABYLON {
  125342. /**
  125343. * @hidden
  125344. */
  125345. export interface IMaterialBRDFDefines {
  125346. BRDF_V_HEIGHT_CORRELATED: boolean;
  125347. MS_BRDF_ENERGY_CONSERVATION: boolean;
  125348. SPHERICAL_HARMONICS: boolean;
  125349. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  125350. /** @hidden */
  125351. _areMiscDirty: boolean;
  125352. }
  125353. /**
  125354. * Define the code related to the BRDF parameters of the pbr material.
  125355. */
  125356. export class PBRBRDFConfiguration {
  125357. /**
  125358. * Default value used for the energy conservation.
  125359. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  125360. */
  125361. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  125362. /**
  125363. * Default value used for the Smith Visibility Height Correlated mode.
  125364. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  125365. */
  125366. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  125367. /**
  125368. * Default value used for the IBL diffuse part.
  125369. * This can help switching back to the polynomials mode globally which is a tiny bit
  125370. * less GPU intensive at the drawback of a lower quality.
  125371. */
  125372. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  125373. /**
  125374. * Default value used for activating energy conservation for the specular workflow.
  125375. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  125376. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  125377. */
  125378. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  125379. private _useEnergyConservation;
  125380. /**
  125381. * Defines if the material uses energy conservation.
  125382. */
  125383. useEnergyConservation: boolean;
  125384. private _useSmithVisibilityHeightCorrelated;
  125385. /**
  125386. * LEGACY Mode set to false
  125387. * Defines if the material uses height smith correlated visibility term.
  125388. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  125389. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  125390. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  125391. * Not relying on height correlated will also disable energy conservation.
  125392. */
  125393. useSmithVisibilityHeightCorrelated: boolean;
  125394. private _useSphericalHarmonics;
  125395. /**
  125396. * LEGACY Mode set to false
  125397. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  125398. * diffuse part of the IBL.
  125399. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  125400. * to the ground truth.
  125401. */
  125402. useSphericalHarmonics: boolean;
  125403. private _useSpecularGlossinessInputEnergyConservation;
  125404. /**
  125405. * Defines if the material uses energy conservation, when the specular workflow is active.
  125406. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  125407. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  125408. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  125409. */
  125410. useSpecularGlossinessInputEnergyConservation: boolean;
  125411. /** @hidden */
  125412. private _internalMarkAllSubMeshesAsMiscDirty;
  125413. /** @hidden */
  125414. _markAllSubMeshesAsMiscDirty(): void;
  125415. /**
  125416. * Instantiate a new istance of clear coat configuration.
  125417. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  125418. */
  125419. constructor(markAllSubMeshesAsMiscDirty: () => void);
  125420. /**
  125421. * Checks to see if a texture is used in the material.
  125422. * @param defines the list of "defines" to update.
  125423. */
  125424. prepareDefines(defines: IMaterialBRDFDefines): void;
  125425. /**
  125426. * Get the current class name of the texture useful for serialization or dynamic coding.
  125427. * @returns "PBRClearCoatConfiguration"
  125428. */
  125429. getClassName(): string;
  125430. /**
  125431. * Makes a duplicate of the current configuration into another one.
  125432. * @param brdfConfiguration define the config where to copy the info
  125433. */
  125434. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  125435. /**
  125436. * Serializes this BRDF configuration.
  125437. * @returns - An object with the serialized config.
  125438. */
  125439. serialize(): any;
  125440. /**
  125441. * Parses a anisotropy Configuration from a serialized object.
  125442. * @param source - Serialized object.
  125443. * @param scene Defines the scene we are parsing for
  125444. * @param rootUrl Defines the rootUrl to load from
  125445. */
  125446. parse(source: any, scene: Scene, rootUrl: string): void;
  125447. }
  125448. }
  125449. declare module BABYLON {
  125450. /**
  125451. * @hidden
  125452. */
  125453. export interface IMaterialSheenDefines {
  125454. SHEEN: boolean;
  125455. SHEEN_TEXTURE: boolean;
  125456. SHEEN_TEXTUREDIRECTUV: number;
  125457. SHEEN_LINKWITHALBEDO: boolean;
  125458. SHEEN_ROUGHNESS: boolean;
  125459. SHEEN_ALBEDOSCALING: boolean;
  125460. /** @hidden */
  125461. _areTexturesDirty: boolean;
  125462. }
  125463. /**
  125464. * Define the code related to the Sheen parameters of the pbr material.
  125465. */
  125466. export class PBRSheenConfiguration {
  125467. private _isEnabled;
  125468. /**
  125469. * Defines if the material uses sheen.
  125470. */
  125471. isEnabled: boolean;
  125472. private _linkSheenWithAlbedo;
  125473. /**
  125474. * Defines if the sheen is linked to the sheen color.
  125475. */
  125476. linkSheenWithAlbedo: boolean;
  125477. /**
  125478. * Defines the sheen intensity.
  125479. */
  125480. intensity: number;
  125481. /**
  125482. * Defines the sheen color.
  125483. */
  125484. color: Color3;
  125485. private _texture;
  125486. /**
  125487. * Stores the sheen tint values in a texture.
  125488. * rgb is tint
  125489. * a is a intensity
  125490. */
  125491. texture: Nullable<BaseTexture>;
  125492. private _roughness;
  125493. /**
  125494. * Defines the sheen roughness.
  125495. * It is not taken into account if linkSheenWithAlbedo is true.
  125496. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  125497. */
  125498. roughness: Nullable<number>;
  125499. private _albedoScaling;
  125500. /**
  125501. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  125502. * It allows the strength of the sheen effect to not depend on the base color of the material,
  125503. * making it easier to setup and tweak the effect
  125504. */
  125505. albedoScaling: boolean;
  125506. /** @hidden */
  125507. private _internalMarkAllSubMeshesAsTexturesDirty;
  125508. /** @hidden */
  125509. _markAllSubMeshesAsTexturesDirty(): void;
  125510. /**
  125511. * Instantiate a new istance of clear coat configuration.
  125512. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  125513. */
  125514. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  125515. /**
  125516. * Specifies that the submesh is ready to be used.
  125517. * @param defines the list of "defines" to update.
  125518. * @param scene defines the scene the material belongs to.
  125519. * @returns - boolean indicating that the submesh is ready or not.
  125520. */
  125521. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  125522. /**
  125523. * Checks to see if a texture is used in the material.
  125524. * @param defines the list of "defines" to update.
  125525. * @param scene defines the scene the material belongs to.
  125526. */
  125527. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  125528. /**
  125529. * Binds the material data.
  125530. * @param uniformBuffer defines the Uniform buffer to fill in.
  125531. * @param scene defines the scene the material belongs to.
  125532. * @param isFrozen defines wether the material is frozen or not.
  125533. */
  125534. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  125535. /**
  125536. * Checks to see if a texture is used in the material.
  125537. * @param texture - Base texture to use.
  125538. * @returns - Boolean specifying if a texture is used in the material.
  125539. */
  125540. hasTexture(texture: BaseTexture): boolean;
  125541. /**
  125542. * Returns an array of the actively used textures.
  125543. * @param activeTextures Array of BaseTextures
  125544. */
  125545. getActiveTextures(activeTextures: BaseTexture[]): void;
  125546. /**
  125547. * Returns the animatable textures.
  125548. * @param animatables Array of animatable textures.
  125549. */
  125550. getAnimatables(animatables: IAnimatable[]): void;
  125551. /**
  125552. * Disposes the resources of the material.
  125553. * @param forceDisposeTextures - Forces the disposal of all textures.
  125554. */
  125555. dispose(forceDisposeTextures?: boolean): void;
  125556. /**
  125557. * Get the current class name of the texture useful for serialization or dynamic coding.
  125558. * @returns "PBRSheenConfiguration"
  125559. */
  125560. getClassName(): string;
  125561. /**
  125562. * Add fallbacks to the effect fallbacks list.
  125563. * @param defines defines the Base texture to use.
  125564. * @param fallbacks defines the current fallback list.
  125565. * @param currentRank defines the current fallback rank.
  125566. * @returns the new fallback rank.
  125567. */
  125568. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  125569. /**
  125570. * Add the required uniforms to the current list.
  125571. * @param uniforms defines the current uniform list.
  125572. */
  125573. static AddUniforms(uniforms: string[]): void;
  125574. /**
  125575. * Add the required uniforms to the current buffer.
  125576. * @param uniformBuffer defines the current uniform buffer.
  125577. */
  125578. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  125579. /**
  125580. * Add the required samplers to the current list.
  125581. * @param samplers defines the current sampler list.
  125582. */
  125583. static AddSamplers(samplers: string[]): void;
  125584. /**
  125585. * Makes a duplicate of the current configuration into another one.
  125586. * @param sheenConfiguration define the config where to copy the info
  125587. */
  125588. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  125589. /**
  125590. * Serializes this BRDF configuration.
  125591. * @returns - An object with the serialized config.
  125592. */
  125593. serialize(): any;
  125594. /**
  125595. * Parses a anisotropy Configuration from a serialized object.
  125596. * @param source - Serialized object.
  125597. * @param scene Defines the scene we are parsing for
  125598. * @param rootUrl Defines the rootUrl to load from
  125599. */
  125600. parse(source: any, scene: Scene, rootUrl: string): void;
  125601. }
  125602. }
  125603. declare module BABYLON {
  125604. /**
  125605. * @hidden
  125606. */
  125607. export interface IMaterialSubSurfaceDefines {
  125608. SUBSURFACE: boolean;
  125609. SS_REFRACTION: boolean;
  125610. SS_TRANSLUCENCY: boolean;
  125611. SS_SCATERRING: boolean;
  125612. SS_THICKNESSANDMASK_TEXTURE: boolean;
  125613. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  125614. SS_REFRACTIONMAP_3D: boolean;
  125615. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  125616. SS_LODINREFRACTIONALPHA: boolean;
  125617. SS_GAMMAREFRACTION: boolean;
  125618. SS_RGBDREFRACTION: boolean;
  125619. SS_LINEARSPECULARREFRACTION: boolean;
  125620. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  125621. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  125622. /** @hidden */
  125623. _areTexturesDirty: boolean;
  125624. }
  125625. /**
  125626. * Define the code related to the sub surface parameters of the pbr material.
  125627. */
  125628. export class PBRSubSurfaceConfiguration {
  125629. private _isRefractionEnabled;
  125630. /**
  125631. * Defines if the refraction is enabled in the material.
  125632. */
  125633. isRefractionEnabled: boolean;
  125634. private _isTranslucencyEnabled;
  125635. /**
  125636. * Defines if the translucency is enabled in the material.
  125637. */
  125638. isTranslucencyEnabled: boolean;
  125639. private _isScatteringEnabled;
  125640. /**
  125641. * Defines the refraction intensity of the material.
  125642. * The refraction when enabled replaces the Diffuse part of the material.
  125643. * The intensity helps transitionning between diffuse and refraction.
  125644. */
  125645. refractionIntensity: number;
  125646. /**
  125647. * Defines the translucency intensity of the material.
  125648. * When translucency has been enabled, this defines how much of the "translucency"
  125649. * is addded to the diffuse part of the material.
  125650. */
  125651. translucencyIntensity: number;
  125652. /**
  125653. * Defines the scattering intensity of the material.
  125654. * When scattering has been enabled, this defines how much of the "scattered light"
  125655. * is addded to the diffuse part of the material.
  125656. */
  125657. scatteringIntensity: number;
  125658. private _thicknessTexture;
  125659. /**
  125660. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  125661. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  125662. * 0 would mean minimumThickness
  125663. * 1 would mean maximumThickness
  125664. * The other channels might be use as a mask to vary the different effects intensity.
  125665. */
  125666. thicknessTexture: Nullable<BaseTexture>;
  125667. private _refractionTexture;
  125668. /**
  125669. * Defines the texture to use for refraction.
  125670. */
  125671. refractionTexture: Nullable<BaseTexture>;
  125672. private _indexOfRefraction;
  125673. /**
  125674. * Defines the index of refraction used in the material.
  125675. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  125676. */
  125677. indexOfRefraction: number;
  125678. private _invertRefractionY;
  125679. /**
  125680. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  125681. */
  125682. invertRefractionY: boolean;
  125683. private _linkRefractionWithTransparency;
  125684. /**
  125685. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  125686. * Materials half opaque for instance using refraction could benefit from this control.
  125687. */
  125688. linkRefractionWithTransparency: boolean;
  125689. /**
  125690. * Defines the minimum thickness stored in the thickness map.
  125691. * If no thickness map is defined, this value will be used to simulate thickness.
  125692. */
  125693. minimumThickness: number;
  125694. /**
  125695. * Defines the maximum thickness stored in the thickness map.
  125696. */
  125697. maximumThickness: number;
  125698. /**
  125699. * Defines the volume tint of the material.
  125700. * This is used for both translucency and scattering.
  125701. */
  125702. tintColor: Color3;
  125703. /**
  125704. * Defines the distance at which the tint color should be found in the media.
  125705. * This is used for refraction only.
  125706. */
  125707. tintColorAtDistance: number;
  125708. /**
  125709. * Defines how far each channel transmit through the media.
  125710. * It is defined as a color to simplify it selection.
  125711. */
  125712. diffusionDistance: Color3;
  125713. private _useMaskFromThicknessTexture;
  125714. /**
  125715. * Stores the intensity of the different subsurface effects in the thickness texture.
  125716. * * the green channel is the translucency intensity.
  125717. * * the blue channel is the scattering intensity.
  125718. * * the alpha channel is the refraction intensity.
  125719. */
  125720. useMaskFromThicknessTexture: boolean;
  125721. /** @hidden */
  125722. private _internalMarkAllSubMeshesAsTexturesDirty;
  125723. /** @hidden */
  125724. _markAllSubMeshesAsTexturesDirty(): void;
  125725. /**
  125726. * Instantiate a new istance of sub surface configuration.
  125727. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  125728. */
  125729. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  125730. /**
  125731. * Gets wehter the submesh is ready to be used or not.
  125732. * @param defines the list of "defines" to update.
  125733. * @param scene defines the scene the material belongs to.
  125734. * @returns - boolean indicating that the submesh is ready or not.
  125735. */
  125736. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  125737. /**
  125738. * Checks to see if a texture is used in the material.
  125739. * @param defines the list of "defines" to update.
  125740. * @param scene defines the scene to the material belongs to.
  125741. */
  125742. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  125743. /**
  125744. * Binds the material data.
  125745. * @param uniformBuffer defines the Uniform buffer to fill in.
  125746. * @param scene defines the scene the material belongs to.
  125747. * @param engine defines the engine the material belongs to.
  125748. * @param isFrozen defines wether the material is frozen or not.
  125749. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  125750. */
  125751. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  125752. /**
  125753. * Unbinds the material from the mesh.
  125754. * @param activeEffect defines the effect that should be unbound from.
  125755. * @returns true if unbound, otherwise false
  125756. */
  125757. unbind(activeEffect: Effect): boolean;
  125758. /**
  125759. * Returns the texture used for refraction or null if none is used.
  125760. * @param scene defines the scene the material belongs to.
  125761. * @returns - Refraction texture if present. If no refraction texture and refraction
  125762. * is linked with transparency, returns environment texture. Otherwise, returns null.
  125763. */
  125764. private _getRefractionTexture;
  125765. /**
  125766. * Returns true if alpha blending should be disabled.
  125767. */
  125768. get disableAlphaBlending(): boolean;
  125769. /**
  125770. * Fills the list of render target textures.
  125771. * @param renderTargets the list of render targets to update
  125772. */
  125773. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  125774. /**
  125775. * Checks to see if a texture is used in the material.
  125776. * @param texture - Base texture to use.
  125777. * @returns - Boolean specifying if a texture is used in the material.
  125778. */
  125779. hasTexture(texture: BaseTexture): boolean;
  125780. /**
  125781. * Gets a boolean indicating that current material needs to register RTT
  125782. * @returns true if this uses a render target otherwise false.
  125783. */
  125784. hasRenderTargetTextures(): boolean;
  125785. /**
  125786. * Returns an array of the actively used textures.
  125787. * @param activeTextures Array of BaseTextures
  125788. */
  125789. getActiveTextures(activeTextures: BaseTexture[]): void;
  125790. /**
  125791. * Returns the animatable textures.
  125792. * @param animatables Array of animatable textures.
  125793. */
  125794. getAnimatables(animatables: IAnimatable[]): void;
  125795. /**
  125796. * Disposes the resources of the material.
  125797. * @param forceDisposeTextures - Forces the disposal of all textures.
  125798. */
  125799. dispose(forceDisposeTextures?: boolean): void;
  125800. /**
  125801. * Get the current class name of the texture useful for serialization or dynamic coding.
  125802. * @returns "PBRSubSurfaceConfiguration"
  125803. */
  125804. getClassName(): string;
  125805. /**
  125806. * Add fallbacks to the effect fallbacks list.
  125807. * @param defines defines the Base texture to use.
  125808. * @param fallbacks defines the current fallback list.
  125809. * @param currentRank defines the current fallback rank.
  125810. * @returns the new fallback rank.
  125811. */
  125812. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  125813. /**
  125814. * Add the required uniforms to the current list.
  125815. * @param uniforms defines the current uniform list.
  125816. */
  125817. static AddUniforms(uniforms: string[]): void;
  125818. /**
  125819. * Add the required samplers to the current list.
  125820. * @param samplers defines the current sampler list.
  125821. */
  125822. static AddSamplers(samplers: string[]): void;
  125823. /**
  125824. * Add the required uniforms to the current buffer.
  125825. * @param uniformBuffer defines the current uniform buffer.
  125826. */
  125827. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  125828. /**
  125829. * Makes a duplicate of the current configuration into another one.
  125830. * @param configuration define the config where to copy the info
  125831. */
  125832. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  125833. /**
  125834. * Serializes this Sub Surface configuration.
  125835. * @returns - An object with the serialized config.
  125836. */
  125837. serialize(): any;
  125838. /**
  125839. * Parses a anisotropy Configuration from a serialized object.
  125840. * @param source - Serialized object.
  125841. * @param scene Defines the scene we are parsing for
  125842. * @param rootUrl Defines the rootUrl to load from
  125843. */
  125844. parse(source: any, scene: Scene, rootUrl: string): void;
  125845. }
  125846. }
  125847. declare module BABYLON {
  125848. /** @hidden */
  125849. export var pbrFragmentDeclaration: {
  125850. name: string;
  125851. shader: string;
  125852. };
  125853. }
  125854. declare module BABYLON {
  125855. /** @hidden */
  125856. export var pbrUboDeclaration: {
  125857. name: string;
  125858. shader: string;
  125859. };
  125860. }
  125861. declare module BABYLON {
  125862. /** @hidden */
  125863. export var pbrFragmentExtraDeclaration: {
  125864. name: string;
  125865. shader: string;
  125866. };
  125867. }
  125868. declare module BABYLON {
  125869. /** @hidden */
  125870. export var pbrFragmentSamplersDeclaration: {
  125871. name: string;
  125872. shader: string;
  125873. };
  125874. }
  125875. declare module BABYLON {
  125876. /** @hidden */
  125877. export var pbrHelperFunctions: {
  125878. name: string;
  125879. shader: string;
  125880. };
  125881. }
  125882. declare module BABYLON {
  125883. /** @hidden */
  125884. export var harmonicsFunctions: {
  125885. name: string;
  125886. shader: string;
  125887. };
  125888. }
  125889. declare module BABYLON {
  125890. /** @hidden */
  125891. export var pbrDirectLightingSetupFunctions: {
  125892. name: string;
  125893. shader: string;
  125894. };
  125895. }
  125896. declare module BABYLON {
  125897. /** @hidden */
  125898. export var pbrDirectLightingFalloffFunctions: {
  125899. name: string;
  125900. shader: string;
  125901. };
  125902. }
  125903. declare module BABYLON {
  125904. /** @hidden */
  125905. export var pbrBRDFFunctions: {
  125906. name: string;
  125907. shader: string;
  125908. };
  125909. }
  125910. declare module BABYLON {
  125911. /** @hidden */
  125912. export var pbrDirectLightingFunctions: {
  125913. name: string;
  125914. shader: string;
  125915. };
  125916. }
  125917. declare module BABYLON {
  125918. /** @hidden */
  125919. export var pbrIBLFunctions: {
  125920. name: string;
  125921. shader: string;
  125922. };
  125923. }
  125924. declare module BABYLON {
  125925. /** @hidden */
  125926. export var pbrBlockAlbedoOpacity: {
  125927. name: string;
  125928. shader: string;
  125929. };
  125930. }
  125931. declare module BABYLON {
  125932. /** @hidden */
  125933. export var pbrBlockReflectivity: {
  125934. name: string;
  125935. shader: string;
  125936. };
  125937. }
  125938. declare module BABYLON {
  125939. /** @hidden */
  125940. export var pbrBlockAmbientOcclusion: {
  125941. name: string;
  125942. shader: string;
  125943. };
  125944. }
  125945. declare module BABYLON {
  125946. /** @hidden */
  125947. export var pbrBlockAlphaFresnel: {
  125948. name: string;
  125949. shader: string;
  125950. };
  125951. }
  125952. declare module BABYLON {
  125953. /** @hidden */
  125954. export var pbrBlockAnisotropic: {
  125955. name: string;
  125956. shader: string;
  125957. };
  125958. }
  125959. declare module BABYLON {
  125960. /** @hidden */
  125961. export var pbrBlockReflection: {
  125962. name: string;
  125963. shader: string;
  125964. };
  125965. }
  125966. declare module BABYLON {
  125967. /** @hidden */
  125968. export var pbrBlockSheen: {
  125969. name: string;
  125970. shader: string;
  125971. };
  125972. }
  125973. declare module BABYLON {
  125974. /** @hidden */
  125975. export var pbrBlockClearcoat: {
  125976. name: string;
  125977. shader: string;
  125978. };
  125979. }
  125980. declare module BABYLON {
  125981. /** @hidden */
  125982. export var pbrBlockSubSurface: {
  125983. name: string;
  125984. shader: string;
  125985. };
  125986. }
  125987. declare module BABYLON {
  125988. /** @hidden */
  125989. export var pbrBlockNormalGeometric: {
  125990. name: string;
  125991. shader: string;
  125992. };
  125993. }
  125994. declare module BABYLON {
  125995. /** @hidden */
  125996. export var pbrBlockNormalFinal: {
  125997. name: string;
  125998. shader: string;
  125999. };
  126000. }
  126001. declare module BABYLON {
  126002. /** @hidden */
  126003. export var pbrBlockGeometryInfo: {
  126004. name: string;
  126005. shader: string;
  126006. };
  126007. }
  126008. declare module BABYLON {
  126009. /** @hidden */
  126010. export var pbrBlockReflectance0: {
  126011. name: string;
  126012. shader: string;
  126013. };
  126014. }
  126015. declare module BABYLON {
  126016. /** @hidden */
  126017. export var pbrBlockReflectance: {
  126018. name: string;
  126019. shader: string;
  126020. };
  126021. }
  126022. declare module BABYLON {
  126023. /** @hidden */
  126024. export var pbrBlockDirectLighting: {
  126025. name: string;
  126026. shader: string;
  126027. };
  126028. }
  126029. declare module BABYLON {
  126030. /** @hidden */
  126031. export var pbrBlockFinalLitComponents: {
  126032. name: string;
  126033. shader: string;
  126034. };
  126035. }
  126036. declare module BABYLON {
  126037. /** @hidden */
  126038. export var pbrBlockFinalUnlitComponents: {
  126039. name: string;
  126040. shader: string;
  126041. };
  126042. }
  126043. declare module BABYLON {
  126044. /** @hidden */
  126045. export var pbrBlockFinalColorComposition: {
  126046. name: string;
  126047. shader: string;
  126048. };
  126049. }
  126050. declare module BABYLON {
  126051. /** @hidden */
  126052. export var pbrBlockImageProcessing: {
  126053. name: string;
  126054. shader: string;
  126055. };
  126056. }
  126057. declare module BABYLON {
  126058. /** @hidden */
  126059. export var pbrDebug: {
  126060. name: string;
  126061. shader: string;
  126062. };
  126063. }
  126064. declare module BABYLON {
  126065. /** @hidden */
  126066. export var pbrPixelShader: {
  126067. name: string;
  126068. shader: string;
  126069. };
  126070. }
  126071. declare module BABYLON {
  126072. /** @hidden */
  126073. export var pbrVertexDeclaration: {
  126074. name: string;
  126075. shader: string;
  126076. };
  126077. }
  126078. declare module BABYLON {
  126079. /** @hidden */
  126080. export var pbrVertexShader: {
  126081. name: string;
  126082. shader: string;
  126083. };
  126084. }
  126085. declare module BABYLON {
  126086. /**
  126087. * Manages the defines for the PBR Material.
  126088. * @hidden
  126089. */
  126090. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  126091. PBR: boolean;
  126092. MAINUV1: boolean;
  126093. MAINUV2: boolean;
  126094. UV1: boolean;
  126095. UV2: boolean;
  126096. ALBEDO: boolean;
  126097. GAMMAALBEDO: boolean;
  126098. ALBEDODIRECTUV: number;
  126099. VERTEXCOLOR: boolean;
  126100. AMBIENT: boolean;
  126101. AMBIENTDIRECTUV: number;
  126102. AMBIENTINGRAYSCALE: boolean;
  126103. OPACITY: boolean;
  126104. VERTEXALPHA: boolean;
  126105. OPACITYDIRECTUV: number;
  126106. OPACITYRGB: boolean;
  126107. ALPHATEST: boolean;
  126108. DEPTHPREPASS: boolean;
  126109. ALPHABLEND: boolean;
  126110. ALPHAFROMALBEDO: boolean;
  126111. ALPHATESTVALUE: string;
  126112. SPECULAROVERALPHA: boolean;
  126113. RADIANCEOVERALPHA: boolean;
  126114. ALPHAFRESNEL: boolean;
  126115. LINEARALPHAFRESNEL: boolean;
  126116. PREMULTIPLYALPHA: boolean;
  126117. EMISSIVE: boolean;
  126118. EMISSIVEDIRECTUV: number;
  126119. REFLECTIVITY: boolean;
  126120. REFLECTIVITYDIRECTUV: number;
  126121. SPECULARTERM: boolean;
  126122. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  126123. MICROSURFACEAUTOMATIC: boolean;
  126124. LODBASEDMICROSFURACE: boolean;
  126125. MICROSURFACEMAP: boolean;
  126126. MICROSURFACEMAPDIRECTUV: number;
  126127. METALLICWORKFLOW: boolean;
  126128. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  126129. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  126130. METALLNESSSTOREINMETALMAPBLUE: boolean;
  126131. AOSTOREINMETALMAPRED: boolean;
  126132. METALLICF0FACTORFROMMETALLICMAP: boolean;
  126133. ENVIRONMENTBRDF: boolean;
  126134. ENVIRONMENTBRDF_RGBD: boolean;
  126135. NORMAL: boolean;
  126136. TANGENT: boolean;
  126137. BUMP: boolean;
  126138. BUMPDIRECTUV: number;
  126139. OBJECTSPACE_NORMALMAP: boolean;
  126140. PARALLAX: boolean;
  126141. PARALLAXOCCLUSION: boolean;
  126142. NORMALXYSCALE: boolean;
  126143. LIGHTMAP: boolean;
  126144. LIGHTMAPDIRECTUV: number;
  126145. USELIGHTMAPASSHADOWMAP: boolean;
  126146. GAMMALIGHTMAP: boolean;
  126147. RGBDLIGHTMAP: boolean;
  126148. REFLECTION: boolean;
  126149. REFLECTIONMAP_3D: boolean;
  126150. REFLECTIONMAP_SPHERICAL: boolean;
  126151. REFLECTIONMAP_PLANAR: boolean;
  126152. REFLECTIONMAP_CUBIC: boolean;
  126153. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  126154. REFLECTIONMAP_PROJECTION: boolean;
  126155. REFLECTIONMAP_SKYBOX: boolean;
  126156. REFLECTIONMAP_EXPLICIT: boolean;
  126157. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  126158. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  126159. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  126160. INVERTCUBICMAP: boolean;
  126161. USESPHERICALFROMREFLECTIONMAP: boolean;
  126162. USEIRRADIANCEMAP: boolean;
  126163. SPHERICAL_HARMONICS: boolean;
  126164. USESPHERICALINVERTEX: boolean;
  126165. REFLECTIONMAP_OPPOSITEZ: boolean;
  126166. LODINREFLECTIONALPHA: boolean;
  126167. GAMMAREFLECTION: boolean;
  126168. RGBDREFLECTION: boolean;
  126169. LINEARSPECULARREFLECTION: boolean;
  126170. RADIANCEOCCLUSION: boolean;
  126171. HORIZONOCCLUSION: boolean;
  126172. INSTANCES: boolean;
  126173. NUM_BONE_INFLUENCERS: number;
  126174. BonesPerMesh: number;
  126175. BONETEXTURE: boolean;
  126176. NONUNIFORMSCALING: boolean;
  126177. MORPHTARGETS: boolean;
  126178. MORPHTARGETS_NORMAL: boolean;
  126179. MORPHTARGETS_TANGENT: boolean;
  126180. MORPHTARGETS_UV: boolean;
  126181. NUM_MORPH_INFLUENCERS: number;
  126182. IMAGEPROCESSING: boolean;
  126183. VIGNETTE: boolean;
  126184. VIGNETTEBLENDMODEMULTIPLY: boolean;
  126185. VIGNETTEBLENDMODEOPAQUE: boolean;
  126186. TONEMAPPING: boolean;
  126187. TONEMAPPING_ACES: boolean;
  126188. CONTRAST: boolean;
  126189. COLORCURVES: boolean;
  126190. COLORGRADING: boolean;
  126191. COLORGRADING3D: boolean;
  126192. SAMPLER3DGREENDEPTH: boolean;
  126193. SAMPLER3DBGRMAP: boolean;
  126194. IMAGEPROCESSINGPOSTPROCESS: boolean;
  126195. EXPOSURE: boolean;
  126196. MULTIVIEW: boolean;
  126197. USEPHYSICALLIGHTFALLOFF: boolean;
  126198. USEGLTFLIGHTFALLOFF: boolean;
  126199. TWOSIDEDLIGHTING: boolean;
  126200. SHADOWFLOAT: boolean;
  126201. CLIPPLANE: boolean;
  126202. CLIPPLANE2: boolean;
  126203. CLIPPLANE3: boolean;
  126204. CLIPPLANE4: boolean;
  126205. CLIPPLANE5: boolean;
  126206. CLIPPLANE6: boolean;
  126207. POINTSIZE: boolean;
  126208. FOG: boolean;
  126209. LOGARITHMICDEPTH: boolean;
  126210. FORCENORMALFORWARD: boolean;
  126211. SPECULARAA: boolean;
  126212. CLEARCOAT: boolean;
  126213. CLEARCOAT_DEFAULTIOR: boolean;
  126214. CLEARCOAT_TEXTURE: boolean;
  126215. CLEARCOAT_TEXTUREDIRECTUV: number;
  126216. CLEARCOAT_BUMP: boolean;
  126217. CLEARCOAT_BUMPDIRECTUV: number;
  126218. CLEARCOAT_TINT: boolean;
  126219. CLEARCOAT_TINT_TEXTURE: boolean;
  126220. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  126221. ANISOTROPIC: boolean;
  126222. ANISOTROPIC_TEXTURE: boolean;
  126223. ANISOTROPIC_TEXTUREDIRECTUV: number;
  126224. BRDF_V_HEIGHT_CORRELATED: boolean;
  126225. MS_BRDF_ENERGY_CONSERVATION: boolean;
  126226. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  126227. SHEEN: boolean;
  126228. SHEEN_TEXTURE: boolean;
  126229. SHEEN_TEXTUREDIRECTUV: number;
  126230. SHEEN_LINKWITHALBEDO: boolean;
  126231. SHEEN_ROUGHNESS: boolean;
  126232. SHEEN_ALBEDOSCALING: boolean;
  126233. SUBSURFACE: boolean;
  126234. SS_REFRACTION: boolean;
  126235. SS_TRANSLUCENCY: boolean;
  126236. SS_SCATERRING: boolean;
  126237. SS_THICKNESSANDMASK_TEXTURE: boolean;
  126238. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  126239. SS_REFRACTIONMAP_3D: boolean;
  126240. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  126241. SS_LODINREFRACTIONALPHA: boolean;
  126242. SS_GAMMAREFRACTION: boolean;
  126243. SS_RGBDREFRACTION: boolean;
  126244. SS_LINEARSPECULARREFRACTION: boolean;
  126245. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  126246. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  126247. UNLIT: boolean;
  126248. DEBUGMODE: number;
  126249. /**
  126250. * Initializes the PBR Material defines.
  126251. */
  126252. constructor();
  126253. /**
  126254. * Resets the PBR Material defines.
  126255. */
  126256. reset(): void;
  126257. }
  126258. /**
  126259. * The Physically based material base class of BJS.
  126260. *
  126261. * This offers the main features of a standard PBR material.
  126262. * For more information, please refer to the documentation :
  126263. * https://doc.babylonjs.com/how_to/physically_based_rendering
  126264. */
  126265. export abstract class PBRBaseMaterial extends PushMaterial {
  126266. /**
  126267. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  126268. */
  126269. static readonly PBRMATERIAL_OPAQUE: number;
  126270. /**
  126271. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  126272. */
  126273. static readonly PBRMATERIAL_ALPHATEST: number;
  126274. /**
  126275. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  126276. */
  126277. static readonly PBRMATERIAL_ALPHABLEND: number;
  126278. /**
  126279. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  126280. * They are also discarded below the alpha cutoff threshold to improve performances.
  126281. */
  126282. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  126283. /**
  126284. * Defines the default value of how much AO map is occluding the analytical lights
  126285. * (point spot...).
  126286. */
  126287. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  126288. /**
  126289. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  126290. */
  126291. static readonly LIGHTFALLOFF_PHYSICAL: number;
  126292. /**
  126293. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  126294. * to enhance interoperability with other engines.
  126295. */
  126296. static readonly LIGHTFALLOFF_GLTF: number;
  126297. /**
  126298. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  126299. * to enhance interoperability with other materials.
  126300. */
  126301. static readonly LIGHTFALLOFF_STANDARD: number;
  126302. /**
  126303. * Intensity of the direct lights e.g. the four lights available in your scene.
  126304. * This impacts both the direct diffuse and specular highlights.
  126305. */
  126306. protected _directIntensity: number;
  126307. /**
  126308. * Intensity of the emissive part of the material.
  126309. * This helps controlling the emissive effect without modifying the emissive color.
  126310. */
  126311. protected _emissiveIntensity: number;
  126312. /**
  126313. * Intensity of the environment e.g. how much the environment will light the object
  126314. * either through harmonics for rough material or through the refelction for shiny ones.
  126315. */
  126316. protected _environmentIntensity: number;
  126317. /**
  126318. * This is a special control allowing the reduction of the specular highlights coming from the
  126319. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  126320. */
  126321. protected _specularIntensity: number;
  126322. /**
  126323. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  126324. */
  126325. private _lightingInfos;
  126326. /**
  126327. * Debug Control allowing disabling the bump map on this material.
  126328. */
  126329. protected _disableBumpMap: boolean;
  126330. /**
  126331. * AKA Diffuse Texture in standard nomenclature.
  126332. */
  126333. protected _albedoTexture: Nullable<BaseTexture>;
  126334. /**
  126335. * AKA Occlusion Texture in other nomenclature.
  126336. */
  126337. protected _ambientTexture: Nullable<BaseTexture>;
  126338. /**
  126339. * AKA Occlusion Texture Intensity in other nomenclature.
  126340. */
  126341. protected _ambientTextureStrength: number;
  126342. /**
  126343. * Defines how much the AO map is occluding the analytical lights (point spot...).
  126344. * 1 means it completely occludes it
  126345. * 0 mean it has no impact
  126346. */
  126347. protected _ambientTextureImpactOnAnalyticalLights: number;
  126348. /**
  126349. * Stores the alpha values in a texture.
  126350. */
  126351. protected _opacityTexture: Nullable<BaseTexture>;
  126352. /**
  126353. * Stores the reflection values in a texture.
  126354. */
  126355. protected _reflectionTexture: Nullable<BaseTexture>;
  126356. /**
  126357. * Stores the emissive values in a texture.
  126358. */
  126359. protected _emissiveTexture: Nullable<BaseTexture>;
  126360. /**
  126361. * AKA Specular texture in other nomenclature.
  126362. */
  126363. protected _reflectivityTexture: Nullable<BaseTexture>;
  126364. /**
  126365. * Used to switch from specular/glossiness to metallic/roughness workflow.
  126366. */
  126367. protected _metallicTexture: Nullable<BaseTexture>;
  126368. /**
  126369. * Specifies the metallic scalar of the metallic/roughness workflow.
  126370. * Can also be used to scale the metalness values of the metallic texture.
  126371. */
  126372. protected _metallic: Nullable<number>;
  126373. /**
  126374. * Specifies the roughness scalar of the metallic/roughness workflow.
  126375. * Can also be used to scale the roughness values of the metallic texture.
  126376. */
  126377. protected _roughness: Nullable<number>;
  126378. /**
  126379. * Specifies the an F0 factor to help configuring the material F0.
  126380. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  126381. * to 0.5 the previously hard coded value stays the same.
  126382. * Can also be used to scale the F0 values of the metallic texture.
  126383. */
  126384. protected _metallicF0Factor: number;
  126385. /**
  126386. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  126387. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  126388. * your expectation as it multiplies with the texture data.
  126389. */
  126390. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  126391. /**
  126392. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  126393. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  126394. */
  126395. protected _microSurfaceTexture: Nullable<BaseTexture>;
  126396. /**
  126397. * Stores surface normal data used to displace a mesh in a texture.
  126398. */
  126399. protected _bumpTexture: Nullable<BaseTexture>;
  126400. /**
  126401. * Stores the pre-calculated light information of a mesh in a texture.
  126402. */
  126403. protected _lightmapTexture: Nullable<BaseTexture>;
  126404. /**
  126405. * The color of a material in ambient lighting.
  126406. */
  126407. protected _ambientColor: Color3;
  126408. /**
  126409. * AKA Diffuse Color in other nomenclature.
  126410. */
  126411. protected _albedoColor: Color3;
  126412. /**
  126413. * AKA Specular Color in other nomenclature.
  126414. */
  126415. protected _reflectivityColor: Color3;
  126416. /**
  126417. * The color applied when light is reflected from a material.
  126418. */
  126419. protected _reflectionColor: Color3;
  126420. /**
  126421. * The color applied when light is emitted from a material.
  126422. */
  126423. protected _emissiveColor: Color3;
  126424. /**
  126425. * AKA Glossiness in other nomenclature.
  126426. */
  126427. protected _microSurface: number;
  126428. /**
  126429. * Specifies that the material will use the light map as a show map.
  126430. */
  126431. protected _useLightmapAsShadowmap: boolean;
  126432. /**
  126433. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  126434. * makes the reflect vector face the model (under horizon).
  126435. */
  126436. protected _useHorizonOcclusion: boolean;
  126437. /**
  126438. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  126439. * too much the area relying on ambient texture to define their ambient occlusion.
  126440. */
  126441. protected _useRadianceOcclusion: boolean;
  126442. /**
  126443. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  126444. */
  126445. protected _useAlphaFromAlbedoTexture: boolean;
  126446. /**
  126447. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  126448. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  126449. */
  126450. protected _useSpecularOverAlpha: boolean;
  126451. /**
  126452. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  126453. */
  126454. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  126455. /**
  126456. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  126457. */
  126458. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  126459. /**
  126460. * Specifies if the metallic texture contains the roughness information in its green channel.
  126461. */
  126462. protected _useRoughnessFromMetallicTextureGreen: boolean;
  126463. /**
  126464. * Specifies if the metallic texture contains the metallness information in its blue channel.
  126465. */
  126466. protected _useMetallnessFromMetallicTextureBlue: boolean;
  126467. /**
  126468. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  126469. */
  126470. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  126471. /**
  126472. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  126473. */
  126474. protected _useAmbientInGrayScale: boolean;
  126475. /**
  126476. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  126477. * The material will try to infer what glossiness each pixel should be.
  126478. */
  126479. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  126480. /**
  126481. * Defines the falloff type used in this material.
  126482. * It by default is Physical.
  126483. */
  126484. protected _lightFalloff: number;
  126485. /**
  126486. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  126487. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  126488. */
  126489. protected _useRadianceOverAlpha: boolean;
  126490. /**
  126491. * Allows using an object space normal map (instead of tangent space).
  126492. */
  126493. protected _useObjectSpaceNormalMap: boolean;
  126494. /**
  126495. * Allows using the bump map in parallax mode.
  126496. */
  126497. protected _useParallax: boolean;
  126498. /**
  126499. * Allows using the bump map in parallax occlusion mode.
  126500. */
  126501. protected _useParallaxOcclusion: boolean;
  126502. /**
  126503. * Controls the scale bias of the parallax mode.
  126504. */
  126505. protected _parallaxScaleBias: number;
  126506. /**
  126507. * If sets to true, disables all the lights affecting the material.
  126508. */
  126509. protected _disableLighting: boolean;
  126510. /**
  126511. * Number of Simultaneous lights allowed on the material.
  126512. */
  126513. protected _maxSimultaneousLights: number;
  126514. /**
  126515. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  126516. */
  126517. protected _invertNormalMapX: boolean;
  126518. /**
  126519. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  126520. */
  126521. protected _invertNormalMapY: boolean;
  126522. /**
  126523. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  126524. */
  126525. protected _twoSidedLighting: boolean;
  126526. /**
  126527. * Defines the alpha limits in alpha test mode.
  126528. */
  126529. protected _alphaCutOff: number;
  126530. /**
  126531. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  126532. */
  126533. protected _forceAlphaTest: boolean;
  126534. /**
  126535. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  126536. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  126537. */
  126538. protected _useAlphaFresnel: boolean;
  126539. /**
  126540. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  126541. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  126542. */
  126543. protected _useLinearAlphaFresnel: boolean;
  126544. /**
  126545. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  126546. * from cos thetav and roughness:
  126547. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  126548. */
  126549. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  126550. /**
  126551. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  126552. */
  126553. protected _forceIrradianceInFragment: boolean;
  126554. /**
  126555. * Force normal to face away from face.
  126556. */
  126557. protected _forceNormalForward: boolean;
  126558. /**
  126559. * Enables specular anti aliasing in the PBR shader.
  126560. * It will both interacts on the Geometry for analytical and IBL lighting.
  126561. * It also prefilter the roughness map based on the bump values.
  126562. */
  126563. protected _enableSpecularAntiAliasing: boolean;
  126564. /**
  126565. * Default configuration related to image processing available in the PBR Material.
  126566. */
  126567. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  126568. /**
  126569. * Keep track of the image processing observer to allow dispose and replace.
  126570. */
  126571. private _imageProcessingObserver;
  126572. /**
  126573. * Attaches a new image processing configuration to the PBR Material.
  126574. * @param configuration
  126575. */
  126576. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  126577. /**
  126578. * Stores the available render targets.
  126579. */
  126580. private _renderTargets;
  126581. /**
  126582. * Sets the global ambient color for the material used in lighting calculations.
  126583. */
  126584. private _globalAmbientColor;
  126585. /**
  126586. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  126587. */
  126588. private _useLogarithmicDepth;
  126589. /**
  126590. * If set to true, no lighting calculations will be applied.
  126591. */
  126592. private _unlit;
  126593. private _debugMode;
  126594. /**
  126595. * @hidden
  126596. * This is reserved for the inspector.
  126597. * Defines the material debug mode.
  126598. * It helps seeing only some components of the material while troubleshooting.
  126599. */
  126600. debugMode: number;
  126601. /**
  126602. * @hidden
  126603. * This is reserved for the inspector.
  126604. * Specify from where on screen the debug mode should start.
  126605. * The value goes from -1 (full screen) to 1 (not visible)
  126606. * It helps with side by side comparison against the final render
  126607. * This defaults to -1
  126608. */
  126609. private debugLimit;
  126610. /**
  126611. * @hidden
  126612. * This is reserved for the inspector.
  126613. * As the default viewing range might not be enough (if the ambient is really small for instance)
  126614. * You can use the factor to better multiply the final value.
  126615. */
  126616. private debugFactor;
  126617. /**
  126618. * Defines the clear coat layer parameters for the material.
  126619. */
  126620. readonly clearCoat: PBRClearCoatConfiguration;
  126621. /**
  126622. * Defines the anisotropic parameters for the material.
  126623. */
  126624. readonly anisotropy: PBRAnisotropicConfiguration;
  126625. /**
  126626. * Defines the BRDF parameters for the material.
  126627. */
  126628. readonly brdf: PBRBRDFConfiguration;
  126629. /**
  126630. * Defines the Sheen parameters for the material.
  126631. */
  126632. readonly sheen: PBRSheenConfiguration;
  126633. /**
  126634. * Defines the SubSurface parameters for the material.
  126635. */
  126636. readonly subSurface: PBRSubSurfaceConfiguration;
  126637. protected _rebuildInParallel: boolean;
  126638. /**
  126639. * Instantiates a new PBRMaterial instance.
  126640. *
  126641. * @param name The material name
  126642. * @param scene The scene the material will be use in.
  126643. */
  126644. constructor(name: string, scene: Scene);
  126645. /**
  126646. * Gets a boolean indicating that current material needs to register RTT
  126647. */
  126648. get hasRenderTargetTextures(): boolean;
  126649. /**
  126650. * Gets the name of the material class.
  126651. */
  126652. getClassName(): string;
  126653. /**
  126654. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  126655. */
  126656. get useLogarithmicDepth(): boolean;
  126657. /**
  126658. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  126659. */
  126660. set useLogarithmicDepth(value: boolean);
  126661. /**
  126662. * Returns true if alpha blending should be disabled.
  126663. */
  126664. protected get _disableAlphaBlending(): boolean;
  126665. /**
  126666. * Specifies whether or not this material should be rendered in alpha blend mode.
  126667. */
  126668. needAlphaBlending(): boolean;
  126669. /**
  126670. * Specifies whether or not this material should be rendered in alpha test mode.
  126671. */
  126672. needAlphaTesting(): boolean;
  126673. /**
  126674. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  126675. */
  126676. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  126677. /**
  126678. * Gets the texture used for the alpha test.
  126679. */
  126680. getAlphaTestTexture(): Nullable<BaseTexture>;
  126681. /**
  126682. * Specifies that the submesh is ready to be used.
  126683. * @param mesh - BJS mesh.
  126684. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  126685. * @param useInstances - Specifies that instances should be used.
  126686. * @returns - boolean indicating that the submesh is ready or not.
  126687. */
  126688. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  126689. /**
  126690. * Specifies if the material uses metallic roughness workflow.
  126691. * @returns boolean specifiying if the material uses metallic roughness workflow.
  126692. */
  126693. isMetallicWorkflow(): boolean;
  126694. private _prepareEffect;
  126695. private _prepareDefines;
  126696. /**
  126697. * Force shader compilation
  126698. */
  126699. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  126700. /**
  126701. * Initializes the uniform buffer layout for the shader.
  126702. */
  126703. buildUniformLayout(): void;
  126704. /**
  126705. * Unbinds the material from the mesh
  126706. */
  126707. unbind(): void;
  126708. /**
  126709. * Binds the submesh data.
  126710. * @param world - The world matrix.
  126711. * @param mesh - The BJS mesh.
  126712. * @param subMesh - A submesh of the BJS mesh.
  126713. */
  126714. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  126715. /**
  126716. * Returns the animatable textures.
  126717. * @returns - Array of animatable textures.
  126718. */
  126719. getAnimatables(): IAnimatable[];
  126720. /**
  126721. * Returns the texture used for reflections.
  126722. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  126723. */
  126724. private _getReflectionTexture;
  126725. /**
  126726. * Returns an array of the actively used textures.
  126727. * @returns - Array of BaseTextures
  126728. */
  126729. getActiveTextures(): BaseTexture[];
  126730. /**
  126731. * Checks to see if a texture is used in the material.
  126732. * @param texture - Base texture to use.
  126733. * @returns - Boolean specifying if a texture is used in the material.
  126734. */
  126735. hasTexture(texture: BaseTexture): boolean;
  126736. /**
  126737. * Disposes the resources of the material.
  126738. * @param forceDisposeEffect - Forces the disposal of effects.
  126739. * @param forceDisposeTextures - Forces the disposal of all textures.
  126740. */
  126741. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  126742. }
  126743. }
  126744. declare module BABYLON {
  126745. /**
  126746. * The Physically based material of BJS.
  126747. *
  126748. * This offers the main features of a standard PBR material.
  126749. * For more information, please refer to the documentation :
  126750. * https://doc.babylonjs.com/how_to/physically_based_rendering
  126751. */
  126752. export class PBRMaterial extends PBRBaseMaterial {
  126753. /**
  126754. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  126755. */
  126756. static readonly PBRMATERIAL_OPAQUE: number;
  126757. /**
  126758. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  126759. */
  126760. static readonly PBRMATERIAL_ALPHATEST: number;
  126761. /**
  126762. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  126763. */
  126764. static readonly PBRMATERIAL_ALPHABLEND: number;
  126765. /**
  126766. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  126767. * They are also discarded below the alpha cutoff threshold to improve performances.
  126768. */
  126769. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  126770. /**
  126771. * Defines the default value of how much AO map is occluding the analytical lights
  126772. * (point spot...).
  126773. */
  126774. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  126775. /**
  126776. * Intensity of the direct lights e.g. the four lights available in your scene.
  126777. * This impacts both the direct diffuse and specular highlights.
  126778. */
  126779. directIntensity: number;
  126780. /**
  126781. * Intensity of the emissive part of the material.
  126782. * This helps controlling the emissive effect without modifying the emissive color.
  126783. */
  126784. emissiveIntensity: number;
  126785. /**
  126786. * Intensity of the environment e.g. how much the environment will light the object
  126787. * either through harmonics for rough material or through the refelction for shiny ones.
  126788. */
  126789. environmentIntensity: number;
  126790. /**
  126791. * This is a special control allowing the reduction of the specular highlights coming from the
  126792. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  126793. */
  126794. specularIntensity: number;
  126795. /**
  126796. * Debug Control allowing disabling the bump map on this material.
  126797. */
  126798. disableBumpMap: boolean;
  126799. /**
  126800. * AKA Diffuse Texture in standard nomenclature.
  126801. */
  126802. albedoTexture: BaseTexture;
  126803. /**
  126804. * AKA Occlusion Texture in other nomenclature.
  126805. */
  126806. ambientTexture: BaseTexture;
  126807. /**
  126808. * AKA Occlusion Texture Intensity in other nomenclature.
  126809. */
  126810. ambientTextureStrength: number;
  126811. /**
  126812. * Defines how much the AO map is occluding the analytical lights (point spot...).
  126813. * 1 means it completely occludes it
  126814. * 0 mean it has no impact
  126815. */
  126816. ambientTextureImpactOnAnalyticalLights: number;
  126817. /**
  126818. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  126819. */
  126820. opacityTexture: BaseTexture;
  126821. /**
  126822. * Stores the reflection values in a texture.
  126823. */
  126824. reflectionTexture: Nullable<BaseTexture>;
  126825. /**
  126826. * Stores the emissive values in a texture.
  126827. */
  126828. emissiveTexture: BaseTexture;
  126829. /**
  126830. * AKA Specular texture in other nomenclature.
  126831. */
  126832. reflectivityTexture: BaseTexture;
  126833. /**
  126834. * Used to switch from specular/glossiness to metallic/roughness workflow.
  126835. */
  126836. metallicTexture: BaseTexture;
  126837. /**
  126838. * Specifies the metallic scalar of the metallic/roughness workflow.
  126839. * Can also be used to scale the metalness values of the metallic texture.
  126840. */
  126841. metallic: Nullable<number>;
  126842. /**
  126843. * Specifies the roughness scalar of the metallic/roughness workflow.
  126844. * Can also be used to scale the roughness values of the metallic texture.
  126845. */
  126846. roughness: Nullable<number>;
  126847. /**
  126848. * Specifies the an F0 factor to help configuring the material F0.
  126849. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  126850. * to 0.5 the previously hard coded value stays the same.
  126851. * Can also be used to scale the F0 values of the metallic texture.
  126852. */
  126853. metallicF0Factor: number;
  126854. /**
  126855. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  126856. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  126857. * your expectation as it multiplies with the texture data.
  126858. */
  126859. useMetallicF0FactorFromMetallicTexture: boolean;
  126860. /**
  126861. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  126862. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  126863. */
  126864. microSurfaceTexture: BaseTexture;
  126865. /**
  126866. * Stores surface normal data used to displace a mesh in a texture.
  126867. */
  126868. bumpTexture: BaseTexture;
  126869. /**
  126870. * Stores the pre-calculated light information of a mesh in a texture.
  126871. */
  126872. lightmapTexture: BaseTexture;
  126873. /**
  126874. * Stores the refracted light information in a texture.
  126875. */
  126876. get refractionTexture(): Nullable<BaseTexture>;
  126877. set refractionTexture(value: Nullable<BaseTexture>);
  126878. /**
  126879. * The color of a material in ambient lighting.
  126880. */
  126881. ambientColor: Color3;
  126882. /**
  126883. * AKA Diffuse Color in other nomenclature.
  126884. */
  126885. albedoColor: Color3;
  126886. /**
  126887. * AKA Specular Color in other nomenclature.
  126888. */
  126889. reflectivityColor: Color3;
  126890. /**
  126891. * The color reflected from the material.
  126892. */
  126893. reflectionColor: Color3;
  126894. /**
  126895. * The color emitted from the material.
  126896. */
  126897. emissiveColor: Color3;
  126898. /**
  126899. * AKA Glossiness in other nomenclature.
  126900. */
  126901. microSurface: number;
  126902. /**
  126903. * source material index of refraction (IOR)' / 'destination material IOR.
  126904. */
  126905. get indexOfRefraction(): number;
  126906. set indexOfRefraction(value: number);
  126907. /**
  126908. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  126909. */
  126910. get invertRefractionY(): boolean;
  126911. set invertRefractionY(value: boolean);
  126912. /**
  126913. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  126914. * Materials half opaque for instance using refraction could benefit from this control.
  126915. */
  126916. get linkRefractionWithTransparency(): boolean;
  126917. set linkRefractionWithTransparency(value: boolean);
  126918. /**
  126919. * If true, the light map contains occlusion information instead of lighting info.
  126920. */
  126921. useLightmapAsShadowmap: boolean;
  126922. /**
  126923. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  126924. */
  126925. useAlphaFromAlbedoTexture: boolean;
  126926. /**
  126927. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  126928. */
  126929. forceAlphaTest: boolean;
  126930. /**
  126931. * Defines the alpha limits in alpha test mode.
  126932. */
  126933. alphaCutOff: number;
  126934. /**
  126935. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  126936. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  126937. */
  126938. useSpecularOverAlpha: boolean;
  126939. /**
  126940. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  126941. */
  126942. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  126943. /**
  126944. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  126945. */
  126946. useRoughnessFromMetallicTextureAlpha: boolean;
  126947. /**
  126948. * Specifies if the metallic texture contains the roughness information in its green channel.
  126949. */
  126950. useRoughnessFromMetallicTextureGreen: boolean;
  126951. /**
  126952. * Specifies if the metallic texture contains the metallness information in its blue channel.
  126953. */
  126954. useMetallnessFromMetallicTextureBlue: boolean;
  126955. /**
  126956. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  126957. */
  126958. useAmbientOcclusionFromMetallicTextureRed: boolean;
  126959. /**
  126960. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  126961. */
  126962. useAmbientInGrayScale: boolean;
  126963. /**
  126964. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  126965. * The material will try to infer what glossiness each pixel should be.
  126966. */
  126967. useAutoMicroSurfaceFromReflectivityMap: boolean;
  126968. /**
  126969. * BJS is using an harcoded light falloff based on a manually sets up range.
  126970. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  126971. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  126972. */
  126973. get usePhysicalLightFalloff(): boolean;
  126974. /**
  126975. * BJS is using an harcoded light falloff based on a manually sets up range.
  126976. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  126977. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  126978. */
  126979. set usePhysicalLightFalloff(value: boolean);
  126980. /**
  126981. * In order to support the falloff compatibility with gltf, a special mode has been added
  126982. * to reproduce the gltf light falloff.
  126983. */
  126984. get useGLTFLightFalloff(): boolean;
  126985. /**
  126986. * In order to support the falloff compatibility with gltf, a special mode has been added
  126987. * to reproduce the gltf light falloff.
  126988. */
  126989. set useGLTFLightFalloff(value: boolean);
  126990. /**
  126991. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  126992. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  126993. */
  126994. useRadianceOverAlpha: boolean;
  126995. /**
  126996. * Allows using an object space normal map (instead of tangent space).
  126997. */
  126998. useObjectSpaceNormalMap: boolean;
  126999. /**
  127000. * Allows using the bump map in parallax mode.
  127001. */
  127002. useParallax: boolean;
  127003. /**
  127004. * Allows using the bump map in parallax occlusion mode.
  127005. */
  127006. useParallaxOcclusion: boolean;
  127007. /**
  127008. * Controls the scale bias of the parallax mode.
  127009. */
  127010. parallaxScaleBias: number;
  127011. /**
  127012. * If sets to true, disables all the lights affecting the material.
  127013. */
  127014. disableLighting: boolean;
  127015. /**
  127016. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  127017. */
  127018. forceIrradianceInFragment: boolean;
  127019. /**
  127020. * Number of Simultaneous lights allowed on the material.
  127021. */
  127022. maxSimultaneousLights: number;
  127023. /**
  127024. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  127025. */
  127026. invertNormalMapX: boolean;
  127027. /**
  127028. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  127029. */
  127030. invertNormalMapY: boolean;
  127031. /**
  127032. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  127033. */
  127034. twoSidedLighting: boolean;
  127035. /**
  127036. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  127037. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  127038. */
  127039. useAlphaFresnel: boolean;
  127040. /**
  127041. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  127042. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  127043. */
  127044. useLinearAlphaFresnel: boolean;
  127045. /**
  127046. * Let user defines the brdf lookup texture used for IBL.
  127047. * A default 8bit version is embedded but you could point at :
  127048. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  127049. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  127050. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  127051. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  127052. */
  127053. environmentBRDFTexture: Nullable<BaseTexture>;
  127054. /**
  127055. * Force normal to face away from face.
  127056. */
  127057. forceNormalForward: boolean;
  127058. /**
  127059. * Enables specular anti aliasing in the PBR shader.
  127060. * It will both interacts on the Geometry for analytical and IBL lighting.
  127061. * It also prefilter the roughness map based on the bump values.
  127062. */
  127063. enableSpecularAntiAliasing: boolean;
  127064. /**
  127065. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  127066. * makes the reflect vector face the model (under horizon).
  127067. */
  127068. useHorizonOcclusion: boolean;
  127069. /**
  127070. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  127071. * too much the area relying on ambient texture to define their ambient occlusion.
  127072. */
  127073. useRadianceOcclusion: boolean;
  127074. /**
  127075. * If set to true, no lighting calculations will be applied.
  127076. */
  127077. unlit: boolean;
  127078. /**
  127079. * Gets the image processing configuration used either in this material.
  127080. */
  127081. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  127082. /**
  127083. * Sets the Default image processing configuration used either in the this material.
  127084. *
  127085. * If sets to null, the scene one is in use.
  127086. */
  127087. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  127088. /**
  127089. * Gets wether the color curves effect is enabled.
  127090. */
  127091. get cameraColorCurvesEnabled(): boolean;
  127092. /**
  127093. * Sets wether the color curves effect is enabled.
  127094. */
  127095. set cameraColorCurvesEnabled(value: boolean);
  127096. /**
  127097. * Gets wether the color grading effect is enabled.
  127098. */
  127099. get cameraColorGradingEnabled(): boolean;
  127100. /**
  127101. * Gets wether the color grading effect is enabled.
  127102. */
  127103. set cameraColorGradingEnabled(value: boolean);
  127104. /**
  127105. * Gets wether tonemapping is enabled or not.
  127106. */
  127107. get cameraToneMappingEnabled(): boolean;
  127108. /**
  127109. * Sets wether tonemapping is enabled or not
  127110. */
  127111. set cameraToneMappingEnabled(value: boolean);
  127112. /**
  127113. * The camera exposure used on this material.
  127114. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  127115. * This corresponds to a photographic exposure.
  127116. */
  127117. get cameraExposure(): number;
  127118. /**
  127119. * The camera exposure used on this material.
  127120. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  127121. * This corresponds to a photographic exposure.
  127122. */
  127123. set cameraExposure(value: number);
  127124. /**
  127125. * Gets The camera contrast used on this material.
  127126. */
  127127. get cameraContrast(): number;
  127128. /**
  127129. * Sets The camera contrast used on this material.
  127130. */
  127131. set cameraContrast(value: number);
  127132. /**
  127133. * Gets the Color Grading 2D Lookup Texture.
  127134. */
  127135. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  127136. /**
  127137. * Sets the Color Grading 2D Lookup Texture.
  127138. */
  127139. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  127140. /**
  127141. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  127142. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  127143. * 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;
  127144. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  127145. */
  127146. get cameraColorCurves(): Nullable<ColorCurves>;
  127147. /**
  127148. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  127149. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  127150. * 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;
  127151. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  127152. */
  127153. set cameraColorCurves(value: Nullable<ColorCurves>);
  127154. /**
  127155. * Instantiates a new PBRMaterial instance.
  127156. *
  127157. * @param name The material name
  127158. * @param scene The scene the material will be use in.
  127159. */
  127160. constructor(name: string, scene: Scene);
  127161. /**
  127162. * Returns the name of this material class.
  127163. */
  127164. getClassName(): string;
  127165. /**
  127166. * Makes a duplicate of the current material.
  127167. * @param name - name to use for the new material.
  127168. */
  127169. clone(name: string): PBRMaterial;
  127170. /**
  127171. * Serializes this PBR Material.
  127172. * @returns - An object with the serialized material.
  127173. */
  127174. serialize(): any;
  127175. /**
  127176. * Parses a PBR Material from a serialized object.
  127177. * @param source - Serialized object.
  127178. * @param scene - BJS scene instance.
  127179. * @param rootUrl - url for the scene object
  127180. * @returns - PBRMaterial
  127181. */
  127182. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  127183. }
  127184. }
  127185. declare module BABYLON {
  127186. /**
  127187. * Direct draw surface info
  127188. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  127189. */
  127190. export interface DDSInfo {
  127191. /**
  127192. * Width of the texture
  127193. */
  127194. width: number;
  127195. /**
  127196. * Width of the texture
  127197. */
  127198. height: number;
  127199. /**
  127200. * Number of Mipmaps for the texture
  127201. * @see https://en.wikipedia.org/wiki/Mipmap
  127202. */
  127203. mipmapCount: number;
  127204. /**
  127205. * If the textures format is a known fourCC format
  127206. * @see https://www.fourcc.org/
  127207. */
  127208. isFourCC: boolean;
  127209. /**
  127210. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  127211. */
  127212. isRGB: boolean;
  127213. /**
  127214. * If the texture is a lumincance format
  127215. */
  127216. isLuminance: boolean;
  127217. /**
  127218. * If this is a cube texture
  127219. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  127220. */
  127221. isCube: boolean;
  127222. /**
  127223. * If the texture is a compressed format eg. FOURCC_DXT1
  127224. */
  127225. isCompressed: boolean;
  127226. /**
  127227. * The dxgiFormat of the texture
  127228. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  127229. */
  127230. dxgiFormat: number;
  127231. /**
  127232. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  127233. */
  127234. textureType: number;
  127235. /**
  127236. * Sphericle polynomial created for the dds texture
  127237. */
  127238. sphericalPolynomial?: SphericalPolynomial;
  127239. }
  127240. /**
  127241. * Class used to provide DDS decompression tools
  127242. */
  127243. export class DDSTools {
  127244. /**
  127245. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  127246. */
  127247. static StoreLODInAlphaChannel: boolean;
  127248. /**
  127249. * Gets DDS information from an array buffer
  127250. * @param data defines the array buffer view to read data from
  127251. * @returns the DDS information
  127252. */
  127253. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  127254. private static _FloatView;
  127255. private static _Int32View;
  127256. private static _ToHalfFloat;
  127257. private static _FromHalfFloat;
  127258. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  127259. private static _GetHalfFloatRGBAArrayBuffer;
  127260. private static _GetFloatRGBAArrayBuffer;
  127261. private static _GetFloatAsUIntRGBAArrayBuffer;
  127262. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  127263. private static _GetRGBAArrayBuffer;
  127264. private static _ExtractLongWordOrder;
  127265. private static _GetRGBArrayBuffer;
  127266. private static _GetLuminanceArrayBuffer;
  127267. /**
  127268. * Uploads DDS Levels to a Babylon Texture
  127269. * @hidden
  127270. */
  127271. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  127272. }
  127273. interface ThinEngine {
  127274. /**
  127275. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  127276. * @param rootUrl defines the url where the file to load is located
  127277. * @param scene defines the current scene
  127278. * @param lodScale defines scale to apply to the mip map selection
  127279. * @param lodOffset defines offset to apply to the mip map selection
  127280. * @param onLoad defines an optional callback raised when the texture is loaded
  127281. * @param onError defines an optional callback raised if there is an issue to load the texture
  127282. * @param format defines the format of the data
  127283. * @param forcedExtension defines the extension to use to pick the right loader
  127284. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  127285. * @returns the cube texture as an InternalTexture
  127286. */
  127287. 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;
  127288. }
  127289. }
  127290. declare module BABYLON {
  127291. /**
  127292. * Implementation of the DDS Texture Loader.
  127293. * @hidden
  127294. */
  127295. export class _DDSTextureLoader implements IInternalTextureLoader {
  127296. /**
  127297. * Defines wether the loader supports cascade loading the different faces.
  127298. */
  127299. readonly supportCascades: boolean;
  127300. /**
  127301. * This returns if the loader support the current file information.
  127302. * @param extension defines the file extension of the file being loaded
  127303. * @returns true if the loader can load the specified file
  127304. */
  127305. canLoad(extension: string): boolean;
  127306. /**
  127307. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  127308. * @param data contains the texture data
  127309. * @param texture defines the BabylonJS internal texture
  127310. * @param createPolynomials will be true if polynomials have been requested
  127311. * @param onLoad defines the callback to trigger once the texture is ready
  127312. * @param onError defines the callback to trigger in case of error
  127313. */
  127314. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  127315. /**
  127316. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  127317. * @param data contains the texture data
  127318. * @param texture defines the BabylonJS internal texture
  127319. * @param callback defines the method to call once ready to upload
  127320. */
  127321. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  127322. }
  127323. }
  127324. declare module BABYLON {
  127325. /**
  127326. * Implementation of the ENV Texture Loader.
  127327. * @hidden
  127328. */
  127329. export class _ENVTextureLoader implements IInternalTextureLoader {
  127330. /**
  127331. * Defines wether the loader supports cascade loading the different faces.
  127332. */
  127333. readonly supportCascades: boolean;
  127334. /**
  127335. * This returns if the loader support the current file information.
  127336. * @param extension defines the file extension of the file being loaded
  127337. * @returns true if the loader can load the specified file
  127338. */
  127339. canLoad(extension: string): boolean;
  127340. /**
  127341. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  127342. * @param data contains the texture data
  127343. * @param texture defines the BabylonJS internal texture
  127344. * @param createPolynomials will be true if polynomials have been requested
  127345. * @param onLoad defines the callback to trigger once the texture is ready
  127346. * @param onError defines the callback to trigger in case of error
  127347. */
  127348. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  127349. /**
  127350. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  127351. * @param data contains the texture data
  127352. * @param texture defines the BabylonJS internal texture
  127353. * @param callback defines the method to call once ready to upload
  127354. */
  127355. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  127356. }
  127357. }
  127358. declare module BABYLON {
  127359. /**
  127360. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  127361. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  127362. */
  127363. export class KhronosTextureContainer {
  127364. /** contents of the KTX container file */
  127365. data: ArrayBufferView;
  127366. private static HEADER_LEN;
  127367. private static COMPRESSED_2D;
  127368. private static COMPRESSED_3D;
  127369. private static TEX_2D;
  127370. private static TEX_3D;
  127371. /**
  127372. * Gets the openGL type
  127373. */
  127374. glType: number;
  127375. /**
  127376. * Gets the openGL type size
  127377. */
  127378. glTypeSize: number;
  127379. /**
  127380. * Gets the openGL format
  127381. */
  127382. glFormat: number;
  127383. /**
  127384. * Gets the openGL internal format
  127385. */
  127386. glInternalFormat: number;
  127387. /**
  127388. * Gets the base internal format
  127389. */
  127390. glBaseInternalFormat: number;
  127391. /**
  127392. * Gets image width in pixel
  127393. */
  127394. pixelWidth: number;
  127395. /**
  127396. * Gets image height in pixel
  127397. */
  127398. pixelHeight: number;
  127399. /**
  127400. * Gets image depth in pixels
  127401. */
  127402. pixelDepth: number;
  127403. /**
  127404. * Gets the number of array elements
  127405. */
  127406. numberOfArrayElements: number;
  127407. /**
  127408. * Gets the number of faces
  127409. */
  127410. numberOfFaces: number;
  127411. /**
  127412. * Gets the number of mipmap levels
  127413. */
  127414. numberOfMipmapLevels: number;
  127415. /**
  127416. * Gets the bytes of key value data
  127417. */
  127418. bytesOfKeyValueData: number;
  127419. /**
  127420. * Gets the load type
  127421. */
  127422. loadType: number;
  127423. /**
  127424. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  127425. */
  127426. isInvalid: boolean;
  127427. /**
  127428. * Creates a new KhronosTextureContainer
  127429. * @param data contents of the KTX container file
  127430. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  127431. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  127432. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  127433. */
  127434. constructor(
  127435. /** contents of the KTX container file */
  127436. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  127437. /**
  127438. * Uploads KTX content to a Babylon Texture.
  127439. * It is assumed that the texture has already been created & is currently bound
  127440. * @hidden
  127441. */
  127442. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  127443. private _upload2DCompressedLevels;
  127444. /**
  127445. * Checks if the given data starts with a KTX file identifier.
  127446. * @param data the data to check
  127447. * @returns true if the data is a KTX file or false otherwise
  127448. */
  127449. static IsValid(data: ArrayBufferView): boolean;
  127450. }
  127451. }
  127452. declare module BABYLON {
  127453. /**
  127454. * Class for loading KTX2 files
  127455. * !!! Experimental Extension Subject to Changes !!!
  127456. * @hidden
  127457. */
  127458. export class KhronosTextureContainer2 {
  127459. private static _ModulePromise;
  127460. private static _TranscodeFormat;
  127461. constructor(engine: ThinEngine);
  127462. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  127463. private _determineTranscodeFormat;
  127464. /**
  127465. * Checks if the given data starts with a KTX2 file identifier.
  127466. * @param data the data to check
  127467. * @returns true if the data is a KTX2 file or false otherwise
  127468. */
  127469. static IsValid(data: ArrayBufferView): boolean;
  127470. }
  127471. }
  127472. declare module BABYLON {
  127473. /**
  127474. * Implementation of the KTX Texture Loader.
  127475. * @hidden
  127476. */
  127477. export class _KTXTextureLoader implements IInternalTextureLoader {
  127478. /**
  127479. * Defines wether the loader supports cascade loading the different faces.
  127480. */
  127481. readonly supportCascades: boolean;
  127482. /**
  127483. * This returns if the loader support the current file information.
  127484. * @param extension defines the file extension of the file being loaded
  127485. * @returns true if the loader can load the specified file
  127486. */
  127487. canLoad(extension: string): boolean;
  127488. /**
  127489. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  127490. * @param data contains the texture data
  127491. * @param texture defines the BabylonJS internal texture
  127492. * @param createPolynomials will be true if polynomials have been requested
  127493. * @param onLoad defines the callback to trigger once the texture is ready
  127494. * @param onError defines the callback to trigger in case of error
  127495. */
  127496. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  127497. /**
  127498. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  127499. * @param data contains the texture data
  127500. * @param texture defines the BabylonJS internal texture
  127501. * @param callback defines the method to call once ready to upload
  127502. */
  127503. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  127504. }
  127505. }
  127506. declare module BABYLON {
  127507. /** @hidden */
  127508. export var _forceSceneHelpersToBundle: boolean;
  127509. interface Scene {
  127510. /**
  127511. * Creates a default light for the scene.
  127512. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  127513. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  127514. */
  127515. createDefaultLight(replace?: boolean): void;
  127516. /**
  127517. * Creates a default camera for the scene.
  127518. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  127519. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  127520. * @param replace has default false, when true replaces the active camera in the scene
  127521. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  127522. */
  127523. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  127524. /**
  127525. * Creates a default camera and a default light.
  127526. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  127527. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  127528. * @param replace has the default false, when true replaces the active camera/light in the scene
  127529. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  127530. */
  127531. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  127532. /**
  127533. * Creates a new sky box
  127534. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  127535. * @param environmentTexture defines the texture to use as environment texture
  127536. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  127537. * @param scale defines the overall scale of the skybox
  127538. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  127539. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  127540. * @returns a new mesh holding the sky box
  127541. */
  127542. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  127543. /**
  127544. * Creates a new environment
  127545. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  127546. * @param options defines the options you can use to configure the environment
  127547. * @returns the new EnvironmentHelper
  127548. */
  127549. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  127550. /**
  127551. * Creates a new VREXperienceHelper
  127552. * @see http://doc.babylonjs.com/how_to/webvr_helper
  127553. * @param webVROptions defines the options used to create the new VREXperienceHelper
  127554. * @returns a new VREXperienceHelper
  127555. */
  127556. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  127557. /**
  127558. * Creates a new WebXRDefaultExperience
  127559. * @see http://doc.babylonjs.com/how_to/webxr
  127560. * @param options experience options
  127561. * @returns a promise for a new WebXRDefaultExperience
  127562. */
  127563. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  127564. }
  127565. }
  127566. declare module BABYLON {
  127567. /**
  127568. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  127569. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  127570. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  127571. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  127572. */
  127573. export class VideoDome extends TransformNode {
  127574. /**
  127575. * Define the video source as a Monoscopic panoramic 360 video.
  127576. */
  127577. static readonly MODE_MONOSCOPIC: number;
  127578. /**
  127579. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  127580. */
  127581. static readonly MODE_TOPBOTTOM: number;
  127582. /**
  127583. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  127584. */
  127585. static readonly MODE_SIDEBYSIDE: number;
  127586. private _halfDome;
  127587. private _useDirectMapping;
  127588. /**
  127589. * The video texture being displayed on the sphere
  127590. */
  127591. protected _videoTexture: VideoTexture;
  127592. /**
  127593. * Gets the video texture being displayed on the sphere
  127594. */
  127595. get videoTexture(): VideoTexture;
  127596. /**
  127597. * The skybox material
  127598. */
  127599. protected _material: BackgroundMaterial;
  127600. /**
  127601. * The surface used for the skybox
  127602. */
  127603. protected _mesh: Mesh;
  127604. /**
  127605. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  127606. */
  127607. private _halfDomeMask;
  127608. /**
  127609. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  127610. * Also see the options.resolution property.
  127611. */
  127612. get fovMultiplier(): number;
  127613. set fovMultiplier(value: number);
  127614. private _videoMode;
  127615. /**
  127616. * Gets or set the current video mode for the video. It can be:
  127617. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  127618. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  127619. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  127620. */
  127621. get videoMode(): number;
  127622. set videoMode(value: number);
  127623. /**
  127624. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  127625. *
  127626. */
  127627. get halfDome(): boolean;
  127628. /**
  127629. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  127630. */
  127631. set halfDome(enabled: boolean);
  127632. /**
  127633. * Oberserver used in Stereoscopic VR Mode.
  127634. */
  127635. private _onBeforeCameraRenderObserver;
  127636. /**
  127637. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  127638. * @param name Element's name, child elements will append suffixes for their own names.
  127639. * @param urlsOrVideo defines the url(s) or the video element to use
  127640. * @param options An object containing optional or exposed sub element properties
  127641. */
  127642. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  127643. resolution?: number;
  127644. clickToPlay?: boolean;
  127645. autoPlay?: boolean;
  127646. loop?: boolean;
  127647. size?: number;
  127648. poster?: string;
  127649. faceForward?: boolean;
  127650. useDirectMapping?: boolean;
  127651. halfDomeMode?: boolean;
  127652. }, scene: Scene);
  127653. private _changeVideoMode;
  127654. /**
  127655. * Releases resources associated with this node.
  127656. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  127657. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  127658. */
  127659. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  127660. }
  127661. }
  127662. declare module BABYLON {
  127663. /**
  127664. * This class can be used to get instrumentation data from a Babylon engine
  127665. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  127666. */
  127667. export class EngineInstrumentation implements IDisposable {
  127668. /**
  127669. * Define the instrumented engine.
  127670. */
  127671. engine: Engine;
  127672. private _captureGPUFrameTime;
  127673. private _gpuFrameTimeToken;
  127674. private _gpuFrameTime;
  127675. private _captureShaderCompilationTime;
  127676. private _shaderCompilationTime;
  127677. private _onBeginFrameObserver;
  127678. private _onEndFrameObserver;
  127679. private _onBeforeShaderCompilationObserver;
  127680. private _onAfterShaderCompilationObserver;
  127681. /**
  127682. * Gets the perf counter used for GPU frame time
  127683. */
  127684. get gpuFrameTimeCounter(): PerfCounter;
  127685. /**
  127686. * Gets the GPU frame time capture status
  127687. */
  127688. get captureGPUFrameTime(): boolean;
  127689. /**
  127690. * Enable or disable the GPU frame time capture
  127691. */
  127692. set captureGPUFrameTime(value: boolean);
  127693. /**
  127694. * Gets the perf counter used for shader compilation time
  127695. */
  127696. get shaderCompilationTimeCounter(): PerfCounter;
  127697. /**
  127698. * Gets the shader compilation time capture status
  127699. */
  127700. get captureShaderCompilationTime(): boolean;
  127701. /**
  127702. * Enable or disable the shader compilation time capture
  127703. */
  127704. set captureShaderCompilationTime(value: boolean);
  127705. /**
  127706. * Instantiates a new engine instrumentation.
  127707. * This class can be used to get instrumentation data from a Babylon engine
  127708. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  127709. * @param engine Defines the engine to instrument
  127710. */
  127711. constructor(
  127712. /**
  127713. * Define the instrumented engine.
  127714. */
  127715. engine: Engine);
  127716. /**
  127717. * Dispose and release associated resources.
  127718. */
  127719. dispose(): void;
  127720. }
  127721. }
  127722. declare module BABYLON {
  127723. /**
  127724. * This class can be used to get instrumentation data from a Babylon engine
  127725. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  127726. */
  127727. export class SceneInstrumentation implements IDisposable {
  127728. /**
  127729. * Defines the scene to instrument
  127730. */
  127731. scene: Scene;
  127732. private _captureActiveMeshesEvaluationTime;
  127733. private _activeMeshesEvaluationTime;
  127734. private _captureRenderTargetsRenderTime;
  127735. private _renderTargetsRenderTime;
  127736. private _captureFrameTime;
  127737. private _frameTime;
  127738. private _captureRenderTime;
  127739. private _renderTime;
  127740. private _captureInterFrameTime;
  127741. private _interFrameTime;
  127742. private _captureParticlesRenderTime;
  127743. private _particlesRenderTime;
  127744. private _captureSpritesRenderTime;
  127745. private _spritesRenderTime;
  127746. private _capturePhysicsTime;
  127747. private _physicsTime;
  127748. private _captureAnimationsTime;
  127749. private _animationsTime;
  127750. private _captureCameraRenderTime;
  127751. private _cameraRenderTime;
  127752. private _onBeforeActiveMeshesEvaluationObserver;
  127753. private _onAfterActiveMeshesEvaluationObserver;
  127754. private _onBeforeRenderTargetsRenderObserver;
  127755. private _onAfterRenderTargetsRenderObserver;
  127756. private _onAfterRenderObserver;
  127757. private _onBeforeDrawPhaseObserver;
  127758. private _onAfterDrawPhaseObserver;
  127759. private _onBeforeAnimationsObserver;
  127760. private _onBeforeParticlesRenderingObserver;
  127761. private _onAfterParticlesRenderingObserver;
  127762. private _onBeforeSpritesRenderingObserver;
  127763. private _onAfterSpritesRenderingObserver;
  127764. private _onBeforePhysicsObserver;
  127765. private _onAfterPhysicsObserver;
  127766. private _onAfterAnimationsObserver;
  127767. private _onBeforeCameraRenderObserver;
  127768. private _onAfterCameraRenderObserver;
  127769. /**
  127770. * Gets the perf counter used for active meshes evaluation time
  127771. */
  127772. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  127773. /**
  127774. * Gets the active meshes evaluation time capture status
  127775. */
  127776. get captureActiveMeshesEvaluationTime(): boolean;
  127777. /**
  127778. * Enable or disable the active meshes evaluation time capture
  127779. */
  127780. set captureActiveMeshesEvaluationTime(value: boolean);
  127781. /**
  127782. * Gets the perf counter used for render targets render time
  127783. */
  127784. get renderTargetsRenderTimeCounter(): PerfCounter;
  127785. /**
  127786. * Gets the render targets render time capture status
  127787. */
  127788. get captureRenderTargetsRenderTime(): boolean;
  127789. /**
  127790. * Enable or disable the render targets render time capture
  127791. */
  127792. set captureRenderTargetsRenderTime(value: boolean);
  127793. /**
  127794. * Gets the perf counter used for particles render time
  127795. */
  127796. get particlesRenderTimeCounter(): PerfCounter;
  127797. /**
  127798. * Gets the particles render time capture status
  127799. */
  127800. get captureParticlesRenderTime(): boolean;
  127801. /**
  127802. * Enable or disable the particles render time capture
  127803. */
  127804. set captureParticlesRenderTime(value: boolean);
  127805. /**
  127806. * Gets the perf counter used for sprites render time
  127807. */
  127808. get spritesRenderTimeCounter(): PerfCounter;
  127809. /**
  127810. * Gets the sprites render time capture status
  127811. */
  127812. get captureSpritesRenderTime(): boolean;
  127813. /**
  127814. * Enable or disable the sprites render time capture
  127815. */
  127816. set captureSpritesRenderTime(value: boolean);
  127817. /**
  127818. * Gets the perf counter used for physics time
  127819. */
  127820. get physicsTimeCounter(): PerfCounter;
  127821. /**
  127822. * Gets the physics time capture status
  127823. */
  127824. get capturePhysicsTime(): boolean;
  127825. /**
  127826. * Enable or disable the physics time capture
  127827. */
  127828. set capturePhysicsTime(value: boolean);
  127829. /**
  127830. * Gets the perf counter used for animations time
  127831. */
  127832. get animationsTimeCounter(): PerfCounter;
  127833. /**
  127834. * Gets the animations time capture status
  127835. */
  127836. get captureAnimationsTime(): boolean;
  127837. /**
  127838. * Enable or disable the animations time capture
  127839. */
  127840. set captureAnimationsTime(value: boolean);
  127841. /**
  127842. * Gets the perf counter used for frame time capture
  127843. */
  127844. get frameTimeCounter(): PerfCounter;
  127845. /**
  127846. * Gets the frame time capture status
  127847. */
  127848. get captureFrameTime(): boolean;
  127849. /**
  127850. * Enable or disable the frame time capture
  127851. */
  127852. set captureFrameTime(value: boolean);
  127853. /**
  127854. * Gets the perf counter used for inter-frames time capture
  127855. */
  127856. get interFrameTimeCounter(): PerfCounter;
  127857. /**
  127858. * Gets the inter-frames time capture status
  127859. */
  127860. get captureInterFrameTime(): boolean;
  127861. /**
  127862. * Enable or disable the inter-frames time capture
  127863. */
  127864. set captureInterFrameTime(value: boolean);
  127865. /**
  127866. * Gets the perf counter used for render time capture
  127867. */
  127868. get renderTimeCounter(): PerfCounter;
  127869. /**
  127870. * Gets the render time capture status
  127871. */
  127872. get captureRenderTime(): boolean;
  127873. /**
  127874. * Enable or disable the render time capture
  127875. */
  127876. set captureRenderTime(value: boolean);
  127877. /**
  127878. * Gets the perf counter used for camera render time capture
  127879. */
  127880. get cameraRenderTimeCounter(): PerfCounter;
  127881. /**
  127882. * Gets the camera render time capture status
  127883. */
  127884. get captureCameraRenderTime(): boolean;
  127885. /**
  127886. * Enable or disable the camera render time capture
  127887. */
  127888. set captureCameraRenderTime(value: boolean);
  127889. /**
  127890. * Gets the perf counter used for draw calls
  127891. */
  127892. get drawCallsCounter(): PerfCounter;
  127893. /**
  127894. * Instantiates a new scene instrumentation.
  127895. * This class can be used to get instrumentation data from a Babylon engine
  127896. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  127897. * @param scene Defines the scene to instrument
  127898. */
  127899. constructor(
  127900. /**
  127901. * Defines the scene to instrument
  127902. */
  127903. scene: Scene);
  127904. /**
  127905. * Dispose and release associated resources.
  127906. */
  127907. dispose(): void;
  127908. }
  127909. }
  127910. declare module BABYLON {
  127911. /** @hidden */
  127912. export var glowMapGenerationPixelShader: {
  127913. name: string;
  127914. shader: string;
  127915. };
  127916. }
  127917. declare module BABYLON {
  127918. /** @hidden */
  127919. export var glowMapGenerationVertexShader: {
  127920. name: string;
  127921. shader: string;
  127922. };
  127923. }
  127924. declare module BABYLON {
  127925. /**
  127926. * Effect layer options. This helps customizing the behaviour
  127927. * of the effect layer.
  127928. */
  127929. export interface IEffectLayerOptions {
  127930. /**
  127931. * Multiplication factor apply to the canvas size to compute the render target size
  127932. * used to generated the objects (the smaller the faster).
  127933. */
  127934. mainTextureRatio: number;
  127935. /**
  127936. * Enforces a fixed size texture to ensure effect stability across devices.
  127937. */
  127938. mainTextureFixedSize?: number;
  127939. /**
  127940. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  127941. */
  127942. alphaBlendingMode: number;
  127943. /**
  127944. * The camera attached to the layer.
  127945. */
  127946. camera: Nullable<Camera>;
  127947. /**
  127948. * The rendering group to draw the layer in.
  127949. */
  127950. renderingGroupId: number;
  127951. }
  127952. /**
  127953. * The effect layer Helps adding post process effect blended with the main pass.
  127954. *
  127955. * This can be for instance use to generate glow or higlight effects on the scene.
  127956. *
  127957. * The effect layer class can not be used directly and is intented to inherited from to be
  127958. * customized per effects.
  127959. */
  127960. export abstract class EffectLayer {
  127961. private _vertexBuffers;
  127962. private _indexBuffer;
  127963. private _cachedDefines;
  127964. private _effectLayerMapGenerationEffect;
  127965. private _effectLayerOptions;
  127966. private _mergeEffect;
  127967. protected _scene: Scene;
  127968. protected _engine: Engine;
  127969. protected _maxSize: number;
  127970. protected _mainTextureDesiredSize: ISize;
  127971. protected _mainTexture: RenderTargetTexture;
  127972. protected _shouldRender: boolean;
  127973. protected _postProcesses: PostProcess[];
  127974. protected _textures: BaseTexture[];
  127975. protected _emissiveTextureAndColor: {
  127976. texture: Nullable<BaseTexture>;
  127977. color: Color4;
  127978. };
  127979. /**
  127980. * The name of the layer
  127981. */
  127982. name: string;
  127983. /**
  127984. * The clear color of the texture used to generate the glow map.
  127985. */
  127986. neutralColor: Color4;
  127987. /**
  127988. * Specifies whether the highlight layer is enabled or not.
  127989. */
  127990. isEnabled: boolean;
  127991. /**
  127992. * Gets the camera attached to the layer.
  127993. */
  127994. get camera(): Nullable<Camera>;
  127995. /**
  127996. * Gets the rendering group id the layer should render in.
  127997. */
  127998. get renderingGroupId(): number;
  127999. set renderingGroupId(renderingGroupId: number);
  128000. /**
  128001. * An event triggered when the effect layer has been disposed.
  128002. */
  128003. onDisposeObservable: Observable<EffectLayer>;
  128004. /**
  128005. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  128006. */
  128007. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  128008. /**
  128009. * An event triggered when the generated texture is being merged in the scene.
  128010. */
  128011. onBeforeComposeObservable: Observable<EffectLayer>;
  128012. /**
  128013. * An event triggered when the mesh is rendered into the effect render target.
  128014. */
  128015. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  128016. /**
  128017. * An event triggered after the mesh has been rendered into the effect render target.
  128018. */
  128019. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  128020. /**
  128021. * An event triggered when the generated texture has been merged in the scene.
  128022. */
  128023. onAfterComposeObservable: Observable<EffectLayer>;
  128024. /**
  128025. * An event triggered when the efffect layer changes its size.
  128026. */
  128027. onSizeChangedObservable: Observable<EffectLayer>;
  128028. /** @hidden */
  128029. static _SceneComponentInitialization: (scene: Scene) => void;
  128030. /**
  128031. * Instantiates a new effect Layer and references it in the scene.
  128032. * @param name The name of the layer
  128033. * @param scene The scene to use the layer in
  128034. */
  128035. constructor(
  128036. /** The Friendly of the effect in the scene */
  128037. name: string, scene: Scene);
  128038. /**
  128039. * Get the effect name of the layer.
  128040. * @return The effect name
  128041. */
  128042. abstract getEffectName(): string;
  128043. /**
  128044. * Checks for the readiness of the element composing the layer.
  128045. * @param subMesh the mesh to check for
  128046. * @param useInstances specify whether or not to use instances to render the mesh
  128047. * @return true if ready otherwise, false
  128048. */
  128049. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128050. /**
  128051. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  128052. * @returns true if the effect requires stencil during the main canvas render pass.
  128053. */
  128054. abstract needStencil(): boolean;
  128055. /**
  128056. * Create the merge effect. This is the shader use to blit the information back
  128057. * to the main canvas at the end of the scene rendering.
  128058. * @returns The effect containing the shader used to merge the effect on the main canvas
  128059. */
  128060. protected abstract _createMergeEffect(): Effect;
  128061. /**
  128062. * Creates the render target textures and post processes used in the effect layer.
  128063. */
  128064. protected abstract _createTextureAndPostProcesses(): void;
  128065. /**
  128066. * Implementation specific of rendering the generating effect on the main canvas.
  128067. * @param effect The effect used to render through
  128068. */
  128069. protected abstract _internalRender(effect: Effect): void;
  128070. /**
  128071. * Sets the required values for both the emissive texture and and the main color.
  128072. */
  128073. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  128074. /**
  128075. * Free any resources and references associated to a mesh.
  128076. * Internal use
  128077. * @param mesh The mesh to free.
  128078. */
  128079. abstract _disposeMesh(mesh: Mesh): void;
  128080. /**
  128081. * Serializes this layer (Glow or Highlight for example)
  128082. * @returns a serialized layer object
  128083. */
  128084. abstract serialize?(): any;
  128085. /**
  128086. * Initializes the effect layer with the required options.
  128087. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  128088. */
  128089. protected _init(options: Partial<IEffectLayerOptions>): void;
  128090. /**
  128091. * Generates the index buffer of the full screen quad blending to the main canvas.
  128092. */
  128093. private _generateIndexBuffer;
  128094. /**
  128095. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  128096. */
  128097. private _generateVertexBuffer;
  128098. /**
  128099. * Sets the main texture desired size which is the closest power of two
  128100. * of the engine canvas size.
  128101. */
  128102. private _setMainTextureSize;
  128103. /**
  128104. * Creates the main texture for the effect layer.
  128105. */
  128106. protected _createMainTexture(): void;
  128107. /**
  128108. * Adds specific effects defines.
  128109. * @param defines The defines to add specifics to.
  128110. */
  128111. protected _addCustomEffectDefines(defines: string[]): void;
  128112. /**
  128113. * Checks for the readiness of the element composing the layer.
  128114. * @param subMesh the mesh to check for
  128115. * @param useInstances specify whether or not to use instances to render the mesh
  128116. * @param emissiveTexture the associated emissive texture used to generate the glow
  128117. * @return true if ready otherwise, false
  128118. */
  128119. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  128120. /**
  128121. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  128122. */
  128123. render(): void;
  128124. /**
  128125. * Determine if a given mesh will be used in the current effect.
  128126. * @param mesh mesh to test
  128127. * @returns true if the mesh will be used
  128128. */
  128129. hasMesh(mesh: AbstractMesh): boolean;
  128130. /**
  128131. * Returns true if the layer contains information to display, otherwise false.
  128132. * @returns true if the glow layer should be rendered
  128133. */
  128134. shouldRender(): boolean;
  128135. /**
  128136. * Returns true if the mesh should render, otherwise false.
  128137. * @param mesh The mesh to render
  128138. * @returns true if it should render otherwise false
  128139. */
  128140. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  128141. /**
  128142. * Returns true if the mesh can be rendered, otherwise false.
  128143. * @param mesh The mesh to render
  128144. * @param material The material used on the mesh
  128145. * @returns true if it can be rendered otherwise false
  128146. */
  128147. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  128148. /**
  128149. * Returns true if the mesh should render, otherwise false.
  128150. * @param mesh The mesh to render
  128151. * @returns true if it should render otherwise false
  128152. */
  128153. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  128154. /**
  128155. * Renders the submesh passed in parameter to the generation map.
  128156. */
  128157. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  128158. /**
  128159. * Defines whether the current material of the mesh should be use to render the effect.
  128160. * @param mesh defines the current mesh to render
  128161. */
  128162. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  128163. /**
  128164. * Rebuild the required buffers.
  128165. * @hidden Internal use only.
  128166. */
  128167. _rebuild(): void;
  128168. /**
  128169. * Dispose only the render target textures and post process.
  128170. */
  128171. private _disposeTextureAndPostProcesses;
  128172. /**
  128173. * Dispose the highlight layer and free resources.
  128174. */
  128175. dispose(): void;
  128176. /**
  128177. * Gets the class name of the effect layer
  128178. * @returns the string with the class name of the effect layer
  128179. */
  128180. getClassName(): string;
  128181. /**
  128182. * Creates an effect layer from parsed effect layer data
  128183. * @param parsedEffectLayer defines effect layer data
  128184. * @param scene defines the current scene
  128185. * @param rootUrl defines the root URL containing the effect layer information
  128186. * @returns a parsed effect Layer
  128187. */
  128188. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  128189. }
  128190. }
  128191. declare module BABYLON {
  128192. interface AbstractScene {
  128193. /**
  128194. * The list of effect layers (highlights/glow) added to the scene
  128195. * @see http://doc.babylonjs.com/how_to/highlight_layer
  128196. * @see http://doc.babylonjs.com/how_to/glow_layer
  128197. */
  128198. effectLayers: Array<EffectLayer>;
  128199. /**
  128200. * Removes the given effect layer from this scene.
  128201. * @param toRemove defines the effect layer to remove
  128202. * @returns the index of the removed effect layer
  128203. */
  128204. removeEffectLayer(toRemove: EffectLayer): number;
  128205. /**
  128206. * Adds the given effect layer to this scene
  128207. * @param newEffectLayer defines the effect layer to add
  128208. */
  128209. addEffectLayer(newEffectLayer: EffectLayer): void;
  128210. }
  128211. /**
  128212. * Defines the layer scene component responsible to manage any effect layers
  128213. * in a given scene.
  128214. */
  128215. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  128216. /**
  128217. * The component name helpfull to identify the component in the list of scene components.
  128218. */
  128219. readonly name: string;
  128220. /**
  128221. * The scene the component belongs to.
  128222. */
  128223. scene: Scene;
  128224. private _engine;
  128225. private _renderEffects;
  128226. private _needStencil;
  128227. private _previousStencilState;
  128228. /**
  128229. * Creates a new instance of the component for the given scene
  128230. * @param scene Defines the scene to register the component in
  128231. */
  128232. constructor(scene: Scene);
  128233. /**
  128234. * Registers the component in a given scene
  128235. */
  128236. register(): void;
  128237. /**
  128238. * Rebuilds the elements related to this component in case of
  128239. * context lost for instance.
  128240. */
  128241. rebuild(): void;
  128242. /**
  128243. * Serializes the component data to the specified json object
  128244. * @param serializationObject The object to serialize to
  128245. */
  128246. serialize(serializationObject: any): void;
  128247. /**
  128248. * Adds all the elements from the container to the scene
  128249. * @param container the container holding the elements
  128250. */
  128251. addFromContainer(container: AbstractScene): void;
  128252. /**
  128253. * Removes all the elements in the container from the scene
  128254. * @param container contains the elements to remove
  128255. * @param dispose if the removed element should be disposed (default: false)
  128256. */
  128257. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  128258. /**
  128259. * Disposes the component and the associated ressources.
  128260. */
  128261. dispose(): void;
  128262. private _isReadyForMesh;
  128263. private _renderMainTexture;
  128264. private _setStencil;
  128265. private _setStencilBack;
  128266. private _draw;
  128267. private _drawCamera;
  128268. private _drawRenderingGroup;
  128269. }
  128270. }
  128271. declare module BABYLON {
  128272. /** @hidden */
  128273. export var glowMapMergePixelShader: {
  128274. name: string;
  128275. shader: string;
  128276. };
  128277. }
  128278. declare module BABYLON {
  128279. /** @hidden */
  128280. export var glowMapMergeVertexShader: {
  128281. name: string;
  128282. shader: string;
  128283. };
  128284. }
  128285. declare module BABYLON {
  128286. interface AbstractScene {
  128287. /**
  128288. * Return a the first highlight layer of the scene with a given name.
  128289. * @param name The name of the highlight layer to look for.
  128290. * @return The highlight layer if found otherwise null.
  128291. */
  128292. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  128293. }
  128294. /**
  128295. * Glow layer options. This helps customizing the behaviour
  128296. * of the glow layer.
  128297. */
  128298. export interface IGlowLayerOptions {
  128299. /**
  128300. * Multiplication factor apply to the canvas size to compute the render target size
  128301. * used to generated the glowing objects (the smaller the faster).
  128302. */
  128303. mainTextureRatio: number;
  128304. /**
  128305. * Enforces a fixed size texture to ensure resize independant blur.
  128306. */
  128307. mainTextureFixedSize?: number;
  128308. /**
  128309. * How big is the kernel of the blur texture.
  128310. */
  128311. blurKernelSize: number;
  128312. /**
  128313. * The camera attached to the layer.
  128314. */
  128315. camera: Nullable<Camera>;
  128316. /**
  128317. * Enable MSAA by chosing the number of samples.
  128318. */
  128319. mainTextureSamples?: number;
  128320. /**
  128321. * The rendering group to draw the layer in.
  128322. */
  128323. renderingGroupId: number;
  128324. }
  128325. /**
  128326. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  128327. *
  128328. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  128329. *
  128330. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  128331. */
  128332. export class GlowLayer extends EffectLayer {
  128333. /**
  128334. * Effect Name of the layer.
  128335. */
  128336. static readonly EffectName: string;
  128337. /**
  128338. * The default blur kernel size used for the glow.
  128339. */
  128340. static DefaultBlurKernelSize: number;
  128341. /**
  128342. * The default texture size ratio used for the glow.
  128343. */
  128344. static DefaultTextureRatio: number;
  128345. /**
  128346. * Sets the kernel size of the blur.
  128347. */
  128348. set blurKernelSize(value: number);
  128349. /**
  128350. * Gets the kernel size of the blur.
  128351. */
  128352. get blurKernelSize(): number;
  128353. /**
  128354. * Sets the glow intensity.
  128355. */
  128356. set intensity(value: number);
  128357. /**
  128358. * Gets the glow intensity.
  128359. */
  128360. get intensity(): number;
  128361. private _options;
  128362. private _intensity;
  128363. private _horizontalBlurPostprocess1;
  128364. private _verticalBlurPostprocess1;
  128365. private _horizontalBlurPostprocess2;
  128366. private _verticalBlurPostprocess2;
  128367. private _blurTexture1;
  128368. private _blurTexture2;
  128369. private _postProcesses1;
  128370. private _postProcesses2;
  128371. private _includedOnlyMeshes;
  128372. private _excludedMeshes;
  128373. private _meshesUsingTheirOwnMaterials;
  128374. /**
  128375. * Callback used to let the user override the color selection on a per mesh basis
  128376. */
  128377. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  128378. /**
  128379. * Callback used to let the user override the texture selection on a per mesh basis
  128380. */
  128381. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  128382. /**
  128383. * Instantiates a new glow Layer and references it to the scene.
  128384. * @param name The name of the layer
  128385. * @param scene The scene to use the layer in
  128386. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  128387. */
  128388. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  128389. /**
  128390. * Get the effect name of the layer.
  128391. * @return The effect name
  128392. */
  128393. getEffectName(): string;
  128394. /**
  128395. * Create the merge effect. This is the shader use to blit the information back
  128396. * to the main canvas at the end of the scene rendering.
  128397. */
  128398. protected _createMergeEffect(): Effect;
  128399. /**
  128400. * Creates the render target textures and post processes used in the glow layer.
  128401. */
  128402. protected _createTextureAndPostProcesses(): void;
  128403. /**
  128404. * Checks for the readiness of the element composing the layer.
  128405. * @param subMesh the mesh to check for
  128406. * @param useInstances specify wether or not to use instances to render the mesh
  128407. * @param emissiveTexture the associated emissive texture used to generate the glow
  128408. * @return true if ready otherwise, false
  128409. */
  128410. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128411. /**
  128412. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  128413. */
  128414. needStencil(): boolean;
  128415. /**
  128416. * Returns true if the mesh can be rendered, otherwise false.
  128417. * @param mesh The mesh to render
  128418. * @param material The material used on the mesh
  128419. * @returns true if it can be rendered otherwise false
  128420. */
  128421. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  128422. /**
  128423. * Implementation specific of rendering the generating effect on the main canvas.
  128424. * @param effect The effect used to render through
  128425. */
  128426. protected _internalRender(effect: Effect): void;
  128427. /**
  128428. * Sets the required values for both the emissive texture and and the main color.
  128429. */
  128430. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  128431. /**
  128432. * Returns true if the mesh should render, otherwise false.
  128433. * @param mesh The mesh to render
  128434. * @returns true if it should render otherwise false
  128435. */
  128436. protected _shouldRenderMesh(mesh: Mesh): boolean;
  128437. /**
  128438. * Adds specific effects defines.
  128439. * @param defines The defines to add specifics to.
  128440. */
  128441. protected _addCustomEffectDefines(defines: string[]): void;
  128442. /**
  128443. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  128444. * @param mesh The mesh to exclude from the glow layer
  128445. */
  128446. addExcludedMesh(mesh: Mesh): void;
  128447. /**
  128448. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  128449. * @param mesh The mesh to remove
  128450. */
  128451. removeExcludedMesh(mesh: Mesh): void;
  128452. /**
  128453. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  128454. * @param mesh The mesh to include in the glow layer
  128455. */
  128456. addIncludedOnlyMesh(mesh: Mesh): void;
  128457. /**
  128458. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  128459. * @param mesh The mesh to remove
  128460. */
  128461. removeIncludedOnlyMesh(mesh: Mesh): void;
  128462. /**
  128463. * Determine if a given mesh will be used in the glow layer
  128464. * @param mesh The mesh to test
  128465. * @returns true if the mesh will be highlighted by the current glow layer
  128466. */
  128467. hasMesh(mesh: AbstractMesh): boolean;
  128468. /**
  128469. * Defines whether the current material of the mesh should be use to render the effect.
  128470. * @param mesh defines the current mesh to render
  128471. */
  128472. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  128473. /**
  128474. * Add a mesh to be rendered through its own material and not with emissive only.
  128475. * @param mesh The mesh for which we need to use its material
  128476. */
  128477. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  128478. /**
  128479. * Remove a mesh from being rendered through its own material and not with emissive only.
  128480. * @param mesh The mesh for which we need to not use its material
  128481. */
  128482. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  128483. /**
  128484. * Free any resources and references associated to a mesh.
  128485. * Internal use
  128486. * @param mesh The mesh to free.
  128487. * @hidden
  128488. */
  128489. _disposeMesh(mesh: Mesh): void;
  128490. /**
  128491. * Gets the class name of the effect layer
  128492. * @returns the string with the class name of the effect layer
  128493. */
  128494. getClassName(): string;
  128495. /**
  128496. * Serializes this glow layer
  128497. * @returns a serialized glow layer object
  128498. */
  128499. serialize(): any;
  128500. /**
  128501. * Creates a Glow Layer from parsed glow layer data
  128502. * @param parsedGlowLayer defines glow layer data
  128503. * @param scene defines the current scene
  128504. * @param rootUrl defines the root URL containing the glow layer information
  128505. * @returns a parsed Glow Layer
  128506. */
  128507. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  128508. }
  128509. }
  128510. declare module BABYLON {
  128511. /** @hidden */
  128512. export var glowBlurPostProcessPixelShader: {
  128513. name: string;
  128514. shader: string;
  128515. };
  128516. }
  128517. declare module BABYLON {
  128518. interface AbstractScene {
  128519. /**
  128520. * Return a the first highlight layer of the scene with a given name.
  128521. * @param name The name of the highlight layer to look for.
  128522. * @return The highlight layer if found otherwise null.
  128523. */
  128524. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  128525. }
  128526. /**
  128527. * Highlight layer options. This helps customizing the behaviour
  128528. * of the highlight layer.
  128529. */
  128530. export interface IHighlightLayerOptions {
  128531. /**
  128532. * Multiplication factor apply to the canvas size to compute the render target size
  128533. * used to generated the glowing objects (the smaller the faster).
  128534. */
  128535. mainTextureRatio: number;
  128536. /**
  128537. * Enforces a fixed size texture to ensure resize independant blur.
  128538. */
  128539. mainTextureFixedSize?: number;
  128540. /**
  128541. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  128542. * of the picture to blur (the smaller the faster).
  128543. */
  128544. blurTextureSizeRatio: number;
  128545. /**
  128546. * How big in texel of the blur texture is the vertical blur.
  128547. */
  128548. blurVerticalSize: number;
  128549. /**
  128550. * How big in texel of the blur texture is the horizontal blur.
  128551. */
  128552. blurHorizontalSize: number;
  128553. /**
  128554. * Alpha blending mode used to apply the blur. Default is combine.
  128555. */
  128556. alphaBlendingMode: number;
  128557. /**
  128558. * The camera attached to the layer.
  128559. */
  128560. camera: Nullable<Camera>;
  128561. /**
  128562. * Should we display highlight as a solid stroke?
  128563. */
  128564. isStroke?: boolean;
  128565. /**
  128566. * The rendering group to draw the layer in.
  128567. */
  128568. renderingGroupId: number;
  128569. }
  128570. /**
  128571. * The highlight layer Helps adding a glow effect around a mesh.
  128572. *
  128573. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  128574. * glowy meshes to your scene.
  128575. *
  128576. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  128577. */
  128578. export class HighlightLayer extends EffectLayer {
  128579. name: string;
  128580. /**
  128581. * Effect Name of the highlight layer.
  128582. */
  128583. static readonly EffectName: string;
  128584. /**
  128585. * The neutral color used during the preparation of the glow effect.
  128586. * This is black by default as the blend operation is a blend operation.
  128587. */
  128588. static NeutralColor: Color4;
  128589. /**
  128590. * Stencil value used for glowing meshes.
  128591. */
  128592. static GlowingMeshStencilReference: number;
  128593. /**
  128594. * Stencil value used for the other meshes in the scene.
  128595. */
  128596. static NormalMeshStencilReference: number;
  128597. /**
  128598. * Specifies whether or not the inner glow is ACTIVE in the layer.
  128599. */
  128600. innerGlow: boolean;
  128601. /**
  128602. * Specifies whether or not the outer glow is ACTIVE in the layer.
  128603. */
  128604. outerGlow: boolean;
  128605. /**
  128606. * Specifies the horizontal size of the blur.
  128607. */
  128608. set blurHorizontalSize(value: number);
  128609. /**
  128610. * Specifies the vertical size of the blur.
  128611. */
  128612. set blurVerticalSize(value: number);
  128613. /**
  128614. * Gets the horizontal size of the blur.
  128615. */
  128616. get blurHorizontalSize(): number;
  128617. /**
  128618. * Gets the vertical size of the blur.
  128619. */
  128620. get blurVerticalSize(): number;
  128621. /**
  128622. * An event triggered when the highlight layer is being blurred.
  128623. */
  128624. onBeforeBlurObservable: Observable<HighlightLayer>;
  128625. /**
  128626. * An event triggered when the highlight layer has been blurred.
  128627. */
  128628. onAfterBlurObservable: Observable<HighlightLayer>;
  128629. private _instanceGlowingMeshStencilReference;
  128630. private _options;
  128631. private _downSamplePostprocess;
  128632. private _horizontalBlurPostprocess;
  128633. private _verticalBlurPostprocess;
  128634. private _blurTexture;
  128635. private _meshes;
  128636. private _excludedMeshes;
  128637. /**
  128638. * Instantiates a new highlight Layer and references it to the scene..
  128639. * @param name The name of the layer
  128640. * @param scene The scene to use the layer in
  128641. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  128642. */
  128643. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  128644. /**
  128645. * Get the effect name of the layer.
  128646. * @return The effect name
  128647. */
  128648. getEffectName(): string;
  128649. /**
  128650. * Create the merge effect. This is the shader use to blit the information back
  128651. * to the main canvas at the end of the scene rendering.
  128652. */
  128653. protected _createMergeEffect(): Effect;
  128654. /**
  128655. * Creates the render target textures and post processes used in the highlight layer.
  128656. */
  128657. protected _createTextureAndPostProcesses(): void;
  128658. /**
  128659. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  128660. */
  128661. needStencil(): boolean;
  128662. /**
  128663. * Checks for the readiness of the element composing the layer.
  128664. * @param subMesh the mesh to check for
  128665. * @param useInstances specify wether or not to use instances to render the mesh
  128666. * @param emissiveTexture the associated emissive texture used to generate the glow
  128667. * @return true if ready otherwise, false
  128668. */
  128669. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128670. /**
  128671. * Implementation specific of rendering the generating effect on the main canvas.
  128672. * @param effect The effect used to render through
  128673. */
  128674. protected _internalRender(effect: Effect): void;
  128675. /**
  128676. * Returns true if the layer contains information to display, otherwise false.
  128677. */
  128678. shouldRender(): boolean;
  128679. /**
  128680. * Returns true if the mesh should render, otherwise false.
  128681. * @param mesh The mesh to render
  128682. * @returns true if it should render otherwise false
  128683. */
  128684. protected _shouldRenderMesh(mesh: Mesh): boolean;
  128685. /**
  128686. * Adds specific effects defines.
  128687. * @param defines The defines to add specifics to.
  128688. */
  128689. protected _addCustomEffectDefines(defines: string[]): void;
  128690. /**
  128691. * Sets the required values for both the emissive texture and and the main color.
  128692. */
  128693. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  128694. /**
  128695. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  128696. * @param mesh The mesh to exclude from the highlight layer
  128697. */
  128698. addExcludedMesh(mesh: Mesh): void;
  128699. /**
  128700. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  128701. * @param mesh The mesh to highlight
  128702. */
  128703. removeExcludedMesh(mesh: Mesh): void;
  128704. /**
  128705. * Determine if a given mesh will be highlighted by the current HighlightLayer
  128706. * @param mesh mesh to test
  128707. * @returns true if the mesh will be highlighted by the current HighlightLayer
  128708. */
  128709. hasMesh(mesh: AbstractMesh): boolean;
  128710. /**
  128711. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  128712. * @param mesh The mesh to highlight
  128713. * @param color The color of the highlight
  128714. * @param glowEmissiveOnly Extract the glow from the emissive texture
  128715. */
  128716. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  128717. /**
  128718. * Remove a mesh from the highlight layer in order to make it stop glowing.
  128719. * @param mesh The mesh to highlight
  128720. */
  128721. removeMesh(mesh: Mesh): void;
  128722. /**
  128723. * Remove all the meshes currently referenced in the highlight layer
  128724. */
  128725. removeAllMeshes(): void;
  128726. /**
  128727. * Force the stencil to the normal expected value for none glowing parts
  128728. */
  128729. private _defaultStencilReference;
  128730. /**
  128731. * Free any resources and references associated to a mesh.
  128732. * Internal use
  128733. * @param mesh The mesh to free.
  128734. * @hidden
  128735. */
  128736. _disposeMesh(mesh: Mesh): void;
  128737. /**
  128738. * Dispose the highlight layer and free resources.
  128739. */
  128740. dispose(): void;
  128741. /**
  128742. * Gets the class name of the effect layer
  128743. * @returns the string with the class name of the effect layer
  128744. */
  128745. getClassName(): string;
  128746. /**
  128747. * Serializes this Highlight layer
  128748. * @returns a serialized Highlight layer object
  128749. */
  128750. serialize(): any;
  128751. /**
  128752. * Creates a Highlight layer from parsed Highlight layer data
  128753. * @param parsedHightlightLayer defines the Highlight layer data
  128754. * @param scene defines the current scene
  128755. * @param rootUrl defines the root URL containing the Highlight layer information
  128756. * @returns a parsed Highlight layer
  128757. */
  128758. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  128759. }
  128760. }
  128761. declare module BABYLON {
  128762. interface AbstractScene {
  128763. /**
  128764. * The list of layers (background and foreground) of the scene
  128765. */
  128766. layers: Array<Layer>;
  128767. }
  128768. /**
  128769. * Defines the layer scene component responsible to manage any layers
  128770. * in a given scene.
  128771. */
  128772. export class LayerSceneComponent implements ISceneComponent {
  128773. /**
  128774. * The component name helpfull to identify the component in the list of scene components.
  128775. */
  128776. readonly name: string;
  128777. /**
  128778. * The scene the component belongs to.
  128779. */
  128780. scene: Scene;
  128781. private _engine;
  128782. /**
  128783. * Creates a new instance of the component for the given scene
  128784. * @param scene Defines the scene to register the component in
  128785. */
  128786. constructor(scene: Scene);
  128787. /**
  128788. * Registers the component in a given scene
  128789. */
  128790. register(): void;
  128791. /**
  128792. * Rebuilds the elements related to this component in case of
  128793. * context lost for instance.
  128794. */
  128795. rebuild(): void;
  128796. /**
  128797. * Disposes the component and the associated ressources.
  128798. */
  128799. dispose(): void;
  128800. private _draw;
  128801. private _drawCameraPredicate;
  128802. private _drawCameraBackground;
  128803. private _drawCameraForeground;
  128804. private _drawRenderTargetPredicate;
  128805. private _drawRenderTargetBackground;
  128806. private _drawRenderTargetForeground;
  128807. /**
  128808. * Adds all the elements from the container to the scene
  128809. * @param container the container holding the elements
  128810. */
  128811. addFromContainer(container: AbstractScene): void;
  128812. /**
  128813. * Removes all the elements in the container from the scene
  128814. * @param container contains the elements to remove
  128815. * @param dispose if the removed element should be disposed (default: false)
  128816. */
  128817. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  128818. }
  128819. }
  128820. declare module BABYLON {
  128821. /** @hidden */
  128822. export var layerPixelShader: {
  128823. name: string;
  128824. shader: string;
  128825. };
  128826. }
  128827. declare module BABYLON {
  128828. /** @hidden */
  128829. export var layerVertexShader: {
  128830. name: string;
  128831. shader: string;
  128832. };
  128833. }
  128834. declare module BABYLON {
  128835. /**
  128836. * This represents a full screen 2d layer.
  128837. * This can be useful to display a picture in the background of your scene for instance.
  128838. * @see https://www.babylonjs-playground.com/#08A2BS#1
  128839. */
  128840. export class Layer {
  128841. /**
  128842. * Define the name of the layer.
  128843. */
  128844. name: string;
  128845. /**
  128846. * Define the texture the layer should display.
  128847. */
  128848. texture: Nullable<Texture>;
  128849. /**
  128850. * Is the layer in background or foreground.
  128851. */
  128852. isBackground: boolean;
  128853. /**
  128854. * Define the color of the layer (instead of texture).
  128855. */
  128856. color: Color4;
  128857. /**
  128858. * Define the scale of the layer in order to zoom in out of the texture.
  128859. */
  128860. scale: Vector2;
  128861. /**
  128862. * Define an offset for the layer in order to shift the texture.
  128863. */
  128864. offset: Vector2;
  128865. /**
  128866. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  128867. */
  128868. alphaBlendingMode: number;
  128869. /**
  128870. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  128871. * Alpha test will not mix with the background color in case of transparency.
  128872. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  128873. */
  128874. alphaTest: boolean;
  128875. /**
  128876. * Define a mask to restrict the layer to only some of the scene cameras.
  128877. */
  128878. layerMask: number;
  128879. /**
  128880. * Define the list of render target the layer is visible into.
  128881. */
  128882. renderTargetTextures: RenderTargetTexture[];
  128883. /**
  128884. * Define if the layer is only used in renderTarget or if it also
  128885. * renders in the main frame buffer of the canvas.
  128886. */
  128887. renderOnlyInRenderTargetTextures: boolean;
  128888. private _scene;
  128889. private _vertexBuffers;
  128890. private _indexBuffer;
  128891. private _effect;
  128892. private _previousDefines;
  128893. /**
  128894. * An event triggered when the layer is disposed.
  128895. */
  128896. onDisposeObservable: Observable<Layer>;
  128897. private _onDisposeObserver;
  128898. /**
  128899. * Back compatibility with callback before the onDisposeObservable existed.
  128900. * The set callback will be triggered when the layer has been disposed.
  128901. */
  128902. set onDispose(callback: () => void);
  128903. /**
  128904. * An event triggered before rendering the scene
  128905. */
  128906. onBeforeRenderObservable: Observable<Layer>;
  128907. private _onBeforeRenderObserver;
  128908. /**
  128909. * Back compatibility with callback before the onBeforeRenderObservable existed.
  128910. * The set callback will be triggered just before rendering the layer.
  128911. */
  128912. set onBeforeRender(callback: () => void);
  128913. /**
  128914. * An event triggered after rendering the scene
  128915. */
  128916. onAfterRenderObservable: Observable<Layer>;
  128917. private _onAfterRenderObserver;
  128918. /**
  128919. * Back compatibility with callback before the onAfterRenderObservable existed.
  128920. * The set callback will be triggered just after rendering the layer.
  128921. */
  128922. set onAfterRender(callback: () => void);
  128923. /**
  128924. * Instantiates a new layer.
  128925. * This represents a full screen 2d layer.
  128926. * This can be useful to display a picture in the background of your scene for instance.
  128927. * @see https://www.babylonjs-playground.com/#08A2BS#1
  128928. * @param name Define the name of the layer in the scene
  128929. * @param imgUrl Define the url of the texture to display in the layer
  128930. * @param scene Define the scene the layer belongs to
  128931. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  128932. * @param color Defines a color for the layer
  128933. */
  128934. constructor(
  128935. /**
  128936. * Define the name of the layer.
  128937. */
  128938. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  128939. private _createIndexBuffer;
  128940. /** @hidden */
  128941. _rebuild(): void;
  128942. /**
  128943. * Renders the layer in the scene.
  128944. */
  128945. render(): void;
  128946. /**
  128947. * Disposes and releases the associated ressources.
  128948. */
  128949. dispose(): void;
  128950. }
  128951. }
  128952. declare module BABYLON {
  128953. /** @hidden */
  128954. export var lensFlarePixelShader: {
  128955. name: string;
  128956. shader: string;
  128957. };
  128958. }
  128959. declare module BABYLON {
  128960. /** @hidden */
  128961. export var lensFlareVertexShader: {
  128962. name: string;
  128963. shader: string;
  128964. };
  128965. }
  128966. declare module BABYLON {
  128967. /**
  128968. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  128969. * It is usually composed of several `lensFlare`.
  128970. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128971. */
  128972. export class LensFlareSystem {
  128973. /**
  128974. * Define the name of the lens flare system
  128975. */
  128976. name: string;
  128977. /**
  128978. * List of lens flares used in this system.
  128979. */
  128980. lensFlares: LensFlare[];
  128981. /**
  128982. * Define a limit from the border the lens flare can be visible.
  128983. */
  128984. borderLimit: number;
  128985. /**
  128986. * Define a viewport border we do not want to see the lens flare in.
  128987. */
  128988. viewportBorder: number;
  128989. /**
  128990. * Define a predicate which could limit the list of meshes able to occlude the effect.
  128991. */
  128992. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  128993. /**
  128994. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  128995. */
  128996. layerMask: number;
  128997. /**
  128998. * Define the id of the lens flare system in the scene.
  128999. * (equal to name by default)
  129000. */
  129001. id: string;
  129002. private _scene;
  129003. private _emitter;
  129004. private _vertexBuffers;
  129005. private _indexBuffer;
  129006. private _effect;
  129007. private _positionX;
  129008. private _positionY;
  129009. private _isEnabled;
  129010. /** @hidden */
  129011. static _SceneComponentInitialization: (scene: Scene) => void;
  129012. /**
  129013. * Instantiates a lens flare system.
  129014. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  129015. * It is usually composed of several `lensFlare`.
  129016. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  129017. * @param name Define the name of the lens flare system in the scene
  129018. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  129019. * @param scene Define the scene the lens flare system belongs to
  129020. */
  129021. constructor(
  129022. /**
  129023. * Define the name of the lens flare system
  129024. */
  129025. name: string, emitter: any, scene: Scene);
  129026. /**
  129027. * Define if the lens flare system is enabled.
  129028. */
  129029. get isEnabled(): boolean;
  129030. set isEnabled(value: boolean);
  129031. /**
  129032. * Get the scene the effects belongs to.
  129033. * @returns the scene holding the lens flare system
  129034. */
  129035. getScene(): Scene;
  129036. /**
  129037. * Get the emitter of the lens flare system.
  129038. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  129039. * @returns the emitter of the lens flare system
  129040. */
  129041. getEmitter(): any;
  129042. /**
  129043. * Set the emitter of the lens flare system.
  129044. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  129045. * @param newEmitter Define the new emitter of the system
  129046. */
  129047. setEmitter(newEmitter: any): void;
  129048. /**
  129049. * Get the lens flare system emitter position.
  129050. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  129051. * @returns the position
  129052. */
  129053. getEmitterPosition(): Vector3;
  129054. /**
  129055. * @hidden
  129056. */
  129057. computeEffectivePosition(globalViewport: Viewport): boolean;
  129058. /** @hidden */
  129059. _isVisible(): boolean;
  129060. /**
  129061. * @hidden
  129062. */
  129063. render(): boolean;
  129064. /**
  129065. * Dispose and release the lens flare with its associated resources.
  129066. */
  129067. dispose(): void;
  129068. /**
  129069. * Parse a lens flare system from a JSON repressentation
  129070. * @param parsedLensFlareSystem Define the JSON to parse
  129071. * @param scene Define the scene the parsed system should be instantiated in
  129072. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  129073. * @returns the parsed system
  129074. */
  129075. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  129076. /**
  129077. * Serialize the current Lens Flare System into a JSON representation.
  129078. * @returns the serialized JSON
  129079. */
  129080. serialize(): any;
  129081. }
  129082. }
  129083. declare module BABYLON {
  129084. /**
  129085. * This represents one of the lens effect in a `lensFlareSystem`.
  129086. * It controls one of the indiviual texture used in the effect.
  129087. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  129088. */
  129089. export class LensFlare {
  129090. /**
  129091. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  129092. */
  129093. size: number;
  129094. /**
  129095. * 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.
  129096. */
  129097. position: number;
  129098. /**
  129099. * Define the lens color.
  129100. */
  129101. color: Color3;
  129102. /**
  129103. * Define the lens texture.
  129104. */
  129105. texture: Nullable<Texture>;
  129106. /**
  129107. * Define the alpha mode to render this particular lens.
  129108. */
  129109. alphaMode: number;
  129110. private _system;
  129111. /**
  129112. * Creates a new Lens Flare.
  129113. * This represents one of the lens effect in a `lensFlareSystem`.
  129114. * It controls one of the indiviual texture used in the effect.
  129115. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  129116. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  129117. * @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.
  129118. * @param color Define the lens color
  129119. * @param imgUrl Define the lens texture url
  129120. * @param system Define the `lensFlareSystem` this flare is part of
  129121. * @returns The newly created Lens Flare
  129122. */
  129123. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  129124. /**
  129125. * Instantiates a new Lens Flare.
  129126. * This represents one of the lens effect in a `lensFlareSystem`.
  129127. * It controls one of the indiviual texture used in the effect.
  129128. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  129129. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  129130. * @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.
  129131. * @param color Define the lens color
  129132. * @param imgUrl Define the lens texture url
  129133. * @param system Define the `lensFlareSystem` this flare is part of
  129134. */
  129135. constructor(
  129136. /**
  129137. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  129138. */
  129139. size: number,
  129140. /**
  129141. * 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.
  129142. */
  129143. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  129144. /**
  129145. * Dispose and release the lens flare with its associated resources.
  129146. */
  129147. dispose(): void;
  129148. }
  129149. }
  129150. declare module BABYLON {
  129151. interface AbstractScene {
  129152. /**
  129153. * The list of lens flare system added to the scene
  129154. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  129155. */
  129156. lensFlareSystems: Array<LensFlareSystem>;
  129157. /**
  129158. * Removes the given lens flare system from this scene.
  129159. * @param toRemove The lens flare system to remove
  129160. * @returns The index of the removed lens flare system
  129161. */
  129162. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  129163. /**
  129164. * Adds the given lens flare system to this scene
  129165. * @param newLensFlareSystem The lens flare system to add
  129166. */
  129167. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  129168. /**
  129169. * Gets a lens flare system using its name
  129170. * @param name defines the name to look for
  129171. * @returns the lens flare system or null if not found
  129172. */
  129173. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  129174. /**
  129175. * Gets a lens flare system using its id
  129176. * @param id defines the id to look for
  129177. * @returns the lens flare system or null if not found
  129178. */
  129179. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  129180. }
  129181. /**
  129182. * Defines the lens flare scene component responsible to manage any lens flares
  129183. * in a given scene.
  129184. */
  129185. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  129186. /**
  129187. * The component name helpfull to identify the component in the list of scene components.
  129188. */
  129189. readonly name: string;
  129190. /**
  129191. * The scene the component belongs to.
  129192. */
  129193. scene: Scene;
  129194. /**
  129195. * Creates a new instance of the component for the given scene
  129196. * @param scene Defines the scene to register the component in
  129197. */
  129198. constructor(scene: Scene);
  129199. /**
  129200. * Registers the component in a given scene
  129201. */
  129202. register(): void;
  129203. /**
  129204. * Rebuilds the elements related to this component in case of
  129205. * context lost for instance.
  129206. */
  129207. rebuild(): void;
  129208. /**
  129209. * Adds all the elements from the container to the scene
  129210. * @param container the container holding the elements
  129211. */
  129212. addFromContainer(container: AbstractScene): void;
  129213. /**
  129214. * Removes all the elements in the container from the scene
  129215. * @param container contains the elements to remove
  129216. * @param dispose if the removed element should be disposed (default: false)
  129217. */
  129218. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  129219. /**
  129220. * Serializes the component data to the specified json object
  129221. * @param serializationObject The object to serialize to
  129222. */
  129223. serialize(serializationObject: any): void;
  129224. /**
  129225. * Disposes the component and the associated ressources.
  129226. */
  129227. dispose(): void;
  129228. private _draw;
  129229. }
  129230. }
  129231. declare module BABYLON {
  129232. /** @hidden */
  129233. export var depthPixelShader: {
  129234. name: string;
  129235. shader: string;
  129236. };
  129237. }
  129238. declare module BABYLON {
  129239. /** @hidden */
  129240. export var depthVertexShader: {
  129241. name: string;
  129242. shader: string;
  129243. };
  129244. }
  129245. declare module BABYLON {
  129246. /**
  129247. * This represents a depth renderer in Babylon.
  129248. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  129249. */
  129250. export class DepthRenderer {
  129251. private _scene;
  129252. private _depthMap;
  129253. private _effect;
  129254. private readonly _storeNonLinearDepth;
  129255. private readonly _clearColor;
  129256. /** Get if the depth renderer is using packed depth or not */
  129257. readonly isPacked: boolean;
  129258. private _cachedDefines;
  129259. private _camera;
  129260. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  129261. enabled: boolean;
  129262. /**
  129263. * Specifiess that the depth renderer will only be used within
  129264. * the camera it is created for.
  129265. * This can help forcing its rendering during the camera processing.
  129266. */
  129267. useOnlyInActiveCamera: boolean;
  129268. /** @hidden */
  129269. static _SceneComponentInitialization: (scene: Scene) => void;
  129270. /**
  129271. * Instantiates a depth renderer
  129272. * @param scene The scene the renderer belongs to
  129273. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  129274. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  129275. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  129276. */
  129277. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  129278. /**
  129279. * Creates the depth rendering effect and checks if the effect is ready.
  129280. * @param subMesh The submesh to be used to render the depth map of
  129281. * @param useInstances If multiple world instances should be used
  129282. * @returns if the depth renderer is ready to render the depth map
  129283. */
  129284. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  129285. /**
  129286. * Gets the texture which the depth map will be written to.
  129287. * @returns The depth map texture
  129288. */
  129289. getDepthMap(): RenderTargetTexture;
  129290. /**
  129291. * Disposes of the depth renderer.
  129292. */
  129293. dispose(): void;
  129294. }
  129295. }
  129296. declare module BABYLON {
  129297. /** @hidden */
  129298. export var minmaxReduxPixelShader: {
  129299. name: string;
  129300. shader: string;
  129301. };
  129302. }
  129303. declare module BABYLON {
  129304. /**
  129305. * This class computes a min/max reduction from a texture: it means it computes the minimum
  129306. * and maximum values from all values of the texture.
  129307. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  129308. * The source values are read from the red channel of the texture.
  129309. */
  129310. export class MinMaxReducer {
  129311. /**
  129312. * Observable triggered when the computation has been performed
  129313. */
  129314. onAfterReductionPerformed: Observable<{
  129315. min: number;
  129316. max: number;
  129317. }>;
  129318. protected _camera: Camera;
  129319. protected _sourceTexture: Nullable<RenderTargetTexture>;
  129320. protected _reductionSteps: Nullable<Array<PostProcess>>;
  129321. protected _postProcessManager: PostProcessManager;
  129322. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  129323. protected _forceFullscreenViewport: boolean;
  129324. /**
  129325. * Creates a min/max reducer
  129326. * @param camera The camera to use for the post processes
  129327. */
  129328. constructor(camera: Camera);
  129329. /**
  129330. * Gets the texture used to read the values from.
  129331. */
  129332. get sourceTexture(): Nullable<RenderTargetTexture>;
  129333. /**
  129334. * Sets the source texture to read the values from.
  129335. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  129336. * because in such textures '1' value must not be taken into account to compute the maximum
  129337. * as this value is used to clear the texture.
  129338. * Note that the computation is not activated by calling this function, you must call activate() for that!
  129339. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  129340. * @param depthRedux Indicates if the texture is a depth texture or not
  129341. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  129342. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  129343. */
  129344. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  129345. /**
  129346. * Defines the refresh rate of the computation.
  129347. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  129348. */
  129349. get refreshRate(): number;
  129350. set refreshRate(value: number);
  129351. protected _activated: boolean;
  129352. /**
  129353. * Gets the activation status of the reducer
  129354. */
  129355. get activated(): boolean;
  129356. /**
  129357. * Activates the reduction computation.
  129358. * When activated, the observers registered in onAfterReductionPerformed are
  129359. * called after the compuation is performed
  129360. */
  129361. activate(): void;
  129362. /**
  129363. * Deactivates the reduction computation.
  129364. */
  129365. deactivate(): void;
  129366. /**
  129367. * Disposes the min/max reducer
  129368. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  129369. */
  129370. dispose(disposeAll?: boolean): void;
  129371. }
  129372. }
  129373. declare module BABYLON {
  129374. /**
  129375. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  129376. */
  129377. export class DepthReducer extends MinMaxReducer {
  129378. private _depthRenderer;
  129379. private _depthRendererId;
  129380. /**
  129381. * Gets the depth renderer used for the computation.
  129382. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  129383. */
  129384. get depthRenderer(): Nullable<DepthRenderer>;
  129385. /**
  129386. * Creates a depth reducer
  129387. * @param camera The camera used to render the depth texture
  129388. */
  129389. constructor(camera: Camera);
  129390. /**
  129391. * Sets the depth renderer to use to generate the depth map
  129392. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  129393. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  129394. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  129395. */
  129396. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  129397. /** @hidden */
  129398. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  129399. /**
  129400. * Activates the reduction computation.
  129401. * When activated, the observers registered in onAfterReductionPerformed are
  129402. * called after the compuation is performed
  129403. */
  129404. activate(): void;
  129405. /**
  129406. * Deactivates the reduction computation.
  129407. */
  129408. deactivate(): void;
  129409. /**
  129410. * Disposes the depth reducer
  129411. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  129412. */
  129413. dispose(disposeAll?: boolean): void;
  129414. }
  129415. }
  129416. declare module BABYLON {
  129417. /**
  129418. * A CSM implementation allowing casting shadows on large scenes.
  129419. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  129420. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  129421. */
  129422. export class CascadedShadowGenerator extends ShadowGenerator {
  129423. private static readonly frustumCornersNDCSpace;
  129424. /**
  129425. * Name of the CSM class
  129426. */
  129427. static CLASSNAME: string;
  129428. /**
  129429. * Defines the default number of cascades used by the CSM.
  129430. */
  129431. static readonly DEFAULT_CASCADES_COUNT: number;
  129432. /**
  129433. * Defines the minimum number of cascades used by the CSM.
  129434. */
  129435. static readonly MIN_CASCADES_COUNT: number;
  129436. /**
  129437. * Defines the maximum number of cascades used by the CSM.
  129438. */
  129439. static readonly MAX_CASCADES_COUNT: number;
  129440. protected _validateFilter(filter: number): number;
  129441. /**
  129442. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  129443. */
  129444. penumbraDarkness: number;
  129445. private _numCascades;
  129446. /**
  129447. * Gets or set the number of cascades used by the CSM.
  129448. */
  129449. get numCascades(): number;
  129450. set numCascades(value: number);
  129451. /**
  129452. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  129453. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  129454. */
  129455. stabilizeCascades: boolean;
  129456. private _freezeShadowCastersBoundingInfo;
  129457. private _freezeShadowCastersBoundingInfoObservable;
  129458. /**
  129459. * Enables or disables the shadow casters bounding info computation.
  129460. * If your shadow casters don't move, you can disable this feature.
  129461. * If it is enabled, the bounding box computation is done every frame.
  129462. */
  129463. get freezeShadowCastersBoundingInfo(): boolean;
  129464. set freezeShadowCastersBoundingInfo(freeze: boolean);
  129465. private _scbiMin;
  129466. private _scbiMax;
  129467. protected _computeShadowCastersBoundingInfo(): void;
  129468. protected _shadowCastersBoundingInfo: BoundingInfo;
  129469. /**
  129470. * Gets or sets the shadow casters bounding info.
  129471. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  129472. * so that the system won't overwrite the bounds you provide
  129473. */
  129474. get shadowCastersBoundingInfo(): BoundingInfo;
  129475. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  129476. protected _breaksAreDirty: boolean;
  129477. protected _minDistance: number;
  129478. protected _maxDistance: number;
  129479. /**
  129480. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  129481. *
  129482. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  129483. * If you don't know these values, simply leave them to their defaults and don't call this function.
  129484. * @param min minimal distance for the breaks (default to 0.)
  129485. * @param max maximal distance for the breaks (default to 1.)
  129486. */
  129487. setMinMaxDistance(min: number, max: number): void;
  129488. /** Gets the minimal distance used in the cascade break computation */
  129489. get minDistance(): number;
  129490. /** Gets the maximal distance used in the cascade break computation */
  129491. get maxDistance(): number;
  129492. /**
  129493. * Gets the class name of that object
  129494. * @returns "CascadedShadowGenerator"
  129495. */
  129496. getClassName(): string;
  129497. private _cascadeMinExtents;
  129498. private _cascadeMaxExtents;
  129499. /**
  129500. * Gets a cascade minimum extents
  129501. * @param cascadeIndex index of the cascade
  129502. * @returns the minimum cascade extents
  129503. */
  129504. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  129505. /**
  129506. * Gets a cascade maximum extents
  129507. * @param cascadeIndex index of the cascade
  129508. * @returns the maximum cascade extents
  129509. */
  129510. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  129511. private _cascades;
  129512. private _currentLayer;
  129513. private _viewSpaceFrustumsZ;
  129514. private _viewMatrices;
  129515. private _projectionMatrices;
  129516. private _transformMatrices;
  129517. private _transformMatricesAsArray;
  129518. private _frustumLengths;
  129519. private _lightSizeUVCorrection;
  129520. private _depthCorrection;
  129521. private _frustumCornersWorldSpace;
  129522. private _frustumCenter;
  129523. private _shadowCameraPos;
  129524. private _shadowMaxZ;
  129525. /**
  129526. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  129527. * It defaults to camera.maxZ
  129528. */
  129529. get shadowMaxZ(): number;
  129530. /**
  129531. * Sets the shadow max z distance.
  129532. */
  129533. set shadowMaxZ(value: number);
  129534. protected _debug: boolean;
  129535. /**
  129536. * Gets or sets the debug flag.
  129537. * When enabled, the cascades are materialized by different colors on the screen.
  129538. */
  129539. get debug(): boolean;
  129540. set debug(dbg: boolean);
  129541. private _depthClamp;
  129542. /**
  129543. * Gets or sets the depth clamping value.
  129544. *
  129545. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  129546. * to account for the shadow casters far away.
  129547. *
  129548. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  129549. */
  129550. get depthClamp(): boolean;
  129551. set depthClamp(value: boolean);
  129552. private _cascadeBlendPercentage;
  129553. /**
  129554. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  129555. * It defaults to 0.1 (10% blending).
  129556. */
  129557. get cascadeBlendPercentage(): number;
  129558. set cascadeBlendPercentage(value: number);
  129559. private _lambda;
  129560. /**
  129561. * Gets or set the lambda parameter.
  129562. * This parameter is used to split the camera frustum and create the cascades.
  129563. * It's a value between 0. and 1.: If 0, the split is a uniform split of the frustum, if 1 it is a logarithmic split.
  129564. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  129565. */
  129566. get lambda(): number;
  129567. set lambda(value: number);
  129568. /**
  129569. * Gets the view matrix corresponding to a given cascade
  129570. * @param cascadeNum cascade to retrieve the view matrix from
  129571. * @returns the cascade view matrix
  129572. */
  129573. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  129574. /**
  129575. * Gets the projection matrix corresponding to a given cascade
  129576. * @param cascadeNum cascade to retrieve the projection matrix from
  129577. * @returns the cascade projection matrix
  129578. */
  129579. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  129580. /**
  129581. * Gets the transformation matrix corresponding to a given cascade
  129582. * @param cascadeNum cascade to retrieve the transformation matrix from
  129583. * @returns the cascade transformation matrix
  129584. */
  129585. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  129586. private _depthRenderer;
  129587. /**
  129588. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  129589. *
  129590. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  129591. *
  129592. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  129593. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  129594. * @param depthRenderer The depth renderer to use when autoCalcDepthBounds is enabled. If you pass null or don't call this function at all, a depth renderer will be automatically created
  129595. */
  129596. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  129597. private _depthReducer;
  129598. private _autoCalcDepthBounds;
  129599. /**
  129600. * Gets or sets the autoCalcDepthBounds property.
  129601. *
  129602. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  129603. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  129604. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  129605. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  129606. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  129607. */
  129608. get autoCalcDepthBounds(): boolean;
  129609. set autoCalcDepthBounds(value: boolean);
  129610. /**
  129611. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  129612. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  129613. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  129614. * for setting the refresh rate on the renderer yourself!
  129615. */
  129616. get autoCalcDepthBoundsRefreshRate(): number;
  129617. set autoCalcDepthBoundsRefreshRate(value: number);
  129618. /**
  129619. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  129620. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  129621. * you change the camera near/far planes!
  129622. */
  129623. splitFrustum(): void;
  129624. private _splitFrustum;
  129625. private _computeMatrices;
  129626. private _computeFrustumInWorldSpace;
  129627. private _computeCascadeFrustum;
  129628. /**
  129629. * Support test.
  129630. */
  129631. static get IsSupported(): boolean;
  129632. /** @hidden */
  129633. static _SceneComponentInitialization: (scene: Scene) => void;
  129634. /**
  129635. * Creates a Cascaded Shadow Generator object.
  129636. * A ShadowGenerator is the required tool to use the shadows.
  129637. * Each directional light casting shadows needs to use its own ShadowGenerator.
  129638. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  129639. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  129640. * @param light The directional light object generating the shadows.
  129641. * @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.
  129642. */
  129643. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  129644. protected _initializeGenerator(): void;
  129645. protected _createTargetRenderTexture(): void;
  129646. protected _initializeShadowMap(): void;
  129647. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  129648. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  129649. /**
  129650. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  129651. * @param defines Defines of the material we want to update
  129652. * @param lightIndex Index of the light in the enabled light list of the material
  129653. */
  129654. prepareDefines(defines: any, lightIndex: number): void;
  129655. /**
  129656. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  129657. * defined in the generator but impacting the effect).
  129658. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  129659. * @param effect The effect we are binfing the information for
  129660. */
  129661. bindShadowLight(lightIndex: string, effect: Effect): void;
  129662. /**
  129663. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  129664. * (eq to view projection * shadow projection matrices)
  129665. * @returns The transform matrix used to create the shadow map
  129666. */
  129667. getTransformMatrix(): Matrix;
  129668. /**
  129669. * Disposes the ShadowGenerator.
  129670. * Returns nothing.
  129671. */
  129672. dispose(): void;
  129673. /**
  129674. * Serializes the shadow generator setup to a json object.
  129675. * @returns The serialized JSON object
  129676. */
  129677. serialize(): any;
  129678. /**
  129679. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  129680. * @param parsedShadowGenerator The JSON object to parse
  129681. * @param scene The scene to create the shadow map for
  129682. * @returns The parsed shadow generator
  129683. */
  129684. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  129685. }
  129686. }
  129687. declare module BABYLON {
  129688. /**
  129689. * Defines the shadow generator component responsible to manage any shadow generators
  129690. * in a given scene.
  129691. */
  129692. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  129693. /**
  129694. * The component name helpfull to identify the component in the list of scene components.
  129695. */
  129696. readonly name: string;
  129697. /**
  129698. * The scene the component belongs to.
  129699. */
  129700. scene: Scene;
  129701. /**
  129702. * Creates a new instance of the component for the given scene
  129703. * @param scene Defines the scene to register the component in
  129704. */
  129705. constructor(scene: Scene);
  129706. /**
  129707. * Registers the component in a given scene
  129708. */
  129709. register(): void;
  129710. /**
  129711. * Rebuilds the elements related to this component in case of
  129712. * context lost for instance.
  129713. */
  129714. rebuild(): void;
  129715. /**
  129716. * Serializes the component data to the specified json object
  129717. * @param serializationObject The object to serialize to
  129718. */
  129719. serialize(serializationObject: any): void;
  129720. /**
  129721. * Adds all the elements from the container to the scene
  129722. * @param container the container holding the elements
  129723. */
  129724. addFromContainer(container: AbstractScene): void;
  129725. /**
  129726. * Removes all the elements in the container from the scene
  129727. * @param container contains the elements to remove
  129728. * @param dispose if the removed element should be disposed (default: false)
  129729. */
  129730. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  129731. /**
  129732. * Rebuilds the elements related to this component in case of
  129733. * context lost for instance.
  129734. */
  129735. dispose(): void;
  129736. private _gatherRenderTargets;
  129737. }
  129738. }
  129739. declare module BABYLON {
  129740. /**
  129741. * A point light is a light defined by an unique point in world space.
  129742. * The light is emitted in every direction from this point.
  129743. * A good example of a point light is a standard light bulb.
  129744. * Documentation: https://doc.babylonjs.com/babylon101/lights
  129745. */
  129746. export class PointLight extends ShadowLight {
  129747. private _shadowAngle;
  129748. /**
  129749. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  129750. * This specifies what angle the shadow will use to be created.
  129751. *
  129752. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  129753. */
  129754. get shadowAngle(): number;
  129755. /**
  129756. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  129757. * This specifies what angle the shadow will use to be created.
  129758. *
  129759. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  129760. */
  129761. set shadowAngle(value: number);
  129762. /**
  129763. * Gets the direction if it has been set.
  129764. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  129765. */
  129766. get direction(): Vector3;
  129767. /**
  129768. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  129769. */
  129770. set direction(value: Vector3);
  129771. /**
  129772. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  129773. * A PointLight emits the light in every direction.
  129774. * It can cast shadows.
  129775. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  129776. * ```javascript
  129777. * var pointLight = new PointLight("pl", camera.position, scene);
  129778. * ```
  129779. * Documentation : https://doc.babylonjs.com/babylon101/lights
  129780. * @param name The light friendly name
  129781. * @param position The position of the point light in the scene
  129782. * @param scene The scene the lights belongs to
  129783. */
  129784. constructor(name: string, position: Vector3, scene: Scene);
  129785. /**
  129786. * Returns the string "PointLight"
  129787. * @returns the class name
  129788. */
  129789. getClassName(): string;
  129790. /**
  129791. * Returns the integer 0.
  129792. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  129793. */
  129794. getTypeID(): number;
  129795. /**
  129796. * Specifies wether or not the shadowmap should be a cube texture.
  129797. * @returns true if the shadowmap needs to be a cube texture.
  129798. */
  129799. needCube(): boolean;
  129800. /**
  129801. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  129802. * @param faceIndex The index of the face we are computed the direction to generate shadow
  129803. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  129804. */
  129805. getShadowDirection(faceIndex?: number): Vector3;
  129806. /**
  129807. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  129808. * - fov = PI / 2
  129809. * - aspect ratio : 1.0
  129810. * - z-near and far equal to the active camera minZ and maxZ.
  129811. * Returns the PointLight.
  129812. */
  129813. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  129814. protected _buildUniformLayout(): void;
  129815. /**
  129816. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  129817. * @param effect The effect to update
  129818. * @param lightIndex The index of the light in the effect to update
  129819. * @returns The point light
  129820. */
  129821. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  129822. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  129823. /**
  129824. * Prepares the list of defines specific to the light type.
  129825. * @param defines the list of defines
  129826. * @param lightIndex defines the index of the light for the effect
  129827. */
  129828. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  129829. }
  129830. }
  129831. declare module BABYLON {
  129832. /**
  129833. * Header information of HDR texture files.
  129834. */
  129835. export interface HDRInfo {
  129836. /**
  129837. * The height of the texture in pixels.
  129838. */
  129839. height: number;
  129840. /**
  129841. * The width of the texture in pixels.
  129842. */
  129843. width: number;
  129844. /**
  129845. * The index of the beginning of the data in the binary file.
  129846. */
  129847. dataPosition: number;
  129848. }
  129849. /**
  129850. * This groups tools to convert HDR texture to native colors array.
  129851. */
  129852. export class HDRTools {
  129853. private static Ldexp;
  129854. private static Rgbe2float;
  129855. private static readStringLine;
  129856. /**
  129857. * Reads header information from an RGBE texture stored in a native array.
  129858. * More information on this format are available here:
  129859. * https://en.wikipedia.org/wiki/RGBE_image_format
  129860. *
  129861. * @param uint8array The binary file stored in native array.
  129862. * @return The header information.
  129863. */
  129864. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  129865. /**
  129866. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  129867. * This RGBE texture needs to store the information as a panorama.
  129868. *
  129869. * More information on this format are available here:
  129870. * https://en.wikipedia.org/wiki/RGBE_image_format
  129871. *
  129872. * @param buffer The binary file stored in an array buffer.
  129873. * @param size The expected size of the extracted cubemap.
  129874. * @return The Cube Map information.
  129875. */
  129876. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  129877. /**
  129878. * Returns the pixels data extracted from an RGBE texture.
  129879. * This pixels will be stored left to right up to down in the R G B order in one array.
  129880. *
  129881. * More information on this format are available here:
  129882. * https://en.wikipedia.org/wiki/RGBE_image_format
  129883. *
  129884. * @param uint8array The binary file stored in an array buffer.
  129885. * @param hdrInfo The header information of the file.
  129886. * @return The pixels data in RGB right to left up to down order.
  129887. */
  129888. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  129889. private static RGBE_ReadPixels_RLE;
  129890. }
  129891. }
  129892. declare module BABYLON {
  129893. /**
  129894. * This represents a texture coming from an HDR input.
  129895. *
  129896. * The only supported format is currently panorama picture stored in RGBE format.
  129897. * Example of such files can be found on HDRLib: http://hdrlib.com/
  129898. */
  129899. export class HDRCubeTexture extends BaseTexture {
  129900. private static _facesMapping;
  129901. private _generateHarmonics;
  129902. private _noMipmap;
  129903. private _textureMatrix;
  129904. private _size;
  129905. private _onLoad;
  129906. private _onError;
  129907. /**
  129908. * The texture URL.
  129909. */
  129910. url: string;
  129911. /**
  129912. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  129913. */
  129914. coordinatesMode: number;
  129915. protected _isBlocking: boolean;
  129916. /**
  129917. * Sets wether or not the texture is blocking during loading.
  129918. */
  129919. set isBlocking(value: boolean);
  129920. /**
  129921. * Gets wether or not the texture is blocking during loading.
  129922. */
  129923. get isBlocking(): boolean;
  129924. protected _rotationY: number;
  129925. /**
  129926. * Sets texture matrix rotation angle around Y axis in radians.
  129927. */
  129928. set rotationY(value: number);
  129929. /**
  129930. * Gets texture matrix rotation angle around Y axis radians.
  129931. */
  129932. get rotationY(): number;
  129933. /**
  129934. * Gets or sets the center of the bounding box associated with the cube texture
  129935. * It must define where the camera used to render the texture was set
  129936. */
  129937. boundingBoxPosition: Vector3;
  129938. private _boundingBoxSize;
  129939. /**
  129940. * Gets or sets the size of the bounding box associated with the cube texture
  129941. * When defined, the cubemap will switch to local mode
  129942. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  129943. * @example https://www.babylonjs-playground.com/#RNASML
  129944. */
  129945. set boundingBoxSize(value: Vector3);
  129946. get boundingBoxSize(): Vector3;
  129947. /**
  129948. * Instantiates an HDRTexture from the following parameters.
  129949. *
  129950. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  129951. * @param scene The scene the texture will be used in
  129952. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  129953. * @param noMipmap Forces to not generate the mipmap if true
  129954. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  129955. * @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)
  129956. * @param reserved Reserved flag for internal use.
  129957. */
  129958. 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>);
  129959. /**
  129960. * Get the current class name of the texture useful for serialization or dynamic coding.
  129961. * @returns "HDRCubeTexture"
  129962. */
  129963. getClassName(): string;
  129964. /**
  129965. * Occurs when the file is raw .hdr file.
  129966. */
  129967. private loadTexture;
  129968. clone(): HDRCubeTexture;
  129969. delayLoad(): void;
  129970. /**
  129971. * Get the texture reflection matrix used to rotate/transform the reflection.
  129972. * @returns the reflection matrix
  129973. */
  129974. getReflectionTextureMatrix(): Matrix;
  129975. /**
  129976. * Set the texture reflection matrix used to rotate/transform the reflection.
  129977. * @param value Define the reflection matrix to set
  129978. */
  129979. setReflectionTextureMatrix(value: Matrix): void;
  129980. /**
  129981. * Parses a JSON representation of an HDR Texture in order to create the texture
  129982. * @param parsedTexture Define the JSON representation
  129983. * @param scene Define the scene the texture should be created in
  129984. * @param rootUrl Define the root url in case we need to load relative dependencies
  129985. * @returns the newly created texture after parsing
  129986. */
  129987. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  129988. serialize(): any;
  129989. }
  129990. }
  129991. declare module BABYLON {
  129992. /**
  129993. * Class used to control physics engine
  129994. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  129995. */
  129996. export class PhysicsEngine implements IPhysicsEngine {
  129997. private _physicsPlugin;
  129998. /**
  129999. * Global value used to control the smallest number supported by the simulation
  130000. */
  130001. static Epsilon: number;
  130002. private _impostors;
  130003. private _joints;
  130004. private _subTimeStep;
  130005. /**
  130006. * Gets the gravity vector used by the simulation
  130007. */
  130008. gravity: Vector3;
  130009. /**
  130010. * Factory used to create the default physics plugin.
  130011. * @returns The default physics plugin
  130012. */
  130013. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  130014. /**
  130015. * Creates a new Physics Engine
  130016. * @param gravity defines the gravity vector used by the simulation
  130017. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  130018. */
  130019. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  130020. /**
  130021. * Sets the gravity vector used by the simulation
  130022. * @param gravity defines the gravity vector to use
  130023. */
  130024. setGravity(gravity: Vector3): void;
  130025. /**
  130026. * Set the time step of the physics engine.
  130027. * Default is 1/60.
  130028. * To slow it down, enter 1/600 for example.
  130029. * To speed it up, 1/30
  130030. * @param newTimeStep defines the new timestep to apply to this world.
  130031. */
  130032. setTimeStep(newTimeStep?: number): void;
  130033. /**
  130034. * Get the time step of the physics engine.
  130035. * @returns the current time step
  130036. */
  130037. getTimeStep(): number;
  130038. /**
  130039. * Set the sub time step of the physics engine.
  130040. * Default is 0 meaning there is no sub steps
  130041. * To increase physics resolution precision, set a small value (like 1 ms)
  130042. * @param subTimeStep defines the new sub timestep used for physics resolution.
  130043. */
  130044. setSubTimeStep(subTimeStep?: number): void;
  130045. /**
  130046. * Get the sub time step of the physics engine.
  130047. * @returns the current sub time step
  130048. */
  130049. getSubTimeStep(): number;
  130050. /**
  130051. * Release all resources
  130052. */
  130053. dispose(): void;
  130054. /**
  130055. * Gets the name of the current physics plugin
  130056. * @returns the name of the plugin
  130057. */
  130058. getPhysicsPluginName(): string;
  130059. /**
  130060. * Adding a new impostor for the impostor tracking.
  130061. * This will be done by the impostor itself.
  130062. * @param impostor the impostor to add
  130063. */
  130064. addImpostor(impostor: PhysicsImpostor): void;
  130065. /**
  130066. * Remove an impostor from the engine.
  130067. * This impostor and its mesh will not longer be updated by the physics engine.
  130068. * @param impostor the impostor to remove
  130069. */
  130070. removeImpostor(impostor: PhysicsImpostor): void;
  130071. /**
  130072. * Add a joint to the physics engine
  130073. * @param mainImpostor defines the main impostor to which the joint is added.
  130074. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  130075. * @param joint defines the joint that will connect both impostors.
  130076. */
  130077. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  130078. /**
  130079. * Removes a joint from the simulation
  130080. * @param mainImpostor defines the impostor used with the joint
  130081. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  130082. * @param joint defines the joint to remove
  130083. */
  130084. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  130085. /**
  130086. * Called by the scene. No need to call it.
  130087. * @param delta defines the timespam between frames
  130088. */
  130089. _step(delta: number): void;
  130090. /**
  130091. * Gets the current plugin used to run the simulation
  130092. * @returns current plugin
  130093. */
  130094. getPhysicsPlugin(): IPhysicsEnginePlugin;
  130095. /**
  130096. * Gets the list of physic impostors
  130097. * @returns an array of PhysicsImpostor
  130098. */
  130099. getImpostors(): Array<PhysicsImpostor>;
  130100. /**
  130101. * Gets the impostor for a physics enabled object
  130102. * @param object defines the object impersonated by the impostor
  130103. * @returns the PhysicsImpostor or null if not found
  130104. */
  130105. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  130106. /**
  130107. * Gets the impostor for a physics body object
  130108. * @param body defines physics body used by the impostor
  130109. * @returns the PhysicsImpostor or null if not found
  130110. */
  130111. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  130112. /**
  130113. * Does a raycast in the physics world
  130114. * @param from when should the ray start?
  130115. * @param to when should the ray end?
  130116. * @returns PhysicsRaycastResult
  130117. */
  130118. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  130119. }
  130120. }
  130121. declare module BABYLON {
  130122. /** @hidden */
  130123. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  130124. private _useDeltaForWorldStep;
  130125. world: any;
  130126. name: string;
  130127. private _physicsMaterials;
  130128. private _fixedTimeStep;
  130129. private _cannonRaycastResult;
  130130. private _raycastResult;
  130131. private _physicsBodysToRemoveAfterStep;
  130132. BJSCANNON: any;
  130133. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  130134. setGravity(gravity: Vector3): void;
  130135. setTimeStep(timeStep: number): void;
  130136. getTimeStep(): number;
  130137. executeStep(delta: number): void;
  130138. private _removeMarkedPhysicsBodiesFromWorld;
  130139. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  130140. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  130141. generatePhysicsBody(impostor: PhysicsImpostor): void;
  130142. private _processChildMeshes;
  130143. removePhysicsBody(impostor: PhysicsImpostor): void;
  130144. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  130145. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  130146. private _addMaterial;
  130147. private _checkWithEpsilon;
  130148. private _createShape;
  130149. private _createHeightmap;
  130150. private _minus90X;
  130151. private _plus90X;
  130152. private _tmpPosition;
  130153. private _tmpDeltaPosition;
  130154. private _tmpUnityRotation;
  130155. private _updatePhysicsBodyTransformation;
  130156. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  130157. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  130158. isSupported(): boolean;
  130159. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  130160. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  130161. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  130162. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  130163. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  130164. getBodyMass(impostor: PhysicsImpostor): number;
  130165. getBodyFriction(impostor: PhysicsImpostor): number;
  130166. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  130167. getBodyRestitution(impostor: PhysicsImpostor): number;
  130168. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  130169. sleepBody(impostor: PhysicsImpostor): void;
  130170. wakeUpBody(impostor: PhysicsImpostor): void;
  130171. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  130172. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  130173. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  130174. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  130175. getRadius(impostor: PhysicsImpostor): number;
  130176. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  130177. dispose(): void;
  130178. private _extendNamespace;
  130179. /**
  130180. * Does a raycast in the physics world
  130181. * @param from when should the ray start?
  130182. * @param to when should the ray end?
  130183. * @returns PhysicsRaycastResult
  130184. */
  130185. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  130186. }
  130187. }
  130188. declare module BABYLON {
  130189. /** @hidden */
  130190. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  130191. private _useDeltaForWorldStep;
  130192. world: any;
  130193. name: string;
  130194. BJSOIMO: any;
  130195. private _raycastResult;
  130196. private _fixedTimeStep;
  130197. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  130198. setGravity(gravity: Vector3): void;
  130199. setTimeStep(timeStep: number): void;
  130200. getTimeStep(): number;
  130201. private _tmpImpostorsArray;
  130202. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  130203. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  130204. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  130205. generatePhysicsBody(impostor: PhysicsImpostor): void;
  130206. private _tmpPositionVector;
  130207. removePhysicsBody(impostor: PhysicsImpostor): void;
  130208. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  130209. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  130210. isSupported(): boolean;
  130211. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  130212. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  130213. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  130214. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  130215. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  130216. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  130217. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  130218. getBodyMass(impostor: PhysicsImpostor): number;
  130219. getBodyFriction(impostor: PhysicsImpostor): number;
  130220. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  130221. getBodyRestitution(impostor: PhysicsImpostor): number;
  130222. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  130223. sleepBody(impostor: PhysicsImpostor): void;
  130224. wakeUpBody(impostor: PhysicsImpostor): void;
  130225. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  130226. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  130227. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  130228. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  130229. getRadius(impostor: PhysicsImpostor): number;
  130230. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  130231. dispose(): void;
  130232. /**
  130233. * Does a raycast in the physics world
  130234. * @param from when should the ray start?
  130235. * @param to when should the ray end?
  130236. * @returns PhysicsRaycastResult
  130237. */
  130238. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  130239. }
  130240. }
  130241. declare module BABYLON {
  130242. /**
  130243. * Class containing static functions to help procedurally build meshes
  130244. */
  130245. export class RibbonBuilder {
  130246. /**
  130247. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  130248. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  130249. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  130250. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  130251. * * 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
  130252. * * 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
  130253. * * 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
  130254. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130255. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130256. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130257. * * 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
  130258. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  130259. * * 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
  130260. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  130261. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130262. * @param name defines the name of the mesh
  130263. * @param options defines the options used to create the mesh
  130264. * @param scene defines the hosting scene
  130265. * @returns the ribbon mesh
  130266. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  130267. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130268. */
  130269. static CreateRibbon(name: string, options: {
  130270. pathArray: Vector3[][];
  130271. closeArray?: boolean;
  130272. closePath?: boolean;
  130273. offset?: number;
  130274. updatable?: boolean;
  130275. sideOrientation?: number;
  130276. frontUVs?: Vector4;
  130277. backUVs?: Vector4;
  130278. instance?: Mesh;
  130279. invertUV?: boolean;
  130280. uvs?: Vector2[];
  130281. colors?: Color4[];
  130282. }, scene?: Nullable<Scene>): Mesh;
  130283. }
  130284. }
  130285. declare module BABYLON {
  130286. /**
  130287. * Class containing static functions to help procedurally build meshes
  130288. */
  130289. export class ShapeBuilder {
  130290. /**
  130291. * 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.
  130292. * * 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.
  130293. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  130294. * * 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.
  130295. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  130296. * * 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
  130297. * * 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
  130298. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  130299. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130300. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130301. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  130302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130303. * @param name defines the name of the mesh
  130304. * @param options defines the options used to create the mesh
  130305. * @param scene defines the hosting scene
  130306. * @returns the extruded shape mesh
  130307. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130308. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  130309. */
  130310. static ExtrudeShape(name: string, options: {
  130311. shape: Vector3[];
  130312. path: Vector3[];
  130313. scale?: number;
  130314. rotation?: number;
  130315. cap?: number;
  130316. updatable?: boolean;
  130317. sideOrientation?: number;
  130318. frontUVs?: Vector4;
  130319. backUVs?: Vector4;
  130320. instance?: Mesh;
  130321. invertUV?: boolean;
  130322. }, scene?: Nullable<Scene>): Mesh;
  130323. /**
  130324. * Creates an custom extruded shape mesh.
  130325. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  130326. * * 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.
  130327. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  130328. * * 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
  130329. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  130330. * * 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
  130331. * * It must returns a float value that will be the scale value applied to the shape on each path point
  130332. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  130333. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  130334. * * 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
  130335. * * 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
  130336. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  130337. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130338. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130339. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130341. * @param name defines the name of the mesh
  130342. * @param options defines the options used to create the mesh
  130343. * @param scene defines the hosting scene
  130344. * @returns the custom extruded shape mesh
  130345. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  130346. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130347. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  130348. */
  130349. static ExtrudeShapeCustom(name: string, options: {
  130350. shape: Vector3[];
  130351. path: Vector3[];
  130352. scaleFunction?: any;
  130353. rotationFunction?: any;
  130354. ribbonCloseArray?: boolean;
  130355. ribbonClosePath?: boolean;
  130356. cap?: number;
  130357. updatable?: boolean;
  130358. sideOrientation?: number;
  130359. frontUVs?: Vector4;
  130360. backUVs?: Vector4;
  130361. instance?: Mesh;
  130362. invertUV?: boolean;
  130363. }, scene?: Nullable<Scene>): Mesh;
  130364. private static _ExtrudeShapeGeneric;
  130365. }
  130366. }
  130367. declare module BABYLON {
  130368. /**
  130369. * AmmoJS Physics plugin
  130370. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  130371. * @see https://github.com/kripken/ammo.js/
  130372. */
  130373. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  130374. private _useDeltaForWorldStep;
  130375. /**
  130376. * Reference to the Ammo library
  130377. */
  130378. bjsAMMO: any;
  130379. /**
  130380. * Created ammoJS world which physics bodies are added to
  130381. */
  130382. world: any;
  130383. /**
  130384. * Name of the plugin
  130385. */
  130386. name: string;
  130387. private _timeStep;
  130388. private _fixedTimeStep;
  130389. private _maxSteps;
  130390. private _tmpQuaternion;
  130391. private _tmpAmmoTransform;
  130392. private _tmpAmmoQuaternion;
  130393. private _tmpAmmoConcreteContactResultCallback;
  130394. private _collisionConfiguration;
  130395. private _dispatcher;
  130396. private _overlappingPairCache;
  130397. private _solver;
  130398. private _softBodySolver;
  130399. private _tmpAmmoVectorA;
  130400. private _tmpAmmoVectorB;
  130401. private _tmpAmmoVectorC;
  130402. private _tmpAmmoVectorD;
  130403. private _tmpContactCallbackResult;
  130404. private _tmpAmmoVectorRCA;
  130405. private _tmpAmmoVectorRCB;
  130406. private _raycastResult;
  130407. private static readonly DISABLE_COLLISION_FLAG;
  130408. private static readonly KINEMATIC_FLAG;
  130409. private static readonly DISABLE_DEACTIVATION_FLAG;
  130410. /**
  130411. * Initializes the ammoJS plugin
  130412. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  130413. * @param ammoInjection can be used to inject your own ammo reference
  130414. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  130415. */
  130416. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  130417. /**
  130418. * Sets the gravity of the physics world (m/(s^2))
  130419. * @param gravity Gravity to set
  130420. */
  130421. setGravity(gravity: Vector3): void;
  130422. /**
  130423. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  130424. * @param timeStep timestep to use in seconds
  130425. */
  130426. setTimeStep(timeStep: number): void;
  130427. /**
  130428. * 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)
  130429. * @param fixedTimeStep fixedTimeStep to use in seconds
  130430. */
  130431. setFixedTimeStep(fixedTimeStep: number): void;
  130432. /**
  130433. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  130434. * @param maxSteps the maximum number of steps by the physics engine per frame
  130435. */
  130436. setMaxSteps(maxSteps: number): void;
  130437. /**
  130438. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  130439. * @returns the current timestep in seconds
  130440. */
  130441. getTimeStep(): number;
  130442. /**
  130443. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  130444. */
  130445. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  130446. private _isImpostorInContact;
  130447. private _isImpostorPairInContact;
  130448. private _stepSimulation;
  130449. /**
  130450. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  130451. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  130452. * After the step the babylon meshes are set to the position of the physics imposters
  130453. * @param delta amount of time to step forward
  130454. * @param impostors array of imposters to update before/after the step
  130455. */
  130456. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  130457. /**
  130458. * Update babylon mesh to match physics world object
  130459. * @param impostor imposter to match
  130460. */
  130461. private _afterSoftStep;
  130462. /**
  130463. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  130464. * @param impostor imposter to match
  130465. */
  130466. private _ropeStep;
  130467. /**
  130468. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  130469. * @param impostor imposter to match
  130470. */
  130471. private _softbodyOrClothStep;
  130472. private _tmpMatrix;
  130473. /**
  130474. * Applies an impulse on the imposter
  130475. * @param impostor imposter to apply impulse to
  130476. * @param force amount of force to be applied to the imposter
  130477. * @param contactPoint the location to apply the impulse on the imposter
  130478. */
  130479. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  130480. /**
  130481. * Applies a force on the imposter
  130482. * @param impostor imposter to apply force
  130483. * @param force amount of force to be applied to the imposter
  130484. * @param contactPoint the location to apply the force on the imposter
  130485. */
  130486. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  130487. /**
  130488. * Creates a physics body using the plugin
  130489. * @param impostor the imposter to create the physics body on
  130490. */
  130491. generatePhysicsBody(impostor: PhysicsImpostor): void;
  130492. /**
  130493. * Removes the physics body from the imposter and disposes of the body's memory
  130494. * @param impostor imposter to remove the physics body from
  130495. */
  130496. removePhysicsBody(impostor: PhysicsImpostor): void;
  130497. /**
  130498. * Generates a joint
  130499. * @param impostorJoint the imposter joint to create the joint with
  130500. */
  130501. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  130502. /**
  130503. * Removes a joint
  130504. * @param impostorJoint the imposter joint to remove the joint from
  130505. */
  130506. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  130507. private _addMeshVerts;
  130508. /**
  130509. * Initialise the soft body vertices to match its object's (mesh) vertices
  130510. * Softbody vertices (nodes) are in world space and to match this
  130511. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  130512. * @param impostor to create the softbody for
  130513. */
  130514. private _softVertexData;
  130515. /**
  130516. * Create an impostor's soft body
  130517. * @param impostor to create the softbody for
  130518. */
  130519. private _createSoftbody;
  130520. /**
  130521. * Create cloth for an impostor
  130522. * @param impostor to create the softbody for
  130523. */
  130524. private _createCloth;
  130525. /**
  130526. * Create rope for an impostor
  130527. * @param impostor to create the softbody for
  130528. */
  130529. private _createRope;
  130530. /**
  130531. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  130532. * @param impostor to create the custom physics shape for
  130533. */
  130534. private _createCustom;
  130535. private _addHullVerts;
  130536. private _createShape;
  130537. /**
  130538. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  130539. * @param impostor imposter containing the physics body and babylon object
  130540. */
  130541. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  130542. /**
  130543. * Sets the babylon object's position/rotation from the physics body's position/rotation
  130544. * @param impostor imposter containing the physics body and babylon object
  130545. * @param newPosition new position
  130546. * @param newRotation new rotation
  130547. */
  130548. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  130549. /**
  130550. * If this plugin is supported
  130551. * @returns true if its supported
  130552. */
  130553. isSupported(): boolean;
  130554. /**
  130555. * Sets the linear velocity of the physics body
  130556. * @param impostor imposter to set the velocity on
  130557. * @param velocity velocity to set
  130558. */
  130559. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  130560. /**
  130561. * Sets the angular velocity of the physics body
  130562. * @param impostor imposter to set the velocity on
  130563. * @param velocity velocity to set
  130564. */
  130565. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  130566. /**
  130567. * gets the linear velocity
  130568. * @param impostor imposter to get linear velocity from
  130569. * @returns linear velocity
  130570. */
  130571. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  130572. /**
  130573. * gets the angular velocity
  130574. * @param impostor imposter to get angular velocity from
  130575. * @returns angular velocity
  130576. */
  130577. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  130578. /**
  130579. * Sets the mass of physics body
  130580. * @param impostor imposter to set the mass on
  130581. * @param mass mass to set
  130582. */
  130583. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  130584. /**
  130585. * Gets the mass of the physics body
  130586. * @param impostor imposter to get the mass from
  130587. * @returns mass
  130588. */
  130589. getBodyMass(impostor: PhysicsImpostor): number;
  130590. /**
  130591. * Gets friction of the impostor
  130592. * @param impostor impostor to get friction from
  130593. * @returns friction value
  130594. */
  130595. getBodyFriction(impostor: PhysicsImpostor): number;
  130596. /**
  130597. * Sets friction of the impostor
  130598. * @param impostor impostor to set friction on
  130599. * @param friction friction value
  130600. */
  130601. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  130602. /**
  130603. * Gets restitution of the impostor
  130604. * @param impostor impostor to get restitution from
  130605. * @returns restitution value
  130606. */
  130607. getBodyRestitution(impostor: PhysicsImpostor): number;
  130608. /**
  130609. * Sets resitution of the impostor
  130610. * @param impostor impostor to set resitution on
  130611. * @param restitution resitution value
  130612. */
  130613. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  130614. /**
  130615. * Gets pressure inside the impostor
  130616. * @param impostor impostor to get pressure from
  130617. * @returns pressure value
  130618. */
  130619. getBodyPressure(impostor: PhysicsImpostor): number;
  130620. /**
  130621. * Sets pressure inside a soft body impostor
  130622. * Cloth and rope must remain 0 pressure
  130623. * @param impostor impostor to set pressure on
  130624. * @param pressure pressure value
  130625. */
  130626. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  130627. /**
  130628. * Gets stiffness of the impostor
  130629. * @param impostor impostor to get stiffness from
  130630. * @returns pressure value
  130631. */
  130632. getBodyStiffness(impostor: PhysicsImpostor): number;
  130633. /**
  130634. * Sets stiffness of the impostor
  130635. * @param impostor impostor to set stiffness on
  130636. * @param stiffness stiffness value from 0 to 1
  130637. */
  130638. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  130639. /**
  130640. * Gets velocityIterations of the impostor
  130641. * @param impostor impostor to get velocity iterations from
  130642. * @returns velocityIterations value
  130643. */
  130644. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  130645. /**
  130646. * Sets velocityIterations of the impostor
  130647. * @param impostor impostor to set velocity iterations on
  130648. * @param velocityIterations velocityIterations value
  130649. */
  130650. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  130651. /**
  130652. * Gets positionIterations of the impostor
  130653. * @param impostor impostor to get position iterations from
  130654. * @returns positionIterations value
  130655. */
  130656. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  130657. /**
  130658. * Sets positionIterations of the impostor
  130659. * @param impostor impostor to set position on
  130660. * @param positionIterations positionIterations value
  130661. */
  130662. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  130663. /**
  130664. * Append an anchor to a cloth object
  130665. * @param impostor is the cloth impostor to add anchor to
  130666. * @param otherImpostor is the rigid impostor to anchor to
  130667. * @param width ratio across width from 0 to 1
  130668. * @param height ratio up height from 0 to 1
  130669. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  130670. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  130671. */
  130672. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  130673. /**
  130674. * Append an hook to a rope object
  130675. * @param impostor is the rope impostor to add hook to
  130676. * @param otherImpostor is the rigid impostor to hook to
  130677. * @param length ratio along the rope from 0 to 1
  130678. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  130679. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  130680. */
  130681. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  130682. /**
  130683. * Sleeps the physics body and stops it from being active
  130684. * @param impostor impostor to sleep
  130685. */
  130686. sleepBody(impostor: PhysicsImpostor): void;
  130687. /**
  130688. * Activates the physics body
  130689. * @param impostor impostor to activate
  130690. */
  130691. wakeUpBody(impostor: PhysicsImpostor): void;
  130692. /**
  130693. * Updates the distance parameters of the joint
  130694. * @param joint joint to update
  130695. * @param maxDistance maximum distance of the joint
  130696. * @param minDistance minimum distance of the joint
  130697. */
  130698. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  130699. /**
  130700. * Sets a motor on the joint
  130701. * @param joint joint to set motor on
  130702. * @param speed speed of the motor
  130703. * @param maxForce maximum force of the motor
  130704. * @param motorIndex index of the motor
  130705. */
  130706. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  130707. /**
  130708. * Sets the motors limit
  130709. * @param joint joint to set limit on
  130710. * @param upperLimit upper limit
  130711. * @param lowerLimit lower limit
  130712. */
  130713. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  130714. /**
  130715. * Syncs the position and rotation of a mesh with the impostor
  130716. * @param mesh mesh to sync
  130717. * @param impostor impostor to update the mesh with
  130718. */
  130719. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  130720. /**
  130721. * Gets the radius of the impostor
  130722. * @param impostor impostor to get radius from
  130723. * @returns the radius
  130724. */
  130725. getRadius(impostor: PhysicsImpostor): number;
  130726. /**
  130727. * Gets the box size of the impostor
  130728. * @param impostor impostor to get box size from
  130729. * @param result the resulting box size
  130730. */
  130731. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  130732. /**
  130733. * Disposes of the impostor
  130734. */
  130735. dispose(): void;
  130736. /**
  130737. * Does a raycast in the physics world
  130738. * @param from when should the ray start?
  130739. * @param to when should the ray end?
  130740. * @returns PhysicsRaycastResult
  130741. */
  130742. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  130743. }
  130744. }
  130745. declare module BABYLON {
  130746. interface AbstractScene {
  130747. /**
  130748. * The list of reflection probes added to the scene
  130749. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  130750. */
  130751. reflectionProbes: Array<ReflectionProbe>;
  130752. /**
  130753. * Removes the given reflection probe from this scene.
  130754. * @param toRemove The reflection probe to remove
  130755. * @returns The index of the removed reflection probe
  130756. */
  130757. removeReflectionProbe(toRemove: ReflectionProbe): number;
  130758. /**
  130759. * Adds the given reflection probe to this scene.
  130760. * @param newReflectionProbe The reflection probe to add
  130761. */
  130762. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  130763. }
  130764. /**
  130765. * Class used to generate realtime reflection / refraction cube textures
  130766. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  130767. */
  130768. export class ReflectionProbe {
  130769. /** defines the name of the probe */
  130770. name: string;
  130771. private _scene;
  130772. private _renderTargetTexture;
  130773. private _projectionMatrix;
  130774. private _viewMatrix;
  130775. private _target;
  130776. private _add;
  130777. private _attachedMesh;
  130778. private _invertYAxis;
  130779. /** Gets or sets probe position (center of the cube map) */
  130780. position: Vector3;
  130781. /**
  130782. * Creates a new reflection probe
  130783. * @param name defines the name of the probe
  130784. * @param size defines the texture resolution (for each face)
  130785. * @param scene defines the hosting scene
  130786. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  130787. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  130788. */
  130789. constructor(
  130790. /** defines the name of the probe */
  130791. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  130792. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  130793. get samples(): number;
  130794. set samples(value: number);
  130795. /** Gets or sets the refresh rate to use (on every frame by default) */
  130796. get refreshRate(): number;
  130797. set refreshRate(value: number);
  130798. /**
  130799. * Gets the hosting scene
  130800. * @returns a Scene
  130801. */
  130802. getScene(): Scene;
  130803. /** Gets the internal CubeTexture used to render to */
  130804. get cubeTexture(): RenderTargetTexture;
  130805. /** Gets the list of meshes to render */
  130806. get renderList(): Nullable<AbstractMesh[]>;
  130807. /**
  130808. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  130809. * @param mesh defines the mesh to attach to
  130810. */
  130811. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  130812. /**
  130813. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  130814. * @param renderingGroupId The rendering group id corresponding to its index
  130815. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  130816. */
  130817. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  130818. /**
  130819. * Clean all associated resources
  130820. */
  130821. dispose(): void;
  130822. /**
  130823. * Converts the reflection probe information to a readable string for debug purpose.
  130824. * @param fullDetails Supports for multiple levels of logging within scene loading
  130825. * @returns the human readable reflection probe info
  130826. */
  130827. toString(fullDetails?: boolean): string;
  130828. /**
  130829. * Get the class name of the relfection probe.
  130830. * @returns "ReflectionProbe"
  130831. */
  130832. getClassName(): string;
  130833. /**
  130834. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  130835. * @returns The JSON representation of the texture
  130836. */
  130837. serialize(): any;
  130838. /**
  130839. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  130840. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  130841. * @param scene Define the scene the parsed reflection probe should be instantiated in
  130842. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  130843. * @returns The parsed reflection probe if successful
  130844. */
  130845. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  130846. }
  130847. }
  130848. declare module BABYLON {
  130849. /** @hidden */
  130850. export var _BabylonLoaderRegistered: boolean;
  130851. /**
  130852. * Helps setting up some configuration for the babylon file loader.
  130853. */
  130854. export class BabylonFileLoaderConfiguration {
  130855. /**
  130856. * The loader does not allow injecting custom physix engine into the plugins.
  130857. * Unfortunately in ES6, we need to manually inject them into the plugin.
  130858. * So you could set this variable to your engine import to make it work.
  130859. */
  130860. static LoaderInjectedPhysicsEngine: any;
  130861. }
  130862. }
  130863. declare module BABYLON {
  130864. /**
  130865. * The Physically based simple base material of BJS.
  130866. *
  130867. * This enables better naming and convention enforcements on top of the pbrMaterial.
  130868. * It is used as the base class for both the specGloss and metalRough conventions.
  130869. */
  130870. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  130871. /**
  130872. * Number of Simultaneous lights allowed on the material.
  130873. */
  130874. maxSimultaneousLights: number;
  130875. /**
  130876. * If sets to true, disables all the lights affecting the material.
  130877. */
  130878. disableLighting: boolean;
  130879. /**
  130880. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  130881. */
  130882. environmentTexture: BaseTexture;
  130883. /**
  130884. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  130885. */
  130886. invertNormalMapX: boolean;
  130887. /**
  130888. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  130889. */
  130890. invertNormalMapY: boolean;
  130891. /**
  130892. * Normal map used in the model.
  130893. */
  130894. normalTexture: BaseTexture;
  130895. /**
  130896. * Emissivie color used to self-illuminate the model.
  130897. */
  130898. emissiveColor: Color3;
  130899. /**
  130900. * Emissivie texture used to self-illuminate the model.
  130901. */
  130902. emissiveTexture: BaseTexture;
  130903. /**
  130904. * Occlusion Channel Strenght.
  130905. */
  130906. occlusionStrength: number;
  130907. /**
  130908. * Occlusion Texture of the material (adding extra occlusion effects).
  130909. */
  130910. occlusionTexture: BaseTexture;
  130911. /**
  130912. * Defines the alpha limits in alpha test mode.
  130913. */
  130914. alphaCutOff: number;
  130915. /**
  130916. * Gets the current double sided mode.
  130917. */
  130918. get doubleSided(): boolean;
  130919. /**
  130920. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  130921. */
  130922. set doubleSided(value: boolean);
  130923. /**
  130924. * Stores the pre-calculated light information of a mesh in a texture.
  130925. */
  130926. lightmapTexture: BaseTexture;
  130927. /**
  130928. * If true, the light map contains occlusion information instead of lighting info.
  130929. */
  130930. useLightmapAsShadowmap: boolean;
  130931. /**
  130932. * Instantiates a new PBRMaterial instance.
  130933. *
  130934. * @param name The material name
  130935. * @param scene The scene the material will be use in.
  130936. */
  130937. constructor(name: string, scene: Scene);
  130938. getClassName(): string;
  130939. }
  130940. }
  130941. declare module BABYLON {
  130942. /**
  130943. * The PBR material of BJS following the metal roughness convention.
  130944. *
  130945. * This fits to the PBR convention in the GLTF definition:
  130946. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  130947. */
  130948. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  130949. /**
  130950. * The base color has two different interpretations depending on the value of metalness.
  130951. * When the material is a metal, the base color is the specific measured reflectance value
  130952. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  130953. * of the material.
  130954. */
  130955. baseColor: Color3;
  130956. /**
  130957. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  130958. * well as opacity information in the alpha channel.
  130959. */
  130960. baseTexture: BaseTexture;
  130961. /**
  130962. * Specifies the metallic scalar value of the material.
  130963. * Can also be used to scale the metalness values of the metallic texture.
  130964. */
  130965. metallic: number;
  130966. /**
  130967. * Specifies the roughness scalar value of the material.
  130968. * Can also be used to scale the roughness values of the metallic texture.
  130969. */
  130970. roughness: number;
  130971. /**
  130972. * Texture containing both the metallic value in the B channel and the
  130973. * roughness value in the G channel to keep better precision.
  130974. */
  130975. metallicRoughnessTexture: BaseTexture;
  130976. /**
  130977. * Instantiates a new PBRMetalRoughnessMaterial instance.
  130978. *
  130979. * @param name The material name
  130980. * @param scene The scene the material will be use in.
  130981. */
  130982. constructor(name: string, scene: Scene);
  130983. /**
  130984. * Return the currrent class name of the material.
  130985. */
  130986. getClassName(): string;
  130987. /**
  130988. * Makes a duplicate of the current material.
  130989. * @param name - name to use for the new material.
  130990. */
  130991. clone(name: string): PBRMetallicRoughnessMaterial;
  130992. /**
  130993. * Serialize the material to a parsable JSON object.
  130994. */
  130995. serialize(): any;
  130996. /**
  130997. * Parses a JSON object correponding to the serialize function.
  130998. */
  130999. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  131000. }
  131001. }
  131002. declare module BABYLON {
  131003. /**
  131004. * The PBR material of BJS following the specular glossiness convention.
  131005. *
  131006. * This fits to the PBR convention in the GLTF definition:
  131007. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  131008. */
  131009. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  131010. /**
  131011. * Specifies the diffuse color of the material.
  131012. */
  131013. diffuseColor: Color3;
  131014. /**
  131015. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  131016. * channel.
  131017. */
  131018. diffuseTexture: BaseTexture;
  131019. /**
  131020. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  131021. */
  131022. specularColor: Color3;
  131023. /**
  131024. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  131025. */
  131026. glossiness: number;
  131027. /**
  131028. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  131029. */
  131030. specularGlossinessTexture: BaseTexture;
  131031. /**
  131032. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  131033. *
  131034. * @param name The material name
  131035. * @param scene The scene the material will be use in.
  131036. */
  131037. constructor(name: string, scene: Scene);
  131038. /**
  131039. * Return the currrent class name of the material.
  131040. */
  131041. getClassName(): string;
  131042. /**
  131043. * Makes a duplicate of the current material.
  131044. * @param name - name to use for the new material.
  131045. */
  131046. clone(name: string): PBRSpecularGlossinessMaterial;
  131047. /**
  131048. * Serialize the material to a parsable JSON object.
  131049. */
  131050. serialize(): any;
  131051. /**
  131052. * Parses a JSON object correponding to the serialize function.
  131053. */
  131054. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  131055. }
  131056. }
  131057. declare module BABYLON {
  131058. /**
  131059. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  131060. * It can help converting any input color in a desired output one. This can then be used to create effects
  131061. * from sepia, black and white to sixties or futuristic rendering...
  131062. *
  131063. * The only supported format is currently 3dl.
  131064. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  131065. */
  131066. export class ColorGradingTexture extends BaseTexture {
  131067. /**
  131068. * The texture URL.
  131069. */
  131070. url: string;
  131071. /**
  131072. * Empty line regex stored for GC.
  131073. */
  131074. private static _noneEmptyLineRegex;
  131075. private _textureMatrix;
  131076. private _engine;
  131077. private _onLoad;
  131078. /**
  131079. * Instantiates a ColorGradingTexture from the following parameters.
  131080. *
  131081. * @param url The location of the color gradind data (currently only supporting 3dl)
  131082. * @param sceneOrEngine The scene or engine the texture will be used in
  131083. * @param onLoad defines a callback triggered when the texture has been loaded
  131084. */
  131085. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  131086. /**
  131087. * Fires the onload event from the constructor if requested.
  131088. */
  131089. private _triggerOnLoad;
  131090. /**
  131091. * Returns the texture matrix used in most of the material.
  131092. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  131093. */
  131094. getTextureMatrix(): Matrix;
  131095. /**
  131096. * Occurs when the file being loaded is a .3dl LUT file.
  131097. */
  131098. private load3dlTexture;
  131099. /**
  131100. * Starts the loading process of the texture.
  131101. */
  131102. private loadTexture;
  131103. /**
  131104. * Clones the color gradind texture.
  131105. */
  131106. clone(): ColorGradingTexture;
  131107. /**
  131108. * Called during delayed load for textures.
  131109. */
  131110. delayLoad(): void;
  131111. /**
  131112. * Parses a color grading texture serialized by Babylon.
  131113. * @param parsedTexture The texture information being parsedTexture
  131114. * @param scene The scene to load the texture in
  131115. * @param rootUrl The root url of the data assets to load
  131116. * @return A color gradind texture
  131117. */
  131118. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  131119. /**
  131120. * Serializes the LUT texture to json format.
  131121. */
  131122. serialize(): any;
  131123. /**
  131124. * Returns true if the passed parameter is a scene object (can be use for typings)
  131125. * @param sceneOrEngine The object to test.
  131126. */
  131127. private static _isScene;
  131128. }
  131129. }
  131130. declare module BABYLON {
  131131. /**
  131132. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  131133. */
  131134. export class EquiRectangularCubeTexture extends BaseTexture {
  131135. /** The six faces of the cube. */
  131136. private static _FacesMapping;
  131137. private _noMipmap;
  131138. private _onLoad;
  131139. private _onError;
  131140. /** The size of the cubemap. */
  131141. private _size;
  131142. /** The buffer of the image. */
  131143. private _buffer;
  131144. /** The width of the input image. */
  131145. private _width;
  131146. /** The height of the input image. */
  131147. private _height;
  131148. /** The URL to the image. */
  131149. url: string;
  131150. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  131151. coordinatesMode: number;
  131152. /**
  131153. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  131154. * @param url The location of the image
  131155. * @param scene The scene the texture will be used in
  131156. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  131157. * @param noMipmap Forces to not generate the mipmap if true
  131158. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  131159. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  131160. * @param onLoad — defines a callback called when texture is loaded
  131161. * @param onError — defines a callback called if there is an error
  131162. */
  131163. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  131164. /**
  131165. * Load the image data, by putting the image on a canvas and extracting its buffer.
  131166. */
  131167. private loadImage;
  131168. /**
  131169. * Convert the image buffer into a cubemap and create a CubeTexture.
  131170. */
  131171. private loadTexture;
  131172. /**
  131173. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  131174. * @param buffer The ArrayBuffer that should be converted.
  131175. * @returns The buffer as Float32Array.
  131176. */
  131177. private getFloat32ArrayFromArrayBuffer;
  131178. /**
  131179. * Get the current class name of the texture useful for serialization or dynamic coding.
  131180. * @returns "EquiRectangularCubeTexture"
  131181. */
  131182. getClassName(): string;
  131183. /**
  131184. * Create a clone of the current EquiRectangularCubeTexture and return it.
  131185. * @returns A clone of the current EquiRectangularCubeTexture.
  131186. */
  131187. clone(): EquiRectangularCubeTexture;
  131188. }
  131189. }
  131190. declare module BABYLON {
  131191. /**
  131192. * Based on jsTGALoader - Javascript loader for TGA file
  131193. * By Vincent Thibault
  131194. * @see http://blog.robrowser.com/javascript-tga-loader.html
  131195. */
  131196. export class TGATools {
  131197. private static _TYPE_INDEXED;
  131198. private static _TYPE_RGB;
  131199. private static _TYPE_GREY;
  131200. private static _TYPE_RLE_INDEXED;
  131201. private static _TYPE_RLE_RGB;
  131202. private static _TYPE_RLE_GREY;
  131203. private static _ORIGIN_MASK;
  131204. private static _ORIGIN_SHIFT;
  131205. private static _ORIGIN_BL;
  131206. private static _ORIGIN_BR;
  131207. private static _ORIGIN_UL;
  131208. private static _ORIGIN_UR;
  131209. /**
  131210. * Gets the header of a TGA file
  131211. * @param data defines the TGA data
  131212. * @returns the header
  131213. */
  131214. static GetTGAHeader(data: Uint8Array): any;
  131215. /**
  131216. * Uploads TGA content to a Babylon Texture
  131217. * @hidden
  131218. */
  131219. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  131220. /** @hidden */
  131221. 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;
  131222. /** @hidden */
  131223. 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;
  131224. /** @hidden */
  131225. 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;
  131226. /** @hidden */
  131227. 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;
  131228. /** @hidden */
  131229. 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;
  131230. /** @hidden */
  131231. 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;
  131232. }
  131233. }
  131234. declare module BABYLON {
  131235. /**
  131236. * Implementation of the TGA Texture Loader.
  131237. * @hidden
  131238. */
  131239. export class _TGATextureLoader implements IInternalTextureLoader {
  131240. /**
  131241. * Defines wether the loader supports cascade loading the different faces.
  131242. */
  131243. readonly supportCascades: boolean;
  131244. /**
  131245. * This returns if the loader support the current file information.
  131246. * @param extension defines the file extension of the file being loaded
  131247. * @returns true if the loader can load the specified file
  131248. */
  131249. canLoad(extension: string): boolean;
  131250. /**
  131251. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  131252. * @param data contains the texture data
  131253. * @param texture defines the BabylonJS internal texture
  131254. * @param createPolynomials will be true if polynomials have been requested
  131255. * @param onLoad defines the callback to trigger once the texture is ready
  131256. * @param onError defines the callback to trigger in case of error
  131257. */
  131258. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  131259. /**
  131260. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  131261. * @param data contains the texture data
  131262. * @param texture defines the BabylonJS internal texture
  131263. * @param callback defines the method to call once ready to upload
  131264. */
  131265. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  131266. }
  131267. }
  131268. declare module BABYLON {
  131269. /**
  131270. * Info about the .basis files
  131271. */
  131272. class BasisFileInfo {
  131273. /**
  131274. * If the file has alpha
  131275. */
  131276. hasAlpha: boolean;
  131277. /**
  131278. * Info about each image of the basis file
  131279. */
  131280. images: Array<{
  131281. levels: Array<{
  131282. width: number;
  131283. height: number;
  131284. transcodedPixels: ArrayBufferView;
  131285. }>;
  131286. }>;
  131287. }
  131288. /**
  131289. * Result of transcoding a basis file
  131290. */
  131291. class TranscodeResult {
  131292. /**
  131293. * Info about the .basis file
  131294. */
  131295. fileInfo: BasisFileInfo;
  131296. /**
  131297. * Format to use when loading the file
  131298. */
  131299. format: number;
  131300. }
  131301. /**
  131302. * Configuration options for the Basis transcoder
  131303. */
  131304. export class BasisTranscodeConfiguration {
  131305. /**
  131306. * Supported compression formats used to determine the supported output format of the transcoder
  131307. */
  131308. supportedCompressionFormats?: {
  131309. /**
  131310. * etc1 compression format
  131311. */
  131312. etc1?: boolean;
  131313. /**
  131314. * s3tc compression format
  131315. */
  131316. s3tc?: boolean;
  131317. /**
  131318. * pvrtc compression format
  131319. */
  131320. pvrtc?: boolean;
  131321. /**
  131322. * etc2 compression format
  131323. */
  131324. etc2?: boolean;
  131325. };
  131326. /**
  131327. * If mipmap levels should be loaded for transcoded images (Default: true)
  131328. */
  131329. loadMipmapLevels?: boolean;
  131330. /**
  131331. * Index of a single image to load (Default: all images)
  131332. */
  131333. loadSingleImage?: number;
  131334. }
  131335. /**
  131336. * Used to load .Basis files
  131337. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  131338. */
  131339. export class BasisTools {
  131340. private static _IgnoreSupportedFormats;
  131341. /**
  131342. * URL to use when loading the basis transcoder
  131343. */
  131344. static JSModuleURL: string;
  131345. /**
  131346. * URL to use when loading the wasm module for the transcoder
  131347. */
  131348. static WasmModuleURL: string;
  131349. /**
  131350. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  131351. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  131352. * @returns internal format corresponding to the Basis format
  131353. */
  131354. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  131355. private static _WorkerPromise;
  131356. private static _Worker;
  131357. private static _actionId;
  131358. private static _CreateWorkerAsync;
  131359. /**
  131360. * Transcodes a loaded image file to compressed pixel data
  131361. * @param data image data to transcode
  131362. * @param config configuration options for the transcoding
  131363. * @returns a promise resulting in the transcoded image
  131364. */
  131365. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  131366. /**
  131367. * Loads a texture from the transcode result
  131368. * @param texture texture load to
  131369. * @param transcodeResult the result of transcoding the basis file to load from
  131370. */
  131371. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  131372. }
  131373. }
  131374. declare module BABYLON {
  131375. /**
  131376. * Loader for .basis file format
  131377. */
  131378. export class _BasisTextureLoader implements IInternalTextureLoader {
  131379. /**
  131380. * Defines whether the loader supports cascade loading the different faces.
  131381. */
  131382. readonly supportCascades: boolean;
  131383. /**
  131384. * This returns if the loader support the current file information.
  131385. * @param extension defines the file extension of the file being loaded
  131386. * @returns true if the loader can load the specified file
  131387. */
  131388. canLoad(extension: string): boolean;
  131389. /**
  131390. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  131391. * @param data contains the texture data
  131392. * @param texture defines the BabylonJS internal texture
  131393. * @param createPolynomials will be true if polynomials have been requested
  131394. * @param onLoad defines the callback to trigger once the texture is ready
  131395. * @param onError defines the callback to trigger in case of error
  131396. */
  131397. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  131398. /**
  131399. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  131400. * @param data contains the texture data
  131401. * @param texture defines the BabylonJS internal texture
  131402. * @param callback defines the method to call once ready to upload
  131403. */
  131404. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  131405. }
  131406. }
  131407. declare module BABYLON {
  131408. /**
  131409. * 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.
  131410. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  131411. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  131412. */
  131413. export class CustomProceduralTexture extends ProceduralTexture {
  131414. private _animate;
  131415. private _time;
  131416. private _config;
  131417. private _texturePath;
  131418. /**
  131419. * Instantiates a new Custom Procedural Texture.
  131420. * 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.
  131421. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  131422. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  131423. * @param name Define the name of the texture
  131424. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  131425. * @param size Define the size of the texture to create
  131426. * @param scene Define the scene the texture belongs to
  131427. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  131428. * @param generateMipMaps Define if the texture should creates mip maps or not
  131429. */
  131430. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  131431. private _loadJson;
  131432. /**
  131433. * Is the texture ready to be used ? (rendered at least once)
  131434. * @returns true if ready, otherwise, false.
  131435. */
  131436. isReady(): boolean;
  131437. /**
  131438. * Render the texture to its associated render target.
  131439. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  131440. */
  131441. render(useCameraPostProcess?: boolean): void;
  131442. /**
  131443. * Update the list of dependant textures samplers in the shader.
  131444. */
  131445. updateTextures(): void;
  131446. /**
  131447. * Update the uniform values of the procedural texture in the shader.
  131448. */
  131449. updateShaderUniforms(): void;
  131450. /**
  131451. * Define if the texture animates or not.
  131452. */
  131453. get animate(): boolean;
  131454. set animate(value: boolean);
  131455. }
  131456. }
  131457. declare module BABYLON {
  131458. /** @hidden */
  131459. export var noisePixelShader: {
  131460. name: string;
  131461. shader: string;
  131462. };
  131463. }
  131464. declare module BABYLON {
  131465. /**
  131466. * Class used to generate noise procedural textures
  131467. */
  131468. export class NoiseProceduralTexture extends ProceduralTexture {
  131469. private _time;
  131470. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  131471. brightness: number;
  131472. /** Defines the number of octaves to process */
  131473. octaves: number;
  131474. /** Defines the level of persistence (0.8 by default) */
  131475. persistence: number;
  131476. /** Gets or sets animation speed factor (default is 1) */
  131477. animationSpeedFactor: number;
  131478. /**
  131479. * Creates a new NoiseProceduralTexture
  131480. * @param name defines the name fo the texture
  131481. * @param size defines the size of the texture (default is 256)
  131482. * @param scene defines the hosting scene
  131483. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  131484. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  131485. */
  131486. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  131487. private _updateShaderUniforms;
  131488. protected _getDefines(): string;
  131489. /** Generate the current state of the procedural texture */
  131490. render(useCameraPostProcess?: boolean): void;
  131491. /**
  131492. * Serializes this noise procedural texture
  131493. * @returns a serialized noise procedural texture object
  131494. */
  131495. serialize(): any;
  131496. /**
  131497. * Clone the texture.
  131498. * @returns the cloned texture
  131499. */
  131500. clone(): NoiseProceduralTexture;
  131501. /**
  131502. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  131503. * @param parsedTexture defines parsed texture data
  131504. * @param scene defines the current scene
  131505. * @param rootUrl defines the root URL containing noise procedural texture information
  131506. * @returns a parsed NoiseProceduralTexture
  131507. */
  131508. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  131509. }
  131510. }
  131511. declare module BABYLON {
  131512. /**
  131513. * Raw cube texture where the raw buffers are passed in
  131514. */
  131515. export class RawCubeTexture extends CubeTexture {
  131516. /**
  131517. * Creates a cube texture where the raw buffers are passed in.
  131518. * @param scene defines the scene the texture is attached to
  131519. * @param data defines the array of data to use to create each face
  131520. * @param size defines the size of the textures
  131521. * @param format defines the format of the data
  131522. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  131523. * @param generateMipMaps defines if the engine should generate the mip levels
  131524. * @param invertY defines if data must be stored with Y axis inverted
  131525. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  131526. * @param compression defines the compression used (null by default)
  131527. */
  131528. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  131529. /**
  131530. * Updates the raw cube texture.
  131531. * @param data defines the data to store
  131532. * @param format defines the data format
  131533. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  131534. * @param invertY defines if data must be stored with Y axis inverted
  131535. * @param compression defines the compression used (null by default)
  131536. * @param level defines which level of the texture to update
  131537. */
  131538. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  131539. /**
  131540. * Updates a raw cube texture with RGBD encoded data.
  131541. * @param data defines the array of data [mipmap][face] to use to create each face
  131542. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  131543. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  131544. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  131545. * @returns a promsie that resolves when the operation is complete
  131546. */
  131547. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  131548. /**
  131549. * Clones the raw cube texture.
  131550. * @return a new cube texture
  131551. */
  131552. clone(): CubeTexture;
  131553. /** @hidden */
  131554. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  131555. }
  131556. }
  131557. declare module BABYLON {
  131558. /**
  131559. * Class used to store 3D textures containing user data
  131560. */
  131561. export class RawTexture3D extends Texture {
  131562. /** Gets or sets the texture format to use */
  131563. format: number;
  131564. private _engine;
  131565. /**
  131566. * Create a new RawTexture3D
  131567. * @param data defines the data of the texture
  131568. * @param width defines the width of the texture
  131569. * @param height defines the height of the texture
  131570. * @param depth defines the depth of the texture
  131571. * @param format defines the texture format to use
  131572. * @param scene defines the hosting scene
  131573. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  131574. * @param invertY defines if texture must be stored with Y axis inverted
  131575. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  131576. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  131577. */
  131578. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  131579. /** Gets or sets the texture format to use */
  131580. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  131581. /**
  131582. * Update the texture with new data
  131583. * @param data defines the data to store in the texture
  131584. */
  131585. update(data: ArrayBufferView): void;
  131586. }
  131587. }
  131588. declare module BABYLON {
  131589. /**
  131590. * Class used to store 2D array textures containing user data
  131591. */
  131592. export class RawTexture2DArray extends Texture {
  131593. /** Gets or sets the texture format to use */
  131594. format: number;
  131595. private _engine;
  131596. /**
  131597. * Create a new RawTexture2DArray
  131598. * @param data defines the data of the texture
  131599. * @param width defines the width of the texture
  131600. * @param height defines the height of the texture
  131601. * @param depth defines the number of layers of the texture
  131602. * @param format defines the texture format to use
  131603. * @param scene defines the hosting scene
  131604. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  131605. * @param invertY defines if texture must be stored with Y axis inverted
  131606. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  131607. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  131608. */
  131609. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  131610. /** Gets or sets the texture format to use */
  131611. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  131612. /**
  131613. * Update the texture with new data
  131614. * @param data defines the data to store in the texture
  131615. */
  131616. update(data: ArrayBufferView): void;
  131617. }
  131618. }
  131619. declare module BABYLON {
  131620. /**
  131621. * Creates a refraction texture used by refraction channel of the standard material.
  131622. * It is like a mirror but to see through a material.
  131623. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  131624. */
  131625. export class RefractionTexture extends RenderTargetTexture {
  131626. /**
  131627. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  131628. * 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.
  131629. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  131630. */
  131631. refractionPlane: Plane;
  131632. /**
  131633. * Define how deep under the surface we should see.
  131634. */
  131635. depth: number;
  131636. /**
  131637. * Creates a refraction texture used by refraction channel of the standard material.
  131638. * It is like a mirror but to see through a material.
  131639. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  131640. * @param name Define the texture name
  131641. * @param size Define the size of the underlying texture
  131642. * @param scene Define the scene the refraction belongs to
  131643. * @param generateMipMaps Define if we need to generate mips level for the refraction
  131644. */
  131645. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  131646. /**
  131647. * Clone the refraction texture.
  131648. * @returns the cloned texture
  131649. */
  131650. clone(): RefractionTexture;
  131651. /**
  131652. * Serialize the texture to a JSON representation you could use in Parse later on
  131653. * @returns the serialized JSON representation
  131654. */
  131655. serialize(): any;
  131656. }
  131657. }
  131658. declare module BABYLON {
  131659. /**
  131660. * Defines the options related to the creation of an HtmlElementTexture
  131661. */
  131662. export interface IHtmlElementTextureOptions {
  131663. /**
  131664. * Defines wether mip maps should be created or not.
  131665. */
  131666. generateMipMaps?: boolean;
  131667. /**
  131668. * Defines the sampling mode of the texture.
  131669. */
  131670. samplingMode?: number;
  131671. /**
  131672. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  131673. */
  131674. engine: Nullable<ThinEngine>;
  131675. /**
  131676. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  131677. */
  131678. scene: Nullable<Scene>;
  131679. }
  131680. /**
  131681. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  131682. * To be as efficient as possible depending on your constraints nothing aside the first upload
  131683. * is automatically managed.
  131684. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  131685. * in your application.
  131686. *
  131687. * As the update is not automatic, you need to call them manually.
  131688. */
  131689. export class HtmlElementTexture extends BaseTexture {
  131690. /**
  131691. * The texture URL.
  131692. */
  131693. element: HTMLVideoElement | HTMLCanvasElement;
  131694. private static readonly DefaultOptions;
  131695. private _textureMatrix;
  131696. private _engine;
  131697. private _isVideo;
  131698. private _generateMipMaps;
  131699. private _samplingMode;
  131700. /**
  131701. * Instantiates a HtmlElementTexture from the following parameters.
  131702. *
  131703. * @param name Defines the name of the texture
  131704. * @param element Defines the video or canvas the texture is filled with
  131705. * @param options Defines the other none mandatory texture creation options
  131706. */
  131707. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  131708. private _createInternalTexture;
  131709. /**
  131710. * Returns the texture matrix used in most of the material.
  131711. */
  131712. getTextureMatrix(): Matrix;
  131713. /**
  131714. * Updates the content of the texture.
  131715. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  131716. */
  131717. update(invertY?: Nullable<boolean>): void;
  131718. }
  131719. }
  131720. declare module BABYLON {
  131721. /**
  131722. * Defines the basic options interface of a TexturePacker Frame
  131723. */
  131724. export interface ITexturePackerFrame {
  131725. /**
  131726. * The frame ID
  131727. */
  131728. id: number;
  131729. /**
  131730. * The frames Scale
  131731. */
  131732. scale: Vector2;
  131733. /**
  131734. * The Frames offset
  131735. */
  131736. offset: Vector2;
  131737. }
  131738. /**
  131739. * This is a support class for frame Data on texture packer sets.
  131740. */
  131741. export class TexturePackerFrame implements ITexturePackerFrame {
  131742. /**
  131743. * The frame ID
  131744. */
  131745. id: number;
  131746. /**
  131747. * The frames Scale
  131748. */
  131749. scale: Vector2;
  131750. /**
  131751. * The Frames offset
  131752. */
  131753. offset: Vector2;
  131754. /**
  131755. * Initializes a texture package frame.
  131756. * @param id The numerical frame identifier
  131757. * @param scale Scalar Vector2 for UV frame
  131758. * @param offset Vector2 for the frame position in UV units.
  131759. * @returns TexturePackerFrame
  131760. */
  131761. constructor(id: number, scale: Vector2, offset: Vector2);
  131762. }
  131763. }
  131764. declare module BABYLON {
  131765. /**
  131766. * Defines the basic options interface of a TexturePacker
  131767. */
  131768. export interface ITexturePackerOptions {
  131769. /**
  131770. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  131771. */
  131772. map?: string[];
  131773. /**
  131774. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  131775. */
  131776. uvsIn?: string;
  131777. /**
  131778. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  131779. */
  131780. uvsOut?: string;
  131781. /**
  131782. * number representing the layout style. Defaults to LAYOUT_STRIP
  131783. */
  131784. layout?: number;
  131785. /**
  131786. * number of columns if using custom column count layout(2). This defaults to 4.
  131787. */
  131788. colnum?: number;
  131789. /**
  131790. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  131791. */
  131792. updateInputMeshes?: boolean;
  131793. /**
  131794. * boolean flag to dispose all the source textures. Defaults to true.
  131795. */
  131796. disposeSources?: boolean;
  131797. /**
  131798. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  131799. */
  131800. fillBlanks?: boolean;
  131801. /**
  131802. * string value representing the context fill style color. Defaults to 'black'.
  131803. */
  131804. customFillColor?: string;
  131805. /**
  131806. * Width and Height Value of each Frame in the TexturePacker Sets
  131807. */
  131808. frameSize?: number;
  131809. /**
  131810. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  131811. */
  131812. paddingRatio?: number;
  131813. /**
  131814. * Number that declares the fill method for the padding gutter.
  131815. */
  131816. paddingMode?: number;
  131817. /**
  131818. * If in SUBUV_COLOR padding mode what color to use.
  131819. */
  131820. paddingColor?: Color3 | Color4;
  131821. }
  131822. /**
  131823. * Defines the basic interface of a TexturePacker JSON File
  131824. */
  131825. export interface ITexturePackerJSON {
  131826. /**
  131827. * The frame ID
  131828. */
  131829. name: string;
  131830. /**
  131831. * The base64 channel data
  131832. */
  131833. sets: any;
  131834. /**
  131835. * The options of the Packer
  131836. */
  131837. options: ITexturePackerOptions;
  131838. /**
  131839. * The frame data of the Packer
  131840. */
  131841. frames: Array<number>;
  131842. }
  131843. /**
  131844. * This is a support class that generates a series of packed texture sets.
  131845. * @see https://doc.babylonjs.com/babylon101/materials
  131846. */
  131847. export class TexturePacker {
  131848. /** Packer Layout Constant 0 */
  131849. static readonly LAYOUT_STRIP: number;
  131850. /** Packer Layout Constant 1 */
  131851. static readonly LAYOUT_POWER2: number;
  131852. /** Packer Layout Constant 2 */
  131853. static readonly LAYOUT_COLNUM: number;
  131854. /** Packer Layout Constant 0 */
  131855. static readonly SUBUV_WRAP: number;
  131856. /** Packer Layout Constant 1 */
  131857. static readonly SUBUV_EXTEND: number;
  131858. /** Packer Layout Constant 2 */
  131859. static readonly SUBUV_COLOR: number;
  131860. /** The Name of the Texture Package */
  131861. name: string;
  131862. /** The scene scope of the TexturePacker */
  131863. scene: Scene;
  131864. /** The Meshes to target */
  131865. meshes: AbstractMesh[];
  131866. /** Arguments passed with the Constructor */
  131867. options: ITexturePackerOptions;
  131868. /** The promise that is started upon initialization */
  131869. promise: Nullable<Promise<TexturePacker | string>>;
  131870. /** The Container object for the channel sets that are generated */
  131871. sets: object;
  131872. /** The Container array for the frames that are generated */
  131873. frames: TexturePackerFrame[];
  131874. /** The expected number of textures the system is parsing. */
  131875. private _expecting;
  131876. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  131877. private _paddingValue;
  131878. /**
  131879. * Initializes a texture package series from an array of meshes or a single mesh.
  131880. * @param name The name of the package
  131881. * @param meshes The target meshes to compose the package from
  131882. * @param options The arguments that texture packer should follow while building.
  131883. * @param scene The scene which the textures are scoped to.
  131884. * @returns TexturePacker
  131885. */
  131886. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  131887. /**
  131888. * Starts the package process
  131889. * @param resolve The promises resolution function
  131890. * @returns TexturePacker
  131891. */
  131892. private _createFrames;
  131893. /**
  131894. * Calculates the Size of the Channel Sets
  131895. * @returns Vector2
  131896. */
  131897. private _calculateSize;
  131898. /**
  131899. * Calculates the UV data for the frames.
  131900. * @param baseSize the base frameSize
  131901. * @param padding the base frame padding
  131902. * @param dtSize size of the Dynamic Texture for that channel
  131903. * @param dtUnits is 1/dtSize
  131904. * @param update flag to update the input meshes
  131905. */
  131906. private _calculateMeshUVFrames;
  131907. /**
  131908. * Calculates the frames Offset.
  131909. * @param index of the frame
  131910. * @returns Vector2
  131911. */
  131912. private _getFrameOffset;
  131913. /**
  131914. * Updates a Mesh to the frame data
  131915. * @param mesh that is the target
  131916. * @param frameID or the frame index
  131917. */
  131918. private _updateMeshUV;
  131919. /**
  131920. * Updates a Meshes materials to use the texture packer channels
  131921. * @param m is the mesh to target
  131922. * @param force all channels on the packer to be set.
  131923. */
  131924. private _updateTextureReferences;
  131925. /**
  131926. * Public method to set a Mesh to a frame
  131927. * @param m that is the target
  131928. * @param frameID or the frame index
  131929. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  131930. */
  131931. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  131932. /**
  131933. * Starts the async promise to compile the texture packer.
  131934. * @returns Promise<void>
  131935. */
  131936. processAsync(): Promise<void>;
  131937. /**
  131938. * Disposes all textures associated with this packer
  131939. */
  131940. dispose(): void;
  131941. /**
  131942. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  131943. * @param imageType is the image type to use.
  131944. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  131945. */
  131946. download(imageType?: string, quality?: number): void;
  131947. /**
  131948. * Public method to load a texturePacker JSON file.
  131949. * @param data of the JSON file in string format.
  131950. */
  131951. updateFromJSON(data: string): void;
  131952. }
  131953. }
  131954. declare module BABYLON {
  131955. /**
  131956. * Enum used to define the target of a block
  131957. */
  131958. export enum NodeMaterialBlockTargets {
  131959. /** Vertex shader */
  131960. Vertex = 1,
  131961. /** Fragment shader */
  131962. Fragment = 2,
  131963. /** Neutral */
  131964. Neutral = 4,
  131965. /** Vertex and Fragment */
  131966. VertexAndFragment = 3
  131967. }
  131968. }
  131969. declare module BABYLON {
  131970. /**
  131971. * Defines the kind of connection point for node based material
  131972. */
  131973. export enum NodeMaterialBlockConnectionPointTypes {
  131974. /** Float */
  131975. Float = 1,
  131976. /** Int */
  131977. Int = 2,
  131978. /** Vector2 */
  131979. Vector2 = 4,
  131980. /** Vector3 */
  131981. Vector3 = 8,
  131982. /** Vector4 */
  131983. Vector4 = 16,
  131984. /** Color3 */
  131985. Color3 = 32,
  131986. /** Color4 */
  131987. Color4 = 64,
  131988. /** Matrix */
  131989. Matrix = 128,
  131990. /** Detect type based on connection */
  131991. AutoDetect = 1024,
  131992. /** Output type that will be defined by input type */
  131993. BasedOnInput = 2048
  131994. }
  131995. }
  131996. declare module BABYLON {
  131997. /**
  131998. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  131999. */
  132000. export enum NodeMaterialBlockConnectionPointMode {
  132001. /** Value is an uniform */
  132002. Uniform = 0,
  132003. /** Value is a mesh attribute */
  132004. Attribute = 1,
  132005. /** Value is a varying between vertex and fragment shaders */
  132006. Varying = 2,
  132007. /** Mode is undefined */
  132008. Undefined = 3
  132009. }
  132010. }
  132011. declare module BABYLON {
  132012. /**
  132013. * Enum used to define system values e.g. values automatically provided by the system
  132014. */
  132015. export enum NodeMaterialSystemValues {
  132016. /** World */
  132017. World = 1,
  132018. /** View */
  132019. View = 2,
  132020. /** Projection */
  132021. Projection = 3,
  132022. /** ViewProjection */
  132023. ViewProjection = 4,
  132024. /** WorldView */
  132025. WorldView = 5,
  132026. /** WorldViewProjection */
  132027. WorldViewProjection = 6,
  132028. /** CameraPosition */
  132029. CameraPosition = 7,
  132030. /** Fog Color */
  132031. FogColor = 8,
  132032. /** Delta time */
  132033. DeltaTime = 9
  132034. }
  132035. }
  132036. declare module BABYLON {
  132037. /**
  132038. * Root class for all node material optimizers
  132039. */
  132040. export class NodeMaterialOptimizer {
  132041. /**
  132042. * Function used to optimize a NodeMaterial graph
  132043. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  132044. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  132045. */
  132046. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  132047. }
  132048. }
  132049. declare module BABYLON {
  132050. /**
  132051. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  132052. */
  132053. export class TransformBlock extends NodeMaterialBlock {
  132054. /**
  132055. * Defines the value to use to complement W value to transform it to a Vector4
  132056. */
  132057. complementW: number;
  132058. /**
  132059. * Defines the value to use to complement z value to transform it to a Vector4
  132060. */
  132061. complementZ: number;
  132062. /**
  132063. * Creates a new TransformBlock
  132064. * @param name defines the block name
  132065. */
  132066. constructor(name: string);
  132067. /**
  132068. * Gets the current class name
  132069. * @returns the class name
  132070. */
  132071. getClassName(): string;
  132072. /**
  132073. * Gets the vector input
  132074. */
  132075. get vector(): NodeMaterialConnectionPoint;
  132076. /**
  132077. * Gets the output component
  132078. */
  132079. get output(): NodeMaterialConnectionPoint;
  132080. /**
  132081. * Gets the xyz output component
  132082. */
  132083. get xyz(): NodeMaterialConnectionPoint;
  132084. /**
  132085. * Gets the matrix transform input
  132086. */
  132087. get transform(): NodeMaterialConnectionPoint;
  132088. protected _buildBlock(state: NodeMaterialBuildState): this;
  132089. serialize(): any;
  132090. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132091. protected _dumpPropertiesCode(): string;
  132092. }
  132093. }
  132094. declare module BABYLON {
  132095. /**
  132096. * Block used to output the vertex position
  132097. */
  132098. export class VertexOutputBlock extends NodeMaterialBlock {
  132099. /**
  132100. * Creates a new VertexOutputBlock
  132101. * @param name defines the block name
  132102. */
  132103. constructor(name: string);
  132104. /**
  132105. * Gets the current class name
  132106. * @returns the class name
  132107. */
  132108. getClassName(): string;
  132109. /**
  132110. * Gets the vector input component
  132111. */
  132112. get vector(): NodeMaterialConnectionPoint;
  132113. protected _buildBlock(state: NodeMaterialBuildState): this;
  132114. }
  132115. }
  132116. declare module BABYLON {
  132117. /**
  132118. * Block used to output the final color
  132119. */
  132120. export class FragmentOutputBlock extends NodeMaterialBlock {
  132121. /**
  132122. * Create a new FragmentOutputBlock
  132123. * @param name defines the block name
  132124. */
  132125. constructor(name: string);
  132126. /**
  132127. * Gets the current class name
  132128. * @returns the class name
  132129. */
  132130. getClassName(): string;
  132131. /**
  132132. * Gets the rgba input component
  132133. */
  132134. get rgba(): NodeMaterialConnectionPoint;
  132135. /**
  132136. * Gets the rgb input component
  132137. */
  132138. get rgb(): NodeMaterialConnectionPoint;
  132139. /**
  132140. * Gets the a input component
  132141. */
  132142. get a(): NodeMaterialConnectionPoint;
  132143. protected _buildBlock(state: NodeMaterialBuildState): this;
  132144. }
  132145. }
  132146. declare module BABYLON {
  132147. /**
  132148. * Block used to read a reflection texture from a sampler
  132149. */
  132150. export class ReflectionTextureBlock extends NodeMaterialBlock {
  132151. private _define3DName;
  132152. private _defineCubicName;
  132153. private _defineExplicitName;
  132154. private _defineProjectionName;
  132155. private _defineLocalCubicName;
  132156. private _defineSphericalName;
  132157. private _definePlanarName;
  132158. private _defineEquirectangularName;
  132159. private _defineMirroredEquirectangularFixedName;
  132160. private _defineEquirectangularFixedName;
  132161. private _defineSkyboxName;
  132162. private _cubeSamplerName;
  132163. private _2DSamplerName;
  132164. private _positionUVWName;
  132165. private _directionWName;
  132166. private _reflectionCoordsName;
  132167. private _reflection2DCoordsName;
  132168. private _reflectionColorName;
  132169. private _reflectionMatrixName;
  132170. /**
  132171. * Gets or sets the texture associated with the node
  132172. */
  132173. texture: Nullable<BaseTexture>;
  132174. /**
  132175. * Create a new TextureBlock
  132176. * @param name defines the block name
  132177. */
  132178. constructor(name: string);
  132179. /**
  132180. * Gets the current class name
  132181. * @returns the class name
  132182. */
  132183. getClassName(): string;
  132184. /**
  132185. * Gets the world position input component
  132186. */
  132187. get position(): NodeMaterialConnectionPoint;
  132188. /**
  132189. * Gets the world position input component
  132190. */
  132191. get worldPosition(): NodeMaterialConnectionPoint;
  132192. /**
  132193. * Gets the world normal input component
  132194. */
  132195. get worldNormal(): NodeMaterialConnectionPoint;
  132196. /**
  132197. * Gets the world input component
  132198. */
  132199. get world(): NodeMaterialConnectionPoint;
  132200. /**
  132201. * Gets the camera (or eye) position component
  132202. */
  132203. get cameraPosition(): NodeMaterialConnectionPoint;
  132204. /**
  132205. * Gets the view input component
  132206. */
  132207. get view(): NodeMaterialConnectionPoint;
  132208. /**
  132209. * Gets the rgb output component
  132210. */
  132211. get rgb(): NodeMaterialConnectionPoint;
  132212. /**
  132213. * Gets the r output component
  132214. */
  132215. get r(): NodeMaterialConnectionPoint;
  132216. /**
  132217. * Gets the g output component
  132218. */
  132219. get g(): NodeMaterialConnectionPoint;
  132220. /**
  132221. * Gets the b output component
  132222. */
  132223. get b(): NodeMaterialConnectionPoint;
  132224. autoConfigure(material: NodeMaterial): void;
  132225. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132226. isReady(): boolean;
  132227. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132228. private _injectVertexCode;
  132229. private _writeOutput;
  132230. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132231. protected _dumpPropertiesCode(): string;
  132232. serialize(): any;
  132233. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132234. }
  132235. }
  132236. declare module BABYLON {
  132237. /**
  132238. * Interface used to configure the node material editor
  132239. */
  132240. export interface INodeMaterialEditorOptions {
  132241. /** Define the URl to load node editor script */
  132242. editorURL?: string;
  132243. }
  132244. /** @hidden */
  132245. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  132246. NORMAL: boolean;
  132247. TANGENT: boolean;
  132248. UV1: boolean;
  132249. /** BONES */
  132250. NUM_BONE_INFLUENCERS: number;
  132251. BonesPerMesh: number;
  132252. BONETEXTURE: boolean;
  132253. /** MORPH TARGETS */
  132254. MORPHTARGETS: boolean;
  132255. MORPHTARGETS_NORMAL: boolean;
  132256. MORPHTARGETS_TANGENT: boolean;
  132257. MORPHTARGETS_UV: boolean;
  132258. NUM_MORPH_INFLUENCERS: number;
  132259. /** IMAGE PROCESSING */
  132260. IMAGEPROCESSING: boolean;
  132261. VIGNETTE: boolean;
  132262. VIGNETTEBLENDMODEMULTIPLY: boolean;
  132263. VIGNETTEBLENDMODEOPAQUE: boolean;
  132264. TONEMAPPING: boolean;
  132265. TONEMAPPING_ACES: boolean;
  132266. CONTRAST: boolean;
  132267. EXPOSURE: boolean;
  132268. COLORCURVES: boolean;
  132269. COLORGRADING: boolean;
  132270. COLORGRADING3D: boolean;
  132271. SAMPLER3DGREENDEPTH: boolean;
  132272. SAMPLER3DBGRMAP: boolean;
  132273. IMAGEPROCESSINGPOSTPROCESS: boolean;
  132274. /** MISC. */
  132275. BUMPDIRECTUV: number;
  132276. constructor();
  132277. setValue(name: string, value: boolean): void;
  132278. }
  132279. /**
  132280. * Class used to configure NodeMaterial
  132281. */
  132282. export interface INodeMaterialOptions {
  132283. /**
  132284. * Defines if blocks should emit comments
  132285. */
  132286. emitComments: boolean;
  132287. }
  132288. /**
  132289. * Class used to create a node based material built by assembling shader blocks
  132290. */
  132291. export class NodeMaterial extends PushMaterial {
  132292. private static _BuildIdGenerator;
  132293. private _options;
  132294. private _vertexCompilationState;
  132295. private _fragmentCompilationState;
  132296. private _sharedData;
  132297. private _buildId;
  132298. private _buildWasSuccessful;
  132299. private _cachedWorldViewMatrix;
  132300. private _cachedWorldViewProjectionMatrix;
  132301. private _optimizers;
  132302. private _animationFrame;
  132303. /** Define the Url to load node editor script */
  132304. static EditorURL: string;
  132305. /** Define the Url to load snippets */
  132306. static SnippetUrl: string;
  132307. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  132308. static IgnoreTexturesAtLoadTime: boolean;
  132309. private BJSNODEMATERIALEDITOR;
  132310. /** Get the inspector from bundle or global */
  132311. private _getGlobalNodeMaterialEditor;
  132312. /**
  132313. * Snippet ID if the material was created from the snippet server
  132314. */
  132315. snippetId: string;
  132316. /**
  132317. * Gets or sets data used by visual editor
  132318. * @see https://nme.babylonjs.com
  132319. */
  132320. editorData: any;
  132321. /**
  132322. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  132323. */
  132324. ignoreAlpha: boolean;
  132325. /**
  132326. * Defines the maximum number of lights that can be used in the material
  132327. */
  132328. maxSimultaneousLights: number;
  132329. /**
  132330. * Observable raised when the material is built
  132331. */
  132332. onBuildObservable: Observable<NodeMaterial>;
  132333. /**
  132334. * Gets or sets the root nodes of the material vertex shader
  132335. */
  132336. _vertexOutputNodes: NodeMaterialBlock[];
  132337. /**
  132338. * Gets or sets the root nodes of the material fragment (pixel) shader
  132339. */
  132340. _fragmentOutputNodes: NodeMaterialBlock[];
  132341. /** Gets or sets options to control the node material overall behavior */
  132342. get options(): INodeMaterialOptions;
  132343. set options(options: INodeMaterialOptions);
  132344. /**
  132345. * Default configuration related to image processing available in the standard Material.
  132346. */
  132347. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  132348. /**
  132349. * Gets the image processing configuration used either in this material.
  132350. */
  132351. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  132352. /**
  132353. * Sets the Default image processing configuration used either in the this material.
  132354. *
  132355. * If sets to null, the scene one is in use.
  132356. */
  132357. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  132358. /**
  132359. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  132360. */
  132361. attachedBlocks: NodeMaterialBlock[];
  132362. /**
  132363. * Create a new node based material
  132364. * @param name defines the material name
  132365. * @param scene defines the hosting scene
  132366. * @param options defines creation option
  132367. */
  132368. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  132369. /**
  132370. * Gets the current class name of the material e.g. "NodeMaterial"
  132371. * @returns the class name
  132372. */
  132373. getClassName(): string;
  132374. /**
  132375. * Keep track of the image processing observer to allow dispose and replace.
  132376. */
  132377. private _imageProcessingObserver;
  132378. /**
  132379. * Attaches a new image processing configuration to the Standard Material.
  132380. * @param configuration
  132381. */
  132382. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  132383. /**
  132384. * Get a block by its name
  132385. * @param name defines the name of the block to retrieve
  132386. * @returns the required block or null if not found
  132387. */
  132388. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  132389. /**
  132390. * Get a block by its name
  132391. * @param predicate defines the predicate used to find the good candidate
  132392. * @returns the required block or null if not found
  132393. */
  132394. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  132395. /**
  132396. * Get an input block by its name
  132397. * @param predicate defines the predicate used to find the good candidate
  132398. * @returns the required input block or null if not found
  132399. */
  132400. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  132401. /**
  132402. * Gets the list of input blocks attached to this material
  132403. * @returns an array of InputBlocks
  132404. */
  132405. getInputBlocks(): InputBlock[];
  132406. /**
  132407. * Adds a new optimizer to the list of optimizers
  132408. * @param optimizer defines the optimizers to add
  132409. * @returns the current material
  132410. */
  132411. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  132412. /**
  132413. * Remove an optimizer from the list of optimizers
  132414. * @param optimizer defines the optimizers to remove
  132415. * @returns the current material
  132416. */
  132417. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  132418. /**
  132419. * Add a new block to the list of output nodes
  132420. * @param node defines the node to add
  132421. * @returns the current material
  132422. */
  132423. addOutputNode(node: NodeMaterialBlock): this;
  132424. /**
  132425. * Remove a block from the list of root nodes
  132426. * @param node defines the node to remove
  132427. * @returns the current material
  132428. */
  132429. removeOutputNode(node: NodeMaterialBlock): this;
  132430. private _addVertexOutputNode;
  132431. private _removeVertexOutputNode;
  132432. private _addFragmentOutputNode;
  132433. private _removeFragmentOutputNode;
  132434. /**
  132435. * Specifies if the material will require alpha blending
  132436. * @returns a boolean specifying if alpha blending is needed
  132437. */
  132438. needAlphaBlending(): boolean;
  132439. /**
  132440. * Specifies if this material should be rendered in alpha test mode
  132441. * @returns a boolean specifying if an alpha test is needed.
  132442. */
  132443. needAlphaTesting(): boolean;
  132444. private _initializeBlock;
  132445. private _resetDualBlocks;
  132446. /**
  132447. * Remove a block from the current node material
  132448. * @param block defines the block to remove
  132449. */
  132450. removeBlock(block: NodeMaterialBlock): void;
  132451. /**
  132452. * Build the material and generates the inner effect
  132453. * @param verbose defines if the build should log activity
  132454. */
  132455. build(verbose?: boolean): void;
  132456. /**
  132457. * Runs an otpimization phase to try to improve the shader code
  132458. */
  132459. optimize(): void;
  132460. private _prepareDefinesForAttributes;
  132461. /**
  132462. * Get if the submesh is ready to be used and all its information available.
  132463. * Child classes can use it to update shaders
  132464. * @param mesh defines the mesh to check
  132465. * @param subMesh defines which submesh to check
  132466. * @param useInstances specifies that instances should be used
  132467. * @returns a boolean indicating that the submesh is ready or not
  132468. */
  132469. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  132470. /**
  132471. * Get a string representing the shaders built by the current node graph
  132472. */
  132473. get compiledShaders(): string;
  132474. /**
  132475. * Binds the world matrix to the material
  132476. * @param world defines the world transformation matrix
  132477. */
  132478. bindOnlyWorldMatrix(world: Matrix): void;
  132479. /**
  132480. * Binds the submesh to this material by preparing the effect and shader to draw
  132481. * @param world defines the world transformation matrix
  132482. * @param mesh defines the mesh containing the submesh
  132483. * @param subMesh defines the submesh to bind the material to
  132484. */
  132485. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  132486. /**
  132487. * Gets the active textures from the material
  132488. * @returns an array of textures
  132489. */
  132490. getActiveTextures(): BaseTexture[];
  132491. /**
  132492. * Gets the list of texture blocks
  132493. * @returns an array of texture blocks
  132494. */
  132495. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  132496. /**
  132497. * Specifies if the material uses a texture
  132498. * @param texture defines the texture to check against the material
  132499. * @returns a boolean specifying if the material uses the texture
  132500. */
  132501. hasTexture(texture: BaseTexture): boolean;
  132502. /**
  132503. * Disposes the material
  132504. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  132505. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  132506. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  132507. */
  132508. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  132509. /** Creates the node editor window. */
  132510. private _createNodeEditor;
  132511. /**
  132512. * Launch the node material editor
  132513. * @param config Define the configuration of the editor
  132514. * @return a promise fulfilled when the node editor is visible
  132515. */
  132516. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  132517. /**
  132518. * Clear the current material
  132519. */
  132520. clear(): void;
  132521. /**
  132522. * Clear the current material and set it to a default state
  132523. */
  132524. setToDefault(): void;
  132525. /**
  132526. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  132527. * @param url defines the url to load from
  132528. * @returns a promise that will fullfil when the material is fully loaded
  132529. */
  132530. loadAsync(url: string): Promise<void>;
  132531. private _gatherBlocks;
  132532. /**
  132533. * Generate a string containing the code declaration required to create an equivalent of this material
  132534. * @returns a string
  132535. */
  132536. generateCode(): string;
  132537. /**
  132538. * Serializes this material in a JSON representation
  132539. * @returns the serialized material object
  132540. */
  132541. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  132542. private _restoreConnections;
  132543. /**
  132544. * Clear the current graph and load a new one from a serialization object
  132545. * @param source defines the JSON representation of the material
  132546. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  132547. */
  132548. loadFromSerialization(source: any, rootUrl?: string): void;
  132549. /**
  132550. * Makes a duplicate of the current material.
  132551. * @param name - name to use for the new material.
  132552. */
  132553. clone(name: string): NodeMaterial;
  132554. /**
  132555. * Creates a node material from parsed material data
  132556. * @param source defines the JSON representation of the material
  132557. * @param scene defines the hosting scene
  132558. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  132559. * @returns a new node material
  132560. */
  132561. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  132562. /**
  132563. * Creates a node material from a snippet saved in a remote file
  132564. * @param name defines the name of the material to create
  132565. * @param url defines the url to load from
  132566. * @param scene defines the hosting scene
  132567. * @returns a promise that will resolve to the new node material
  132568. */
  132569. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  132570. /**
  132571. * Creates a node material from a snippet saved by the node material editor
  132572. * @param snippetId defines the snippet to load
  132573. * @param scene defines the hosting scene
  132574. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  132575. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  132576. * @returns a promise that will resolve to the new node material
  132577. */
  132578. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  132579. /**
  132580. * Creates a new node material set to default basic configuration
  132581. * @param name defines the name of the material
  132582. * @param scene defines the hosting scene
  132583. * @returns a new NodeMaterial
  132584. */
  132585. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  132586. }
  132587. }
  132588. declare module BABYLON {
  132589. /**
  132590. * Block used to read a texture from a sampler
  132591. */
  132592. export class TextureBlock extends NodeMaterialBlock {
  132593. private _defineName;
  132594. private _linearDefineName;
  132595. private _tempTextureRead;
  132596. private _samplerName;
  132597. private _transformedUVName;
  132598. private _textureTransformName;
  132599. private _textureInfoName;
  132600. private _mainUVName;
  132601. private _mainUVDefineName;
  132602. /**
  132603. * Gets or sets the texture associated with the node
  132604. */
  132605. texture: Nullable<Texture>;
  132606. /**
  132607. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  132608. */
  132609. convertToGammaSpace: boolean;
  132610. /**
  132611. * Create a new TextureBlock
  132612. * @param name defines the block name
  132613. */
  132614. constructor(name: string);
  132615. /**
  132616. * Gets the current class name
  132617. * @returns the class name
  132618. */
  132619. getClassName(): string;
  132620. /**
  132621. * Gets the uv input component
  132622. */
  132623. get uv(): NodeMaterialConnectionPoint;
  132624. /**
  132625. * Gets the rgba output component
  132626. */
  132627. get rgba(): NodeMaterialConnectionPoint;
  132628. /**
  132629. * Gets the rgb output component
  132630. */
  132631. get rgb(): NodeMaterialConnectionPoint;
  132632. /**
  132633. * Gets the r output component
  132634. */
  132635. get r(): NodeMaterialConnectionPoint;
  132636. /**
  132637. * Gets the g output component
  132638. */
  132639. get g(): NodeMaterialConnectionPoint;
  132640. /**
  132641. * Gets the b output component
  132642. */
  132643. get b(): NodeMaterialConnectionPoint;
  132644. /**
  132645. * Gets the a output component
  132646. */
  132647. get a(): NodeMaterialConnectionPoint;
  132648. get target(): NodeMaterialBlockTargets;
  132649. autoConfigure(material: NodeMaterial): void;
  132650. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  132651. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132652. isReady(): boolean;
  132653. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132654. private get _isMixed();
  132655. private _injectVertexCode;
  132656. private _writeTextureRead;
  132657. private _writeOutput;
  132658. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132659. protected _dumpPropertiesCode(): string;
  132660. serialize(): any;
  132661. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132662. }
  132663. }
  132664. declare module BABYLON {
  132665. /**
  132666. * Class used to store shared data between 2 NodeMaterialBuildState
  132667. */
  132668. export class NodeMaterialBuildStateSharedData {
  132669. /**
  132670. * Gets the list of emitted varyings
  132671. */
  132672. temps: string[];
  132673. /**
  132674. * Gets the list of emitted varyings
  132675. */
  132676. varyings: string[];
  132677. /**
  132678. * Gets the varying declaration string
  132679. */
  132680. varyingDeclaration: string;
  132681. /**
  132682. * Input blocks
  132683. */
  132684. inputBlocks: InputBlock[];
  132685. /**
  132686. * Input blocks
  132687. */
  132688. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  132689. /**
  132690. * Bindable blocks (Blocks that need to set data to the effect)
  132691. */
  132692. bindableBlocks: NodeMaterialBlock[];
  132693. /**
  132694. * List of blocks that can provide a compilation fallback
  132695. */
  132696. blocksWithFallbacks: NodeMaterialBlock[];
  132697. /**
  132698. * List of blocks that can provide a define update
  132699. */
  132700. blocksWithDefines: NodeMaterialBlock[];
  132701. /**
  132702. * List of blocks that can provide a repeatable content
  132703. */
  132704. repeatableContentBlocks: NodeMaterialBlock[];
  132705. /**
  132706. * List of blocks that can provide a dynamic list of uniforms
  132707. */
  132708. dynamicUniformBlocks: NodeMaterialBlock[];
  132709. /**
  132710. * List of blocks that can block the isReady function for the material
  132711. */
  132712. blockingBlocks: NodeMaterialBlock[];
  132713. /**
  132714. * Gets the list of animated inputs
  132715. */
  132716. animatedInputs: InputBlock[];
  132717. /**
  132718. * Build Id used to avoid multiple recompilations
  132719. */
  132720. buildId: number;
  132721. /** List of emitted variables */
  132722. variableNames: {
  132723. [key: string]: number;
  132724. };
  132725. /** List of emitted defines */
  132726. defineNames: {
  132727. [key: string]: number;
  132728. };
  132729. /** Should emit comments? */
  132730. emitComments: boolean;
  132731. /** Emit build activity */
  132732. verbose: boolean;
  132733. /** Gets or sets the hosting scene */
  132734. scene: Scene;
  132735. /**
  132736. * Gets the compilation hints emitted at compilation time
  132737. */
  132738. hints: {
  132739. needWorldViewMatrix: boolean;
  132740. needWorldViewProjectionMatrix: boolean;
  132741. needAlphaBlending: boolean;
  132742. needAlphaTesting: boolean;
  132743. };
  132744. /**
  132745. * List of compilation checks
  132746. */
  132747. checks: {
  132748. emitVertex: boolean;
  132749. emitFragment: boolean;
  132750. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  132751. };
  132752. /** Creates a new shared data */
  132753. constructor();
  132754. /**
  132755. * Emits console errors and exceptions if there is a failing check
  132756. */
  132757. emitErrors(): void;
  132758. }
  132759. }
  132760. declare module BABYLON {
  132761. /**
  132762. * Class used to store node based material build state
  132763. */
  132764. export class NodeMaterialBuildState {
  132765. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  132766. supportUniformBuffers: boolean;
  132767. /**
  132768. * Gets the list of emitted attributes
  132769. */
  132770. attributes: string[];
  132771. /**
  132772. * Gets the list of emitted uniforms
  132773. */
  132774. uniforms: string[];
  132775. /**
  132776. * Gets the list of emitted constants
  132777. */
  132778. constants: string[];
  132779. /**
  132780. * Gets the list of emitted samplers
  132781. */
  132782. samplers: string[];
  132783. /**
  132784. * Gets the list of emitted functions
  132785. */
  132786. functions: {
  132787. [key: string]: string;
  132788. };
  132789. /**
  132790. * Gets the list of emitted extensions
  132791. */
  132792. extensions: {
  132793. [key: string]: string;
  132794. };
  132795. /**
  132796. * Gets the target of the compilation state
  132797. */
  132798. target: NodeMaterialBlockTargets;
  132799. /**
  132800. * Gets the list of emitted counters
  132801. */
  132802. counters: {
  132803. [key: string]: number;
  132804. };
  132805. /**
  132806. * Shared data between multiple NodeMaterialBuildState instances
  132807. */
  132808. sharedData: NodeMaterialBuildStateSharedData;
  132809. /** @hidden */
  132810. _vertexState: NodeMaterialBuildState;
  132811. /** @hidden */
  132812. _attributeDeclaration: string;
  132813. /** @hidden */
  132814. _uniformDeclaration: string;
  132815. /** @hidden */
  132816. _constantDeclaration: string;
  132817. /** @hidden */
  132818. _samplerDeclaration: string;
  132819. /** @hidden */
  132820. _varyingTransfer: string;
  132821. private _repeatableContentAnchorIndex;
  132822. /** @hidden */
  132823. _builtCompilationString: string;
  132824. /**
  132825. * Gets the emitted compilation strings
  132826. */
  132827. compilationString: string;
  132828. /**
  132829. * Finalize the compilation strings
  132830. * @param state defines the current compilation state
  132831. */
  132832. finalize(state: NodeMaterialBuildState): void;
  132833. /** @hidden */
  132834. get _repeatableContentAnchor(): string;
  132835. /** @hidden */
  132836. _getFreeVariableName(prefix: string): string;
  132837. /** @hidden */
  132838. _getFreeDefineName(prefix: string): string;
  132839. /** @hidden */
  132840. _excludeVariableName(name: string): void;
  132841. /** @hidden */
  132842. _emit2DSampler(name: string): void;
  132843. /** @hidden */
  132844. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  132845. /** @hidden */
  132846. _emitExtension(name: string, extension: string): void;
  132847. /** @hidden */
  132848. _emitFunction(name: string, code: string, comments: string): void;
  132849. /** @hidden */
  132850. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  132851. replaceStrings?: {
  132852. search: RegExp;
  132853. replace: string;
  132854. }[];
  132855. repeatKey?: string;
  132856. }): string;
  132857. /** @hidden */
  132858. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  132859. repeatKey?: string;
  132860. removeAttributes?: boolean;
  132861. removeUniforms?: boolean;
  132862. removeVaryings?: boolean;
  132863. removeIfDef?: boolean;
  132864. replaceStrings?: {
  132865. search: RegExp;
  132866. replace: string;
  132867. }[];
  132868. }, storeKey?: string): void;
  132869. /** @hidden */
  132870. _registerTempVariable(name: string): boolean;
  132871. /** @hidden */
  132872. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  132873. /** @hidden */
  132874. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  132875. /** @hidden */
  132876. _emitFloat(value: number): string;
  132877. }
  132878. }
  132879. declare module BABYLON {
  132880. /**
  132881. * Defines a block that can be used inside a node based material
  132882. */
  132883. export class NodeMaterialBlock {
  132884. private _buildId;
  132885. private _buildTarget;
  132886. private _target;
  132887. private _isFinalMerger;
  132888. private _isInput;
  132889. protected _isUnique: boolean;
  132890. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  132891. inputsAreExclusive: boolean;
  132892. /** @hidden */
  132893. _codeVariableName: string;
  132894. /** @hidden */
  132895. _inputs: NodeMaterialConnectionPoint[];
  132896. /** @hidden */
  132897. _outputs: NodeMaterialConnectionPoint[];
  132898. /** @hidden */
  132899. _preparationId: number;
  132900. /**
  132901. * Gets or sets the name of the block
  132902. */
  132903. name: string;
  132904. /**
  132905. * Gets or sets the unique id of the node
  132906. */
  132907. uniqueId: number;
  132908. /**
  132909. * Gets or sets the comments associated with this block
  132910. */
  132911. comments: string;
  132912. /**
  132913. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  132914. */
  132915. get isUnique(): boolean;
  132916. /**
  132917. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  132918. */
  132919. get isFinalMerger(): boolean;
  132920. /**
  132921. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  132922. */
  132923. get isInput(): boolean;
  132924. /**
  132925. * Gets or sets the build Id
  132926. */
  132927. get buildId(): number;
  132928. set buildId(value: number);
  132929. /**
  132930. * Gets or sets the target of the block
  132931. */
  132932. get target(): NodeMaterialBlockTargets;
  132933. set target(value: NodeMaterialBlockTargets);
  132934. /**
  132935. * Gets the list of input points
  132936. */
  132937. get inputs(): NodeMaterialConnectionPoint[];
  132938. /** Gets the list of output points */
  132939. get outputs(): NodeMaterialConnectionPoint[];
  132940. /**
  132941. * Find an input by its name
  132942. * @param name defines the name of the input to look for
  132943. * @returns the input or null if not found
  132944. */
  132945. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  132946. /**
  132947. * Find an output by its name
  132948. * @param name defines the name of the outputto look for
  132949. * @returns the output or null if not found
  132950. */
  132951. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  132952. /**
  132953. * Creates a new NodeMaterialBlock
  132954. * @param name defines the block name
  132955. * @param target defines the target of that block (Vertex by default)
  132956. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  132957. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  132958. */
  132959. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  132960. /**
  132961. * Initialize the block and prepare the context for build
  132962. * @param state defines the state that will be used for the build
  132963. */
  132964. initialize(state: NodeMaterialBuildState): void;
  132965. /**
  132966. * Bind data to effect. Will only be called for blocks with isBindable === true
  132967. * @param effect defines the effect to bind data to
  132968. * @param nodeMaterial defines the hosting NodeMaterial
  132969. * @param mesh defines the mesh that will be rendered
  132970. */
  132971. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132972. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  132973. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  132974. protected _writeFloat(value: number): string;
  132975. /**
  132976. * Gets the current class name e.g. "NodeMaterialBlock"
  132977. * @returns the class name
  132978. */
  132979. getClassName(): string;
  132980. /**
  132981. * Register a new input. Must be called inside a block constructor
  132982. * @param name defines the connection point name
  132983. * @param type defines the connection point type
  132984. * @param isOptional defines a boolean indicating that this input can be omitted
  132985. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  132986. * @returns the current block
  132987. */
  132988. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  132989. /**
  132990. * Register a new output. Must be called inside a block constructor
  132991. * @param name defines the connection point name
  132992. * @param type defines the connection point type
  132993. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  132994. * @returns the current block
  132995. */
  132996. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  132997. /**
  132998. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  132999. * @param forOutput defines an optional connection point to check compatibility with
  133000. * @returns the first available input or null
  133001. */
  133002. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  133003. /**
  133004. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  133005. * @param forBlock defines an optional block to check compatibility with
  133006. * @returns the first available input or null
  133007. */
  133008. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  133009. /**
  133010. * Gets the sibling of the given output
  133011. * @param current defines the current output
  133012. * @returns the next output in the list or null
  133013. */
  133014. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  133015. /**
  133016. * Connect current block with another block
  133017. * @param other defines the block to connect with
  133018. * @param options define the various options to help pick the right connections
  133019. * @returns the current block
  133020. */
  133021. connectTo(other: NodeMaterialBlock, options?: {
  133022. input?: string;
  133023. output?: string;
  133024. outputSwizzle?: string;
  133025. }): this | undefined;
  133026. protected _buildBlock(state: NodeMaterialBuildState): void;
  133027. /**
  133028. * Add uniforms, samplers and uniform buffers at compilation time
  133029. * @param state defines the state to update
  133030. * @param nodeMaterial defines the node material requesting the update
  133031. * @param defines defines the material defines to update
  133032. * @param uniformBuffers defines the list of uniform buffer names
  133033. */
  133034. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  133035. /**
  133036. * Add potential fallbacks if shader compilation fails
  133037. * @param mesh defines the mesh to be rendered
  133038. * @param fallbacks defines the current prioritized list of fallbacks
  133039. */
  133040. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  133041. /**
  133042. * Initialize defines for shader compilation
  133043. * @param mesh defines the mesh to be rendered
  133044. * @param nodeMaterial defines the node material requesting the update
  133045. * @param defines defines the material defines to update
  133046. * @param useInstances specifies that instances should be used
  133047. */
  133048. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  133049. /**
  133050. * Update defines for shader compilation
  133051. * @param mesh defines the mesh to be rendered
  133052. * @param nodeMaterial defines the node material requesting the update
  133053. * @param defines defines the material defines to update
  133054. * @param useInstances specifies that instances should be used
  133055. */
  133056. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  133057. /**
  133058. * Lets the block try to connect some inputs automatically
  133059. * @param material defines the hosting NodeMaterial
  133060. */
  133061. autoConfigure(material: NodeMaterial): void;
  133062. /**
  133063. * Function called when a block is declared as repeatable content generator
  133064. * @param vertexShaderState defines the current compilation state for the vertex shader
  133065. * @param fragmentShaderState defines the current compilation state for the fragment shader
  133066. * @param mesh defines the mesh to be rendered
  133067. * @param defines defines the material defines to update
  133068. */
  133069. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  133070. /**
  133071. * Checks if the block is ready
  133072. * @param mesh defines the mesh to be rendered
  133073. * @param nodeMaterial defines the node material requesting the update
  133074. * @param defines defines the material defines to update
  133075. * @param useInstances specifies that instances should be used
  133076. * @returns true if the block is ready
  133077. */
  133078. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  133079. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  133080. private _processBuild;
  133081. /**
  133082. * Compile the current node and generate the shader code
  133083. * @param state defines the current compilation state (uniforms, samplers, current string)
  133084. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  133085. * @returns true if already built
  133086. */
  133087. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  133088. protected _inputRename(name: string): string;
  133089. protected _outputRename(name: string): string;
  133090. protected _dumpPropertiesCode(): string;
  133091. /** @hidden */
  133092. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  133093. /** @hidden */
  133094. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  133095. /**
  133096. * Clone the current block to a new identical block
  133097. * @param scene defines the hosting scene
  133098. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  133099. * @returns a copy of the current block
  133100. */
  133101. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  133102. /**
  133103. * Serializes this block in a JSON representation
  133104. * @returns the serialized block object
  133105. */
  133106. serialize(): any;
  133107. /** @hidden */
  133108. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133109. /**
  133110. * Release resources
  133111. */
  133112. dispose(): void;
  133113. }
  133114. }
  133115. declare module BABYLON {
  133116. /**
  133117. * Enum defining the type of animations supported by InputBlock
  133118. */
  133119. export enum AnimatedInputBlockTypes {
  133120. /** No animation */
  133121. None = 0,
  133122. /** Time based animation. Will only work for floats */
  133123. Time = 1
  133124. }
  133125. }
  133126. declare module BABYLON {
  133127. /**
  133128. * Block used to expose an input value
  133129. */
  133130. export class InputBlock extends NodeMaterialBlock {
  133131. private _mode;
  133132. private _associatedVariableName;
  133133. private _storedValue;
  133134. private _valueCallback;
  133135. private _type;
  133136. private _animationType;
  133137. /** Gets or set a value used to limit the range of float values */
  133138. min: number;
  133139. /** Gets or set a value used to limit the range of float values */
  133140. max: number;
  133141. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  133142. isBoolean: boolean;
  133143. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  133144. matrixMode: number;
  133145. /** @hidden */
  133146. _systemValue: Nullable<NodeMaterialSystemValues>;
  133147. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  133148. visibleInInspector: boolean;
  133149. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  133150. isConstant: boolean;
  133151. /** Gets or sets the group to use to display this block in the Inspector */
  133152. groupInInspector: string;
  133153. /** Gets an observable raised when the value is changed */
  133154. onValueChangedObservable: Observable<InputBlock>;
  133155. /**
  133156. * Gets or sets the connection point type (default is float)
  133157. */
  133158. get type(): NodeMaterialBlockConnectionPointTypes;
  133159. /**
  133160. * Creates a new InputBlock
  133161. * @param name defines the block name
  133162. * @param target defines the target of that block (Vertex by default)
  133163. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  133164. */
  133165. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  133166. /**
  133167. * Gets the output component
  133168. */
  133169. get output(): NodeMaterialConnectionPoint;
  133170. /**
  133171. * Set the source of this connection point to a vertex attribute
  133172. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  133173. * @returns the current connection point
  133174. */
  133175. setAsAttribute(attributeName?: string): InputBlock;
  133176. /**
  133177. * Set the source of this connection point to a system value
  133178. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  133179. * @returns the current connection point
  133180. */
  133181. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  133182. /**
  133183. * Gets or sets the value of that point.
  133184. * Please note that this value will be ignored if valueCallback is defined
  133185. */
  133186. get value(): any;
  133187. set value(value: any);
  133188. /**
  133189. * Gets or sets a callback used to get the value of that point.
  133190. * Please note that setting this value will force the connection point to ignore the value property
  133191. */
  133192. get valueCallback(): () => any;
  133193. set valueCallback(value: () => any);
  133194. /**
  133195. * Gets or sets the associated variable name in the shader
  133196. */
  133197. get associatedVariableName(): string;
  133198. set associatedVariableName(value: string);
  133199. /** Gets or sets the type of animation applied to the input */
  133200. get animationType(): AnimatedInputBlockTypes;
  133201. set animationType(value: AnimatedInputBlockTypes);
  133202. /**
  133203. * Gets a boolean indicating that this connection point not defined yet
  133204. */
  133205. get isUndefined(): boolean;
  133206. /**
  133207. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  133208. * In this case the connection point name must be the name of the uniform to use.
  133209. * Can only be set on inputs
  133210. */
  133211. get isUniform(): boolean;
  133212. set isUniform(value: boolean);
  133213. /**
  133214. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  133215. * In this case the connection point name must be the name of the attribute to use
  133216. * Can only be set on inputs
  133217. */
  133218. get isAttribute(): boolean;
  133219. set isAttribute(value: boolean);
  133220. /**
  133221. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  133222. * Can only be set on exit points
  133223. */
  133224. get isVarying(): boolean;
  133225. set isVarying(value: boolean);
  133226. /**
  133227. * Gets a boolean indicating that the current connection point is a system value
  133228. */
  133229. get isSystemValue(): boolean;
  133230. /**
  133231. * Gets or sets the current well known value or null if not defined as a system value
  133232. */
  133233. get systemValue(): Nullable<NodeMaterialSystemValues>;
  133234. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  133235. /**
  133236. * Gets the current class name
  133237. * @returns the class name
  133238. */
  133239. getClassName(): string;
  133240. /**
  133241. * Animate the input if animationType !== None
  133242. * @param scene defines the rendering scene
  133243. */
  133244. animate(scene: Scene): void;
  133245. private _emitDefine;
  133246. initialize(state: NodeMaterialBuildState): void;
  133247. /**
  133248. * Set the input block to its default value (based on its type)
  133249. */
  133250. setDefaultValue(): void;
  133251. private _emitConstant;
  133252. private _emit;
  133253. /** @hidden */
  133254. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  133255. /** @hidden */
  133256. _transmit(effect: Effect, scene: Scene): void;
  133257. protected _buildBlock(state: NodeMaterialBuildState): void;
  133258. protected _dumpPropertiesCode(): string;
  133259. dispose(): void;
  133260. serialize(): any;
  133261. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133262. }
  133263. }
  133264. declare module BABYLON {
  133265. /**
  133266. * Enum used to define the compatibility state between two connection points
  133267. */
  133268. export enum NodeMaterialConnectionPointCompatibilityStates {
  133269. /** Points are compatibles */
  133270. Compatible = 0,
  133271. /** Points are incompatible because of their types */
  133272. TypeIncompatible = 1,
  133273. /** Points are incompatible because of their targets (vertex vs fragment) */
  133274. TargetIncompatible = 2
  133275. }
  133276. /**
  133277. * Defines the direction of a connection point
  133278. */
  133279. export enum NodeMaterialConnectionPointDirection {
  133280. /** Input */
  133281. Input = 0,
  133282. /** Output */
  133283. Output = 1
  133284. }
  133285. /**
  133286. * Defines a connection point for a block
  133287. */
  133288. export class NodeMaterialConnectionPoint {
  133289. /** @hidden */
  133290. _ownerBlock: NodeMaterialBlock;
  133291. /** @hidden */
  133292. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  133293. private _endpoints;
  133294. private _associatedVariableName;
  133295. private _direction;
  133296. /** @hidden */
  133297. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  133298. /** @hidden */
  133299. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  133300. private _type;
  133301. /** @hidden */
  133302. _enforceAssociatedVariableName: boolean;
  133303. /** Gets the direction of the point */
  133304. get direction(): NodeMaterialConnectionPointDirection;
  133305. /**
  133306. * Gets or sets the additional types supported by this connection point
  133307. */
  133308. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  133309. /**
  133310. * Gets or sets the additional types excluded by this connection point
  133311. */
  133312. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  133313. /**
  133314. * Observable triggered when this point is connected
  133315. */
  133316. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  133317. /**
  133318. * Gets or sets the associated variable name in the shader
  133319. */
  133320. get associatedVariableName(): string;
  133321. set associatedVariableName(value: string);
  133322. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  133323. get innerType(): NodeMaterialBlockConnectionPointTypes;
  133324. /**
  133325. * Gets or sets the connection point type (default is float)
  133326. */
  133327. get type(): NodeMaterialBlockConnectionPointTypes;
  133328. set type(value: NodeMaterialBlockConnectionPointTypes);
  133329. /**
  133330. * Gets or sets the connection point name
  133331. */
  133332. name: string;
  133333. /**
  133334. * Gets or sets a boolean indicating that this connection point can be omitted
  133335. */
  133336. isOptional: boolean;
  133337. /**
  133338. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  133339. */
  133340. define: string;
  133341. /** @hidden */
  133342. _prioritizeVertex: boolean;
  133343. private _target;
  133344. /** Gets or sets the target of that connection point */
  133345. get target(): NodeMaterialBlockTargets;
  133346. set target(value: NodeMaterialBlockTargets);
  133347. /**
  133348. * Gets a boolean indicating that the current point is connected
  133349. */
  133350. get isConnected(): boolean;
  133351. /**
  133352. * Gets a boolean indicating that the current point is connected to an input block
  133353. */
  133354. get isConnectedToInputBlock(): boolean;
  133355. /**
  133356. * Gets a the connected input block (if any)
  133357. */
  133358. get connectInputBlock(): Nullable<InputBlock>;
  133359. /** Get the other side of the connection (if any) */
  133360. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  133361. /** Get the block that owns this connection point */
  133362. get ownerBlock(): NodeMaterialBlock;
  133363. /** Get the block connected on the other side of this connection (if any) */
  133364. get sourceBlock(): Nullable<NodeMaterialBlock>;
  133365. /** Get the block connected on the endpoints of this connection (if any) */
  133366. get connectedBlocks(): Array<NodeMaterialBlock>;
  133367. /** Gets the list of connected endpoints */
  133368. get endpoints(): NodeMaterialConnectionPoint[];
  133369. /** Gets a boolean indicating if that output point is connected to at least one input */
  133370. get hasEndpoints(): boolean;
  133371. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  133372. get isConnectedInVertexShader(): boolean;
  133373. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  133374. get isConnectedInFragmentShader(): boolean;
  133375. /**
  133376. * Creates a new connection point
  133377. * @param name defines the connection point name
  133378. * @param ownerBlock defines the block hosting this connection point
  133379. * @param direction defines the direction of the connection point
  133380. */
  133381. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  133382. /**
  133383. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  133384. * @returns the class name
  133385. */
  133386. getClassName(): string;
  133387. /**
  133388. * Gets a boolean indicating if the current point can be connected to another point
  133389. * @param connectionPoint defines the other connection point
  133390. * @returns a boolean
  133391. */
  133392. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  133393. /**
  133394. * Gets a number indicating if the current point can be connected to another point
  133395. * @param connectionPoint defines the other connection point
  133396. * @returns a number defining the compatibility state
  133397. */
  133398. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  133399. /**
  133400. * Connect this point to another connection point
  133401. * @param connectionPoint defines the other connection point
  133402. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  133403. * @returns the current connection point
  133404. */
  133405. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  133406. /**
  133407. * Disconnect this point from one of his endpoint
  133408. * @param endpoint defines the other connection point
  133409. * @returns the current connection point
  133410. */
  133411. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  133412. /**
  133413. * Serializes this point in a JSON representation
  133414. * @returns the serialized point object
  133415. */
  133416. serialize(): any;
  133417. /**
  133418. * Release resources
  133419. */
  133420. dispose(): void;
  133421. }
  133422. }
  133423. declare module BABYLON {
  133424. /**
  133425. * Block used to add support for vertex skinning (bones)
  133426. */
  133427. export class BonesBlock extends NodeMaterialBlock {
  133428. /**
  133429. * Creates a new BonesBlock
  133430. * @param name defines the block name
  133431. */
  133432. constructor(name: string);
  133433. /**
  133434. * Initialize the block and prepare the context for build
  133435. * @param state defines the state that will be used for the build
  133436. */
  133437. initialize(state: NodeMaterialBuildState): void;
  133438. /**
  133439. * Gets the current class name
  133440. * @returns the class name
  133441. */
  133442. getClassName(): string;
  133443. /**
  133444. * Gets the matrix indices input component
  133445. */
  133446. get matricesIndices(): NodeMaterialConnectionPoint;
  133447. /**
  133448. * Gets the matrix weights input component
  133449. */
  133450. get matricesWeights(): NodeMaterialConnectionPoint;
  133451. /**
  133452. * Gets the extra matrix indices input component
  133453. */
  133454. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  133455. /**
  133456. * Gets the extra matrix weights input component
  133457. */
  133458. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  133459. /**
  133460. * Gets the world input component
  133461. */
  133462. get world(): NodeMaterialConnectionPoint;
  133463. /**
  133464. * Gets the output component
  133465. */
  133466. get output(): NodeMaterialConnectionPoint;
  133467. autoConfigure(material: NodeMaterial): void;
  133468. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  133469. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133470. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133471. protected _buildBlock(state: NodeMaterialBuildState): this;
  133472. }
  133473. }
  133474. declare module BABYLON {
  133475. /**
  133476. * Block used to add support for instances
  133477. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  133478. */
  133479. export class InstancesBlock extends NodeMaterialBlock {
  133480. /**
  133481. * Creates a new InstancesBlock
  133482. * @param name defines the block name
  133483. */
  133484. constructor(name: string);
  133485. /**
  133486. * Gets the current class name
  133487. * @returns the class name
  133488. */
  133489. getClassName(): string;
  133490. /**
  133491. * Gets the first world row input component
  133492. */
  133493. get world0(): NodeMaterialConnectionPoint;
  133494. /**
  133495. * Gets the second world row input component
  133496. */
  133497. get world1(): NodeMaterialConnectionPoint;
  133498. /**
  133499. * Gets the third world row input component
  133500. */
  133501. get world2(): NodeMaterialConnectionPoint;
  133502. /**
  133503. * Gets the forth world row input component
  133504. */
  133505. get world3(): NodeMaterialConnectionPoint;
  133506. /**
  133507. * Gets the world input component
  133508. */
  133509. get world(): NodeMaterialConnectionPoint;
  133510. /**
  133511. * Gets the output component
  133512. */
  133513. get output(): NodeMaterialConnectionPoint;
  133514. /**
  133515. * Gets the isntanceID component
  133516. */
  133517. get instanceID(): NodeMaterialConnectionPoint;
  133518. autoConfigure(material: NodeMaterial): void;
  133519. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  133520. protected _buildBlock(state: NodeMaterialBuildState): this;
  133521. }
  133522. }
  133523. declare module BABYLON {
  133524. /**
  133525. * Block used to add morph targets support to vertex shader
  133526. */
  133527. export class MorphTargetsBlock extends NodeMaterialBlock {
  133528. private _repeatableContentAnchor;
  133529. /**
  133530. * Create a new MorphTargetsBlock
  133531. * @param name defines the block name
  133532. */
  133533. constructor(name: string);
  133534. /**
  133535. * Gets the current class name
  133536. * @returns the class name
  133537. */
  133538. getClassName(): string;
  133539. /**
  133540. * Gets the position input component
  133541. */
  133542. get position(): NodeMaterialConnectionPoint;
  133543. /**
  133544. * Gets the normal input component
  133545. */
  133546. get normal(): NodeMaterialConnectionPoint;
  133547. /**
  133548. * Gets the tangent input component
  133549. */
  133550. get tangent(): NodeMaterialConnectionPoint;
  133551. /**
  133552. * Gets the tangent input component
  133553. */
  133554. get uv(): NodeMaterialConnectionPoint;
  133555. /**
  133556. * Gets the position output component
  133557. */
  133558. get positionOutput(): NodeMaterialConnectionPoint;
  133559. /**
  133560. * Gets the normal output component
  133561. */
  133562. get normalOutput(): NodeMaterialConnectionPoint;
  133563. /**
  133564. * Gets the tangent output component
  133565. */
  133566. get tangentOutput(): NodeMaterialConnectionPoint;
  133567. /**
  133568. * Gets the tangent output component
  133569. */
  133570. get uvOutput(): NodeMaterialConnectionPoint;
  133571. initialize(state: NodeMaterialBuildState): void;
  133572. autoConfigure(material: NodeMaterial): void;
  133573. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133574. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133575. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  133576. protected _buildBlock(state: NodeMaterialBuildState): this;
  133577. }
  133578. }
  133579. declare module BABYLON {
  133580. /**
  133581. * Block used to get data information from a light
  133582. */
  133583. export class LightInformationBlock extends NodeMaterialBlock {
  133584. private _lightDataUniformName;
  133585. private _lightColorUniformName;
  133586. private _lightTypeDefineName;
  133587. /**
  133588. * Gets or sets the light associated with this block
  133589. */
  133590. light: Nullable<Light>;
  133591. /**
  133592. * Creates a new LightInformationBlock
  133593. * @param name defines the block name
  133594. */
  133595. constructor(name: string);
  133596. /**
  133597. * Gets the current class name
  133598. * @returns the class name
  133599. */
  133600. getClassName(): string;
  133601. /**
  133602. * Gets the world position input component
  133603. */
  133604. get worldPosition(): NodeMaterialConnectionPoint;
  133605. /**
  133606. * Gets the direction output component
  133607. */
  133608. get direction(): NodeMaterialConnectionPoint;
  133609. /**
  133610. * Gets the direction output component
  133611. */
  133612. get color(): NodeMaterialConnectionPoint;
  133613. /**
  133614. * Gets the direction output component
  133615. */
  133616. get intensity(): NodeMaterialConnectionPoint;
  133617. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133618. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133619. protected _buildBlock(state: NodeMaterialBuildState): this;
  133620. serialize(): any;
  133621. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133622. }
  133623. }
  133624. declare module BABYLON {
  133625. /**
  133626. * Block used to add image processing support to fragment shader
  133627. */
  133628. export class ImageProcessingBlock extends NodeMaterialBlock {
  133629. /**
  133630. * Create a new ImageProcessingBlock
  133631. * @param name defines the block name
  133632. */
  133633. constructor(name: string);
  133634. /**
  133635. * Gets the current class name
  133636. * @returns the class name
  133637. */
  133638. getClassName(): string;
  133639. /**
  133640. * Gets the color input component
  133641. */
  133642. get color(): NodeMaterialConnectionPoint;
  133643. /**
  133644. * Gets the output component
  133645. */
  133646. get output(): NodeMaterialConnectionPoint;
  133647. /**
  133648. * Initialize the block and prepare the context for build
  133649. * @param state defines the state that will be used for the build
  133650. */
  133651. initialize(state: NodeMaterialBuildState): void;
  133652. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  133653. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133654. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133655. protected _buildBlock(state: NodeMaterialBuildState): this;
  133656. }
  133657. }
  133658. declare module BABYLON {
  133659. /**
  133660. * Block used to pertub normals based on a normal map
  133661. */
  133662. export class PerturbNormalBlock extends NodeMaterialBlock {
  133663. private _tangentSpaceParameterName;
  133664. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  133665. invertX: boolean;
  133666. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  133667. invertY: boolean;
  133668. /**
  133669. * Create a new PerturbNormalBlock
  133670. * @param name defines the block name
  133671. */
  133672. constructor(name: string);
  133673. /**
  133674. * Gets the current class name
  133675. * @returns the class name
  133676. */
  133677. getClassName(): string;
  133678. /**
  133679. * Gets the world position input component
  133680. */
  133681. get worldPosition(): NodeMaterialConnectionPoint;
  133682. /**
  133683. * Gets the world normal input component
  133684. */
  133685. get worldNormal(): NodeMaterialConnectionPoint;
  133686. /**
  133687. * Gets the world tangent input component
  133688. */
  133689. get worldTangent(): NodeMaterialConnectionPoint;
  133690. /**
  133691. * Gets the uv input component
  133692. */
  133693. get uv(): NodeMaterialConnectionPoint;
  133694. /**
  133695. * Gets the normal map color input component
  133696. */
  133697. get normalMapColor(): NodeMaterialConnectionPoint;
  133698. /**
  133699. * Gets the strength input component
  133700. */
  133701. get strength(): NodeMaterialConnectionPoint;
  133702. /**
  133703. * Gets the output component
  133704. */
  133705. get output(): NodeMaterialConnectionPoint;
  133706. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133707. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133708. autoConfigure(material: NodeMaterial): void;
  133709. protected _buildBlock(state: NodeMaterialBuildState): this;
  133710. protected _dumpPropertiesCode(): string;
  133711. serialize(): any;
  133712. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133713. }
  133714. }
  133715. declare module BABYLON {
  133716. /**
  133717. * Block used to discard a pixel if a value is smaller than a cutoff
  133718. */
  133719. export class DiscardBlock extends NodeMaterialBlock {
  133720. /**
  133721. * Create a new DiscardBlock
  133722. * @param name defines the block name
  133723. */
  133724. constructor(name: string);
  133725. /**
  133726. * Gets the current class name
  133727. * @returns the class name
  133728. */
  133729. getClassName(): string;
  133730. /**
  133731. * Gets the color input component
  133732. */
  133733. get value(): NodeMaterialConnectionPoint;
  133734. /**
  133735. * Gets the cutoff input component
  133736. */
  133737. get cutoff(): NodeMaterialConnectionPoint;
  133738. protected _buildBlock(state: NodeMaterialBuildState): this;
  133739. }
  133740. }
  133741. declare module BABYLON {
  133742. /**
  133743. * Block used to test if the fragment shader is front facing
  133744. */
  133745. export class FrontFacingBlock extends NodeMaterialBlock {
  133746. /**
  133747. * Creates a new FrontFacingBlock
  133748. * @param name defines the block name
  133749. */
  133750. constructor(name: string);
  133751. /**
  133752. * Gets the current class name
  133753. * @returns the class name
  133754. */
  133755. getClassName(): string;
  133756. /**
  133757. * Gets the output component
  133758. */
  133759. get output(): NodeMaterialConnectionPoint;
  133760. protected _buildBlock(state: NodeMaterialBuildState): this;
  133761. }
  133762. }
  133763. declare module BABYLON {
  133764. /**
  133765. * Block used to get the derivative value on x and y of a given input
  133766. */
  133767. export class DerivativeBlock extends NodeMaterialBlock {
  133768. /**
  133769. * Create a new DerivativeBlock
  133770. * @param name defines the block name
  133771. */
  133772. constructor(name: string);
  133773. /**
  133774. * Gets the current class name
  133775. * @returns the class name
  133776. */
  133777. getClassName(): string;
  133778. /**
  133779. * Gets the input component
  133780. */
  133781. get input(): NodeMaterialConnectionPoint;
  133782. /**
  133783. * Gets the derivative output on x
  133784. */
  133785. get dx(): NodeMaterialConnectionPoint;
  133786. /**
  133787. * Gets the derivative output on y
  133788. */
  133789. get dy(): NodeMaterialConnectionPoint;
  133790. protected _buildBlock(state: NodeMaterialBuildState): this;
  133791. }
  133792. }
  133793. declare module BABYLON {
  133794. /**
  133795. * Block used to add support for scene fog
  133796. */
  133797. export class FogBlock extends NodeMaterialBlock {
  133798. private _fogDistanceName;
  133799. private _fogParameters;
  133800. /**
  133801. * Create a new FogBlock
  133802. * @param name defines the block name
  133803. */
  133804. constructor(name: string);
  133805. /**
  133806. * Gets the current class name
  133807. * @returns the class name
  133808. */
  133809. getClassName(): string;
  133810. /**
  133811. * Gets the world position input component
  133812. */
  133813. get worldPosition(): NodeMaterialConnectionPoint;
  133814. /**
  133815. * Gets the view input component
  133816. */
  133817. get view(): NodeMaterialConnectionPoint;
  133818. /**
  133819. * Gets the color input component
  133820. */
  133821. get input(): NodeMaterialConnectionPoint;
  133822. /**
  133823. * Gets the fog color input component
  133824. */
  133825. get fogColor(): NodeMaterialConnectionPoint;
  133826. /**
  133827. * Gets the output component
  133828. */
  133829. get output(): NodeMaterialConnectionPoint;
  133830. autoConfigure(material: NodeMaterial): void;
  133831. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133832. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133833. protected _buildBlock(state: NodeMaterialBuildState): this;
  133834. }
  133835. }
  133836. declare module BABYLON {
  133837. /**
  133838. * Block used to add light in the fragment shader
  133839. */
  133840. export class LightBlock extends NodeMaterialBlock {
  133841. private _lightId;
  133842. /**
  133843. * Gets or sets the light associated with this block
  133844. */
  133845. light: Nullable<Light>;
  133846. /**
  133847. * Create a new LightBlock
  133848. * @param name defines the block name
  133849. */
  133850. constructor(name: string);
  133851. /**
  133852. * Gets the current class name
  133853. * @returns the class name
  133854. */
  133855. getClassName(): string;
  133856. /**
  133857. * Gets the world position input component
  133858. */
  133859. get worldPosition(): NodeMaterialConnectionPoint;
  133860. /**
  133861. * Gets the world normal input component
  133862. */
  133863. get worldNormal(): NodeMaterialConnectionPoint;
  133864. /**
  133865. * Gets the camera (or eye) position component
  133866. */
  133867. get cameraPosition(): NodeMaterialConnectionPoint;
  133868. /**
  133869. * Gets the glossiness component
  133870. */
  133871. get glossiness(): NodeMaterialConnectionPoint;
  133872. /**
  133873. * Gets the glossinness power component
  133874. */
  133875. get glossPower(): NodeMaterialConnectionPoint;
  133876. /**
  133877. * Gets the diffuse color component
  133878. */
  133879. get diffuseColor(): NodeMaterialConnectionPoint;
  133880. /**
  133881. * Gets the specular color component
  133882. */
  133883. get specularColor(): NodeMaterialConnectionPoint;
  133884. /**
  133885. * Gets the diffuse output component
  133886. */
  133887. get diffuseOutput(): NodeMaterialConnectionPoint;
  133888. /**
  133889. * Gets the specular output component
  133890. */
  133891. get specularOutput(): NodeMaterialConnectionPoint;
  133892. /**
  133893. * Gets the shadow output component
  133894. */
  133895. get shadow(): NodeMaterialConnectionPoint;
  133896. autoConfigure(material: NodeMaterial): void;
  133897. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133898. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  133899. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133900. private _injectVertexCode;
  133901. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133902. serialize(): any;
  133903. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133904. }
  133905. }
  133906. declare module BABYLON {
  133907. /**
  133908. * Block used to multiply 2 values
  133909. */
  133910. export class MultiplyBlock extends NodeMaterialBlock {
  133911. /**
  133912. * Creates a new MultiplyBlock
  133913. * @param name defines the block name
  133914. */
  133915. constructor(name: string);
  133916. /**
  133917. * Gets the current class name
  133918. * @returns the class name
  133919. */
  133920. getClassName(): string;
  133921. /**
  133922. * Gets the left operand input component
  133923. */
  133924. get left(): NodeMaterialConnectionPoint;
  133925. /**
  133926. * Gets the right operand input component
  133927. */
  133928. get right(): NodeMaterialConnectionPoint;
  133929. /**
  133930. * Gets the output component
  133931. */
  133932. get output(): NodeMaterialConnectionPoint;
  133933. protected _buildBlock(state: NodeMaterialBuildState): this;
  133934. }
  133935. }
  133936. declare module BABYLON {
  133937. /**
  133938. * Block used to add 2 vectors
  133939. */
  133940. export class AddBlock extends NodeMaterialBlock {
  133941. /**
  133942. * Creates a new AddBlock
  133943. * @param name defines the block name
  133944. */
  133945. constructor(name: string);
  133946. /**
  133947. * Gets the current class name
  133948. * @returns the class name
  133949. */
  133950. getClassName(): string;
  133951. /**
  133952. * Gets the left operand input component
  133953. */
  133954. get left(): NodeMaterialConnectionPoint;
  133955. /**
  133956. * Gets the right operand input component
  133957. */
  133958. get right(): NodeMaterialConnectionPoint;
  133959. /**
  133960. * Gets the output component
  133961. */
  133962. get output(): NodeMaterialConnectionPoint;
  133963. protected _buildBlock(state: NodeMaterialBuildState): this;
  133964. }
  133965. }
  133966. declare module BABYLON {
  133967. /**
  133968. * Block used to scale a vector by a float
  133969. */
  133970. export class ScaleBlock extends NodeMaterialBlock {
  133971. /**
  133972. * Creates a new ScaleBlock
  133973. * @param name defines the block name
  133974. */
  133975. constructor(name: string);
  133976. /**
  133977. * Gets the current class name
  133978. * @returns the class name
  133979. */
  133980. getClassName(): string;
  133981. /**
  133982. * Gets the input component
  133983. */
  133984. get input(): NodeMaterialConnectionPoint;
  133985. /**
  133986. * Gets the factor input component
  133987. */
  133988. get factor(): NodeMaterialConnectionPoint;
  133989. /**
  133990. * Gets the output component
  133991. */
  133992. get output(): NodeMaterialConnectionPoint;
  133993. protected _buildBlock(state: NodeMaterialBuildState): this;
  133994. }
  133995. }
  133996. declare module BABYLON {
  133997. /**
  133998. * Block used to clamp a float
  133999. */
  134000. export class ClampBlock extends NodeMaterialBlock {
  134001. /** Gets or sets the minimum range */
  134002. minimum: number;
  134003. /** Gets or sets the maximum range */
  134004. maximum: number;
  134005. /**
  134006. * Creates a new ClampBlock
  134007. * @param name defines the block name
  134008. */
  134009. constructor(name: string);
  134010. /**
  134011. * Gets the current class name
  134012. * @returns the class name
  134013. */
  134014. getClassName(): string;
  134015. /**
  134016. * Gets the value input component
  134017. */
  134018. get value(): NodeMaterialConnectionPoint;
  134019. /**
  134020. * Gets the output component
  134021. */
  134022. get output(): NodeMaterialConnectionPoint;
  134023. protected _buildBlock(state: NodeMaterialBuildState): this;
  134024. protected _dumpPropertiesCode(): string;
  134025. serialize(): any;
  134026. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134027. }
  134028. }
  134029. declare module BABYLON {
  134030. /**
  134031. * Block used to apply a cross product between 2 vectors
  134032. */
  134033. export class CrossBlock extends NodeMaterialBlock {
  134034. /**
  134035. * Creates a new CrossBlock
  134036. * @param name defines the block name
  134037. */
  134038. constructor(name: string);
  134039. /**
  134040. * Gets the current class name
  134041. * @returns the class name
  134042. */
  134043. getClassName(): string;
  134044. /**
  134045. * Gets the left operand input component
  134046. */
  134047. get left(): NodeMaterialConnectionPoint;
  134048. /**
  134049. * Gets the right operand input component
  134050. */
  134051. get right(): NodeMaterialConnectionPoint;
  134052. /**
  134053. * Gets the output component
  134054. */
  134055. get output(): NodeMaterialConnectionPoint;
  134056. protected _buildBlock(state: NodeMaterialBuildState): this;
  134057. }
  134058. }
  134059. declare module BABYLON {
  134060. /**
  134061. * Block used to apply a dot product between 2 vectors
  134062. */
  134063. export class DotBlock extends NodeMaterialBlock {
  134064. /**
  134065. * Creates a new DotBlock
  134066. * @param name defines the block name
  134067. */
  134068. constructor(name: string);
  134069. /**
  134070. * Gets the current class name
  134071. * @returns the class name
  134072. */
  134073. getClassName(): string;
  134074. /**
  134075. * Gets the left operand input component
  134076. */
  134077. get left(): NodeMaterialConnectionPoint;
  134078. /**
  134079. * Gets the right operand input component
  134080. */
  134081. get right(): NodeMaterialConnectionPoint;
  134082. /**
  134083. * Gets the output component
  134084. */
  134085. get output(): NodeMaterialConnectionPoint;
  134086. protected _buildBlock(state: NodeMaterialBuildState): this;
  134087. }
  134088. }
  134089. declare module BABYLON {
  134090. /**
  134091. * Block used to remap a float from a range to a new one
  134092. */
  134093. export class RemapBlock extends NodeMaterialBlock {
  134094. /**
  134095. * Gets or sets the source range
  134096. */
  134097. sourceRange: Vector2;
  134098. /**
  134099. * Gets or sets the target range
  134100. */
  134101. targetRange: Vector2;
  134102. /**
  134103. * Creates a new RemapBlock
  134104. * @param name defines the block name
  134105. */
  134106. constructor(name: string);
  134107. /**
  134108. * Gets the current class name
  134109. * @returns the class name
  134110. */
  134111. getClassName(): string;
  134112. /**
  134113. * Gets the input component
  134114. */
  134115. get input(): NodeMaterialConnectionPoint;
  134116. /**
  134117. * Gets the source min input component
  134118. */
  134119. get sourceMin(): NodeMaterialConnectionPoint;
  134120. /**
  134121. * Gets the source max input component
  134122. */
  134123. get sourceMax(): NodeMaterialConnectionPoint;
  134124. /**
  134125. * Gets the target min input component
  134126. */
  134127. get targetMin(): NodeMaterialConnectionPoint;
  134128. /**
  134129. * Gets the target max input component
  134130. */
  134131. get targetMax(): NodeMaterialConnectionPoint;
  134132. /**
  134133. * Gets the output component
  134134. */
  134135. get output(): NodeMaterialConnectionPoint;
  134136. protected _buildBlock(state: NodeMaterialBuildState): this;
  134137. protected _dumpPropertiesCode(): string;
  134138. serialize(): any;
  134139. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134140. }
  134141. }
  134142. declare module BABYLON {
  134143. /**
  134144. * Block used to normalize a vector
  134145. */
  134146. export class NormalizeBlock extends NodeMaterialBlock {
  134147. /**
  134148. * Creates a new NormalizeBlock
  134149. * @param name defines the block name
  134150. */
  134151. constructor(name: string);
  134152. /**
  134153. * Gets the current class name
  134154. * @returns the class name
  134155. */
  134156. getClassName(): string;
  134157. /**
  134158. * Gets the input component
  134159. */
  134160. get input(): NodeMaterialConnectionPoint;
  134161. /**
  134162. * Gets the output component
  134163. */
  134164. get output(): NodeMaterialConnectionPoint;
  134165. protected _buildBlock(state: NodeMaterialBuildState): this;
  134166. }
  134167. }
  134168. declare module BABYLON {
  134169. /**
  134170. * Operations supported by the Trigonometry block
  134171. */
  134172. export enum TrigonometryBlockOperations {
  134173. /** Cos */
  134174. Cos = 0,
  134175. /** Sin */
  134176. Sin = 1,
  134177. /** Abs */
  134178. Abs = 2,
  134179. /** Exp */
  134180. Exp = 3,
  134181. /** Exp2 */
  134182. Exp2 = 4,
  134183. /** Round */
  134184. Round = 5,
  134185. /** Floor */
  134186. Floor = 6,
  134187. /** Ceiling */
  134188. Ceiling = 7,
  134189. /** Square root */
  134190. Sqrt = 8,
  134191. /** Log */
  134192. Log = 9,
  134193. /** Tangent */
  134194. Tan = 10,
  134195. /** Arc tangent */
  134196. ArcTan = 11,
  134197. /** Arc cosinus */
  134198. ArcCos = 12,
  134199. /** Arc sinus */
  134200. ArcSin = 13,
  134201. /** Fraction */
  134202. Fract = 14,
  134203. /** Sign */
  134204. Sign = 15,
  134205. /** To radians (from degrees) */
  134206. Radians = 16,
  134207. /** To degrees (from radians) */
  134208. Degrees = 17
  134209. }
  134210. /**
  134211. * Block used to apply trigonometry operation to floats
  134212. */
  134213. export class TrigonometryBlock extends NodeMaterialBlock {
  134214. /**
  134215. * Gets or sets the operation applied by the block
  134216. */
  134217. operation: TrigonometryBlockOperations;
  134218. /**
  134219. * Creates a new TrigonometryBlock
  134220. * @param name defines the block name
  134221. */
  134222. constructor(name: string);
  134223. /**
  134224. * Gets the current class name
  134225. * @returns the class name
  134226. */
  134227. getClassName(): string;
  134228. /**
  134229. * Gets the input component
  134230. */
  134231. get input(): NodeMaterialConnectionPoint;
  134232. /**
  134233. * Gets the output component
  134234. */
  134235. get output(): NodeMaterialConnectionPoint;
  134236. protected _buildBlock(state: NodeMaterialBuildState): this;
  134237. serialize(): any;
  134238. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134239. protected _dumpPropertiesCode(): string;
  134240. }
  134241. }
  134242. declare module BABYLON {
  134243. /**
  134244. * Block used to create a Color3/4 out of individual inputs (one for each component)
  134245. */
  134246. export class ColorMergerBlock extends NodeMaterialBlock {
  134247. /**
  134248. * Create a new ColorMergerBlock
  134249. * @param name defines the block name
  134250. */
  134251. constructor(name: string);
  134252. /**
  134253. * Gets the current class name
  134254. * @returns the class name
  134255. */
  134256. getClassName(): string;
  134257. /**
  134258. * Gets the rgb component (input)
  134259. */
  134260. get rgbIn(): NodeMaterialConnectionPoint;
  134261. /**
  134262. * Gets the r component (input)
  134263. */
  134264. get r(): NodeMaterialConnectionPoint;
  134265. /**
  134266. * Gets the g component (input)
  134267. */
  134268. get g(): NodeMaterialConnectionPoint;
  134269. /**
  134270. * Gets the b component (input)
  134271. */
  134272. get b(): NodeMaterialConnectionPoint;
  134273. /**
  134274. * Gets the a component (input)
  134275. */
  134276. get a(): NodeMaterialConnectionPoint;
  134277. /**
  134278. * Gets the rgba component (output)
  134279. */
  134280. get rgba(): NodeMaterialConnectionPoint;
  134281. /**
  134282. * Gets the rgb component (output)
  134283. */
  134284. get rgbOut(): NodeMaterialConnectionPoint;
  134285. /**
  134286. * Gets the rgb component (output)
  134287. * @deprecated Please use rgbOut instead.
  134288. */
  134289. get rgb(): NodeMaterialConnectionPoint;
  134290. protected _buildBlock(state: NodeMaterialBuildState): this;
  134291. }
  134292. }
  134293. declare module BABYLON {
  134294. /**
  134295. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  134296. */
  134297. export class VectorMergerBlock extends NodeMaterialBlock {
  134298. /**
  134299. * Create a new VectorMergerBlock
  134300. * @param name defines the block name
  134301. */
  134302. constructor(name: string);
  134303. /**
  134304. * Gets the current class name
  134305. * @returns the class name
  134306. */
  134307. getClassName(): string;
  134308. /**
  134309. * Gets the xyz component (input)
  134310. */
  134311. get xyzIn(): NodeMaterialConnectionPoint;
  134312. /**
  134313. * Gets the xy component (input)
  134314. */
  134315. get xyIn(): NodeMaterialConnectionPoint;
  134316. /**
  134317. * Gets the x component (input)
  134318. */
  134319. get x(): NodeMaterialConnectionPoint;
  134320. /**
  134321. * Gets the y component (input)
  134322. */
  134323. get y(): NodeMaterialConnectionPoint;
  134324. /**
  134325. * Gets the z component (input)
  134326. */
  134327. get z(): NodeMaterialConnectionPoint;
  134328. /**
  134329. * Gets the w component (input)
  134330. */
  134331. get w(): NodeMaterialConnectionPoint;
  134332. /**
  134333. * Gets the xyzw component (output)
  134334. */
  134335. get xyzw(): NodeMaterialConnectionPoint;
  134336. /**
  134337. * Gets the xyz component (output)
  134338. */
  134339. get xyzOut(): NodeMaterialConnectionPoint;
  134340. /**
  134341. * Gets the xy component (output)
  134342. */
  134343. get xyOut(): NodeMaterialConnectionPoint;
  134344. /**
  134345. * Gets the xy component (output)
  134346. * @deprecated Please use xyOut instead.
  134347. */
  134348. get xy(): NodeMaterialConnectionPoint;
  134349. /**
  134350. * Gets the xyz component (output)
  134351. * @deprecated Please use xyzOut instead.
  134352. */
  134353. get xyz(): NodeMaterialConnectionPoint;
  134354. protected _buildBlock(state: NodeMaterialBuildState): this;
  134355. }
  134356. }
  134357. declare module BABYLON {
  134358. /**
  134359. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  134360. */
  134361. export class ColorSplitterBlock extends NodeMaterialBlock {
  134362. /**
  134363. * Create a new ColorSplitterBlock
  134364. * @param name defines the block name
  134365. */
  134366. constructor(name: string);
  134367. /**
  134368. * Gets the current class name
  134369. * @returns the class name
  134370. */
  134371. getClassName(): string;
  134372. /**
  134373. * Gets the rgba component (input)
  134374. */
  134375. get rgba(): NodeMaterialConnectionPoint;
  134376. /**
  134377. * Gets the rgb component (input)
  134378. */
  134379. get rgbIn(): NodeMaterialConnectionPoint;
  134380. /**
  134381. * Gets the rgb component (output)
  134382. */
  134383. get rgbOut(): NodeMaterialConnectionPoint;
  134384. /**
  134385. * Gets the r component (output)
  134386. */
  134387. get r(): NodeMaterialConnectionPoint;
  134388. /**
  134389. * Gets the g component (output)
  134390. */
  134391. get g(): NodeMaterialConnectionPoint;
  134392. /**
  134393. * Gets the b component (output)
  134394. */
  134395. get b(): NodeMaterialConnectionPoint;
  134396. /**
  134397. * Gets the a component (output)
  134398. */
  134399. get a(): NodeMaterialConnectionPoint;
  134400. protected _inputRename(name: string): string;
  134401. protected _outputRename(name: string): string;
  134402. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  134403. }
  134404. }
  134405. declare module BABYLON {
  134406. /**
  134407. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  134408. */
  134409. export class VectorSplitterBlock extends NodeMaterialBlock {
  134410. /**
  134411. * Create a new VectorSplitterBlock
  134412. * @param name defines the block name
  134413. */
  134414. constructor(name: string);
  134415. /**
  134416. * Gets the current class name
  134417. * @returns the class name
  134418. */
  134419. getClassName(): string;
  134420. /**
  134421. * Gets the xyzw component (input)
  134422. */
  134423. get xyzw(): NodeMaterialConnectionPoint;
  134424. /**
  134425. * Gets the xyz component (input)
  134426. */
  134427. get xyzIn(): NodeMaterialConnectionPoint;
  134428. /**
  134429. * Gets the xy component (input)
  134430. */
  134431. get xyIn(): NodeMaterialConnectionPoint;
  134432. /**
  134433. * Gets the xyz component (output)
  134434. */
  134435. get xyzOut(): NodeMaterialConnectionPoint;
  134436. /**
  134437. * Gets the xy component (output)
  134438. */
  134439. get xyOut(): NodeMaterialConnectionPoint;
  134440. /**
  134441. * Gets the x component (output)
  134442. */
  134443. get x(): NodeMaterialConnectionPoint;
  134444. /**
  134445. * Gets the y component (output)
  134446. */
  134447. get y(): NodeMaterialConnectionPoint;
  134448. /**
  134449. * Gets the z component (output)
  134450. */
  134451. get z(): NodeMaterialConnectionPoint;
  134452. /**
  134453. * Gets the w component (output)
  134454. */
  134455. get w(): NodeMaterialConnectionPoint;
  134456. protected _inputRename(name: string): string;
  134457. protected _outputRename(name: string): string;
  134458. protected _buildBlock(state: NodeMaterialBuildState): this;
  134459. }
  134460. }
  134461. declare module BABYLON {
  134462. /**
  134463. * Block used to lerp between 2 values
  134464. */
  134465. export class LerpBlock extends NodeMaterialBlock {
  134466. /**
  134467. * Creates a new LerpBlock
  134468. * @param name defines the block name
  134469. */
  134470. constructor(name: string);
  134471. /**
  134472. * Gets the current class name
  134473. * @returns the class name
  134474. */
  134475. getClassName(): string;
  134476. /**
  134477. * Gets the left operand input component
  134478. */
  134479. get left(): NodeMaterialConnectionPoint;
  134480. /**
  134481. * Gets the right operand input component
  134482. */
  134483. get right(): NodeMaterialConnectionPoint;
  134484. /**
  134485. * Gets the gradient operand input component
  134486. */
  134487. get gradient(): NodeMaterialConnectionPoint;
  134488. /**
  134489. * Gets the output component
  134490. */
  134491. get output(): NodeMaterialConnectionPoint;
  134492. protected _buildBlock(state: NodeMaterialBuildState): this;
  134493. }
  134494. }
  134495. declare module BABYLON {
  134496. /**
  134497. * Block used to divide 2 vectors
  134498. */
  134499. export class DivideBlock extends NodeMaterialBlock {
  134500. /**
  134501. * Creates a new DivideBlock
  134502. * @param name defines the block name
  134503. */
  134504. constructor(name: string);
  134505. /**
  134506. * Gets the current class name
  134507. * @returns the class name
  134508. */
  134509. getClassName(): string;
  134510. /**
  134511. * Gets the left operand input component
  134512. */
  134513. get left(): NodeMaterialConnectionPoint;
  134514. /**
  134515. * Gets the right operand input component
  134516. */
  134517. get right(): NodeMaterialConnectionPoint;
  134518. /**
  134519. * Gets the output component
  134520. */
  134521. get output(): NodeMaterialConnectionPoint;
  134522. protected _buildBlock(state: NodeMaterialBuildState): this;
  134523. }
  134524. }
  134525. declare module BABYLON {
  134526. /**
  134527. * Block used to subtract 2 vectors
  134528. */
  134529. export class SubtractBlock extends NodeMaterialBlock {
  134530. /**
  134531. * Creates a new SubtractBlock
  134532. * @param name defines the block name
  134533. */
  134534. constructor(name: string);
  134535. /**
  134536. * Gets the current class name
  134537. * @returns the class name
  134538. */
  134539. getClassName(): string;
  134540. /**
  134541. * Gets the left operand input component
  134542. */
  134543. get left(): NodeMaterialConnectionPoint;
  134544. /**
  134545. * Gets the right operand input component
  134546. */
  134547. get right(): NodeMaterialConnectionPoint;
  134548. /**
  134549. * Gets the output component
  134550. */
  134551. get output(): NodeMaterialConnectionPoint;
  134552. protected _buildBlock(state: NodeMaterialBuildState): this;
  134553. }
  134554. }
  134555. declare module BABYLON {
  134556. /**
  134557. * Block used to step a value
  134558. */
  134559. export class StepBlock extends NodeMaterialBlock {
  134560. /**
  134561. * Creates a new StepBlock
  134562. * @param name defines the block name
  134563. */
  134564. constructor(name: string);
  134565. /**
  134566. * Gets the current class name
  134567. * @returns the class name
  134568. */
  134569. getClassName(): string;
  134570. /**
  134571. * Gets the value operand input component
  134572. */
  134573. get value(): NodeMaterialConnectionPoint;
  134574. /**
  134575. * Gets the edge operand input component
  134576. */
  134577. get edge(): NodeMaterialConnectionPoint;
  134578. /**
  134579. * Gets the output component
  134580. */
  134581. get output(): NodeMaterialConnectionPoint;
  134582. protected _buildBlock(state: NodeMaterialBuildState): this;
  134583. }
  134584. }
  134585. declare module BABYLON {
  134586. /**
  134587. * Block used to get the opposite (1 - x) of a value
  134588. */
  134589. export class OneMinusBlock extends NodeMaterialBlock {
  134590. /**
  134591. * Creates a new OneMinusBlock
  134592. * @param name defines the block name
  134593. */
  134594. constructor(name: string);
  134595. /**
  134596. * Gets the current class name
  134597. * @returns the class name
  134598. */
  134599. getClassName(): string;
  134600. /**
  134601. * Gets the input component
  134602. */
  134603. get input(): NodeMaterialConnectionPoint;
  134604. /**
  134605. * Gets the output component
  134606. */
  134607. get output(): NodeMaterialConnectionPoint;
  134608. protected _buildBlock(state: NodeMaterialBuildState): this;
  134609. }
  134610. }
  134611. declare module BABYLON {
  134612. /**
  134613. * Block used to get the view direction
  134614. */
  134615. export class ViewDirectionBlock extends NodeMaterialBlock {
  134616. /**
  134617. * Creates a new ViewDirectionBlock
  134618. * @param name defines the block name
  134619. */
  134620. constructor(name: string);
  134621. /**
  134622. * Gets the current class name
  134623. * @returns the class name
  134624. */
  134625. getClassName(): string;
  134626. /**
  134627. * Gets the world position component
  134628. */
  134629. get worldPosition(): NodeMaterialConnectionPoint;
  134630. /**
  134631. * Gets the camera position component
  134632. */
  134633. get cameraPosition(): NodeMaterialConnectionPoint;
  134634. /**
  134635. * Gets the output component
  134636. */
  134637. get output(): NodeMaterialConnectionPoint;
  134638. autoConfigure(material: NodeMaterial): void;
  134639. protected _buildBlock(state: NodeMaterialBuildState): this;
  134640. }
  134641. }
  134642. declare module BABYLON {
  134643. /**
  134644. * Block used to compute fresnel value
  134645. */
  134646. export class FresnelBlock extends NodeMaterialBlock {
  134647. /**
  134648. * Create a new FresnelBlock
  134649. * @param name defines the block name
  134650. */
  134651. constructor(name: string);
  134652. /**
  134653. * Gets the current class name
  134654. * @returns the class name
  134655. */
  134656. getClassName(): string;
  134657. /**
  134658. * Gets the world normal input component
  134659. */
  134660. get worldNormal(): NodeMaterialConnectionPoint;
  134661. /**
  134662. * Gets the view direction input component
  134663. */
  134664. get viewDirection(): NodeMaterialConnectionPoint;
  134665. /**
  134666. * Gets the bias input component
  134667. */
  134668. get bias(): NodeMaterialConnectionPoint;
  134669. /**
  134670. * Gets the camera (or eye) position component
  134671. */
  134672. get power(): NodeMaterialConnectionPoint;
  134673. /**
  134674. * Gets the fresnel output component
  134675. */
  134676. get fresnel(): NodeMaterialConnectionPoint;
  134677. autoConfigure(material: NodeMaterial): void;
  134678. protected _buildBlock(state: NodeMaterialBuildState): this;
  134679. }
  134680. }
  134681. declare module BABYLON {
  134682. /**
  134683. * Block used to get the max of 2 values
  134684. */
  134685. export class MaxBlock extends NodeMaterialBlock {
  134686. /**
  134687. * Creates a new MaxBlock
  134688. * @param name defines the block name
  134689. */
  134690. constructor(name: string);
  134691. /**
  134692. * Gets the current class name
  134693. * @returns the class name
  134694. */
  134695. getClassName(): string;
  134696. /**
  134697. * Gets the left operand input component
  134698. */
  134699. get left(): NodeMaterialConnectionPoint;
  134700. /**
  134701. * Gets the right operand input component
  134702. */
  134703. get right(): NodeMaterialConnectionPoint;
  134704. /**
  134705. * Gets the output component
  134706. */
  134707. get output(): NodeMaterialConnectionPoint;
  134708. protected _buildBlock(state: NodeMaterialBuildState): this;
  134709. }
  134710. }
  134711. declare module BABYLON {
  134712. /**
  134713. * Block used to get the min of 2 values
  134714. */
  134715. export class MinBlock extends NodeMaterialBlock {
  134716. /**
  134717. * Creates a new MinBlock
  134718. * @param name defines the block name
  134719. */
  134720. constructor(name: string);
  134721. /**
  134722. * Gets the current class name
  134723. * @returns the class name
  134724. */
  134725. getClassName(): string;
  134726. /**
  134727. * Gets the left operand input component
  134728. */
  134729. get left(): NodeMaterialConnectionPoint;
  134730. /**
  134731. * Gets the right operand input component
  134732. */
  134733. get right(): NodeMaterialConnectionPoint;
  134734. /**
  134735. * Gets the output component
  134736. */
  134737. get output(): NodeMaterialConnectionPoint;
  134738. protected _buildBlock(state: NodeMaterialBuildState): this;
  134739. }
  134740. }
  134741. declare module BABYLON {
  134742. /**
  134743. * Block used to get the distance between 2 values
  134744. */
  134745. export class DistanceBlock extends NodeMaterialBlock {
  134746. /**
  134747. * Creates a new DistanceBlock
  134748. * @param name defines the block name
  134749. */
  134750. constructor(name: string);
  134751. /**
  134752. * Gets the current class name
  134753. * @returns the class name
  134754. */
  134755. getClassName(): string;
  134756. /**
  134757. * Gets the left operand input component
  134758. */
  134759. get left(): NodeMaterialConnectionPoint;
  134760. /**
  134761. * Gets the right operand input component
  134762. */
  134763. get right(): NodeMaterialConnectionPoint;
  134764. /**
  134765. * Gets the output component
  134766. */
  134767. get output(): NodeMaterialConnectionPoint;
  134768. protected _buildBlock(state: NodeMaterialBuildState): this;
  134769. }
  134770. }
  134771. declare module BABYLON {
  134772. /**
  134773. * Block used to get the length of a vector
  134774. */
  134775. export class LengthBlock extends NodeMaterialBlock {
  134776. /**
  134777. * Creates a new LengthBlock
  134778. * @param name defines the block name
  134779. */
  134780. constructor(name: string);
  134781. /**
  134782. * Gets the current class name
  134783. * @returns the class name
  134784. */
  134785. getClassName(): string;
  134786. /**
  134787. * Gets the value input component
  134788. */
  134789. get value(): NodeMaterialConnectionPoint;
  134790. /**
  134791. * Gets the output component
  134792. */
  134793. get output(): NodeMaterialConnectionPoint;
  134794. protected _buildBlock(state: NodeMaterialBuildState): this;
  134795. }
  134796. }
  134797. declare module BABYLON {
  134798. /**
  134799. * Block used to get negative version of a value (i.e. x * -1)
  134800. */
  134801. export class NegateBlock extends NodeMaterialBlock {
  134802. /**
  134803. * Creates a new NegateBlock
  134804. * @param name defines the block name
  134805. */
  134806. constructor(name: string);
  134807. /**
  134808. * Gets the current class name
  134809. * @returns the class name
  134810. */
  134811. getClassName(): string;
  134812. /**
  134813. * Gets the value input component
  134814. */
  134815. get value(): NodeMaterialConnectionPoint;
  134816. /**
  134817. * Gets the output component
  134818. */
  134819. get output(): NodeMaterialConnectionPoint;
  134820. protected _buildBlock(state: NodeMaterialBuildState): this;
  134821. }
  134822. }
  134823. declare module BABYLON {
  134824. /**
  134825. * Block used to get the value of the first parameter raised to the power of the second
  134826. */
  134827. export class PowBlock extends NodeMaterialBlock {
  134828. /**
  134829. * Creates a new PowBlock
  134830. * @param name defines the block name
  134831. */
  134832. constructor(name: string);
  134833. /**
  134834. * Gets the current class name
  134835. * @returns the class name
  134836. */
  134837. getClassName(): string;
  134838. /**
  134839. * Gets the value operand input component
  134840. */
  134841. get value(): NodeMaterialConnectionPoint;
  134842. /**
  134843. * Gets the power operand input component
  134844. */
  134845. get power(): NodeMaterialConnectionPoint;
  134846. /**
  134847. * Gets the output component
  134848. */
  134849. get output(): NodeMaterialConnectionPoint;
  134850. protected _buildBlock(state: NodeMaterialBuildState): this;
  134851. }
  134852. }
  134853. declare module BABYLON {
  134854. /**
  134855. * Block used to get a random number
  134856. */
  134857. export class RandomNumberBlock extends NodeMaterialBlock {
  134858. /**
  134859. * Creates a new RandomNumberBlock
  134860. * @param name defines the block name
  134861. */
  134862. constructor(name: string);
  134863. /**
  134864. * Gets the current class name
  134865. * @returns the class name
  134866. */
  134867. getClassName(): string;
  134868. /**
  134869. * Gets the seed input component
  134870. */
  134871. get seed(): NodeMaterialConnectionPoint;
  134872. /**
  134873. * Gets the output component
  134874. */
  134875. get output(): NodeMaterialConnectionPoint;
  134876. protected _buildBlock(state: NodeMaterialBuildState): this;
  134877. }
  134878. }
  134879. declare module BABYLON {
  134880. /**
  134881. * Block used to compute arc tangent of 2 values
  134882. */
  134883. export class ArcTan2Block extends NodeMaterialBlock {
  134884. /**
  134885. * Creates a new ArcTan2Block
  134886. * @param name defines the block name
  134887. */
  134888. constructor(name: string);
  134889. /**
  134890. * Gets the current class name
  134891. * @returns the class name
  134892. */
  134893. getClassName(): string;
  134894. /**
  134895. * Gets the x operand input component
  134896. */
  134897. get x(): NodeMaterialConnectionPoint;
  134898. /**
  134899. * Gets the y operand input component
  134900. */
  134901. get y(): NodeMaterialConnectionPoint;
  134902. /**
  134903. * Gets the output component
  134904. */
  134905. get output(): NodeMaterialConnectionPoint;
  134906. protected _buildBlock(state: NodeMaterialBuildState): this;
  134907. }
  134908. }
  134909. declare module BABYLON {
  134910. /**
  134911. * Block used to smooth step a value
  134912. */
  134913. export class SmoothStepBlock extends NodeMaterialBlock {
  134914. /**
  134915. * Creates a new SmoothStepBlock
  134916. * @param name defines the block name
  134917. */
  134918. constructor(name: string);
  134919. /**
  134920. * Gets the current class name
  134921. * @returns the class name
  134922. */
  134923. getClassName(): string;
  134924. /**
  134925. * Gets the value operand input component
  134926. */
  134927. get value(): NodeMaterialConnectionPoint;
  134928. /**
  134929. * Gets the first edge operand input component
  134930. */
  134931. get edge0(): NodeMaterialConnectionPoint;
  134932. /**
  134933. * Gets the second edge operand input component
  134934. */
  134935. get edge1(): NodeMaterialConnectionPoint;
  134936. /**
  134937. * Gets the output component
  134938. */
  134939. get output(): NodeMaterialConnectionPoint;
  134940. protected _buildBlock(state: NodeMaterialBuildState): this;
  134941. }
  134942. }
  134943. declare module BABYLON {
  134944. /**
  134945. * Block used to get the reciprocal (1 / x) of a value
  134946. */
  134947. export class ReciprocalBlock extends NodeMaterialBlock {
  134948. /**
  134949. * Creates a new ReciprocalBlock
  134950. * @param name defines the block name
  134951. */
  134952. constructor(name: string);
  134953. /**
  134954. * Gets the current class name
  134955. * @returns the class name
  134956. */
  134957. getClassName(): string;
  134958. /**
  134959. * Gets the input component
  134960. */
  134961. get input(): NodeMaterialConnectionPoint;
  134962. /**
  134963. * Gets the output component
  134964. */
  134965. get output(): NodeMaterialConnectionPoint;
  134966. protected _buildBlock(state: NodeMaterialBuildState): this;
  134967. }
  134968. }
  134969. declare module BABYLON {
  134970. /**
  134971. * Block used to replace a color by another one
  134972. */
  134973. export class ReplaceColorBlock extends NodeMaterialBlock {
  134974. /**
  134975. * Creates a new ReplaceColorBlock
  134976. * @param name defines the block name
  134977. */
  134978. constructor(name: string);
  134979. /**
  134980. * Gets the current class name
  134981. * @returns the class name
  134982. */
  134983. getClassName(): string;
  134984. /**
  134985. * Gets the value input component
  134986. */
  134987. get value(): NodeMaterialConnectionPoint;
  134988. /**
  134989. * Gets the reference input component
  134990. */
  134991. get reference(): NodeMaterialConnectionPoint;
  134992. /**
  134993. * Gets the distance input component
  134994. */
  134995. get distance(): NodeMaterialConnectionPoint;
  134996. /**
  134997. * Gets the replacement input component
  134998. */
  134999. get replacement(): NodeMaterialConnectionPoint;
  135000. /**
  135001. * Gets the output component
  135002. */
  135003. get output(): NodeMaterialConnectionPoint;
  135004. protected _buildBlock(state: NodeMaterialBuildState): this;
  135005. }
  135006. }
  135007. declare module BABYLON {
  135008. /**
  135009. * Block used to posterize a value
  135010. * @see https://en.wikipedia.org/wiki/Posterization
  135011. */
  135012. export class PosterizeBlock extends NodeMaterialBlock {
  135013. /**
  135014. * Creates a new PosterizeBlock
  135015. * @param name defines the block name
  135016. */
  135017. constructor(name: string);
  135018. /**
  135019. * Gets the current class name
  135020. * @returns the class name
  135021. */
  135022. getClassName(): string;
  135023. /**
  135024. * Gets the value input component
  135025. */
  135026. get value(): NodeMaterialConnectionPoint;
  135027. /**
  135028. * Gets the steps input component
  135029. */
  135030. get steps(): NodeMaterialConnectionPoint;
  135031. /**
  135032. * Gets the output component
  135033. */
  135034. get output(): NodeMaterialConnectionPoint;
  135035. protected _buildBlock(state: NodeMaterialBuildState): this;
  135036. }
  135037. }
  135038. declare module BABYLON {
  135039. /**
  135040. * Operations supported by the Wave block
  135041. */
  135042. export enum WaveBlockKind {
  135043. /** SawTooth */
  135044. SawTooth = 0,
  135045. /** Square */
  135046. Square = 1,
  135047. /** Triangle */
  135048. Triangle = 2
  135049. }
  135050. /**
  135051. * Block used to apply wave operation to floats
  135052. */
  135053. export class WaveBlock extends NodeMaterialBlock {
  135054. /**
  135055. * Gets or sets the kibnd of wave to be applied by the block
  135056. */
  135057. kind: WaveBlockKind;
  135058. /**
  135059. * Creates a new WaveBlock
  135060. * @param name defines the block name
  135061. */
  135062. constructor(name: string);
  135063. /**
  135064. * Gets the current class name
  135065. * @returns the class name
  135066. */
  135067. getClassName(): string;
  135068. /**
  135069. * Gets the input component
  135070. */
  135071. get input(): NodeMaterialConnectionPoint;
  135072. /**
  135073. * Gets the output component
  135074. */
  135075. get output(): NodeMaterialConnectionPoint;
  135076. protected _buildBlock(state: NodeMaterialBuildState): this;
  135077. serialize(): any;
  135078. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135079. }
  135080. }
  135081. declare module BABYLON {
  135082. /**
  135083. * Class used to store a color step for the GradientBlock
  135084. */
  135085. export class GradientBlockColorStep {
  135086. /**
  135087. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  135088. */
  135089. step: number;
  135090. /**
  135091. * Gets or sets the color associated with this step
  135092. */
  135093. color: Color3;
  135094. /**
  135095. * Creates a new GradientBlockColorStep
  135096. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  135097. * @param color defines the color associated with this step
  135098. */
  135099. constructor(
  135100. /**
  135101. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  135102. */
  135103. step: number,
  135104. /**
  135105. * Gets or sets the color associated with this step
  135106. */
  135107. color: Color3);
  135108. }
  135109. /**
  135110. * Block used to return a color from a gradient based on an input value between 0 and 1
  135111. */
  135112. export class GradientBlock extends NodeMaterialBlock {
  135113. /**
  135114. * Gets or sets the list of color steps
  135115. */
  135116. colorSteps: GradientBlockColorStep[];
  135117. /**
  135118. * Creates a new GradientBlock
  135119. * @param name defines the block name
  135120. */
  135121. constructor(name: string);
  135122. /**
  135123. * Gets the current class name
  135124. * @returns the class name
  135125. */
  135126. getClassName(): string;
  135127. /**
  135128. * Gets the gradient input component
  135129. */
  135130. get gradient(): NodeMaterialConnectionPoint;
  135131. /**
  135132. * Gets the output component
  135133. */
  135134. get output(): NodeMaterialConnectionPoint;
  135135. private _writeColorConstant;
  135136. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  135137. serialize(): any;
  135138. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135139. protected _dumpPropertiesCode(): string;
  135140. }
  135141. }
  135142. declare module BABYLON {
  135143. /**
  135144. * Block used to normalize lerp between 2 values
  135145. */
  135146. export class NLerpBlock extends NodeMaterialBlock {
  135147. /**
  135148. * Creates a new NLerpBlock
  135149. * @param name defines the block name
  135150. */
  135151. constructor(name: string);
  135152. /**
  135153. * Gets the current class name
  135154. * @returns the class name
  135155. */
  135156. getClassName(): string;
  135157. /**
  135158. * Gets the left operand input component
  135159. */
  135160. get left(): NodeMaterialConnectionPoint;
  135161. /**
  135162. * Gets the right operand input component
  135163. */
  135164. get right(): NodeMaterialConnectionPoint;
  135165. /**
  135166. * Gets the gradient operand input component
  135167. */
  135168. get gradient(): NodeMaterialConnectionPoint;
  135169. /**
  135170. * Gets the output component
  135171. */
  135172. get output(): NodeMaterialConnectionPoint;
  135173. protected _buildBlock(state: NodeMaterialBuildState): this;
  135174. }
  135175. }
  135176. declare module BABYLON {
  135177. /**
  135178. * block used to Generate a Worley Noise 3D Noise Pattern
  135179. */
  135180. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  135181. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  135182. manhattanDistance: boolean;
  135183. /**
  135184. * Creates a new WorleyNoise3DBlock
  135185. * @param name defines the block name
  135186. */
  135187. constructor(name: string);
  135188. /**
  135189. * Gets the current class name
  135190. * @returns the class name
  135191. */
  135192. getClassName(): string;
  135193. /**
  135194. * Gets the seed input component
  135195. */
  135196. get seed(): NodeMaterialConnectionPoint;
  135197. /**
  135198. * Gets the jitter input component
  135199. */
  135200. get jitter(): NodeMaterialConnectionPoint;
  135201. /**
  135202. * Gets the output component
  135203. */
  135204. get output(): NodeMaterialConnectionPoint;
  135205. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  135206. /**
  135207. * Exposes the properties to the UI?
  135208. */
  135209. protected _dumpPropertiesCode(): string;
  135210. /**
  135211. * Exposes the properties to the Seralize?
  135212. */
  135213. serialize(): any;
  135214. /**
  135215. * Exposes the properties to the deseralize?
  135216. */
  135217. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135218. }
  135219. }
  135220. declare module BABYLON {
  135221. /**
  135222. * block used to Generate a Simplex Perlin 3d Noise Pattern
  135223. */
  135224. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  135225. /**
  135226. * Creates a new SimplexPerlin3DBlock
  135227. * @param name defines the block name
  135228. */
  135229. constructor(name: string);
  135230. /**
  135231. * Gets the current class name
  135232. * @returns the class name
  135233. */
  135234. getClassName(): string;
  135235. /**
  135236. * Gets the seed operand input component
  135237. */
  135238. get seed(): NodeMaterialConnectionPoint;
  135239. /**
  135240. * Gets the output component
  135241. */
  135242. get output(): NodeMaterialConnectionPoint;
  135243. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  135244. }
  135245. }
  135246. declare module BABYLON {
  135247. /**
  135248. * Block used to blend normals
  135249. */
  135250. export class NormalBlendBlock extends NodeMaterialBlock {
  135251. /**
  135252. * Creates a new NormalBlendBlock
  135253. * @param name defines the block name
  135254. */
  135255. constructor(name: string);
  135256. /**
  135257. * Gets the current class name
  135258. * @returns the class name
  135259. */
  135260. getClassName(): string;
  135261. /**
  135262. * Gets the first input component
  135263. */
  135264. get normalMap0(): NodeMaterialConnectionPoint;
  135265. /**
  135266. * Gets the second input component
  135267. */
  135268. get normalMap1(): NodeMaterialConnectionPoint;
  135269. /**
  135270. * Gets the output component
  135271. */
  135272. get output(): NodeMaterialConnectionPoint;
  135273. protected _buildBlock(state: NodeMaterialBuildState): this;
  135274. }
  135275. }
  135276. declare module BABYLON {
  135277. /**
  135278. * Block used to rotate a 2d vector by a given angle
  135279. */
  135280. export class Rotate2dBlock extends NodeMaterialBlock {
  135281. /**
  135282. * Creates a new Rotate2dBlock
  135283. * @param name defines the block name
  135284. */
  135285. constructor(name: string);
  135286. /**
  135287. * Gets the current class name
  135288. * @returns the class name
  135289. */
  135290. getClassName(): string;
  135291. /**
  135292. * Gets the input vector
  135293. */
  135294. get input(): NodeMaterialConnectionPoint;
  135295. /**
  135296. * Gets the input angle
  135297. */
  135298. get angle(): NodeMaterialConnectionPoint;
  135299. /**
  135300. * Gets the output component
  135301. */
  135302. get output(): NodeMaterialConnectionPoint;
  135303. autoConfigure(material: NodeMaterial): void;
  135304. protected _buildBlock(state: NodeMaterialBuildState): this;
  135305. }
  135306. }
  135307. declare module BABYLON {
  135308. /**
  135309. * Block used to get the reflected vector from a direction and a normal
  135310. */
  135311. export class ReflectBlock extends NodeMaterialBlock {
  135312. /**
  135313. * Creates a new ReflectBlock
  135314. * @param name defines the block name
  135315. */
  135316. constructor(name: string);
  135317. /**
  135318. * Gets the current class name
  135319. * @returns the class name
  135320. */
  135321. getClassName(): string;
  135322. /**
  135323. * Gets the incident component
  135324. */
  135325. get incident(): NodeMaterialConnectionPoint;
  135326. /**
  135327. * Gets the normal component
  135328. */
  135329. get normal(): NodeMaterialConnectionPoint;
  135330. /**
  135331. * Gets the output component
  135332. */
  135333. get output(): NodeMaterialConnectionPoint;
  135334. protected _buildBlock(state: NodeMaterialBuildState): this;
  135335. }
  135336. }
  135337. declare module BABYLON {
  135338. /**
  135339. * Block used to get the refracted vector from a direction and a normal
  135340. */
  135341. export class RefractBlock extends NodeMaterialBlock {
  135342. /**
  135343. * Creates a new RefractBlock
  135344. * @param name defines the block name
  135345. */
  135346. constructor(name: string);
  135347. /**
  135348. * Gets the current class name
  135349. * @returns the class name
  135350. */
  135351. getClassName(): string;
  135352. /**
  135353. * Gets the incident component
  135354. */
  135355. get incident(): NodeMaterialConnectionPoint;
  135356. /**
  135357. * Gets the normal component
  135358. */
  135359. get normal(): NodeMaterialConnectionPoint;
  135360. /**
  135361. * Gets the index of refraction component
  135362. */
  135363. get ior(): NodeMaterialConnectionPoint;
  135364. /**
  135365. * Gets the output component
  135366. */
  135367. get output(): NodeMaterialConnectionPoint;
  135368. protected _buildBlock(state: NodeMaterialBuildState): this;
  135369. }
  135370. }
  135371. declare module BABYLON {
  135372. /**
  135373. * Block used to desaturate a color
  135374. */
  135375. export class DesaturateBlock extends NodeMaterialBlock {
  135376. /**
  135377. * Creates a new DesaturateBlock
  135378. * @param name defines the block name
  135379. */
  135380. constructor(name: string);
  135381. /**
  135382. * Gets the current class name
  135383. * @returns the class name
  135384. */
  135385. getClassName(): string;
  135386. /**
  135387. * Gets the color operand input component
  135388. */
  135389. get color(): NodeMaterialConnectionPoint;
  135390. /**
  135391. * Gets the level operand input component
  135392. */
  135393. get level(): NodeMaterialConnectionPoint;
  135394. /**
  135395. * Gets the output component
  135396. */
  135397. get output(): NodeMaterialConnectionPoint;
  135398. protected _buildBlock(state: NodeMaterialBuildState): this;
  135399. }
  135400. }
  135401. declare module BABYLON {
  135402. /**
  135403. * Effect Render Options
  135404. */
  135405. export interface IEffectRendererOptions {
  135406. /**
  135407. * Defines the vertices positions.
  135408. */
  135409. positions?: number[];
  135410. /**
  135411. * Defines the indices.
  135412. */
  135413. indices?: number[];
  135414. }
  135415. /**
  135416. * Helper class to render one or more effects.
  135417. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  135418. */
  135419. export class EffectRenderer {
  135420. private engine;
  135421. private static _DefaultOptions;
  135422. private _vertexBuffers;
  135423. private _indexBuffer;
  135424. private _fullscreenViewport;
  135425. /**
  135426. * Creates an effect renderer
  135427. * @param engine the engine to use for rendering
  135428. * @param options defines the options of the effect renderer
  135429. */
  135430. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  135431. /**
  135432. * Sets the current viewport in normalized coordinates 0-1
  135433. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  135434. */
  135435. setViewport(viewport?: Viewport): void;
  135436. /**
  135437. * Binds the embedded attributes buffer to the effect.
  135438. * @param effect Defines the effect to bind the attributes for
  135439. */
  135440. bindBuffers(effect: Effect): void;
  135441. /**
  135442. * Sets the current effect wrapper to use during draw.
  135443. * The effect needs to be ready before calling this api.
  135444. * This also sets the default full screen position attribute.
  135445. * @param effectWrapper Defines the effect to draw with
  135446. */
  135447. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  135448. /**
  135449. * Draws a full screen quad.
  135450. */
  135451. draw(): void;
  135452. private isRenderTargetTexture;
  135453. /**
  135454. * renders one or more effects to a specified texture
  135455. * @param effectWrapper the effect to renderer
  135456. * @param outputTexture texture to draw to, if null it will render to the screen.
  135457. */
  135458. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  135459. /**
  135460. * Disposes of the effect renderer
  135461. */
  135462. dispose(): void;
  135463. }
  135464. /**
  135465. * Options to create an EffectWrapper
  135466. */
  135467. interface EffectWrapperCreationOptions {
  135468. /**
  135469. * Engine to use to create the effect
  135470. */
  135471. engine: ThinEngine;
  135472. /**
  135473. * Fragment shader for the effect
  135474. */
  135475. fragmentShader: string;
  135476. /**
  135477. * Vertex shader for the effect
  135478. */
  135479. vertexShader?: string;
  135480. /**
  135481. * Attributes to use in the shader
  135482. */
  135483. attributeNames?: Array<string>;
  135484. /**
  135485. * Uniforms to use in the shader
  135486. */
  135487. uniformNames?: Array<string>;
  135488. /**
  135489. * Texture sampler names to use in the shader
  135490. */
  135491. samplerNames?: Array<string>;
  135492. /**
  135493. * The friendly name of the effect displayed in Spector.
  135494. */
  135495. name?: string;
  135496. }
  135497. /**
  135498. * Wraps an effect to be used for rendering
  135499. */
  135500. export class EffectWrapper {
  135501. /**
  135502. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  135503. */
  135504. onApplyObservable: Observable<{}>;
  135505. /**
  135506. * The underlying effect
  135507. */
  135508. effect: Effect;
  135509. /**
  135510. * Creates an effect to be renderer
  135511. * @param creationOptions options to create the effect
  135512. */
  135513. constructor(creationOptions: EffectWrapperCreationOptions);
  135514. /**
  135515. * Disposes of the effect wrapper
  135516. */
  135517. dispose(): void;
  135518. }
  135519. }
  135520. declare module BABYLON {
  135521. /**
  135522. * Helper class to push actions to a pool of workers.
  135523. */
  135524. export class WorkerPool implements IDisposable {
  135525. private _workerInfos;
  135526. private _pendingActions;
  135527. /**
  135528. * Constructor
  135529. * @param workers Array of workers to use for actions
  135530. */
  135531. constructor(workers: Array<Worker>);
  135532. /**
  135533. * Terminates all workers and clears any pending actions.
  135534. */
  135535. dispose(): void;
  135536. /**
  135537. * Pushes an action to the worker pool. If all the workers are active, the action will be
  135538. * pended until a worker has completed its action.
  135539. * @param action The action to perform. Call onComplete when the action is complete.
  135540. */
  135541. push(action: (worker: Worker, onComplete: () => void) => void): void;
  135542. private _execute;
  135543. }
  135544. }
  135545. declare module BABYLON {
  135546. /**
  135547. * Configuration for Draco compression
  135548. */
  135549. export interface IDracoCompressionConfiguration {
  135550. /**
  135551. * Configuration for the decoder.
  135552. */
  135553. decoder: {
  135554. /**
  135555. * The url to the WebAssembly module.
  135556. */
  135557. wasmUrl?: string;
  135558. /**
  135559. * The url to the WebAssembly binary.
  135560. */
  135561. wasmBinaryUrl?: string;
  135562. /**
  135563. * The url to the fallback JavaScript module.
  135564. */
  135565. fallbackUrl?: string;
  135566. };
  135567. }
  135568. /**
  135569. * Draco compression (https://google.github.io/draco/)
  135570. *
  135571. * This class wraps the Draco module.
  135572. *
  135573. * **Encoder**
  135574. *
  135575. * The encoder is not currently implemented.
  135576. *
  135577. * **Decoder**
  135578. *
  135579. * 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.
  135580. *
  135581. * To update the configuration, use the following code:
  135582. * ```javascript
  135583. * DracoCompression.Configuration = {
  135584. * decoder: {
  135585. * wasmUrl: "<url to the WebAssembly library>",
  135586. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  135587. * fallbackUrl: "<url to the fallback JavaScript library>",
  135588. * }
  135589. * };
  135590. * ```
  135591. *
  135592. * 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.
  135593. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  135594. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  135595. *
  135596. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  135597. * ```javascript
  135598. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  135599. * ```
  135600. *
  135601. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  135602. */
  135603. export class DracoCompression implements IDisposable {
  135604. private _workerPoolPromise?;
  135605. private _decoderModulePromise?;
  135606. /**
  135607. * The configuration. Defaults to the following urls:
  135608. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  135609. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  135610. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  135611. */
  135612. static Configuration: IDracoCompressionConfiguration;
  135613. /**
  135614. * Returns true if the decoder configuration is available.
  135615. */
  135616. static get DecoderAvailable(): boolean;
  135617. /**
  135618. * Default number of workers to create when creating the draco compression object.
  135619. */
  135620. static DefaultNumWorkers: number;
  135621. private static GetDefaultNumWorkers;
  135622. private static _Default;
  135623. /**
  135624. * Default instance for the draco compression object.
  135625. */
  135626. static get Default(): DracoCompression;
  135627. /**
  135628. * Constructor
  135629. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  135630. */
  135631. constructor(numWorkers?: number);
  135632. /**
  135633. * Stop all async operations and release resources.
  135634. */
  135635. dispose(): void;
  135636. /**
  135637. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  135638. * @returns a promise that resolves when ready
  135639. */
  135640. whenReadyAsync(): Promise<void>;
  135641. /**
  135642. * Decode Draco compressed mesh data to vertex data.
  135643. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  135644. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  135645. * @returns A promise that resolves with the decoded vertex data
  135646. */
  135647. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  135648. [kind: string]: number;
  135649. }): Promise<VertexData>;
  135650. }
  135651. }
  135652. declare module BABYLON {
  135653. /**
  135654. * Class for building Constructive Solid Geometry
  135655. */
  135656. export class CSG {
  135657. private polygons;
  135658. /**
  135659. * The world matrix
  135660. */
  135661. matrix: Matrix;
  135662. /**
  135663. * Stores the position
  135664. */
  135665. position: Vector3;
  135666. /**
  135667. * Stores the rotation
  135668. */
  135669. rotation: Vector3;
  135670. /**
  135671. * Stores the rotation quaternion
  135672. */
  135673. rotationQuaternion: Nullable<Quaternion>;
  135674. /**
  135675. * Stores the scaling vector
  135676. */
  135677. scaling: Vector3;
  135678. /**
  135679. * Convert the Mesh to CSG
  135680. * @param mesh The Mesh to convert to CSG
  135681. * @returns A new CSG from the Mesh
  135682. */
  135683. static FromMesh(mesh: Mesh): CSG;
  135684. /**
  135685. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  135686. * @param polygons Polygons used to construct a CSG solid
  135687. */
  135688. private static FromPolygons;
  135689. /**
  135690. * Clones, or makes a deep copy, of the CSG
  135691. * @returns A new CSG
  135692. */
  135693. clone(): CSG;
  135694. /**
  135695. * Unions this CSG with another CSG
  135696. * @param csg The CSG to union against this CSG
  135697. * @returns The unioned CSG
  135698. */
  135699. union(csg: CSG): CSG;
  135700. /**
  135701. * Unions this CSG with another CSG in place
  135702. * @param csg The CSG to union against this CSG
  135703. */
  135704. unionInPlace(csg: CSG): void;
  135705. /**
  135706. * Subtracts this CSG with another CSG
  135707. * @param csg The CSG to subtract against this CSG
  135708. * @returns A new CSG
  135709. */
  135710. subtract(csg: CSG): CSG;
  135711. /**
  135712. * Subtracts this CSG with another CSG in place
  135713. * @param csg The CSG to subtact against this CSG
  135714. */
  135715. subtractInPlace(csg: CSG): void;
  135716. /**
  135717. * Intersect this CSG with another CSG
  135718. * @param csg The CSG to intersect against this CSG
  135719. * @returns A new CSG
  135720. */
  135721. intersect(csg: CSG): CSG;
  135722. /**
  135723. * Intersects this CSG with another CSG in place
  135724. * @param csg The CSG to intersect against this CSG
  135725. */
  135726. intersectInPlace(csg: CSG): void;
  135727. /**
  135728. * Return a new CSG solid with solid and empty space switched. This solid is
  135729. * not modified.
  135730. * @returns A new CSG solid with solid and empty space switched
  135731. */
  135732. inverse(): CSG;
  135733. /**
  135734. * Inverses the CSG in place
  135735. */
  135736. inverseInPlace(): void;
  135737. /**
  135738. * This is used to keep meshes transformations so they can be restored
  135739. * when we build back a Babylon Mesh
  135740. * NB : All CSG operations are performed in world coordinates
  135741. * @param csg The CSG to copy the transform attributes from
  135742. * @returns This CSG
  135743. */
  135744. copyTransformAttributes(csg: CSG): CSG;
  135745. /**
  135746. * Build Raw mesh from CSG
  135747. * Coordinates here are in world space
  135748. * @param name The name of the mesh geometry
  135749. * @param scene The Scene
  135750. * @param keepSubMeshes Specifies if the submeshes should be kept
  135751. * @returns A new Mesh
  135752. */
  135753. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  135754. /**
  135755. * Build Mesh from CSG taking material and transforms into account
  135756. * @param name The name of the Mesh
  135757. * @param material The material of the Mesh
  135758. * @param scene The Scene
  135759. * @param keepSubMeshes Specifies if submeshes should be kept
  135760. * @returns The new Mesh
  135761. */
  135762. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  135763. }
  135764. }
  135765. declare module BABYLON {
  135766. /**
  135767. * Class used to create a trail following a mesh
  135768. */
  135769. export class TrailMesh extends Mesh {
  135770. private _generator;
  135771. private _autoStart;
  135772. private _running;
  135773. private _diameter;
  135774. private _length;
  135775. private _sectionPolygonPointsCount;
  135776. private _sectionVectors;
  135777. private _sectionNormalVectors;
  135778. private _beforeRenderObserver;
  135779. /**
  135780. * @constructor
  135781. * @param name The value used by scene.getMeshByName() to do a lookup.
  135782. * @param generator The mesh or transform node to generate a trail.
  135783. * @param scene The scene to add this mesh to.
  135784. * @param diameter Diameter of trailing mesh. Default is 1.
  135785. * @param length Length of trailing mesh. Default is 60.
  135786. * @param autoStart Automatically start trailing mesh. Default true.
  135787. */
  135788. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  135789. /**
  135790. * "TrailMesh"
  135791. * @returns "TrailMesh"
  135792. */
  135793. getClassName(): string;
  135794. private _createMesh;
  135795. /**
  135796. * Start trailing mesh.
  135797. */
  135798. start(): void;
  135799. /**
  135800. * Stop trailing mesh.
  135801. */
  135802. stop(): void;
  135803. /**
  135804. * Update trailing mesh geometry.
  135805. */
  135806. update(): void;
  135807. /**
  135808. * Returns a new TrailMesh object.
  135809. * @param name is a string, the name given to the new mesh
  135810. * @param newGenerator use new generator object for cloned trail mesh
  135811. * @returns a new mesh
  135812. */
  135813. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  135814. /**
  135815. * Serializes this trail mesh
  135816. * @param serializationObject object to write serialization to
  135817. */
  135818. serialize(serializationObject: any): void;
  135819. /**
  135820. * Parses a serialized trail mesh
  135821. * @param parsedMesh the serialized mesh
  135822. * @param scene the scene to create the trail mesh in
  135823. * @returns the created trail mesh
  135824. */
  135825. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  135826. }
  135827. }
  135828. declare module BABYLON {
  135829. /**
  135830. * Class containing static functions to help procedurally build meshes
  135831. */
  135832. export class TiledBoxBuilder {
  135833. /**
  135834. * Creates a box mesh
  135835. * 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)
  135836. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  135837. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135838. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135840. * @param name defines the name of the mesh
  135841. * @param options defines the options used to create the mesh
  135842. * @param scene defines the hosting scene
  135843. * @returns the box mesh
  135844. */
  135845. static CreateTiledBox(name: string, options: {
  135846. pattern?: number;
  135847. width?: number;
  135848. height?: number;
  135849. depth?: number;
  135850. tileSize?: number;
  135851. tileWidth?: number;
  135852. tileHeight?: number;
  135853. alignHorizontal?: number;
  135854. alignVertical?: number;
  135855. faceUV?: Vector4[];
  135856. faceColors?: Color4[];
  135857. sideOrientation?: number;
  135858. updatable?: boolean;
  135859. }, scene?: Nullable<Scene>): Mesh;
  135860. }
  135861. }
  135862. declare module BABYLON {
  135863. /**
  135864. * Class containing static functions to help procedurally build meshes
  135865. */
  135866. export class TorusKnotBuilder {
  135867. /**
  135868. * Creates a torus knot mesh
  135869. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  135870. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  135871. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  135872. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  135873. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135874. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135876. * @param name defines the name of the mesh
  135877. * @param options defines the options used to create the mesh
  135878. * @param scene defines the hosting scene
  135879. * @returns the torus knot mesh
  135880. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  135881. */
  135882. static CreateTorusKnot(name: string, options: {
  135883. radius?: number;
  135884. tube?: number;
  135885. radialSegments?: number;
  135886. tubularSegments?: number;
  135887. p?: number;
  135888. q?: number;
  135889. updatable?: boolean;
  135890. sideOrientation?: number;
  135891. frontUVs?: Vector4;
  135892. backUVs?: Vector4;
  135893. }, scene: any): Mesh;
  135894. }
  135895. }
  135896. declare module BABYLON {
  135897. /**
  135898. * Polygon
  135899. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  135900. */
  135901. export class Polygon {
  135902. /**
  135903. * Creates a rectangle
  135904. * @param xmin bottom X coord
  135905. * @param ymin bottom Y coord
  135906. * @param xmax top X coord
  135907. * @param ymax top Y coord
  135908. * @returns points that make the resulting rectation
  135909. */
  135910. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  135911. /**
  135912. * Creates a circle
  135913. * @param radius radius of circle
  135914. * @param cx scale in x
  135915. * @param cy scale in y
  135916. * @param numberOfSides number of sides that make up the circle
  135917. * @returns points that make the resulting circle
  135918. */
  135919. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  135920. /**
  135921. * Creates a polygon from input string
  135922. * @param input Input polygon data
  135923. * @returns the parsed points
  135924. */
  135925. static Parse(input: string): Vector2[];
  135926. /**
  135927. * Starts building a polygon from x and y coordinates
  135928. * @param x x coordinate
  135929. * @param y y coordinate
  135930. * @returns the started path2
  135931. */
  135932. static StartingAt(x: number, y: number): Path2;
  135933. }
  135934. /**
  135935. * Builds a polygon
  135936. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  135937. */
  135938. export class PolygonMeshBuilder {
  135939. private _points;
  135940. private _outlinepoints;
  135941. private _holes;
  135942. private _name;
  135943. private _scene;
  135944. private _epoints;
  135945. private _eholes;
  135946. private _addToepoint;
  135947. /**
  135948. * Babylon reference to the earcut plugin.
  135949. */
  135950. bjsEarcut: any;
  135951. /**
  135952. * Creates a PolygonMeshBuilder
  135953. * @param name name of the builder
  135954. * @param contours Path of the polygon
  135955. * @param scene scene to add to when creating the mesh
  135956. * @param earcutInjection can be used to inject your own earcut reference
  135957. */
  135958. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  135959. /**
  135960. * Adds a whole within the polygon
  135961. * @param hole Array of points defining the hole
  135962. * @returns this
  135963. */
  135964. addHole(hole: Vector2[]): PolygonMeshBuilder;
  135965. /**
  135966. * Creates the polygon
  135967. * @param updatable If the mesh should be updatable
  135968. * @param depth The depth of the mesh created
  135969. * @returns the created mesh
  135970. */
  135971. build(updatable?: boolean, depth?: number): Mesh;
  135972. /**
  135973. * Creates the polygon
  135974. * @param depth The depth of the mesh created
  135975. * @returns the created VertexData
  135976. */
  135977. buildVertexData(depth?: number): VertexData;
  135978. /**
  135979. * Adds a side to the polygon
  135980. * @param positions points that make the polygon
  135981. * @param normals normals of the polygon
  135982. * @param uvs uvs of the polygon
  135983. * @param indices indices of the polygon
  135984. * @param bounds bounds of the polygon
  135985. * @param points points of the polygon
  135986. * @param depth depth of the polygon
  135987. * @param flip flip of the polygon
  135988. */
  135989. private addSide;
  135990. }
  135991. }
  135992. declare module BABYLON {
  135993. /**
  135994. * Class containing static functions to help procedurally build meshes
  135995. */
  135996. export class PolygonBuilder {
  135997. /**
  135998. * Creates a polygon mesh
  135999. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  136000. * * 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
  136001. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  136002. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136003. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  136004. * * Remember you can only change the shape positions, not their number when updating a polygon
  136005. * @param name defines the name of the mesh
  136006. * @param options defines the options used to create the mesh
  136007. * @param scene defines the hosting scene
  136008. * @param earcutInjection can be used to inject your own earcut reference
  136009. * @returns the polygon mesh
  136010. */
  136011. static CreatePolygon(name: string, options: {
  136012. shape: Vector3[];
  136013. holes?: Vector3[][];
  136014. depth?: number;
  136015. faceUV?: Vector4[];
  136016. faceColors?: Color4[];
  136017. updatable?: boolean;
  136018. sideOrientation?: number;
  136019. frontUVs?: Vector4;
  136020. backUVs?: Vector4;
  136021. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  136022. /**
  136023. * Creates an extruded polygon mesh, with depth in the Y direction.
  136024. * * 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)
  136025. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  136026. * @param name defines the name of the mesh
  136027. * @param options defines the options used to create the mesh
  136028. * @param scene defines the hosting scene
  136029. * @param earcutInjection can be used to inject your own earcut reference
  136030. * @returns the polygon mesh
  136031. */
  136032. static ExtrudePolygon(name: string, options: {
  136033. shape: Vector3[];
  136034. holes?: Vector3[][];
  136035. depth?: number;
  136036. faceUV?: Vector4[];
  136037. faceColors?: Color4[];
  136038. updatable?: boolean;
  136039. sideOrientation?: number;
  136040. frontUVs?: Vector4;
  136041. backUVs?: Vector4;
  136042. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  136043. }
  136044. }
  136045. declare module BABYLON {
  136046. /**
  136047. * Class containing static functions to help procedurally build meshes
  136048. */
  136049. export class LatheBuilder {
  136050. /**
  136051. * Creates lathe mesh.
  136052. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  136053. * * 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
  136054. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  136055. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  136056. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  136057. * * 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
  136058. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  136059. * * 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
  136060. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136061. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136062. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136064. * @param name defines the name of the mesh
  136065. * @param options defines the options used to create the mesh
  136066. * @param scene defines the hosting scene
  136067. * @returns the lathe mesh
  136068. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  136069. */
  136070. static CreateLathe(name: string, options: {
  136071. shape: Vector3[];
  136072. radius?: number;
  136073. tessellation?: number;
  136074. clip?: number;
  136075. arc?: number;
  136076. closed?: boolean;
  136077. updatable?: boolean;
  136078. sideOrientation?: number;
  136079. frontUVs?: Vector4;
  136080. backUVs?: Vector4;
  136081. cap?: number;
  136082. invertUV?: boolean;
  136083. }, scene?: Nullable<Scene>): Mesh;
  136084. }
  136085. }
  136086. declare module BABYLON {
  136087. /**
  136088. * Class containing static functions to help procedurally build meshes
  136089. */
  136090. export class TiledPlaneBuilder {
  136091. /**
  136092. * Creates a tiled plane mesh
  136093. * * The parameter `pattern` will, depending on value, do nothing or
  136094. * * * flip (reflect about central vertical) alternate tiles across and up
  136095. * * * flip every tile on alternate rows
  136096. * * * rotate (180 degs) alternate tiles across and up
  136097. * * * rotate every tile on alternate rows
  136098. * * * flip and rotate alternate tiles across and up
  136099. * * * flip and rotate every tile on alternate rows
  136100. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  136101. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  136102. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136103. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  136104. * * 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)
  136105. * * 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)
  136106. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  136107. * @param name defines the name of the mesh
  136108. * @param options defines the options used to create the mesh
  136109. * @param scene defines the hosting scene
  136110. * @returns the box mesh
  136111. */
  136112. static CreateTiledPlane(name: string, options: {
  136113. pattern?: number;
  136114. tileSize?: number;
  136115. tileWidth?: number;
  136116. tileHeight?: number;
  136117. size?: number;
  136118. width?: number;
  136119. height?: number;
  136120. alignHorizontal?: number;
  136121. alignVertical?: number;
  136122. sideOrientation?: number;
  136123. frontUVs?: Vector4;
  136124. backUVs?: Vector4;
  136125. updatable?: boolean;
  136126. }, scene?: Nullable<Scene>): Mesh;
  136127. }
  136128. }
  136129. declare module BABYLON {
  136130. /**
  136131. * Class containing static functions to help procedurally build meshes
  136132. */
  136133. export class TubeBuilder {
  136134. /**
  136135. * Creates a tube mesh.
  136136. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  136137. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  136138. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  136139. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  136140. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  136141. * * 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)
  136142. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  136143. * * 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
  136144. * * 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
  136145. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136146. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136147. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136149. * @param name defines the name of the mesh
  136150. * @param options defines the options used to create the mesh
  136151. * @param scene defines the hosting scene
  136152. * @returns the tube mesh
  136153. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136154. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  136155. */
  136156. static CreateTube(name: string, options: {
  136157. path: Vector3[];
  136158. radius?: number;
  136159. tessellation?: number;
  136160. radiusFunction?: {
  136161. (i: number, distance: number): number;
  136162. };
  136163. cap?: number;
  136164. arc?: number;
  136165. updatable?: boolean;
  136166. sideOrientation?: number;
  136167. frontUVs?: Vector4;
  136168. backUVs?: Vector4;
  136169. instance?: Mesh;
  136170. invertUV?: boolean;
  136171. }, scene?: Nullable<Scene>): Mesh;
  136172. }
  136173. }
  136174. declare module BABYLON {
  136175. /**
  136176. * Class containing static functions to help procedurally build meshes
  136177. */
  136178. export class IcoSphereBuilder {
  136179. /**
  136180. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  136181. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  136182. * * 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`)
  136183. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  136184. * * 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
  136185. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136186. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136188. * @param name defines the name of the mesh
  136189. * @param options defines the options used to create the mesh
  136190. * @param scene defines the hosting scene
  136191. * @returns the icosahedron mesh
  136192. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  136193. */
  136194. static CreateIcoSphere(name: string, options: {
  136195. radius?: number;
  136196. radiusX?: number;
  136197. radiusY?: number;
  136198. radiusZ?: number;
  136199. flat?: boolean;
  136200. subdivisions?: number;
  136201. sideOrientation?: number;
  136202. frontUVs?: Vector4;
  136203. backUVs?: Vector4;
  136204. updatable?: boolean;
  136205. }, scene?: Nullable<Scene>): Mesh;
  136206. }
  136207. }
  136208. declare module BABYLON {
  136209. /**
  136210. * Class containing static functions to help procedurally build meshes
  136211. */
  136212. export class DecalBuilder {
  136213. /**
  136214. * Creates a decal mesh.
  136215. * 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
  136216. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  136217. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  136218. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  136219. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  136220. * @param name defines the name of the mesh
  136221. * @param sourceMesh defines the mesh where the decal must be applied
  136222. * @param options defines the options used to create the mesh
  136223. * @param scene defines the hosting scene
  136224. * @returns the decal mesh
  136225. * @see https://doc.babylonjs.com/how_to/decals
  136226. */
  136227. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  136228. position?: Vector3;
  136229. normal?: Vector3;
  136230. size?: Vector3;
  136231. angle?: number;
  136232. }): Mesh;
  136233. }
  136234. }
  136235. declare module BABYLON {
  136236. /**
  136237. * Class containing static functions to help procedurally build meshes
  136238. */
  136239. export class MeshBuilder {
  136240. /**
  136241. * Creates a box mesh
  136242. * * The parameter `size` sets the size (float) of each box side (default 1)
  136243. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  136244. * * 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)
  136245. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  136246. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136247. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136249. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  136250. * @param name defines the name of the mesh
  136251. * @param options defines the options used to create the mesh
  136252. * @param scene defines the hosting scene
  136253. * @returns the box mesh
  136254. */
  136255. static CreateBox(name: string, options: {
  136256. size?: number;
  136257. width?: number;
  136258. height?: number;
  136259. depth?: number;
  136260. faceUV?: Vector4[];
  136261. faceColors?: Color4[];
  136262. sideOrientation?: number;
  136263. frontUVs?: Vector4;
  136264. backUVs?: Vector4;
  136265. wrap?: boolean;
  136266. topBaseAt?: number;
  136267. bottomBaseAt?: number;
  136268. updatable?: boolean;
  136269. }, scene?: Nullable<Scene>): Mesh;
  136270. /**
  136271. * Creates a tiled box mesh
  136272. * * faceTiles sets the pattern, tile size and number of tiles for a face
  136273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136274. * @param name defines the name of the mesh
  136275. * @param options defines the options used to create the mesh
  136276. * @param scene defines the hosting scene
  136277. * @returns the tiled box mesh
  136278. */
  136279. static CreateTiledBox(name: string, options: {
  136280. pattern?: number;
  136281. size?: number;
  136282. width?: number;
  136283. height?: number;
  136284. depth: number;
  136285. tileSize?: number;
  136286. tileWidth?: number;
  136287. tileHeight?: number;
  136288. faceUV?: Vector4[];
  136289. faceColors?: Color4[];
  136290. alignHorizontal?: number;
  136291. alignVertical?: number;
  136292. sideOrientation?: number;
  136293. updatable?: boolean;
  136294. }, scene?: Nullable<Scene>): Mesh;
  136295. /**
  136296. * Creates a sphere mesh
  136297. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  136298. * * 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`)
  136299. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  136300. * * 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
  136301. * * 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)
  136302. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136303. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136304. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136305. * @param name defines the name of the mesh
  136306. * @param options defines the options used to create the mesh
  136307. * @param scene defines the hosting scene
  136308. * @returns the sphere mesh
  136309. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  136310. */
  136311. static CreateSphere(name: string, options: {
  136312. segments?: number;
  136313. diameter?: number;
  136314. diameterX?: number;
  136315. diameterY?: number;
  136316. diameterZ?: number;
  136317. arc?: number;
  136318. slice?: number;
  136319. sideOrientation?: number;
  136320. frontUVs?: Vector4;
  136321. backUVs?: Vector4;
  136322. updatable?: boolean;
  136323. }, scene?: Nullable<Scene>): Mesh;
  136324. /**
  136325. * Creates a plane polygonal mesh. By default, this is a disc
  136326. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  136327. * * 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
  136328. * * 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
  136329. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136330. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136332. * @param name defines the name of the mesh
  136333. * @param options defines the options used to create the mesh
  136334. * @param scene defines the hosting scene
  136335. * @returns the plane polygonal mesh
  136336. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  136337. */
  136338. static CreateDisc(name: string, options: {
  136339. radius?: number;
  136340. tessellation?: number;
  136341. arc?: number;
  136342. updatable?: boolean;
  136343. sideOrientation?: number;
  136344. frontUVs?: Vector4;
  136345. backUVs?: Vector4;
  136346. }, scene?: Nullable<Scene>): Mesh;
  136347. /**
  136348. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  136349. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  136350. * * 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`)
  136351. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  136352. * * 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
  136353. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136354. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136356. * @param name defines the name of the mesh
  136357. * @param options defines the options used to create the mesh
  136358. * @param scene defines the hosting scene
  136359. * @returns the icosahedron mesh
  136360. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  136361. */
  136362. static CreateIcoSphere(name: string, options: {
  136363. radius?: number;
  136364. radiusX?: number;
  136365. radiusY?: number;
  136366. radiusZ?: number;
  136367. flat?: boolean;
  136368. subdivisions?: number;
  136369. sideOrientation?: number;
  136370. frontUVs?: Vector4;
  136371. backUVs?: Vector4;
  136372. updatable?: boolean;
  136373. }, scene?: Nullable<Scene>): Mesh;
  136374. /**
  136375. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  136376. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  136377. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  136378. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  136379. * * 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
  136380. * * 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
  136381. * * 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
  136382. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136383. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136384. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136385. * * 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
  136386. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  136387. * * 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
  136388. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  136389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136390. * @param name defines the name of the mesh
  136391. * @param options defines the options used to create the mesh
  136392. * @param scene defines the hosting scene
  136393. * @returns the ribbon mesh
  136394. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  136395. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136396. */
  136397. static CreateRibbon(name: string, options: {
  136398. pathArray: Vector3[][];
  136399. closeArray?: boolean;
  136400. closePath?: boolean;
  136401. offset?: number;
  136402. updatable?: boolean;
  136403. sideOrientation?: number;
  136404. frontUVs?: Vector4;
  136405. backUVs?: Vector4;
  136406. instance?: Mesh;
  136407. invertUV?: boolean;
  136408. uvs?: Vector2[];
  136409. colors?: Color4[];
  136410. }, scene?: Nullable<Scene>): Mesh;
  136411. /**
  136412. * Creates a cylinder or a cone mesh
  136413. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  136414. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  136415. * * 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.
  136416. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  136417. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  136418. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  136419. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  136420. * * 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).
  136421. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  136422. * * 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).
  136423. * * 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
  136424. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  136425. * * 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
  136426. * * 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.
  136427. * * If `enclose` is false, a ring surface is one element.
  136428. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  136429. * * 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
  136430. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136431. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136433. * @param name defines the name of the mesh
  136434. * @param options defines the options used to create the mesh
  136435. * @param scene defines the hosting scene
  136436. * @returns the cylinder mesh
  136437. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  136438. */
  136439. static CreateCylinder(name: string, options: {
  136440. height?: number;
  136441. diameterTop?: number;
  136442. diameterBottom?: number;
  136443. diameter?: number;
  136444. tessellation?: number;
  136445. subdivisions?: number;
  136446. arc?: number;
  136447. faceColors?: Color4[];
  136448. faceUV?: Vector4[];
  136449. updatable?: boolean;
  136450. hasRings?: boolean;
  136451. enclose?: boolean;
  136452. cap?: number;
  136453. sideOrientation?: number;
  136454. frontUVs?: Vector4;
  136455. backUVs?: Vector4;
  136456. }, scene?: Nullable<Scene>): Mesh;
  136457. /**
  136458. * Creates a torus mesh
  136459. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  136460. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  136461. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  136462. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136463. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136464. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136465. * @param name defines the name of the mesh
  136466. * @param options defines the options used to create the mesh
  136467. * @param scene defines the hosting scene
  136468. * @returns the torus mesh
  136469. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  136470. */
  136471. static CreateTorus(name: string, options: {
  136472. diameter?: number;
  136473. thickness?: number;
  136474. tessellation?: number;
  136475. updatable?: boolean;
  136476. sideOrientation?: number;
  136477. frontUVs?: Vector4;
  136478. backUVs?: Vector4;
  136479. }, scene?: Nullable<Scene>): Mesh;
  136480. /**
  136481. * Creates a torus knot mesh
  136482. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  136483. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  136484. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  136485. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  136486. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136487. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136489. * @param name defines the name of the mesh
  136490. * @param options defines the options used to create the mesh
  136491. * @param scene defines the hosting scene
  136492. * @returns the torus knot mesh
  136493. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  136494. */
  136495. static CreateTorusKnot(name: string, options: {
  136496. radius?: number;
  136497. tube?: number;
  136498. radialSegments?: number;
  136499. tubularSegments?: number;
  136500. p?: number;
  136501. q?: number;
  136502. updatable?: boolean;
  136503. sideOrientation?: number;
  136504. frontUVs?: Vector4;
  136505. backUVs?: Vector4;
  136506. }, scene?: Nullable<Scene>): Mesh;
  136507. /**
  136508. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  136509. * * 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
  136510. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  136511. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  136512. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  136513. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  136514. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  136515. * * 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
  136516. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  136517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136518. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  136519. * @param name defines the name of the new line system
  136520. * @param options defines the options used to create the line system
  136521. * @param scene defines the hosting scene
  136522. * @returns a new line system mesh
  136523. */
  136524. static CreateLineSystem(name: string, options: {
  136525. lines: Vector3[][];
  136526. updatable?: boolean;
  136527. instance?: Nullable<LinesMesh>;
  136528. colors?: Nullable<Color4[][]>;
  136529. useVertexAlpha?: boolean;
  136530. }, scene: Nullable<Scene>): LinesMesh;
  136531. /**
  136532. * Creates a line mesh
  136533. * 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
  136534. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  136535. * * The parameter `points` is an array successive Vector3
  136536. * * 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
  136537. * * The optional parameter `colors` is an array of successive Color4, one per line point
  136538. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  136539. * * When updating an instance, remember that only point positions can change, not the number of points
  136540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136541. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  136542. * @param name defines the name of the new line system
  136543. * @param options defines the options used to create the line system
  136544. * @param scene defines the hosting scene
  136545. * @returns a new line mesh
  136546. */
  136547. static CreateLines(name: string, options: {
  136548. points: Vector3[];
  136549. updatable?: boolean;
  136550. instance?: Nullable<LinesMesh>;
  136551. colors?: Color4[];
  136552. useVertexAlpha?: boolean;
  136553. }, scene?: Nullable<Scene>): LinesMesh;
  136554. /**
  136555. * Creates a dashed line mesh
  136556. * * 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
  136557. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  136558. * * The parameter `points` is an array successive Vector3
  136559. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  136560. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  136561. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  136562. * * 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
  136563. * * When updating an instance, remember that only point positions can change, not the number of points
  136564. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136565. * @param name defines the name of the mesh
  136566. * @param options defines the options used to create the mesh
  136567. * @param scene defines the hosting scene
  136568. * @returns the dashed line mesh
  136569. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  136570. */
  136571. static CreateDashedLines(name: string, options: {
  136572. points: Vector3[];
  136573. dashSize?: number;
  136574. gapSize?: number;
  136575. dashNb?: number;
  136576. updatable?: boolean;
  136577. instance?: LinesMesh;
  136578. }, scene?: Nullable<Scene>): LinesMesh;
  136579. /**
  136580. * 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.
  136581. * * 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.
  136582. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  136583. * * 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.
  136584. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  136585. * * 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
  136586. * * 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
  136587. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  136588. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136589. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136590. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  136591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136592. * @param name defines the name of the mesh
  136593. * @param options defines the options used to create the mesh
  136594. * @param scene defines the hosting scene
  136595. * @returns the extruded shape mesh
  136596. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136597. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  136598. */
  136599. static ExtrudeShape(name: string, options: {
  136600. shape: Vector3[];
  136601. path: Vector3[];
  136602. scale?: number;
  136603. rotation?: number;
  136604. cap?: number;
  136605. updatable?: boolean;
  136606. sideOrientation?: number;
  136607. frontUVs?: Vector4;
  136608. backUVs?: Vector4;
  136609. instance?: Mesh;
  136610. invertUV?: boolean;
  136611. }, scene?: Nullable<Scene>): Mesh;
  136612. /**
  136613. * Creates an custom extruded shape mesh.
  136614. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  136615. * * 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.
  136616. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  136617. * * 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
  136618. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  136619. * * 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
  136620. * * It must returns a float value that will be the scale value applied to the shape on each path point
  136621. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  136622. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  136623. * * 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
  136624. * * 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
  136625. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  136626. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136627. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136628. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136629. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136630. * @param name defines the name of the mesh
  136631. * @param options defines the options used to create the mesh
  136632. * @param scene defines the hosting scene
  136633. * @returns the custom extruded shape mesh
  136634. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  136635. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136636. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  136637. */
  136638. static ExtrudeShapeCustom(name: string, options: {
  136639. shape: Vector3[];
  136640. path: Vector3[];
  136641. scaleFunction?: any;
  136642. rotationFunction?: any;
  136643. ribbonCloseArray?: boolean;
  136644. ribbonClosePath?: boolean;
  136645. cap?: number;
  136646. updatable?: boolean;
  136647. sideOrientation?: number;
  136648. frontUVs?: Vector4;
  136649. backUVs?: Vector4;
  136650. instance?: Mesh;
  136651. invertUV?: boolean;
  136652. }, scene?: Nullable<Scene>): Mesh;
  136653. /**
  136654. * Creates lathe mesh.
  136655. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  136656. * * 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
  136657. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  136658. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  136659. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  136660. * * 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
  136661. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  136662. * * 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
  136663. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136664. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136665. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136667. * @param name defines the name of the mesh
  136668. * @param options defines the options used to create the mesh
  136669. * @param scene defines the hosting scene
  136670. * @returns the lathe mesh
  136671. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  136672. */
  136673. static CreateLathe(name: string, options: {
  136674. shape: Vector3[];
  136675. radius?: number;
  136676. tessellation?: number;
  136677. clip?: number;
  136678. arc?: number;
  136679. closed?: boolean;
  136680. updatable?: boolean;
  136681. sideOrientation?: number;
  136682. frontUVs?: Vector4;
  136683. backUVs?: Vector4;
  136684. cap?: number;
  136685. invertUV?: boolean;
  136686. }, scene?: Nullable<Scene>): Mesh;
  136687. /**
  136688. * Creates a tiled plane mesh
  136689. * * You can set a limited pattern arrangement with the tiles
  136690. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136691. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136693. * @param name defines the name of the mesh
  136694. * @param options defines the options used to create the mesh
  136695. * @param scene defines the hosting scene
  136696. * @returns the plane mesh
  136697. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  136698. */
  136699. static CreateTiledPlane(name: string, options: {
  136700. pattern?: number;
  136701. tileSize?: number;
  136702. tileWidth?: number;
  136703. tileHeight?: number;
  136704. size?: number;
  136705. width?: number;
  136706. height?: number;
  136707. alignHorizontal?: number;
  136708. alignVertical?: number;
  136709. sideOrientation?: number;
  136710. frontUVs?: Vector4;
  136711. backUVs?: Vector4;
  136712. updatable?: boolean;
  136713. }, scene?: Nullable<Scene>): Mesh;
  136714. /**
  136715. * Creates a plane mesh
  136716. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  136717. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  136718. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  136719. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136720. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136722. * @param name defines the name of the mesh
  136723. * @param options defines the options used to create the mesh
  136724. * @param scene defines the hosting scene
  136725. * @returns the plane mesh
  136726. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  136727. */
  136728. static CreatePlane(name: string, options: {
  136729. size?: number;
  136730. width?: number;
  136731. height?: number;
  136732. sideOrientation?: number;
  136733. frontUVs?: Vector4;
  136734. backUVs?: Vector4;
  136735. updatable?: boolean;
  136736. sourcePlane?: Plane;
  136737. }, scene?: Nullable<Scene>): Mesh;
  136738. /**
  136739. * Creates a ground mesh
  136740. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  136741. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  136742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136743. * @param name defines the name of the mesh
  136744. * @param options defines the options used to create the mesh
  136745. * @param scene defines the hosting scene
  136746. * @returns the ground mesh
  136747. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  136748. */
  136749. static CreateGround(name: string, options: {
  136750. width?: number;
  136751. height?: number;
  136752. subdivisions?: number;
  136753. subdivisionsX?: number;
  136754. subdivisionsY?: number;
  136755. updatable?: boolean;
  136756. }, scene?: Nullable<Scene>): Mesh;
  136757. /**
  136758. * Creates a tiled ground mesh
  136759. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  136760. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  136761. * * 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
  136762. * * 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
  136763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136764. * @param name defines the name of the mesh
  136765. * @param options defines the options used to create the mesh
  136766. * @param scene defines the hosting scene
  136767. * @returns the tiled ground mesh
  136768. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  136769. */
  136770. static CreateTiledGround(name: string, options: {
  136771. xmin: number;
  136772. zmin: number;
  136773. xmax: number;
  136774. zmax: number;
  136775. subdivisions?: {
  136776. w: number;
  136777. h: number;
  136778. };
  136779. precision?: {
  136780. w: number;
  136781. h: number;
  136782. };
  136783. updatable?: boolean;
  136784. }, scene?: Nullable<Scene>): Mesh;
  136785. /**
  136786. * Creates a ground mesh from a height map
  136787. * * The parameter `url` sets the URL of the height map image resource.
  136788. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  136789. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  136790. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  136791. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  136792. * * 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.
  136793. * * 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).
  136794. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  136795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136796. * @param name defines the name of the mesh
  136797. * @param url defines the url to the height map
  136798. * @param options defines the options used to create the mesh
  136799. * @param scene defines the hosting scene
  136800. * @returns the ground mesh
  136801. * @see https://doc.babylonjs.com/babylon101/height_map
  136802. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  136803. */
  136804. static CreateGroundFromHeightMap(name: string, url: string, options: {
  136805. width?: number;
  136806. height?: number;
  136807. subdivisions?: number;
  136808. minHeight?: number;
  136809. maxHeight?: number;
  136810. colorFilter?: Color3;
  136811. alphaFilter?: number;
  136812. updatable?: boolean;
  136813. onReady?: (mesh: GroundMesh) => void;
  136814. }, scene?: Nullable<Scene>): GroundMesh;
  136815. /**
  136816. * Creates a polygon mesh
  136817. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  136818. * * 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
  136819. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  136820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136821. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  136822. * * Remember you can only change the shape positions, not their number when updating a polygon
  136823. * @param name defines the name of the mesh
  136824. * @param options defines the options used to create the mesh
  136825. * @param scene defines the hosting scene
  136826. * @param earcutInjection can be used to inject your own earcut reference
  136827. * @returns the polygon mesh
  136828. */
  136829. static CreatePolygon(name: string, options: {
  136830. shape: Vector3[];
  136831. holes?: Vector3[][];
  136832. depth?: number;
  136833. faceUV?: Vector4[];
  136834. faceColors?: Color4[];
  136835. updatable?: boolean;
  136836. sideOrientation?: number;
  136837. frontUVs?: Vector4;
  136838. backUVs?: Vector4;
  136839. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  136840. /**
  136841. * Creates an extruded polygon mesh, with depth in the Y direction.
  136842. * * 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)
  136843. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  136844. * @param name defines the name of the mesh
  136845. * @param options defines the options used to create the mesh
  136846. * @param scene defines the hosting scene
  136847. * @param earcutInjection can be used to inject your own earcut reference
  136848. * @returns the polygon mesh
  136849. */
  136850. static ExtrudePolygon(name: string, options: {
  136851. shape: Vector3[];
  136852. holes?: Vector3[][];
  136853. depth?: number;
  136854. faceUV?: Vector4[];
  136855. faceColors?: Color4[];
  136856. updatable?: boolean;
  136857. sideOrientation?: number;
  136858. frontUVs?: Vector4;
  136859. backUVs?: Vector4;
  136860. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  136861. /**
  136862. * Creates a tube mesh.
  136863. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  136864. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  136865. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  136866. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  136867. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  136868. * * 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)
  136869. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  136870. * * 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
  136871. * * 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
  136872. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136873. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136874. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136876. * @param name defines the name of the mesh
  136877. * @param options defines the options used to create the mesh
  136878. * @param scene defines the hosting scene
  136879. * @returns the tube mesh
  136880. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136881. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  136882. */
  136883. static CreateTube(name: string, options: {
  136884. path: Vector3[];
  136885. radius?: number;
  136886. tessellation?: number;
  136887. radiusFunction?: {
  136888. (i: number, distance: number): number;
  136889. };
  136890. cap?: number;
  136891. arc?: number;
  136892. updatable?: boolean;
  136893. sideOrientation?: number;
  136894. frontUVs?: Vector4;
  136895. backUVs?: Vector4;
  136896. instance?: Mesh;
  136897. invertUV?: boolean;
  136898. }, scene?: Nullable<Scene>): Mesh;
  136899. /**
  136900. * Creates a polyhedron mesh
  136901. * * 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
  136902. * * The parameter `size` (positive float, default 1) sets the polygon size
  136903. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  136904. * * 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`
  136905. * * 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
  136906. * * 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)`)
  136907. * * 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
  136908. * * 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
  136909. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136910. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136912. * @param name defines the name of the mesh
  136913. * @param options defines the options used to create the mesh
  136914. * @param scene defines the hosting scene
  136915. * @returns the polyhedron mesh
  136916. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  136917. */
  136918. static CreatePolyhedron(name: string, options: {
  136919. type?: number;
  136920. size?: number;
  136921. sizeX?: number;
  136922. sizeY?: number;
  136923. sizeZ?: number;
  136924. custom?: any;
  136925. faceUV?: Vector4[];
  136926. faceColors?: Color4[];
  136927. flat?: boolean;
  136928. updatable?: boolean;
  136929. sideOrientation?: number;
  136930. frontUVs?: Vector4;
  136931. backUVs?: Vector4;
  136932. }, scene?: Nullable<Scene>): Mesh;
  136933. /**
  136934. * Creates a decal mesh.
  136935. * 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
  136936. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  136937. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  136938. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  136939. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  136940. * @param name defines the name of the mesh
  136941. * @param sourceMesh defines the mesh where the decal must be applied
  136942. * @param options defines the options used to create the mesh
  136943. * @param scene defines the hosting scene
  136944. * @returns the decal mesh
  136945. * @see https://doc.babylonjs.com/how_to/decals
  136946. */
  136947. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  136948. position?: Vector3;
  136949. normal?: Vector3;
  136950. size?: Vector3;
  136951. angle?: number;
  136952. }): Mesh;
  136953. }
  136954. }
  136955. declare module BABYLON {
  136956. /**
  136957. * A simplifier interface for future simplification implementations
  136958. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136959. */
  136960. export interface ISimplifier {
  136961. /**
  136962. * Simplification of a given mesh according to the given settings.
  136963. * Since this requires computation, it is assumed that the function runs async.
  136964. * @param settings The settings of the simplification, including quality and distance
  136965. * @param successCallback A callback that will be called after the mesh was simplified.
  136966. * @param errorCallback in case of an error, this callback will be called. optional.
  136967. */
  136968. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  136969. }
  136970. /**
  136971. * Expected simplification settings.
  136972. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  136973. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136974. */
  136975. export interface ISimplificationSettings {
  136976. /**
  136977. * Gets or sets the expected quality
  136978. */
  136979. quality: number;
  136980. /**
  136981. * Gets or sets the distance when this optimized version should be used
  136982. */
  136983. distance: number;
  136984. /**
  136985. * Gets an already optimized mesh
  136986. */
  136987. optimizeMesh?: boolean;
  136988. }
  136989. /**
  136990. * Class used to specify simplification options
  136991. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136992. */
  136993. export class SimplificationSettings implements ISimplificationSettings {
  136994. /** expected quality */
  136995. quality: number;
  136996. /** distance when this optimized version should be used */
  136997. distance: number;
  136998. /** already optimized mesh */
  136999. optimizeMesh?: boolean | undefined;
  137000. /**
  137001. * Creates a SimplificationSettings
  137002. * @param quality expected quality
  137003. * @param distance distance when this optimized version should be used
  137004. * @param optimizeMesh already optimized mesh
  137005. */
  137006. constructor(
  137007. /** expected quality */
  137008. quality: number,
  137009. /** distance when this optimized version should be used */
  137010. distance: number,
  137011. /** already optimized mesh */
  137012. optimizeMesh?: boolean | undefined);
  137013. }
  137014. /**
  137015. * Interface used to define a simplification task
  137016. */
  137017. export interface ISimplificationTask {
  137018. /**
  137019. * Array of settings
  137020. */
  137021. settings: Array<ISimplificationSettings>;
  137022. /**
  137023. * Simplification type
  137024. */
  137025. simplificationType: SimplificationType;
  137026. /**
  137027. * Mesh to simplify
  137028. */
  137029. mesh: Mesh;
  137030. /**
  137031. * Callback called on success
  137032. */
  137033. successCallback?: () => void;
  137034. /**
  137035. * Defines if parallel processing can be used
  137036. */
  137037. parallelProcessing: boolean;
  137038. }
  137039. /**
  137040. * Queue used to order the simplification tasks
  137041. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  137042. */
  137043. export class SimplificationQueue {
  137044. private _simplificationArray;
  137045. /**
  137046. * Gets a boolean indicating that the process is still running
  137047. */
  137048. running: boolean;
  137049. /**
  137050. * Creates a new queue
  137051. */
  137052. constructor();
  137053. /**
  137054. * Adds a new simplification task
  137055. * @param task defines a task to add
  137056. */
  137057. addTask(task: ISimplificationTask): void;
  137058. /**
  137059. * Execute next task
  137060. */
  137061. executeNext(): void;
  137062. /**
  137063. * Execute a simplification task
  137064. * @param task defines the task to run
  137065. */
  137066. runSimplification(task: ISimplificationTask): void;
  137067. private getSimplifier;
  137068. }
  137069. /**
  137070. * The implemented types of simplification
  137071. * At the moment only Quadratic Error Decimation is implemented
  137072. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  137073. */
  137074. export enum SimplificationType {
  137075. /** Quadratic error decimation */
  137076. QUADRATIC = 0
  137077. }
  137078. /**
  137079. * An implementation of the Quadratic Error simplification algorithm.
  137080. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  137081. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  137082. * @author RaananW
  137083. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  137084. */
  137085. export class QuadraticErrorSimplification implements ISimplifier {
  137086. private _mesh;
  137087. private triangles;
  137088. private vertices;
  137089. private references;
  137090. private _reconstructedMesh;
  137091. /** Gets or sets the number pf sync interations */
  137092. syncIterations: number;
  137093. /** Gets or sets the aggressiveness of the simplifier */
  137094. aggressiveness: number;
  137095. /** Gets or sets the number of allowed iterations for decimation */
  137096. decimationIterations: number;
  137097. /** Gets or sets the espilon to use for bounding box computation */
  137098. boundingBoxEpsilon: number;
  137099. /**
  137100. * Creates a new QuadraticErrorSimplification
  137101. * @param _mesh defines the target mesh
  137102. */
  137103. constructor(_mesh: Mesh);
  137104. /**
  137105. * Simplification of a given mesh according to the given settings.
  137106. * Since this requires computation, it is assumed that the function runs async.
  137107. * @param settings The settings of the simplification, including quality and distance
  137108. * @param successCallback A callback that will be called after the mesh was simplified.
  137109. */
  137110. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  137111. private runDecimation;
  137112. private initWithMesh;
  137113. private init;
  137114. private reconstructMesh;
  137115. private initDecimatedMesh;
  137116. private isFlipped;
  137117. private updateTriangles;
  137118. private identifyBorder;
  137119. private updateMesh;
  137120. private vertexError;
  137121. private calculateError;
  137122. }
  137123. }
  137124. declare module BABYLON {
  137125. interface Scene {
  137126. /** @hidden (Backing field) */
  137127. _simplificationQueue: SimplificationQueue;
  137128. /**
  137129. * Gets or sets the simplification queue attached to the scene
  137130. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  137131. */
  137132. simplificationQueue: SimplificationQueue;
  137133. }
  137134. interface Mesh {
  137135. /**
  137136. * Simplify the mesh according to the given array of settings.
  137137. * Function will return immediately and will simplify async
  137138. * @param settings a collection of simplification settings
  137139. * @param parallelProcessing should all levels calculate parallel or one after the other
  137140. * @param simplificationType the type of simplification to run
  137141. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  137142. * @returns the current mesh
  137143. */
  137144. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  137145. }
  137146. /**
  137147. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  137148. * created in a scene
  137149. */
  137150. export class SimplicationQueueSceneComponent implements ISceneComponent {
  137151. /**
  137152. * The component name helpfull to identify the component in the list of scene components.
  137153. */
  137154. readonly name: string;
  137155. /**
  137156. * The scene the component belongs to.
  137157. */
  137158. scene: Scene;
  137159. /**
  137160. * Creates a new instance of the component for the given scene
  137161. * @param scene Defines the scene to register the component in
  137162. */
  137163. constructor(scene: Scene);
  137164. /**
  137165. * Registers the component in a given scene
  137166. */
  137167. register(): void;
  137168. /**
  137169. * Rebuilds the elements related to this component in case of
  137170. * context lost for instance.
  137171. */
  137172. rebuild(): void;
  137173. /**
  137174. * Disposes the component and the associated ressources
  137175. */
  137176. dispose(): void;
  137177. private _beforeCameraUpdate;
  137178. }
  137179. }
  137180. declare module BABYLON {
  137181. /**
  137182. * Navigation plugin interface to add navigation constrained by a navigation mesh
  137183. */
  137184. export interface INavigationEnginePlugin {
  137185. /**
  137186. * plugin name
  137187. */
  137188. name: string;
  137189. /**
  137190. * Creates a navigation mesh
  137191. * @param meshes array of all the geometry used to compute the navigatio mesh
  137192. * @param parameters bunch of parameters used to filter geometry
  137193. */
  137194. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  137195. /**
  137196. * Create a navigation mesh debug mesh
  137197. * @param scene is where the mesh will be added
  137198. * @returns debug display mesh
  137199. */
  137200. createDebugNavMesh(scene: Scene): Mesh;
  137201. /**
  137202. * Get a navigation mesh constrained position, closest to the parameter position
  137203. * @param position world position
  137204. * @returns the closest point to position constrained by the navigation mesh
  137205. */
  137206. getClosestPoint(position: Vector3): Vector3;
  137207. /**
  137208. * Get a navigation mesh constrained position, closest to the parameter position
  137209. * @param position world position
  137210. * @param result output the closest point to position constrained by the navigation mesh
  137211. */
  137212. getClosestPointToRef(position: Vector3, result: Vector3): void;
  137213. /**
  137214. * Get a navigation mesh constrained position, within a particular radius
  137215. * @param position world position
  137216. * @param maxRadius the maximum distance to the constrained world position
  137217. * @returns the closest point to position constrained by the navigation mesh
  137218. */
  137219. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  137220. /**
  137221. * Get a navigation mesh constrained position, within a particular radius
  137222. * @param position world position
  137223. * @param maxRadius the maximum distance to the constrained world position
  137224. * @param result output the closest point to position constrained by the navigation mesh
  137225. */
  137226. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  137227. /**
  137228. * Compute the final position from a segment made of destination-position
  137229. * @param position world position
  137230. * @param destination world position
  137231. * @returns the resulting point along the navmesh
  137232. */
  137233. moveAlong(position: Vector3, destination: Vector3): Vector3;
  137234. /**
  137235. * Compute the final position from a segment made of destination-position
  137236. * @param position world position
  137237. * @param destination world position
  137238. * @param result output the resulting point along the navmesh
  137239. */
  137240. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  137241. /**
  137242. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  137243. * @param start world position
  137244. * @param end world position
  137245. * @returns array containing world position composing the path
  137246. */
  137247. computePath(start: Vector3, end: Vector3): Vector3[];
  137248. /**
  137249. * If this plugin is supported
  137250. * @returns true if plugin is supported
  137251. */
  137252. isSupported(): boolean;
  137253. /**
  137254. * Create a new Crowd so you can add agents
  137255. * @param maxAgents the maximum agent count in the crowd
  137256. * @param maxAgentRadius the maximum radius an agent can have
  137257. * @param scene to attach the crowd to
  137258. * @returns the crowd you can add agents to
  137259. */
  137260. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  137261. /**
  137262. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  137263. * The queries will try to find a solution within those bounds
  137264. * default is (1,1,1)
  137265. * @param extent x,y,z value that define the extent around the queries point of reference
  137266. */
  137267. setDefaultQueryExtent(extent: Vector3): void;
  137268. /**
  137269. * Get the Bounding box extent specified by setDefaultQueryExtent
  137270. * @returns the box extent values
  137271. */
  137272. getDefaultQueryExtent(): Vector3;
  137273. /**
  137274. * build the navmesh from a previously saved state using getNavmeshData
  137275. * @param data the Uint8Array returned by getNavmeshData
  137276. */
  137277. buildFromNavmeshData(data: Uint8Array): void;
  137278. /**
  137279. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  137280. * @returns data the Uint8Array that can be saved and reused
  137281. */
  137282. getNavmeshData(): Uint8Array;
  137283. /**
  137284. * Get the Bounding box extent result specified by setDefaultQueryExtent
  137285. * @param result output the box extent values
  137286. */
  137287. getDefaultQueryExtentToRef(result: Vector3): void;
  137288. /**
  137289. * Release all resources
  137290. */
  137291. dispose(): void;
  137292. }
  137293. /**
  137294. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  137295. */
  137296. export interface ICrowd {
  137297. /**
  137298. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  137299. * You can attach anything to that node. The node position is updated in the scene update tick.
  137300. * @param pos world position that will be constrained by the navigation mesh
  137301. * @param parameters agent parameters
  137302. * @param transform hooked to the agent that will be update by the scene
  137303. * @returns agent index
  137304. */
  137305. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  137306. /**
  137307. * Returns the agent position in world space
  137308. * @param index agent index returned by addAgent
  137309. * @returns world space position
  137310. */
  137311. getAgentPosition(index: number): Vector3;
  137312. /**
  137313. * Gets the agent position result in world space
  137314. * @param index agent index returned by addAgent
  137315. * @param result output world space position
  137316. */
  137317. getAgentPositionToRef(index: number, result: Vector3): void;
  137318. /**
  137319. * Gets the agent velocity in world space
  137320. * @param index agent index returned by addAgent
  137321. * @returns world space velocity
  137322. */
  137323. getAgentVelocity(index: number): Vector3;
  137324. /**
  137325. * Gets the agent velocity result in world space
  137326. * @param index agent index returned by addAgent
  137327. * @param result output world space velocity
  137328. */
  137329. getAgentVelocityToRef(index: number, result: Vector3): void;
  137330. /**
  137331. * remove a particular agent previously created
  137332. * @param index agent index returned by addAgent
  137333. */
  137334. removeAgent(index: number): void;
  137335. /**
  137336. * get the list of all agents attached to this crowd
  137337. * @returns list of agent indices
  137338. */
  137339. getAgents(): number[];
  137340. /**
  137341. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  137342. * @param deltaTime in seconds
  137343. */
  137344. update(deltaTime: number): void;
  137345. /**
  137346. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  137347. * @param index agent index returned by addAgent
  137348. * @param destination targeted world position
  137349. */
  137350. agentGoto(index: number, destination: Vector3): void;
  137351. /**
  137352. * Teleport the agent to a new position
  137353. * @param index agent index returned by addAgent
  137354. * @param destination targeted world position
  137355. */
  137356. agentTeleport(index: number, destination: Vector3): void;
  137357. /**
  137358. * Update agent parameters
  137359. * @param index agent index returned by addAgent
  137360. * @param parameters agent parameters
  137361. */
  137362. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  137363. /**
  137364. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  137365. * The queries will try to find a solution within those bounds
  137366. * default is (1,1,1)
  137367. * @param extent x,y,z value that define the extent around the queries point of reference
  137368. */
  137369. setDefaultQueryExtent(extent: Vector3): void;
  137370. /**
  137371. * Get the Bounding box extent specified by setDefaultQueryExtent
  137372. * @returns the box extent values
  137373. */
  137374. getDefaultQueryExtent(): Vector3;
  137375. /**
  137376. * Get the Bounding box extent result specified by setDefaultQueryExtent
  137377. * @param result output the box extent values
  137378. */
  137379. getDefaultQueryExtentToRef(result: Vector3): void;
  137380. /**
  137381. * Release all resources
  137382. */
  137383. dispose(): void;
  137384. }
  137385. /**
  137386. * Configures an agent
  137387. */
  137388. export interface IAgentParameters {
  137389. /**
  137390. * Agent radius. [Limit: >= 0]
  137391. */
  137392. radius: number;
  137393. /**
  137394. * Agent height. [Limit: > 0]
  137395. */
  137396. height: number;
  137397. /**
  137398. * Maximum allowed acceleration. [Limit: >= 0]
  137399. */
  137400. maxAcceleration: number;
  137401. /**
  137402. * Maximum allowed speed. [Limit: >= 0]
  137403. */
  137404. maxSpeed: number;
  137405. /**
  137406. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  137407. */
  137408. collisionQueryRange: number;
  137409. /**
  137410. * The path visibility optimization range. [Limit: > 0]
  137411. */
  137412. pathOptimizationRange: number;
  137413. /**
  137414. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  137415. */
  137416. separationWeight: number;
  137417. }
  137418. /**
  137419. * Configures the navigation mesh creation
  137420. */
  137421. export interface INavMeshParameters {
  137422. /**
  137423. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  137424. */
  137425. cs: number;
  137426. /**
  137427. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  137428. */
  137429. ch: number;
  137430. /**
  137431. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  137432. */
  137433. walkableSlopeAngle: number;
  137434. /**
  137435. * Minimum floor to 'ceiling' height that will still allow the floor area to
  137436. * be considered walkable. [Limit: >= 3] [Units: vx]
  137437. */
  137438. walkableHeight: number;
  137439. /**
  137440. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  137441. */
  137442. walkableClimb: number;
  137443. /**
  137444. * The distance to erode/shrink the walkable area of the heightfield away from
  137445. * obstructions. [Limit: >=0] [Units: vx]
  137446. */
  137447. walkableRadius: number;
  137448. /**
  137449. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  137450. */
  137451. maxEdgeLen: number;
  137452. /**
  137453. * The maximum distance a simplfied contour's border edges should deviate
  137454. * the original raw contour. [Limit: >=0] [Units: vx]
  137455. */
  137456. maxSimplificationError: number;
  137457. /**
  137458. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  137459. */
  137460. minRegionArea: number;
  137461. /**
  137462. * Any regions with a span count smaller than this value will, if possible,
  137463. * be merged with larger regions. [Limit: >=0] [Units: vx]
  137464. */
  137465. mergeRegionArea: number;
  137466. /**
  137467. * The maximum number of vertices allowed for polygons generated during the
  137468. * contour to polygon conversion process. [Limit: >= 3]
  137469. */
  137470. maxVertsPerPoly: number;
  137471. /**
  137472. * Sets the sampling distance to use when generating the detail mesh.
  137473. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  137474. */
  137475. detailSampleDist: number;
  137476. /**
  137477. * The maximum distance the detail mesh surface should deviate from heightfield
  137478. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  137479. */
  137480. detailSampleMaxError: number;
  137481. }
  137482. }
  137483. declare module BABYLON {
  137484. /**
  137485. * RecastJS navigation plugin
  137486. */
  137487. export class RecastJSPlugin implements INavigationEnginePlugin {
  137488. /**
  137489. * Reference to the Recast library
  137490. */
  137491. bjsRECAST: any;
  137492. /**
  137493. * plugin name
  137494. */
  137495. name: string;
  137496. /**
  137497. * the first navmesh created. We might extend this to support multiple navmeshes
  137498. */
  137499. navMesh: any;
  137500. /**
  137501. * Initializes the recastJS plugin
  137502. * @param recastInjection can be used to inject your own recast reference
  137503. */
  137504. constructor(recastInjection?: any);
  137505. /**
  137506. * Creates a navigation mesh
  137507. * @param meshes array of all the geometry used to compute the navigatio mesh
  137508. * @param parameters bunch of parameters used to filter geometry
  137509. */
  137510. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  137511. /**
  137512. * Create a navigation mesh debug mesh
  137513. * @param scene is where the mesh will be added
  137514. * @returns debug display mesh
  137515. */
  137516. createDebugNavMesh(scene: Scene): Mesh;
  137517. /**
  137518. * Get a navigation mesh constrained position, closest to the parameter position
  137519. * @param position world position
  137520. * @returns the closest point to position constrained by the navigation mesh
  137521. */
  137522. getClosestPoint(position: Vector3): Vector3;
  137523. /**
  137524. * Get a navigation mesh constrained position, closest to the parameter position
  137525. * @param position world position
  137526. * @param result output the closest point to position constrained by the navigation mesh
  137527. */
  137528. getClosestPointToRef(position: Vector3, result: Vector3): void;
  137529. /**
  137530. * Get a navigation mesh constrained position, within a particular radius
  137531. * @param position world position
  137532. * @param maxRadius the maximum distance to the constrained world position
  137533. * @returns the closest point to position constrained by the navigation mesh
  137534. */
  137535. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  137536. /**
  137537. * Get a navigation mesh constrained position, within a particular radius
  137538. * @param position world position
  137539. * @param maxRadius the maximum distance to the constrained world position
  137540. * @param result output the closest point to position constrained by the navigation mesh
  137541. */
  137542. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  137543. /**
  137544. * Compute the final position from a segment made of destination-position
  137545. * @param position world position
  137546. * @param destination world position
  137547. * @returns the resulting point along the navmesh
  137548. */
  137549. moveAlong(position: Vector3, destination: Vector3): Vector3;
  137550. /**
  137551. * Compute the final position from a segment made of destination-position
  137552. * @param position world position
  137553. * @param destination world position
  137554. * @param result output the resulting point along the navmesh
  137555. */
  137556. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  137557. /**
  137558. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  137559. * @param start world position
  137560. * @param end world position
  137561. * @returns array containing world position composing the path
  137562. */
  137563. computePath(start: Vector3, end: Vector3): Vector3[];
  137564. /**
  137565. * Create a new Crowd so you can add agents
  137566. * @param maxAgents the maximum agent count in the crowd
  137567. * @param maxAgentRadius the maximum radius an agent can have
  137568. * @param scene to attach the crowd to
  137569. * @returns the crowd you can add agents to
  137570. */
  137571. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  137572. /**
  137573. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  137574. * The queries will try to find a solution within those bounds
  137575. * default is (1,1,1)
  137576. * @param extent x,y,z value that define the extent around the queries point of reference
  137577. */
  137578. setDefaultQueryExtent(extent: Vector3): void;
  137579. /**
  137580. * Get the Bounding box extent specified by setDefaultQueryExtent
  137581. * @returns the box extent values
  137582. */
  137583. getDefaultQueryExtent(): Vector3;
  137584. /**
  137585. * build the navmesh from a previously saved state using getNavmeshData
  137586. * @param data the Uint8Array returned by getNavmeshData
  137587. */
  137588. buildFromNavmeshData(data: Uint8Array): void;
  137589. /**
  137590. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  137591. * @returns data the Uint8Array that can be saved and reused
  137592. */
  137593. getNavmeshData(): Uint8Array;
  137594. /**
  137595. * Get the Bounding box extent result specified by setDefaultQueryExtent
  137596. * @param result output the box extent values
  137597. */
  137598. getDefaultQueryExtentToRef(result: Vector3): void;
  137599. /**
  137600. * Disposes
  137601. */
  137602. dispose(): void;
  137603. /**
  137604. * If this plugin is supported
  137605. * @returns true if plugin is supported
  137606. */
  137607. isSupported(): boolean;
  137608. }
  137609. /**
  137610. * Recast detour crowd implementation
  137611. */
  137612. export class RecastJSCrowd implements ICrowd {
  137613. /**
  137614. * Recast/detour plugin
  137615. */
  137616. bjsRECASTPlugin: RecastJSPlugin;
  137617. /**
  137618. * Link to the detour crowd
  137619. */
  137620. recastCrowd: any;
  137621. /**
  137622. * One transform per agent
  137623. */
  137624. transforms: TransformNode[];
  137625. /**
  137626. * All agents created
  137627. */
  137628. agents: number[];
  137629. /**
  137630. * Link to the scene is kept to unregister the crowd from the scene
  137631. */
  137632. private _scene;
  137633. /**
  137634. * Observer for crowd updates
  137635. */
  137636. private _onBeforeAnimationsObserver;
  137637. /**
  137638. * Constructor
  137639. * @param plugin recastJS plugin
  137640. * @param maxAgents the maximum agent count in the crowd
  137641. * @param maxAgentRadius the maximum radius an agent can have
  137642. * @param scene to attach the crowd to
  137643. * @returns the crowd you can add agents to
  137644. */
  137645. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  137646. /**
  137647. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  137648. * You can attach anything to that node. The node position is updated in the scene update tick.
  137649. * @param pos world position that will be constrained by the navigation mesh
  137650. * @param parameters agent parameters
  137651. * @param transform hooked to the agent that will be update by the scene
  137652. * @returns agent index
  137653. */
  137654. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  137655. /**
  137656. * Returns the agent position in world space
  137657. * @param index agent index returned by addAgent
  137658. * @returns world space position
  137659. */
  137660. getAgentPosition(index: number): Vector3;
  137661. /**
  137662. * Returns the agent position result in world space
  137663. * @param index agent index returned by addAgent
  137664. * @param result output world space position
  137665. */
  137666. getAgentPositionToRef(index: number, result: Vector3): void;
  137667. /**
  137668. * Returns the agent velocity in world space
  137669. * @param index agent index returned by addAgent
  137670. * @returns world space velocity
  137671. */
  137672. getAgentVelocity(index: number): Vector3;
  137673. /**
  137674. * Returns the agent velocity result in world space
  137675. * @param index agent index returned by addAgent
  137676. * @param result output world space velocity
  137677. */
  137678. getAgentVelocityToRef(index: number, result: Vector3): void;
  137679. /**
  137680. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  137681. * @param index agent index returned by addAgent
  137682. * @param destination targeted world position
  137683. */
  137684. agentGoto(index: number, destination: Vector3): void;
  137685. /**
  137686. * Teleport the agent to a new position
  137687. * @param index agent index returned by addAgent
  137688. * @param destination targeted world position
  137689. */
  137690. agentTeleport(index: number, destination: Vector3): void;
  137691. /**
  137692. * Update agent parameters
  137693. * @param index agent index returned by addAgent
  137694. * @param parameters agent parameters
  137695. */
  137696. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  137697. /**
  137698. * remove a particular agent previously created
  137699. * @param index agent index returned by addAgent
  137700. */
  137701. removeAgent(index: number): void;
  137702. /**
  137703. * get the list of all agents attached to this crowd
  137704. * @returns list of agent indices
  137705. */
  137706. getAgents(): number[];
  137707. /**
  137708. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  137709. * @param deltaTime in seconds
  137710. */
  137711. update(deltaTime: number): void;
  137712. /**
  137713. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  137714. * The queries will try to find a solution within those bounds
  137715. * default is (1,1,1)
  137716. * @param extent x,y,z value that define the extent around the queries point of reference
  137717. */
  137718. setDefaultQueryExtent(extent: Vector3): void;
  137719. /**
  137720. * Get the Bounding box extent specified by setDefaultQueryExtent
  137721. * @returns the box extent values
  137722. */
  137723. getDefaultQueryExtent(): Vector3;
  137724. /**
  137725. * Get the Bounding box extent result specified by setDefaultQueryExtent
  137726. * @param result output the box extent values
  137727. */
  137728. getDefaultQueryExtentToRef(result: Vector3): void;
  137729. /**
  137730. * Release all resources
  137731. */
  137732. dispose(): void;
  137733. }
  137734. }
  137735. declare module BABYLON {
  137736. /**
  137737. * Class used to enable access to IndexedDB
  137738. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  137739. */
  137740. export class Database implements IOfflineProvider {
  137741. private _callbackManifestChecked;
  137742. private _currentSceneUrl;
  137743. private _db;
  137744. private _enableSceneOffline;
  137745. private _enableTexturesOffline;
  137746. private _manifestVersionFound;
  137747. private _mustUpdateRessources;
  137748. private _hasReachedQuota;
  137749. private _isSupported;
  137750. private _idbFactory;
  137751. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  137752. private static IsUASupportingBlobStorage;
  137753. /**
  137754. * Gets a boolean indicating if Database storate is enabled (off by default)
  137755. */
  137756. static IDBStorageEnabled: boolean;
  137757. /**
  137758. * Gets a boolean indicating if scene must be saved in the database
  137759. */
  137760. get enableSceneOffline(): boolean;
  137761. /**
  137762. * Gets a boolean indicating if textures must be saved in the database
  137763. */
  137764. get enableTexturesOffline(): boolean;
  137765. /**
  137766. * Creates a new Database
  137767. * @param urlToScene defines the url to load the scene
  137768. * @param callbackManifestChecked defines the callback to use when manifest is checked
  137769. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  137770. */
  137771. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  137772. private static _ParseURL;
  137773. private static _ReturnFullUrlLocation;
  137774. private _checkManifestFile;
  137775. /**
  137776. * Open the database and make it available
  137777. * @param successCallback defines the callback to call on success
  137778. * @param errorCallback defines the callback to call on error
  137779. */
  137780. open(successCallback: () => void, errorCallback: () => void): void;
  137781. /**
  137782. * Loads an image from the database
  137783. * @param url defines the url to load from
  137784. * @param image defines the target DOM image
  137785. */
  137786. loadImage(url: string, image: HTMLImageElement): void;
  137787. private _loadImageFromDBAsync;
  137788. private _saveImageIntoDBAsync;
  137789. private _checkVersionFromDB;
  137790. private _loadVersionFromDBAsync;
  137791. private _saveVersionIntoDBAsync;
  137792. /**
  137793. * Loads a file from database
  137794. * @param url defines the URL to load from
  137795. * @param sceneLoaded defines a callback to call on success
  137796. * @param progressCallBack defines a callback to call when progress changed
  137797. * @param errorCallback defines a callback to call on error
  137798. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  137799. */
  137800. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  137801. private _loadFileAsync;
  137802. private _saveFileAsync;
  137803. /**
  137804. * Validates if xhr data is correct
  137805. * @param xhr defines the request to validate
  137806. * @param dataType defines the expected data type
  137807. * @returns true if data is correct
  137808. */
  137809. private static _ValidateXHRData;
  137810. }
  137811. }
  137812. declare module BABYLON {
  137813. /** @hidden */
  137814. export var gpuUpdateParticlesPixelShader: {
  137815. name: string;
  137816. shader: string;
  137817. };
  137818. }
  137819. declare module BABYLON {
  137820. /** @hidden */
  137821. export var gpuUpdateParticlesVertexShader: {
  137822. name: string;
  137823. shader: string;
  137824. };
  137825. }
  137826. declare module BABYLON {
  137827. /** @hidden */
  137828. export var clipPlaneFragmentDeclaration2: {
  137829. name: string;
  137830. shader: string;
  137831. };
  137832. }
  137833. declare module BABYLON {
  137834. /** @hidden */
  137835. export var gpuRenderParticlesPixelShader: {
  137836. name: string;
  137837. shader: string;
  137838. };
  137839. }
  137840. declare module BABYLON {
  137841. /** @hidden */
  137842. export var clipPlaneVertexDeclaration2: {
  137843. name: string;
  137844. shader: string;
  137845. };
  137846. }
  137847. declare module BABYLON {
  137848. /** @hidden */
  137849. export var gpuRenderParticlesVertexShader: {
  137850. name: string;
  137851. shader: string;
  137852. };
  137853. }
  137854. declare module BABYLON {
  137855. /**
  137856. * This represents a GPU particle system in Babylon
  137857. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  137858. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  137859. */
  137860. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  137861. /**
  137862. * The layer mask we are rendering the particles through.
  137863. */
  137864. layerMask: number;
  137865. private _capacity;
  137866. private _activeCount;
  137867. private _currentActiveCount;
  137868. private _accumulatedCount;
  137869. private _renderEffect;
  137870. private _updateEffect;
  137871. private _buffer0;
  137872. private _buffer1;
  137873. private _spriteBuffer;
  137874. private _updateVAO;
  137875. private _renderVAO;
  137876. private _targetIndex;
  137877. private _sourceBuffer;
  137878. private _targetBuffer;
  137879. private _engine;
  137880. private _currentRenderId;
  137881. private _started;
  137882. private _stopped;
  137883. private _timeDelta;
  137884. private _randomTexture;
  137885. private _randomTexture2;
  137886. private _attributesStrideSize;
  137887. private _updateEffectOptions;
  137888. private _randomTextureSize;
  137889. private _actualFrame;
  137890. private readonly _rawTextureWidth;
  137891. /**
  137892. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  137893. */
  137894. static get IsSupported(): boolean;
  137895. /**
  137896. * An event triggered when the system is disposed.
  137897. */
  137898. onDisposeObservable: Observable<GPUParticleSystem>;
  137899. /**
  137900. * Gets the maximum number of particles active at the same time.
  137901. * @returns The max number of active particles.
  137902. */
  137903. getCapacity(): number;
  137904. /**
  137905. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  137906. * to override the particles.
  137907. */
  137908. forceDepthWrite: boolean;
  137909. /**
  137910. * Gets or set the number of active particles
  137911. */
  137912. get activeParticleCount(): number;
  137913. set activeParticleCount(value: number);
  137914. private _preWarmDone;
  137915. /**
  137916. * Specifies if the particles are updated in emitter local space or world space.
  137917. * This is always false for GPU particles
  137918. */
  137919. get isLocal(): boolean;
  137920. set isLocal(value: boolean);
  137921. /**
  137922. * Is this system ready to be used/rendered
  137923. * @return true if the system is ready
  137924. */
  137925. isReady(): boolean;
  137926. /**
  137927. * Gets if the system has been started. (Note: this will still be true after stop is called)
  137928. * @returns True if it has been started, otherwise false.
  137929. */
  137930. isStarted(): boolean;
  137931. /**
  137932. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  137933. * @returns True if it has been stopped, otherwise false.
  137934. */
  137935. isStopped(): boolean;
  137936. /**
  137937. * Gets a boolean indicating that the system is stopping
  137938. * @returns true if the system is currently stopping
  137939. */
  137940. isStopping(): boolean;
  137941. /**
  137942. * Gets the number of particles active at the same time.
  137943. * @returns The number of active particles.
  137944. */
  137945. getActiveCount(): number;
  137946. /**
  137947. * Starts the particle system and begins to emit
  137948. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  137949. */
  137950. start(delay?: number): void;
  137951. /**
  137952. * Stops the particle system.
  137953. */
  137954. stop(): void;
  137955. /**
  137956. * Remove all active particles
  137957. */
  137958. reset(): void;
  137959. /**
  137960. * Returns the string "GPUParticleSystem"
  137961. * @returns a string containing the class name
  137962. */
  137963. getClassName(): string;
  137964. private _colorGradientsTexture;
  137965. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  137966. /**
  137967. * Adds a new color gradient
  137968. * @param gradient defines the gradient to use (between 0 and 1)
  137969. * @param color1 defines the color to affect to the specified gradient
  137970. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  137971. * @returns the current particle system
  137972. */
  137973. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  137974. private _refreshColorGradient;
  137975. /** Force the system to rebuild all gradients that need to be resync */
  137976. forceRefreshGradients(): void;
  137977. /**
  137978. * Remove a specific color gradient
  137979. * @param gradient defines the gradient to remove
  137980. * @returns the current particle system
  137981. */
  137982. removeColorGradient(gradient: number): GPUParticleSystem;
  137983. private _angularSpeedGradientsTexture;
  137984. private _sizeGradientsTexture;
  137985. private _velocityGradientsTexture;
  137986. private _limitVelocityGradientsTexture;
  137987. private _dragGradientsTexture;
  137988. private _addFactorGradient;
  137989. /**
  137990. * Adds a new size gradient
  137991. * @param gradient defines the gradient to use (between 0 and 1)
  137992. * @param factor defines the size factor to affect to the specified gradient
  137993. * @returns the current particle system
  137994. */
  137995. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  137996. /**
  137997. * Remove a specific size gradient
  137998. * @param gradient defines the gradient to remove
  137999. * @returns the current particle system
  138000. */
  138001. removeSizeGradient(gradient: number): GPUParticleSystem;
  138002. private _refreshFactorGradient;
  138003. /**
  138004. * Adds a new angular speed gradient
  138005. * @param gradient defines the gradient to use (between 0 and 1)
  138006. * @param factor defines the angular speed to affect to the specified gradient
  138007. * @returns the current particle system
  138008. */
  138009. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  138010. /**
  138011. * Remove a specific angular speed gradient
  138012. * @param gradient defines the gradient to remove
  138013. * @returns the current particle system
  138014. */
  138015. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  138016. /**
  138017. * Adds a new velocity gradient
  138018. * @param gradient defines the gradient to use (between 0 and 1)
  138019. * @param factor defines the velocity to affect to the specified gradient
  138020. * @returns the current particle system
  138021. */
  138022. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  138023. /**
  138024. * Remove a specific velocity gradient
  138025. * @param gradient defines the gradient to remove
  138026. * @returns the current particle system
  138027. */
  138028. removeVelocityGradient(gradient: number): GPUParticleSystem;
  138029. /**
  138030. * Adds a new limit velocity gradient
  138031. * @param gradient defines the gradient to use (between 0 and 1)
  138032. * @param factor defines the limit velocity value to affect to the specified gradient
  138033. * @returns the current particle system
  138034. */
  138035. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  138036. /**
  138037. * Remove a specific limit velocity gradient
  138038. * @param gradient defines the gradient to remove
  138039. * @returns the current particle system
  138040. */
  138041. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  138042. /**
  138043. * Adds a new drag gradient
  138044. * @param gradient defines the gradient to use (between 0 and 1)
  138045. * @param factor defines the drag value to affect to the specified gradient
  138046. * @returns the current particle system
  138047. */
  138048. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  138049. /**
  138050. * Remove a specific drag gradient
  138051. * @param gradient defines the gradient to remove
  138052. * @returns the current particle system
  138053. */
  138054. removeDragGradient(gradient: number): GPUParticleSystem;
  138055. /**
  138056. * Not supported by GPUParticleSystem
  138057. * @param gradient defines the gradient to use (between 0 and 1)
  138058. * @param factor defines the emit rate value to affect to the specified gradient
  138059. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  138060. * @returns the current particle system
  138061. */
  138062. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  138063. /**
  138064. * Not supported by GPUParticleSystem
  138065. * @param gradient defines the gradient to remove
  138066. * @returns the current particle system
  138067. */
  138068. removeEmitRateGradient(gradient: number): IParticleSystem;
  138069. /**
  138070. * Not supported by GPUParticleSystem
  138071. * @param gradient defines the gradient to use (between 0 and 1)
  138072. * @param factor defines the start size value to affect to the specified gradient
  138073. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  138074. * @returns the current particle system
  138075. */
  138076. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  138077. /**
  138078. * Not supported by GPUParticleSystem
  138079. * @param gradient defines the gradient to remove
  138080. * @returns the current particle system
  138081. */
  138082. removeStartSizeGradient(gradient: number): IParticleSystem;
  138083. /**
  138084. * Not supported by GPUParticleSystem
  138085. * @param gradient defines the gradient to use (between 0 and 1)
  138086. * @param min defines the color remap minimal range
  138087. * @param max defines the color remap maximal range
  138088. * @returns the current particle system
  138089. */
  138090. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  138091. /**
  138092. * Not supported by GPUParticleSystem
  138093. * @param gradient defines the gradient to remove
  138094. * @returns the current particle system
  138095. */
  138096. removeColorRemapGradient(): IParticleSystem;
  138097. /**
  138098. * Not supported by GPUParticleSystem
  138099. * @param gradient defines the gradient to use (between 0 and 1)
  138100. * @param min defines the alpha remap minimal range
  138101. * @param max defines the alpha remap maximal range
  138102. * @returns the current particle system
  138103. */
  138104. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  138105. /**
  138106. * Not supported by GPUParticleSystem
  138107. * @param gradient defines the gradient to remove
  138108. * @returns the current particle system
  138109. */
  138110. removeAlphaRemapGradient(): IParticleSystem;
  138111. /**
  138112. * Not supported by GPUParticleSystem
  138113. * @param gradient defines the gradient to use (between 0 and 1)
  138114. * @param color defines the color to affect to the specified gradient
  138115. * @returns the current particle system
  138116. */
  138117. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  138118. /**
  138119. * Not supported by GPUParticleSystem
  138120. * @param gradient defines the gradient to remove
  138121. * @returns the current particle system
  138122. */
  138123. removeRampGradient(): IParticleSystem;
  138124. /**
  138125. * Not supported by GPUParticleSystem
  138126. * @returns the list of ramp gradients
  138127. */
  138128. getRampGradients(): Nullable<Array<Color3Gradient>>;
  138129. /**
  138130. * Not supported by GPUParticleSystem
  138131. * Gets or sets a boolean indicating that ramp gradients must be used
  138132. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  138133. */
  138134. get useRampGradients(): boolean;
  138135. set useRampGradients(value: boolean);
  138136. /**
  138137. * Not supported by GPUParticleSystem
  138138. * @param gradient defines the gradient to use (between 0 and 1)
  138139. * @param factor defines the life time factor to affect to the specified gradient
  138140. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  138141. * @returns the current particle system
  138142. */
  138143. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  138144. /**
  138145. * Not supported by GPUParticleSystem
  138146. * @param gradient defines the gradient to remove
  138147. * @returns the current particle system
  138148. */
  138149. removeLifeTimeGradient(gradient: number): IParticleSystem;
  138150. /**
  138151. * Instantiates a GPU particle system.
  138152. * 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.
  138153. * @param name The name of the particle system
  138154. * @param options The options used to create the system
  138155. * @param scene The scene the particle system belongs to
  138156. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  138157. */
  138158. constructor(name: string, options: Partial<{
  138159. capacity: number;
  138160. randomTextureSize: number;
  138161. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  138162. protected _reset(): void;
  138163. private _createUpdateVAO;
  138164. private _createRenderVAO;
  138165. private _initialize;
  138166. /** @hidden */
  138167. _recreateUpdateEffect(): void;
  138168. /** @hidden */
  138169. _recreateRenderEffect(): void;
  138170. /**
  138171. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  138172. * @param preWarm defines if we are in the pre-warmimg phase
  138173. */
  138174. animate(preWarm?: boolean): void;
  138175. private _createFactorGradientTexture;
  138176. private _createSizeGradientTexture;
  138177. private _createAngularSpeedGradientTexture;
  138178. private _createVelocityGradientTexture;
  138179. private _createLimitVelocityGradientTexture;
  138180. private _createDragGradientTexture;
  138181. private _createColorGradientTexture;
  138182. /**
  138183. * Renders the particle system in its current state
  138184. * @param preWarm defines if the system should only update the particles but not render them
  138185. * @returns the current number of particles
  138186. */
  138187. render(preWarm?: boolean): number;
  138188. /**
  138189. * Rebuilds the particle system
  138190. */
  138191. rebuild(): void;
  138192. private _releaseBuffers;
  138193. private _releaseVAOs;
  138194. /**
  138195. * Disposes the particle system and free the associated resources
  138196. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  138197. */
  138198. dispose(disposeTexture?: boolean): void;
  138199. /**
  138200. * Clones the particle system.
  138201. * @param name The name of the cloned object
  138202. * @param newEmitter The new emitter to use
  138203. * @returns the cloned particle system
  138204. */
  138205. clone(name: string, newEmitter: any): GPUParticleSystem;
  138206. /**
  138207. * Serializes the particle system to a JSON object
  138208. * @param serializeTexture defines if the texture must be serialized as well
  138209. * @returns the JSON object
  138210. */
  138211. serialize(serializeTexture?: boolean): any;
  138212. /**
  138213. * Parses a JSON object to create a GPU particle system.
  138214. * @param parsedParticleSystem The JSON object to parse
  138215. * @param scene The scene to create the particle system in
  138216. * @param rootUrl The root url to use to load external dependencies like texture
  138217. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  138218. * @returns the parsed GPU particle system
  138219. */
  138220. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  138221. }
  138222. }
  138223. declare module BABYLON {
  138224. /**
  138225. * Represents a set of particle systems working together to create a specific effect
  138226. */
  138227. export class ParticleSystemSet implements IDisposable {
  138228. /**
  138229. * Gets or sets base Assets URL
  138230. */
  138231. static BaseAssetsUrl: string;
  138232. private _emitterCreationOptions;
  138233. private _emitterNode;
  138234. /**
  138235. * Gets the particle system list
  138236. */
  138237. systems: IParticleSystem[];
  138238. /**
  138239. * Gets the emitter node used with this set
  138240. */
  138241. get emitterNode(): Nullable<TransformNode>;
  138242. /**
  138243. * Creates a new emitter mesh as a sphere
  138244. * @param options defines the options used to create the sphere
  138245. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  138246. * @param scene defines the hosting scene
  138247. */
  138248. setEmitterAsSphere(options: {
  138249. diameter: number;
  138250. segments: number;
  138251. color: Color3;
  138252. }, renderingGroupId: number, scene: Scene): void;
  138253. /**
  138254. * Starts all particle systems of the set
  138255. * @param emitter defines an optional mesh to use as emitter for the particle systems
  138256. */
  138257. start(emitter?: AbstractMesh): void;
  138258. /**
  138259. * Release all associated resources
  138260. */
  138261. dispose(): void;
  138262. /**
  138263. * Serialize the set into a JSON compatible object
  138264. * @param serializeTexture defines if the texture must be serialized as well
  138265. * @returns a JSON compatible representation of the set
  138266. */
  138267. serialize(serializeTexture?: boolean): any;
  138268. /**
  138269. * Parse a new ParticleSystemSet from a serialized source
  138270. * @param data defines a JSON compatible representation of the set
  138271. * @param scene defines the hosting scene
  138272. * @param gpu defines if we want GPU particles or CPU particles
  138273. * @returns a new ParticleSystemSet
  138274. */
  138275. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  138276. }
  138277. }
  138278. declare module BABYLON {
  138279. /**
  138280. * This class is made for on one-liner static method to help creating particle system set.
  138281. */
  138282. export class ParticleHelper {
  138283. /**
  138284. * Gets or sets base Assets URL
  138285. */
  138286. static BaseAssetsUrl: string;
  138287. /** Define the Url to load snippets */
  138288. static SnippetUrl: string;
  138289. /**
  138290. * Create a default particle system that you can tweak
  138291. * @param emitter defines the emitter to use
  138292. * @param capacity defines the system capacity (default is 500 particles)
  138293. * @param scene defines the hosting scene
  138294. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  138295. * @returns the new Particle system
  138296. */
  138297. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  138298. /**
  138299. * This is the main static method (one-liner) of this helper to create different particle systems
  138300. * @param type This string represents the type to the particle system to create
  138301. * @param scene The scene where the particle system should live
  138302. * @param gpu If the system will use gpu
  138303. * @returns the ParticleSystemSet created
  138304. */
  138305. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  138306. /**
  138307. * Static function used to export a particle system to a ParticleSystemSet variable.
  138308. * Please note that the emitter shape is not exported
  138309. * @param systems defines the particle systems to export
  138310. * @returns the created particle system set
  138311. */
  138312. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  138313. /**
  138314. * Creates a particle system from a snippet saved in a remote file
  138315. * @param name defines the name of the particle system to create
  138316. * @param url defines the url to load from
  138317. * @param scene defines the hosting scene
  138318. * @param gpu If the system will use gpu
  138319. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  138320. * @returns a promise that will resolve to the new particle system
  138321. */
  138322. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  138323. /**
  138324. * Creates a particle system from a snippet saved by the particle system editor
  138325. * @param snippetId defines the snippet to load
  138326. * @param scene defines the hosting scene
  138327. * @param gpu If the system will use gpu
  138328. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  138329. * @returns a promise that will resolve to the new particle system
  138330. */
  138331. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  138332. }
  138333. }
  138334. declare module BABYLON {
  138335. interface Engine {
  138336. /**
  138337. * Create an effect to use with particle systems.
  138338. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  138339. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  138340. * @param uniformsNames defines a list of attribute names
  138341. * @param samplers defines an array of string used to represent textures
  138342. * @param defines defines the string containing the defines to use to compile the shaders
  138343. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  138344. * @param onCompiled defines a function to call when the effect creation is successful
  138345. * @param onError defines a function to call when the effect creation has failed
  138346. * @returns the new Effect
  138347. */
  138348. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  138349. }
  138350. interface Mesh {
  138351. /**
  138352. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  138353. * @returns an array of IParticleSystem
  138354. */
  138355. getEmittedParticleSystems(): IParticleSystem[];
  138356. /**
  138357. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  138358. * @returns an array of IParticleSystem
  138359. */
  138360. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  138361. }
  138362. /**
  138363. * @hidden
  138364. */
  138365. export var _IDoNeedToBeInTheBuild: number;
  138366. }
  138367. declare module BABYLON {
  138368. /** Defines the 4 color options */
  138369. export enum PointColor {
  138370. /** color value */
  138371. Color = 2,
  138372. /** uv value */
  138373. UV = 1,
  138374. /** random value */
  138375. Random = 0,
  138376. /** stated value */
  138377. Stated = 3
  138378. }
  138379. /**
  138380. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  138381. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  138382. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  138383. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  138384. *
  138385. * Full documentation here : TO BE ENTERED
  138386. */
  138387. export class PointsCloudSystem implements IDisposable {
  138388. /**
  138389. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  138390. * Example : var p = SPS.particles[i];
  138391. */
  138392. particles: CloudPoint[];
  138393. /**
  138394. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  138395. */
  138396. nbParticles: number;
  138397. /**
  138398. * This a counter for your own usage. It's not set by any SPS functions.
  138399. */
  138400. counter: number;
  138401. /**
  138402. * The PCS name. This name is also given to the underlying mesh.
  138403. */
  138404. name: string;
  138405. /**
  138406. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  138407. */
  138408. mesh: Mesh;
  138409. /**
  138410. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  138411. * Please read :
  138412. */
  138413. vars: any;
  138414. /**
  138415. * @hidden
  138416. */
  138417. _size: number;
  138418. private _scene;
  138419. private _promises;
  138420. private _positions;
  138421. private _indices;
  138422. private _normals;
  138423. private _colors;
  138424. private _uvs;
  138425. private _indices32;
  138426. private _positions32;
  138427. private _colors32;
  138428. private _uvs32;
  138429. private _updatable;
  138430. private _isVisibilityBoxLocked;
  138431. private _alwaysVisible;
  138432. private _groups;
  138433. private _groupCounter;
  138434. private _computeParticleColor;
  138435. private _computeParticleTexture;
  138436. private _computeParticleRotation;
  138437. private _computeBoundingBox;
  138438. private _isReady;
  138439. /**
  138440. * Creates a PCS (Points Cloud System) object
  138441. * @param name (String) is the PCS name, this will be the underlying mesh name
  138442. * @param pointSize (number) is the size for each point
  138443. * @param scene (Scene) is the scene in which the PCS is added
  138444. * @param options defines the options of the PCS e.g.
  138445. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  138446. */
  138447. constructor(name: string, pointSize: number, scene: Scene, options?: {
  138448. updatable?: boolean;
  138449. });
  138450. /**
  138451. * Builds the PCS underlying mesh. Returns a standard Mesh.
  138452. * If no points were added to the PCS, the returned mesh is just a single point.
  138453. * @returns a promise for the created mesh
  138454. */
  138455. buildMeshAsync(): Promise<Mesh>;
  138456. /**
  138457. * @hidden
  138458. */
  138459. private _buildMesh;
  138460. private _addParticle;
  138461. private _randomUnitVector;
  138462. private _getColorIndicesForCoord;
  138463. private _setPointsColorOrUV;
  138464. private _colorFromTexture;
  138465. private _calculateDensity;
  138466. /**
  138467. * Adds points to the PCS in random positions within a unit sphere
  138468. * @param nb (positive integer) the number of particles to be created from this model
  138469. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  138470. * @returns the number of groups in the system
  138471. */
  138472. addPoints(nb: number, pointFunction?: any): number;
  138473. /**
  138474. * Adds points to the PCS from the surface of the model shape
  138475. * @param mesh is any Mesh object that will be used as a surface model for the points
  138476. * @param nb (positive integer) the number of particles to be created from this model
  138477. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  138478. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  138479. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  138480. * @returns the number of groups in the system
  138481. */
  138482. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  138483. /**
  138484. * Adds points to the PCS inside the model shape
  138485. * @param mesh is any Mesh object that will be used as a surface model for the points
  138486. * @param nb (positive integer) the number of particles to be created from this model
  138487. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  138488. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  138489. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  138490. * @returns the number of groups in the system
  138491. */
  138492. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  138493. /**
  138494. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  138495. * This method calls `updateParticle()` for each particle of the SPS.
  138496. * For an animated SPS, it is usually called within the render loop.
  138497. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  138498. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  138499. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  138500. * @returns the PCS.
  138501. */
  138502. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  138503. /**
  138504. * Disposes the PCS.
  138505. */
  138506. dispose(): void;
  138507. /**
  138508. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  138509. * doc :
  138510. * @returns the PCS.
  138511. */
  138512. refreshVisibleSize(): PointsCloudSystem;
  138513. /**
  138514. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  138515. * @param size the size (float) of the visibility box
  138516. * note : this doesn't lock the PCS mesh bounding box.
  138517. * doc :
  138518. */
  138519. setVisibilityBox(size: number): void;
  138520. /**
  138521. * Gets whether the PCS is always visible or not
  138522. * doc :
  138523. */
  138524. get isAlwaysVisible(): boolean;
  138525. /**
  138526. * Sets the PCS as always visible or not
  138527. * doc :
  138528. */
  138529. set isAlwaysVisible(val: boolean);
  138530. /**
  138531. * Tells to `setParticles()` to compute the particle rotations or not
  138532. * Default value : false. The PCS is faster when it's set to false
  138533. * Note : particle rotations are only applied to parent particles
  138534. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  138535. */
  138536. set computeParticleRotation(val: boolean);
  138537. /**
  138538. * Tells to `setParticles()` to compute the particle colors or not.
  138539. * Default value : true. The PCS is faster when it's set to false.
  138540. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  138541. */
  138542. set computeParticleColor(val: boolean);
  138543. set computeParticleTexture(val: boolean);
  138544. /**
  138545. * Gets if `setParticles()` computes the particle colors or not.
  138546. * Default value : false. The PCS is faster when it's set to false.
  138547. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  138548. */
  138549. get computeParticleColor(): boolean;
  138550. /**
  138551. * Gets if `setParticles()` computes the particle textures or not.
  138552. * Default value : false. The PCS is faster when it's set to false.
  138553. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  138554. */
  138555. get computeParticleTexture(): boolean;
  138556. /**
  138557. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  138558. */
  138559. set computeBoundingBox(val: boolean);
  138560. /**
  138561. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  138562. */
  138563. get computeBoundingBox(): boolean;
  138564. /**
  138565. * This function does nothing. It may be overwritten to set all the particle first values.
  138566. * The PCS doesn't call this function, you may have to call it by your own.
  138567. * doc :
  138568. */
  138569. initParticles(): void;
  138570. /**
  138571. * This function does nothing. It may be overwritten to recycle a particle
  138572. * The PCS doesn't call this function, you can to call it
  138573. * doc :
  138574. * @param particle The particle to recycle
  138575. * @returns the recycled particle
  138576. */
  138577. recycleParticle(particle: CloudPoint): CloudPoint;
  138578. /**
  138579. * Updates a particle : this function should be overwritten by the user.
  138580. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  138581. * doc :
  138582. * @example : just set a particle position or velocity and recycle conditions
  138583. * @param particle The particle to update
  138584. * @returns the updated particle
  138585. */
  138586. updateParticle(particle: CloudPoint): CloudPoint;
  138587. /**
  138588. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  138589. * This does nothing and may be overwritten by the user.
  138590. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  138591. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  138592. * @param update the boolean update value actually passed to setParticles()
  138593. */
  138594. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  138595. /**
  138596. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  138597. * This will be passed three parameters.
  138598. * This does nothing and may be overwritten by the user.
  138599. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  138600. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  138601. * @param update the boolean update value actually passed to setParticles()
  138602. */
  138603. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  138604. }
  138605. }
  138606. declare module BABYLON {
  138607. /**
  138608. * Represents one particle of a points cloud system.
  138609. */
  138610. export class CloudPoint {
  138611. /**
  138612. * particle global index
  138613. */
  138614. idx: number;
  138615. /**
  138616. * The color of the particle
  138617. */
  138618. color: Nullable<Color4>;
  138619. /**
  138620. * The world space position of the particle.
  138621. */
  138622. position: Vector3;
  138623. /**
  138624. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  138625. */
  138626. rotation: Vector3;
  138627. /**
  138628. * The world space rotation quaternion of the particle.
  138629. */
  138630. rotationQuaternion: Nullable<Quaternion>;
  138631. /**
  138632. * The uv of the particle.
  138633. */
  138634. uv: Nullable<Vector2>;
  138635. /**
  138636. * The current speed of the particle.
  138637. */
  138638. velocity: Vector3;
  138639. /**
  138640. * The pivot point in the particle local space.
  138641. */
  138642. pivot: Vector3;
  138643. /**
  138644. * Must the particle be translated from its pivot point in its local space ?
  138645. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  138646. * Default : false
  138647. */
  138648. translateFromPivot: boolean;
  138649. /**
  138650. * Index of this particle in the global "positions" array (Internal use)
  138651. * @hidden
  138652. */
  138653. _pos: number;
  138654. /**
  138655. * @hidden Index of this particle in the global "indices" array (Internal use)
  138656. */
  138657. _ind: number;
  138658. /**
  138659. * Group this particle belongs to
  138660. */
  138661. _group: PointsGroup;
  138662. /**
  138663. * Group id of this particle
  138664. */
  138665. groupId: number;
  138666. /**
  138667. * Index of the particle in its group id (Internal use)
  138668. */
  138669. idxInGroup: number;
  138670. /**
  138671. * @hidden Particle BoundingInfo object (Internal use)
  138672. */
  138673. _boundingInfo: BoundingInfo;
  138674. /**
  138675. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  138676. */
  138677. _pcs: PointsCloudSystem;
  138678. /**
  138679. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  138680. */
  138681. _stillInvisible: boolean;
  138682. /**
  138683. * @hidden Last computed particle rotation matrix
  138684. */
  138685. _rotationMatrix: number[];
  138686. /**
  138687. * Parent particle Id, if any.
  138688. * Default null.
  138689. */
  138690. parentId: Nullable<number>;
  138691. /**
  138692. * @hidden Internal global position in the PCS.
  138693. */
  138694. _globalPosition: Vector3;
  138695. /**
  138696. * Creates a Point Cloud object.
  138697. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  138698. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  138699. * @param group (PointsGroup) is the group the particle belongs to
  138700. * @param groupId (integer) is the group identifier in the PCS.
  138701. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  138702. * @param pcs defines the PCS it is associated to
  138703. */
  138704. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  138705. /**
  138706. * get point size
  138707. */
  138708. get size(): Vector3;
  138709. /**
  138710. * Set point size
  138711. */
  138712. set size(scale: Vector3);
  138713. /**
  138714. * Legacy support, changed quaternion to rotationQuaternion
  138715. */
  138716. get quaternion(): Nullable<Quaternion>;
  138717. /**
  138718. * Legacy support, changed quaternion to rotationQuaternion
  138719. */
  138720. set quaternion(q: Nullable<Quaternion>);
  138721. /**
  138722. * Returns a boolean. True if the particle intersects a mesh, else false
  138723. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  138724. * @param target is the object (point or mesh) what the intersection is computed against
  138725. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  138726. * @returns true if it intersects
  138727. */
  138728. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  138729. /**
  138730. * get the rotation matrix of the particle
  138731. * @hidden
  138732. */
  138733. getRotationMatrix(m: Matrix): void;
  138734. }
  138735. /**
  138736. * Represents a group of points in a points cloud system
  138737. * * PCS internal tool, don't use it manually.
  138738. */
  138739. export class PointsGroup {
  138740. /**
  138741. * The group id
  138742. * @hidden
  138743. */
  138744. groupID: number;
  138745. /**
  138746. * image data for group (internal use)
  138747. * @hidden
  138748. */
  138749. _groupImageData: Nullable<ArrayBufferView>;
  138750. /**
  138751. * Image Width (internal use)
  138752. * @hidden
  138753. */
  138754. _groupImgWidth: number;
  138755. /**
  138756. * Image Height (internal use)
  138757. * @hidden
  138758. */
  138759. _groupImgHeight: number;
  138760. /**
  138761. * Custom position function (internal use)
  138762. * @hidden
  138763. */
  138764. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  138765. /**
  138766. * density per facet for surface points
  138767. * @hidden
  138768. */
  138769. _groupDensity: number[];
  138770. /**
  138771. * Only when points are colored by texture carries pointer to texture list array
  138772. * @hidden
  138773. */
  138774. _textureNb: number;
  138775. /**
  138776. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  138777. * PCS internal tool, don't use it manually.
  138778. * @hidden
  138779. */
  138780. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  138781. }
  138782. }
  138783. declare module BABYLON {
  138784. interface Scene {
  138785. /** @hidden (Backing field) */
  138786. _physicsEngine: Nullable<IPhysicsEngine>;
  138787. /** @hidden */
  138788. _physicsTimeAccumulator: number;
  138789. /**
  138790. * Gets the current physics engine
  138791. * @returns a IPhysicsEngine or null if none attached
  138792. */
  138793. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  138794. /**
  138795. * Enables physics to the current scene
  138796. * @param gravity defines the scene's gravity for the physics engine
  138797. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  138798. * @return a boolean indicating if the physics engine was initialized
  138799. */
  138800. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  138801. /**
  138802. * Disables and disposes the physics engine associated with the scene
  138803. */
  138804. disablePhysicsEngine(): void;
  138805. /**
  138806. * Gets a boolean indicating if there is an active physics engine
  138807. * @returns a boolean indicating if there is an active physics engine
  138808. */
  138809. isPhysicsEnabled(): boolean;
  138810. /**
  138811. * Deletes a physics compound impostor
  138812. * @param compound defines the compound to delete
  138813. */
  138814. deleteCompoundImpostor(compound: any): void;
  138815. /**
  138816. * An event triggered when physic simulation is about to be run
  138817. */
  138818. onBeforePhysicsObservable: Observable<Scene>;
  138819. /**
  138820. * An event triggered when physic simulation has been done
  138821. */
  138822. onAfterPhysicsObservable: Observable<Scene>;
  138823. }
  138824. interface AbstractMesh {
  138825. /** @hidden */
  138826. _physicsImpostor: Nullable<PhysicsImpostor>;
  138827. /**
  138828. * Gets or sets impostor used for physic simulation
  138829. * @see http://doc.babylonjs.com/features/physics_engine
  138830. */
  138831. physicsImpostor: Nullable<PhysicsImpostor>;
  138832. /**
  138833. * Gets the current physics impostor
  138834. * @see http://doc.babylonjs.com/features/physics_engine
  138835. * @returns a physics impostor or null
  138836. */
  138837. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  138838. /** Apply a physic impulse to the mesh
  138839. * @param force defines the force to apply
  138840. * @param contactPoint defines where to apply the force
  138841. * @returns the current mesh
  138842. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  138843. */
  138844. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  138845. /**
  138846. * Creates a physic joint between two meshes
  138847. * @param otherMesh defines the other mesh to use
  138848. * @param pivot1 defines the pivot to use on this mesh
  138849. * @param pivot2 defines the pivot to use on the other mesh
  138850. * @param options defines additional options (can be plugin dependent)
  138851. * @returns the current mesh
  138852. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  138853. */
  138854. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  138855. /** @hidden */
  138856. _disposePhysicsObserver: Nullable<Observer<Node>>;
  138857. }
  138858. /**
  138859. * Defines the physics engine scene component responsible to manage a physics engine
  138860. */
  138861. export class PhysicsEngineSceneComponent implements ISceneComponent {
  138862. /**
  138863. * The component name helpful to identify the component in the list of scene components.
  138864. */
  138865. readonly name: string;
  138866. /**
  138867. * The scene the component belongs to.
  138868. */
  138869. scene: Scene;
  138870. /**
  138871. * Creates a new instance of the component for the given scene
  138872. * @param scene Defines the scene to register the component in
  138873. */
  138874. constructor(scene: Scene);
  138875. /**
  138876. * Registers the component in a given scene
  138877. */
  138878. register(): void;
  138879. /**
  138880. * Rebuilds the elements related to this component in case of
  138881. * context lost for instance.
  138882. */
  138883. rebuild(): void;
  138884. /**
  138885. * Disposes the component and the associated ressources
  138886. */
  138887. dispose(): void;
  138888. }
  138889. }
  138890. declare module BABYLON {
  138891. /**
  138892. * A helper for physics simulations
  138893. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138894. */
  138895. export class PhysicsHelper {
  138896. private _scene;
  138897. private _physicsEngine;
  138898. /**
  138899. * Initializes the Physics helper
  138900. * @param scene Babylon.js scene
  138901. */
  138902. constructor(scene: Scene);
  138903. /**
  138904. * Applies a radial explosion impulse
  138905. * @param origin the origin of the explosion
  138906. * @param radiusOrEventOptions the radius or the options of radial explosion
  138907. * @param strength the explosion strength
  138908. * @param falloff possible options: Constant & Linear. Defaults to Constant
  138909. * @returns A physics radial explosion event, or null
  138910. */
  138911. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  138912. /**
  138913. * Applies a radial explosion force
  138914. * @param origin the origin of the explosion
  138915. * @param radiusOrEventOptions the radius or the options of radial explosion
  138916. * @param strength the explosion strength
  138917. * @param falloff possible options: Constant & Linear. Defaults to Constant
  138918. * @returns A physics radial explosion event, or null
  138919. */
  138920. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  138921. /**
  138922. * Creates a gravitational field
  138923. * @param origin the origin of the explosion
  138924. * @param radiusOrEventOptions the radius or the options of radial explosion
  138925. * @param strength the explosion strength
  138926. * @param falloff possible options: Constant & Linear. Defaults to Constant
  138927. * @returns A physics gravitational field event, or null
  138928. */
  138929. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  138930. /**
  138931. * Creates a physics updraft event
  138932. * @param origin the origin of the updraft
  138933. * @param radiusOrEventOptions the radius or the options of the updraft
  138934. * @param strength the strength of the updraft
  138935. * @param height the height of the updraft
  138936. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  138937. * @returns A physics updraft event, or null
  138938. */
  138939. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  138940. /**
  138941. * Creates a physics vortex event
  138942. * @param origin the of the vortex
  138943. * @param radiusOrEventOptions the radius or the options of the vortex
  138944. * @param strength the strength of the vortex
  138945. * @param height the height of the vortex
  138946. * @returns a Physics vortex event, or null
  138947. * A physics vortex event or null
  138948. */
  138949. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  138950. }
  138951. /**
  138952. * Represents a physics radial explosion event
  138953. */
  138954. class PhysicsRadialExplosionEvent {
  138955. private _scene;
  138956. private _options;
  138957. private _sphere;
  138958. private _dataFetched;
  138959. /**
  138960. * Initializes a radial explosioin event
  138961. * @param _scene BabylonJS scene
  138962. * @param _options The options for the vortex event
  138963. */
  138964. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  138965. /**
  138966. * Returns the data related to the radial explosion event (sphere).
  138967. * @returns The radial explosion event data
  138968. */
  138969. getData(): PhysicsRadialExplosionEventData;
  138970. /**
  138971. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  138972. * @param impostor A physics imposter
  138973. * @param origin the origin of the explosion
  138974. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  138975. */
  138976. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  138977. /**
  138978. * Triggers affecterd impostors callbacks
  138979. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  138980. */
  138981. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  138982. /**
  138983. * Disposes the sphere.
  138984. * @param force Specifies if the sphere should be disposed by force
  138985. */
  138986. dispose(force?: boolean): void;
  138987. /*** Helpers ***/
  138988. private _prepareSphere;
  138989. private _intersectsWithSphere;
  138990. }
  138991. /**
  138992. * Represents a gravitational field event
  138993. */
  138994. class PhysicsGravitationalFieldEvent {
  138995. private _physicsHelper;
  138996. private _scene;
  138997. private _origin;
  138998. private _options;
  138999. private _tickCallback;
  139000. private _sphere;
  139001. private _dataFetched;
  139002. /**
  139003. * Initializes the physics gravitational field event
  139004. * @param _physicsHelper A physics helper
  139005. * @param _scene BabylonJS scene
  139006. * @param _origin The origin position of the gravitational field event
  139007. * @param _options The options for the vortex event
  139008. */
  139009. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  139010. /**
  139011. * Returns the data related to the gravitational field event (sphere).
  139012. * @returns A gravitational field event
  139013. */
  139014. getData(): PhysicsGravitationalFieldEventData;
  139015. /**
  139016. * Enables the gravitational field.
  139017. */
  139018. enable(): void;
  139019. /**
  139020. * Disables the gravitational field.
  139021. */
  139022. disable(): void;
  139023. /**
  139024. * Disposes the sphere.
  139025. * @param force The force to dispose from the gravitational field event
  139026. */
  139027. dispose(force?: boolean): void;
  139028. private _tick;
  139029. }
  139030. /**
  139031. * Represents a physics updraft event
  139032. */
  139033. class PhysicsUpdraftEvent {
  139034. private _scene;
  139035. private _origin;
  139036. private _options;
  139037. private _physicsEngine;
  139038. private _originTop;
  139039. private _originDirection;
  139040. private _tickCallback;
  139041. private _cylinder;
  139042. private _cylinderPosition;
  139043. private _dataFetched;
  139044. /**
  139045. * Initializes the physics updraft event
  139046. * @param _scene BabylonJS scene
  139047. * @param _origin The origin position of the updraft
  139048. * @param _options The options for the updraft event
  139049. */
  139050. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  139051. /**
  139052. * Returns the data related to the updraft event (cylinder).
  139053. * @returns A physics updraft event
  139054. */
  139055. getData(): PhysicsUpdraftEventData;
  139056. /**
  139057. * Enables the updraft.
  139058. */
  139059. enable(): void;
  139060. /**
  139061. * Disables the updraft.
  139062. */
  139063. disable(): void;
  139064. /**
  139065. * Disposes the cylinder.
  139066. * @param force Specifies if the updraft should be disposed by force
  139067. */
  139068. dispose(force?: boolean): void;
  139069. private getImpostorHitData;
  139070. private _tick;
  139071. /*** Helpers ***/
  139072. private _prepareCylinder;
  139073. private _intersectsWithCylinder;
  139074. }
  139075. /**
  139076. * Represents a physics vortex event
  139077. */
  139078. class PhysicsVortexEvent {
  139079. private _scene;
  139080. private _origin;
  139081. private _options;
  139082. private _physicsEngine;
  139083. private _originTop;
  139084. private _tickCallback;
  139085. private _cylinder;
  139086. private _cylinderPosition;
  139087. private _dataFetched;
  139088. /**
  139089. * Initializes the physics vortex event
  139090. * @param _scene The BabylonJS scene
  139091. * @param _origin The origin position of the vortex
  139092. * @param _options The options for the vortex event
  139093. */
  139094. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  139095. /**
  139096. * Returns the data related to the vortex event (cylinder).
  139097. * @returns The physics vortex event data
  139098. */
  139099. getData(): PhysicsVortexEventData;
  139100. /**
  139101. * Enables the vortex.
  139102. */
  139103. enable(): void;
  139104. /**
  139105. * Disables the cortex.
  139106. */
  139107. disable(): void;
  139108. /**
  139109. * Disposes the sphere.
  139110. * @param force
  139111. */
  139112. dispose(force?: boolean): void;
  139113. private getImpostorHitData;
  139114. private _tick;
  139115. /*** Helpers ***/
  139116. private _prepareCylinder;
  139117. private _intersectsWithCylinder;
  139118. }
  139119. /**
  139120. * Options fot the radial explosion event
  139121. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  139122. */
  139123. export class PhysicsRadialExplosionEventOptions {
  139124. /**
  139125. * The radius of the sphere for the radial explosion.
  139126. */
  139127. radius: number;
  139128. /**
  139129. * The strenth of the explosion.
  139130. */
  139131. strength: number;
  139132. /**
  139133. * The strenght of the force in correspondence to the distance of the affected object
  139134. */
  139135. falloff: PhysicsRadialImpulseFalloff;
  139136. /**
  139137. * Sphere options for the radial explosion.
  139138. */
  139139. sphere: {
  139140. segments: number;
  139141. diameter: number;
  139142. };
  139143. /**
  139144. * Sphere options for the radial explosion.
  139145. */
  139146. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  139147. }
  139148. /**
  139149. * Options fot the updraft event
  139150. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  139151. */
  139152. export class PhysicsUpdraftEventOptions {
  139153. /**
  139154. * The radius of the cylinder for the vortex
  139155. */
  139156. radius: number;
  139157. /**
  139158. * The strenth of the updraft.
  139159. */
  139160. strength: number;
  139161. /**
  139162. * The height of the cylinder for the updraft.
  139163. */
  139164. height: number;
  139165. /**
  139166. * The mode for the the updraft.
  139167. */
  139168. updraftMode: PhysicsUpdraftMode;
  139169. }
  139170. /**
  139171. * Options fot the vortex event
  139172. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  139173. */
  139174. export class PhysicsVortexEventOptions {
  139175. /**
  139176. * The radius of the cylinder for the vortex
  139177. */
  139178. radius: number;
  139179. /**
  139180. * The strenth of the vortex.
  139181. */
  139182. strength: number;
  139183. /**
  139184. * The height of the cylinder for the vortex.
  139185. */
  139186. height: number;
  139187. /**
  139188. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  139189. */
  139190. centripetalForceThreshold: number;
  139191. /**
  139192. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  139193. */
  139194. centripetalForceMultiplier: number;
  139195. /**
  139196. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  139197. */
  139198. centrifugalForceMultiplier: number;
  139199. /**
  139200. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  139201. */
  139202. updraftForceMultiplier: number;
  139203. }
  139204. /**
  139205. * The strenght of the force in correspondence to the distance of the affected object
  139206. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  139207. */
  139208. export enum PhysicsRadialImpulseFalloff {
  139209. /** Defines that impulse is constant in strength across it's whole radius */
  139210. Constant = 0,
  139211. /** Defines that impulse gets weaker if it's further from the origin */
  139212. Linear = 1
  139213. }
  139214. /**
  139215. * The strength of the force in correspondence to the distance of the affected object
  139216. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  139217. */
  139218. export enum PhysicsUpdraftMode {
  139219. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  139220. Center = 0,
  139221. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  139222. Perpendicular = 1
  139223. }
  139224. /**
  139225. * Interface for a physics hit data
  139226. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  139227. */
  139228. export interface PhysicsHitData {
  139229. /**
  139230. * The force applied at the contact point
  139231. */
  139232. force: Vector3;
  139233. /**
  139234. * The contact point
  139235. */
  139236. contactPoint: Vector3;
  139237. /**
  139238. * The distance from the origin to the contact point
  139239. */
  139240. distanceFromOrigin: number;
  139241. }
  139242. /**
  139243. * Interface for radial explosion event data
  139244. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  139245. */
  139246. export interface PhysicsRadialExplosionEventData {
  139247. /**
  139248. * A sphere used for the radial explosion event
  139249. */
  139250. sphere: Mesh;
  139251. }
  139252. /**
  139253. * Interface for gravitational field event data
  139254. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  139255. */
  139256. export interface PhysicsGravitationalFieldEventData {
  139257. /**
  139258. * A sphere mesh used for the gravitational field event
  139259. */
  139260. sphere: Mesh;
  139261. }
  139262. /**
  139263. * Interface for updraft event data
  139264. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  139265. */
  139266. export interface PhysicsUpdraftEventData {
  139267. /**
  139268. * A cylinder used for the updraft event
  139269. */
  139270. cylinder: Mesh;
  139271. }
  139272. /**
  139273. * Interface for vortex event data
  139274. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  139275. */
  139276. export interface PhysicsVortexEventData {
  139277. /**
  139278. * A cylinder used for the vortex event
  139279. */
  139280. cylinder: Mesh;
  139281. }
  139282. /**
  139283. * Interface for an affected physics impostor
  139284. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  139285. */
  139286. export interface PhysicsAffectedImpostorWithData {
  139287. /**
  139288. * The impostor affected by the effect
  139289. */
  139290. impostor: PhysicsImpostor;
  139291. /**
  139292. * The data about the hit/horce from the explosion
  139293. */
  139294. hitData: PhysicsHitData;
  139295. }
  139296. }
  139297. declare module BABYLON {
  139298. /** @hidden */
  139299. export var blackAndWhitePixelShader: {
  139300. name: string;
  139301. shader: string;
  139302. };
  139303. }
  139304. declare module BABYLON {
  139305. /**
  139306. * Post process used to render in black and white
  139307. */
  139308. export class BlackAndWhitePostProcess extends PostProcess {
  139309. /**
  139310. * Linear about to convert he result to black and white (default: 1)
  139311. */
  139312. degree: number;
  139313. /**
  139314. * Creates a black and white post process
  139315. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  139316. * @param name The name of the effect.
  139317. * @param options The required width/height ratio to downsize to before computing the render pass.
  139318. * @param camera The camera to apply the render pass to.
  139319. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139320. * @param engine The engine which the post process will be applied. (default: current engine)
  139321. * @param reusable If the post process can be reused on the same frame. (default: false)
  139322. */
  139323. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  139324. }
  139325. }
  139326. declare module BABYLON {
  139327. /**
  139328. * This represents a set of one or more post processes in Babylon.
  139329. * A post process can be used to apply a shader to a texture after it is rendered.
  139330. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  139331. */
  139332. export class PostProcessRenderEffect {
  139333. private _postProcesses;
  139334. private _getPostProcesses;
  139335. private _singleInstance;
  139336. private _cameras;
  139337. private _indicesForCamera;
  139338. /**
  139339. * Name of the effect
  139340. * @hidden
  139341. */
  139342. _name: string;
  139343. /**
  139344. * Instantiates a post process render effect.
  139345. * A post process can be used to apply a shader to a texture after it is rendered.
  139346. * @param engine The engine the effect is tied to
  139347. * @param name The name of the effect
  139348. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  139349. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  139350. */
  139351. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  139352. /**
  139353. * Checks if all the post processes in the effect are supported.
  139354. */
  139355. get isSupported(): boolean;
  139356. /**
  139357. * Updates the current state of the effect
  139358. * @hidden
  139359. */
  139360. _update(): void;
  139361. /**
  139362. * Attaches the effect on cameras
  139363. * @param cameras The camera to attach to.
  139364. * @hidden
  139365. */
  139366. _attachCameras(cameras: Camera): void;
  139367. /**
  139368. * Attaches the effect on cameras
  139369. * @param cameras The camera to attach to.
  139370. * @hidden
  139371. */
  139372. _attachCameras(cameras: Camera[]): void;
  139373. /**
  139374. * Detaches the effect on cameras
  139375. * @param cameras The camera to detatch from.
  139376. * @hidden
  139377. */
  139378. _detachCameras(cameras: Camera): void;
  139379. /**
  139380. * Detatches the effect on cameras
  139381. * @param cameras The camera to detatch from.
  139382. * @hidden
  139383. */
  139384. _detachCameras(cameras: Camera[]): void;
  139385. /**
  139386. * Enables the effect on given cameras
  139387. * @param cameras The camera to enable.
  139388. * @hidden
  139389. */
  139390. _enable(cameras: Camera): void;
  139391. /**
  139392. * Enables the effect on given cameras
  139393. * @param cameras The camera to enable.
  139394. * @hidden
  139395. */
  139396. _enable(cameras: Nullable<Camera[]>): void;
  139397. /**
  139398. * Disables the effect on the given cameras
  139399. * @param cameras The camera to disable.
  139400. * @hidden
  139401. */
  139402. _disable(cameras: Camera): void;
  139403. /**
  139404. * Disables the effect on the given cameras
  139405. * @param cameras The camera to disable.
  139406. * @hidden
  139407. */
  139408. _disable(cameras: Nullable<Camera[]>): void;
  139409. /**
  139410. * Gets a list of the post processes contained in the effect.
  139411. * @param camera The camera to get the post processes on.
  139412. * @returns The list of the post processes in the effect.
  139413. */
  139414. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  139415. }
  139416. }
  139417. declare module BABYLON {
  139418. /** @hidden */
  139419. export var extractHighlightsPixelShader: {
  139420. name: string;
  139421. shader: string;
  139422. };
  139423. }
  139424. declare module BABYLON {
  139425. /**
  139426. * 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.
  139427. */
  139428. export class ExtractHighlightsPostProcess extends PostProcess {
  139429. /**
  139430. * The luminance threshold, pixels below this value will be set to black.
  139431. */
  139432. threshold: number;
  139433. /** @hidden */
  139434. _exposure: number;
  139435. /**
  139436. * Post process which has the input texture to be used when performing highlight extraction
  139437. * @hidden
  139438. */
  139439. _inputPostProcess: Nullable<PostProcess>;
  139440. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139441. }
  139442. }
  139443. declare module BABYLON {
  139444. /** @hidden */
  139445. export var bloomMergePixelShader: {
  139446. name: string;
  139447. shader: string;
  139448. };
  139449. }
  139450. declare module BABYLON {
  139451. /**
  139452. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  139453. */
  139454. export class BloomMergePostProcess extends PostProcess {
  139455. /** Weight of the bloom to be added to the original input. */
  139456. weight: number;
  139457. /**
  139458. * Creates a new instance of @see BloomMergePostProcess
  139459. * @param name The name of the effect.
  139460. * @param originalFromInput Post process which's input will be used for the merge.
  139461. * @param blurred Blurred highlights post process which's output will be used.
  139462. * @param weight Weight of the bloom to be added to the original input.
  139463. * @param options The required width/height ratio to downsize to before computing the render pass.
  139464. * @param camera The camera to apply the render pass to.
  139465. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139466. * @param engine The engine which the post process will be applied. (default: current engine)
  139467. * @param reusable If the post process can be reused on the same frame. (default: false)
  139468. * @param textureType Type of textures used when performing the post process. (default: 0)
  139469. * @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)
  139470. */
  139471. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  139472. /** Weight of the bloom to be added to the original input. */
  139473. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139474. }
  139475. }
  139476. declare module BABYLON {
  139477. /**
  139478. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  139479. */
  139480. export class BloomEffect extends PostProcessRenderEffect {
  139481. private bloomScale;
  139482. /**
  139483. * @hidden Internal
  139484. */
  139485. _effects: Array<PostProcess>;
  139486. /**
  139487. * @hidden Internal
  139488. */
  139489. _downscale: ExtractHighlightsPostProcess;
  139490. private _blurX;
  139491. private _blurY;
  139492. private _merge;
  139493. /**
  139494. * The luminance threshold to find bright areas of the image to bloom.
  139495. */
  139496. get threshold(): number;
  139497. set threshold(value: number);
  139498. /**
  139499. * The strength of the bloom.
  139500. */
  139501. get weight(): number;
  139502. set weight(value: number);
  139503. /**
  139504. * Specifies the size of the bloom blur kernel, relative to the final output size
  139505. */
  139506. get kernel(): number;
  139507. set kernel(value: number);
  139508. /**
  139509. * Creates a new instance of @see BloomEffect
  139510. * @param scene The scene the effect belongs to.
  139511. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  139512. * @param bloomKernel The size of the kernel to be used when applying the blur.
  139513. * @param bloomWeight The the strength of bloom.
  139514. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  139515. * @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)
  139516. */
  139517. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  139518. /**
  139519. * Disposes each of the internal effects for a given camera.
  139520. * @param camera The camera to dispose the effect on.
  139521. */
  139522. disposeEffects(camera: Camera): void;
  139523. /**
  139524. * @hidden Internal
  139525. */
  139526. _updateEffects(): void;
  139527. /**
  139528. * Internal
  139529. * @returns if all the contained post processes are ready.
  139530. * @hidden
  139531. */
  139532. _isReady(): boolean;
  139533. }
  139534. }
  139535. declare module BABYLON {
  139536. /** @hidden */
  139537. export var chromaticAberrationPixelShader: {
  139538. name: string;
  139539. shader: string;
  139540. };
  139541. }
  139542. declare module BABYLON {
  139543. /**
  139544. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  139545. */
  139546. export class ChromaticAberrationPostProcess extends PostProcess {
  139547. /**
  139548. * The amount of seperation of rgb channels (default: 30)
  139549. */
  139550. aberrationAmount: number;
  139551. /**
  139552. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  139553. */
  139554. radialIntensity: number;
  139555. /**
  139556. * 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))
  139557. */
  139558. direction: Vector2;
  139559. /**
  139560. * 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))
  139561. */
  139562. centerPosition: Vector2;
  139563. /**
  139564. * Creates a new instance ChromaticAberrationPostProcess
  139565. * @param name The name of the effect.
  139566. * @param screenWidth The width of the screen to apply the effect on.
  139567. * @param screenHeight The height of the screen to apply the effect on.
  139568. * @param options The required width/height ratio to downsize to before computing the render pass.
  139569. * @param camera The camera to apply the render pass to.
  139570. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139571. * @param engine The engine which the post process will be applied. (default: current engine)
  139572. * @param reusable If the post process can be reused on the same frame. (default: false)
  139573. * @param textureType Type of textures used when performing the post process. (default: 0)
  139574. * @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)
  139575. */
  139576. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139577. }
  139578. }
  139579. declare module BABYLON {
  139580. /** @hidden */
  139581. export var circleOfConfusionPixelShader: {
  139582. name: string;
  139583. shader: string;
  139584. };
  139585. }
  139586. declare module BABYLON {
  139587. /**
  139588. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  139589. */
  139590. export class CircleOfConfusionPostProcess extends PostProcess {
  139591. /**
  139592. * 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.
  139593. */
  139594. lensSize: number;
  139595. /**
  139596. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  139597. */
  139598. fStop: number;
  139599. /**
  139600. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  139601. */
  139602. focusDistance: number;
  139603. /**
  139604. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  139605. */
  139606. focalLength: number;
  139607. private _depthTexture;
  139608. /**
  139609. * Creates a new instance CircleOfConfusionPostProcess
  139610. * @param name The name of the effect.
  139611. * @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.
  139612. * @param options The required width/height ratio to downsize to before computing the render pass.
  139613. * @param camera The camera to apply the render pass to.
  139614. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139615. * @param engine The engine which the post process will be applied. (default: current engine)
  139616. * @param reusable If the post process can be reused on the same frame. (default: false)
  139617. * @param textureType Type of textures used when performing the post process. (default: 0)
  139618. * @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)
  139619. */
  139620. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139621. /**
  139622. * 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.
  139623. */
  139624. set depthTexture(value: RenderTargetTexture);
  139625. }
  139626. }
  139627. declare module BABYLON {
  139628. /** @hidden */
  139629. export var colorCorrectionPixelShader: {
  139630. name: string;
  139631. shader: string;
  139632. };
  139633. }
  139634. declare module BABYLON {
  139635. /**
  139636. *
  139637. * This post-process allows the modification of rendered colors by using
  139638. * a 'look-up table' (LUT). This effect is also called Color Grading.
  139639. *
  139640. * The object needs to be provided an url to a texture containing the color
  139641. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  139642. * Use an image editing software to tweak the LUT to match your needs.
  139643. *
  139644. * For an example of a color LUT, see here:
  139645. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  139646. * For explanations on color grading, see here:
  139647. * @see http://udn.epicgames.com/Three/ColorGrading.html
  139648. *
  139649. */
  139650. export class ColorCorrectionPostProcess extends PostProcess {
  139651. private _colorTableTexture;
  139652. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  139653. }
  139654. }
  139655. declare module BABYLON {
  139656. /** @hidden */
  139657. export var convolutionPixelShader: {
  139658. name: string;
  139659. shader: string;
  139660. };
  139661. }
  139662. declare module BABYLON {
  139663. /**
  139664. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  139665. * input texture to perform effects such as edge detection or sharpening
  139666. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  139667. */
  139668. export class ConvolutionPostProcess extends PostProcess {
  139669. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  139670. kernel: number[];
  139671. /**
  139672. * Creates a new instance ConvolutionPostProcess
  139673. * @param name The name of the effect.
  139674. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  139675. * @param options The required width/height ratio to downsize to before computing the render pass.
  139676. * @param camera The camera to apply the render pass to.
  139677. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139678. * @param engine The engine which the post process will be applied. (default: current engine)
  139679. * @param reusable If the post process can be reused on the same frame. (default: false)
  139680. * @param textureType Type of textures used when performing the post process. (default: 0)
  139681. */
  139682. constructor(name: string,
  139683. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  139684. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  139685. /**
  139686. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139687. */
  139688. static EdgeDetect0Kernel: number[];
  139689. /**
  139690. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139691. */
  139692. static EdgeDetect1Kernel: number[];
  139693. /**
  139694. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139695. */
  139696. static EdgeDetect2Kernel: number[];
  139697. /**
  139698. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139699. */
  139700. static SharpenKernel: number[];
  139701. /**
  139702. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139703. */
  139704. static EmbossKernel: number[];
  139705. /**
  139706. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139707. */
  139708. static GaussianKernel: number[];
  139709. }
  139710. }
  139711. declare module BABYLON {
  139712. /**
  139713. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  139714. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  139715. * based on samples that have a large difference in distance than the center pixel.
  139716. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  139717. */
  139718. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  139719. direction: Vector2;
  139720. /**
  139721. * Creates a new instance CircleOfConfusionPostProcess
  139722. * @param name The name of the effect.
  139723. * @param scene The scene the effect belongs to.
  139724. * @param direction The direction the blur should be applied.
  139725. * @param kernel The size of the kernel used to blur.
  139726. * @param options The required width/height ratio to downsize to before computing the render pass.
  139727. * @param camera The camera to apply the render pass to.
  139728. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  139729. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  139730. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139731. * @param engine The engine which the post process will be applied. (default: current engine)
  139732. * @param reusable If the post process can be reused on the same frame. (default: false)
  139733. * @param textureType Type of textures used when performing the post process. (default: 0)
  139734. * @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)
  139735. */
  139736. 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);
  139737. }
  139738. }
  139739. declare module BABYLON {
  139740. /** @hidden */
  139741. export var depthOfFieldMergePixelShader: {
  139742. name: string;
  139743. shader: string;
  139744. };
  139745. }
  139746. declare module BABYLON {
  139747. /**
  139748. * Options to be set when merging outputs from the default pipeline.
  139749. */
  139750. export class DepthOfFieldMergePostProcessOptions {
  139751. /**
  139752. * The original image to merge on top of
  139753. */
  139754. originalFromInput: PostProcess;
  139755. /**
  139756. * Parameters to perform the merge of the depth of field effect
  139757. */
  139758. depthOfField?: {
  139759. circleOfConfusion: PostProcess;
  139760. blurSteps: Array<PostProcess>;
  139761. };
  139762. /**
  139763. * Parameters to perform the merge of bloom effect
  139764. */
  139765. bloom?: {
  139766. blurred: PostProcess;
  139767. weight: number;
  139768. };
  139769. }
  139770. /**
  139771. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  139772. */
  139773. export class DepthOfFieldMergePostProcess extends PostProcess {
  139774. private blurSteps;
  139775. /**
  139776. * Creates a new instance of DepthOfFieldMergePostProcess
  139777. * @param name The name of the effect.
  139778. * @param originalFromInput Post process which's input will be used for the merge.
  139779. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  139780. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  139781. * @param options The required width/height ratio to downsize to before computing the render pass.
  139782. * @param camera The camera to apply the render pass to.
  139783. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139784. * @param engine The engine which the post process will be applied. (default: current engine)
  139785. * @param reusable If the post process can be reused on the same frame. (default: false)
  139786. * @param textureType Type of textures used when performing the post process. (default: 0)
  139787. * @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)
  139788. */
  139789. 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);
  139790. /**
  139791. * Updates the effect with the current post process compile time values and recompiles the shader.
  139792. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  139793. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  139794. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  139795. * @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
  139796. * @param onCompiled Called when the shader has been compiled.
  139797. * @param onError Called if there is an error when compiling a shader.
  139798. */
  139799. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  139800. }
  139801. }
  139802. declare module BABYLON {
  139803. /**
  139804. * Specifies the level of max blur that should be applied when using the depth of field effect
  139805. */
  139806. export enum DepthOfFieldEffectBlurLevel {
  139807. /**
  139808. * Subtle blur
  139809. */
  139810. Low = 0,
  139811. /**
  139812. * Medium blur
  139813. */
  139814. Medium = 1,
  139815. /**
  139816. * Large blur
  139817. */
  139818. High = 2
  139819. }
  139820. /**
  139821. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  139822. */
  139823. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  139824. private _circleOfConfusion;
  139825. /**
  139826. * @hidden Internal, blurs from high to low
  139827. */
  139828. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  139829. private _depthOfFieldBlurY;
  139830. private _dofMerge;
  139831. /**
  139832. * @hidden Internal post processes in depth of field effect
  139833. */
  139834. _effects: Array<PostProcess>;
  139835. /**
  139836. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  139837. */
  139838. set focalLength(value: number);
  139839. get focalLength(): number;
  139840. /**
  139841. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  139842. */
  139843. set fStop(value: number);
  139844. get fStop(): number;
  139845. /**
  139846. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  139847. */
  139848. set focusDistance(value: number);
  139849. get focusDistance(): number;
  139850. /**
  139851. * 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.
  139852. */
  139853. set lensSize(value: number);
  139854. get lensSize(): number;
  139855. /**
  139856. * Creates a new instance DepthOfFieldEffect
  139857. * @param scene The scene the effect belongs to.
  139858. * @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.
  139859. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  139860. * @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)
  139861. */
  139862. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  139863. /**
  139864. * Get the current class name of the current effet
  139865. * @returns "DepthOfFieldEffect"
  139866. */
  139867. getClassName(): string;
  139868. /**
  139869. * 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.
  139870. */
  139871. set depthTexture(value: RenderTargetTexture);
  139872. /**
  139873. * Disposes each of the internal effects for a given camera.
  139874. * @param camera The camera to dispose the effect on.
  139875. */
  139876. disposeEffects(camera: Camera): void;
  139877. /**
  139878. * @hidden Internal
  139879. */
  139880. _updateEffects(): void;
  139881. /**
  139882. * Internal
  139883. * @returns if all the contained post processes are ready.
  139884. * @hidden
  139885. */
  139886. _isReady(): boolean;
  139887. }
  139888. }
  139889. declare module BABYLON {
  139890. /** @hidden */
  139891. export var displayPassPixelShader: {
  139892. name: string;
  139893. shader: string;
  139894. };
  139895. }
  139896. declare module BABYLON {
  139897. /**
  139898. * DisplayPassPostProcess which produces an output the same as it's input
  139899. */
  139900. export class DisplayPassPostProcess extends PostProcess {
  139901. /**
  139902. * Creates the DisplayPassPostProcess
  139903. * @param name The name of the effect.
  139904. * @param options The required width/height ratio to downsize to before computing the render pass.
  139905. * @param camera The camera to apply the render pass to.
  139906. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139907. * @param engine The engine which the post process will be applied. (default: current engine)
  139908. * @param reusable If the post process can be reused on the same frame. (default: false)
  139909. */
  139910. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  139911. }
  139912. }
  139913. declare module BABYLON {
  139914. /** @hidden */
  139915. export var filterPixelShader: {
  139916. name: string;
  139917. shader: string;
  139918. };
  139919. }
  139920. declare module BABYLON {
  139921. /**
  139922. * Applies a kernel filter to the image
  139923. */
  139924. export class FilterPostProcess extends PostProcess {
  139925. /** The matrix to be applied to the image */
  139926. kernelMatrix: Matrix;
  139927. /**
  139928. *
  139929. * @param name The name of the effect.
  139930. * @param kernelMatrix The matrix to be applied to the image
  139931. * @param options The required width/height ratio to downsize to before computing the render pass.
  139932. * @param camera The camera to apply the render pass to.
  139933. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139934. * @param engine The engine which the post process will be applied. (default: current engine)
  139935. * @param reusable If the post process can be reused on the same frame. (default: false)
  139936. */
  139937. constructor(name: string,
  139938. /** The matrix to be applied to the image */
  139939. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  139940. }
  139941. }
  139942. declare module BABYLON {
  139943. /** @hidden */
  139944. export var fxaaPixelShader: {
  139945. name: string;
  139946. shader: string;
  139947. };
  139948. }
  139949. declare module BABYLON {
  139950. /** @hidden */
  139951. export var fxaaVertexShader: {
  139952. name: string;
  139953. shader: string;
  139954. };
  139955. }
  139956. declare module BABYLON {
  139957. /**
  139958. * Fxaa post process
  139959. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  139960. */
  139961. export class FxaaPostProcess extends PostProcess {
  139962. /** @hidden */
  139963. texelWidth: number;
  139964. /** @hidden */
  139965. texelHeight: number;
  139966. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  139967. private _getDefines;
  139968. }
  139969. }
  139970. declare module BABYLON {
  139971. /** @hidden */
  139972. export var grainPixelShader: {
  139973. name: string;
  139974. shader: string;
  139975. };
  139976. }
  139977. declare module BABYLON {
  139978. /**
  139979. * The GrainPostProcess adds noise to the image at mid luminance levels
  139980. */
  139981. export class GrainPostProcess extends PostProcess {
  139982. /**
  139983. * The intensity of the grain added (default: 30)
  139984. */
  139985. intensity: number;
  139986. /**
  139987. * If the grain should be randomized on every frame
  139988. */
  139989. animated: boolean;
  139990. /**
  139991. * Creates a new instance of @see GrainPostProcess
  139992. * @param name The name of the effect.
  139993. * @param options The required width/height ratio to downsize to before computing the render pass.
  139994. * @param camera The camera to apply the render pass to.
  139995. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139996. * @param engine The engine which the post process will be applied. (default: current engine)
  139997. * @param reusable If the post process can be reused on the same frame. (default: false)
  139998. * @param textureType Type of textures used when performing the post process. (default: 0)
  139999. * @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)
  140000. */
  140001. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  140002. }
  140003. }
  140004. declare module BABYLON {
  140005. /** @hidden */
  140006. export var highlightsPixelShader: {
  140007. name: string;
  140008. shader: string;
  140009. };
  140010. }
  140011. declare module BABYLON {
  140012. /**
  140013. * Extracts highlights from the image
  140014. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  140015. */
  140016. export class HighlightsPostProcess extends PostProcess {
  140017. /**
  140018. * Extracts highlights from the image
  140019. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  140020. * @param name The name of the effect.
  140021. * @param options The required width/height ratio to downsize to before computing the render pass.
  140022. * @param camera The camera to apply the render pass to.
  140023. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  140024. * @param engine The engine which the post process will be applied. (default: current engine)
  140025. * @param reusable If the post process can be reused on the same frame. (default: false)
  140026. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  140027. */
  140028. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  140029. }
  140030. }
  140031. declare module BABYLON {
  140032. /** @hidden */
  140033. export var mrtFragmentDeclaration: {
  140034. name: string;
  140035. shader: string;
  140036. };
  140037. }
  140038. declare module BABYLON {
  140039. /** @hidden */
  140040. export var geometryPixelShader: {
  140041. name: string;
  140042. shader: string;
  140043. };
  140044. }
  140045. declare module BABYLON {
  140046. /** @hidden */
  140047. export var geometryVertexShader: {
  140048. name: string;
  140049. shader: string;
  140050. };
  140051. }
  140052. declare module BABYLON {
  140053. /** @hidden */
  140054. interface ISavedTransformationMatrix {
  140055. world: Matrix;
  140056. viewProjection: Matrix;
  140057. }
  140058. /**
  140059. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  140060. */
  140061. export class GeometryBufferRenderer {
  140062. /**
  140063. * Constant used to retrieve the position texture index in the G-Buffer textures array
  140064. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  140065. */
  140066. static readonly POSITION_TEXTURE_TYPE: number;
  140067. /**
  140068. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  140069. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  140070. */
  140071. static readonly VELOCITY_TEXTURE_TYPE: number;
  140072. /**
  140073. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  140074. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  140075. */
  140076. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  140077. /**
  140078. * Dictionary used to store the previous transformation matrices of each rendered mesh
  140079. * in order to compute objects velocities when enableVelocity is set to "true"
  140080. * @hidden
  140081. */
  140082. _previousTransformationMatrices: {
  140083. [index: number]: ISavedTransformationMatrix;
  140084. };
  140085. /**
  140086. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  140087. * in order to compute objects velocities when enableVelocity is set to "true"
  140088. * @hidden
  140089. */
  140090. _previousBonesTransformationMatrices: {
  140091. [index: number]: Float32Array;
  140092. };
  140093. /**
  140094. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  140095. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  140096. */
  140097. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  140098. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  140099. renderTransparentMeshes: boolean;
  140100. private _scene;
  140101. private _multiRenderTarget;
  140102. private _ratio;
  140103. private _enablePosition;
  140104. private _enableVelocity;
  140105. private _enableReflectivity;
  140106. private _positionIndex;
  140107. private _velocityIndex;
  140108. private _reflectivityIndex;
  140109. protected _effect: Effect;
  140110. protected _cachedDefines: string;
  140111. /**
  140112. * Set the render list (meshes to be rendered) used in the G buffer.
  140113. */
  140114. set renderList(meshes: Mesh[]);
  140115. /**
  140116. * Gets wether or not G buffer are supported by the running hardware.
  140117. * This requires draw buffer supports
  140118. */
  140119. get isSupported(): boolean;
  140120. /**
  140121. * Returns the index of the given texture type in the G-Buffer textures array
  140122. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  140123. * @returns the index of the given texture type in the G-Buffer textures array
  140124. */
  140125. getTextureIndex(textureType: number): number;
  140126. /**
  140127. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  140128. */
  140129. get enablePosition(): boolean;
  140130. /**
  140131. * Sets whether or not objects positions are enabled for the G buffer.
  140132. */
  140133. set enablePosition(enable: boolean);
  140134. /**
  140135. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  140136. */
  140137. get enableVelocity(): boolean;
  140138. /**
  140139. * Sets wether or not objects velocities are enabled for the G buffer.
  140140. */
  140141. set enableVelocity(enable: boolean);
  140142. /**
  140143. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  140144. */
  140145. get enableReflectivity(): boolean;
  140146. /**
  140147. * Sets wether or not objects roughness are enabled for the G buffer.
  140148. */
  140149. set enableReflectivity(enable: boolean);
  140150. /**
  140151. * Gets the scene associated with the buffer.
  140152. */
  140153. get scene(): Scene;
  140154. /**
  140155. * Gets the ratio used by the buffer during its creation.
  140156. * How big is the buffer related to the main canvas.
  140157. */
  140158. get ratio(): number;
  140159. /** @hidden */
  140160. static _SceneComponentInitialization: (scene: Scene) => void;
  140161. /**
  140162. * Creates a new G Buffer for the scene
  140163. * @param scene The scene the buffer belongs to
  140164. * @param ratio How big is the buffer related to the main canvas.
  140165. */
  140166. constructor(scene: Scene, ratio?: number);
  140167. /**
  140168. * Checks wether everything is ready to render a submesh to the G buffer.
  140169. * @param subMesh the submesh to check readiness for
  140170. * @param useInstances is the mesh drawn using instance or not
  140171. * @returns true if ready otherwise false
  140172. */
  140173. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140174. /**
  140175. * Gets the current underlying G Buffer.
  140176. * @returns the buffer
  140177. */
  140178. getGBuffer(): MultiRenderTarget;
  140179. /**
  140180. * Gets the number of samples used to render the buffer (anti aliasing).
  140181. */
  140182. get samples(): number;
  140183. /**
  140184. * Sets the number of samples used to render the buffer (anti aliasing).
  140185. */
  140186. set samples(value: number);
  140187. /**
  140188. * Disposes the renderer and frees up associated resources.
  140189. */
  140190. dispose(): void;
  140191. protected _createRenderTargets(): void;
  140192. private _copyBonesTransformationMatrices;
  140193. }
  140194. }
  140195. declare module BABYLON {
  140196. interface Scene {
  140197. /** @hidden (Backing field) */
  140198. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  140199. /**
  140200. * Gets or Sets the current geometry buffer associated to the scene.
  140201. */
  140202. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  140203. /**
  140204. * Enables a GeometryBufferRender and associates it with the scene
  140205. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  140206. * @returns the GeometryBufferRenderer
  140207. */
  140208. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  140209. /**
  140210. * Disables the GeometryBufferRender associated with the scene
  140211. */
  140212. disableGeometryBufferRenderer(): void;
  140213. }
  140214. /**
  140215. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  140216. * in several rendering techniques.
  140217. */
  140218. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  140219. /**
  140220. * The component name helpful to identify the component in the list of scene components.
  140221. */
  140222. readonly name: string;
  140223. /**
  140224. * The scene the component belongs to.
  140225. */
  140226. scene: Scene;
  140227. /**
  140228. * Creates a new instance of the component for the given scene
  140229. * @param scene Defines the scene to register the component in
  140230. */
  140231. constructor(scene: Scene);
  140232. /**
  140233. * Registers the component in a given scene
  140234. */
  140235. register(): void;
  140236. /**
  140237. * Rebuilds the elements related to this component in case of
  140238. * context lost for instance.
  140239. */
  140240. rebuild(): void;
  140241. /**
  140242. * Disposes the component and the associated ressources
  140243. */
  140244. dispose(): void;
  140245. private _gatherRenderTargets;
  140246. }
  140247. }
  140248. declare module BABYLON {
  140249. /** @hidden */
  140250. export var motionBlurPixelShader: {
  140251. name: string;
  140252. shader: string;
  140253. };
  140254. }
  140255. declare module BABYLON {
  140256. /**
  140257. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  140258. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  140259. * As an example, all you have to do is to create the post-process:
  140260. * var mb = new BABYLON.MotionBlurPostProcess(
  140261. * 'mb', // The name of the effect.
  140262. * scene, // The scene containing the objects to blur according to their velocity.
  140263. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  140264. * camera // The camera to apply the render pass to.
  140265. * );
  140266. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  140267. */
  140268. export class MotionBlurPostProcess extends PostProcess {
  140269. /**
  140270. * Defines how much the image is blurred by the movement. Default value is equal to 1
  140271. */
  140272. motionStrength: number;
  140273. /**
  140274. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  140275. */
  140276. get motionBlurSamples(): number;
  140277. /**
  140278. * Sets the number of iterations to be used for motion blur quality
  140279. */
  140280. set motionBlurSamples(samples: number);
  140281. private _motionBlurSamples;
  140282. private _geometryBufferRenderer;
  140283. /**
  140284. * Creates a new instance MotionBlurPostProcess
  140285. * @param name The name of the effect.
  140286. * @param scene The scene containing the objects to blur according to their velocity.
  140287. * @param options The required width/height ratio to downsize to before computing the render pass.
  140288. * @param camera The camera to apply the render pass to.
  140289. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  140290. * @param engine The engine which the post process will be applied. (default: current engine)
  140291. * @param reusable If the post process can be reused on the same frame. (default: false)
  140292. * @param textureType Type of textures used when performing the post process. (default: 0)
  140293. * @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)
  140294. */
  140295. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  140296. /**
  140297. * Excludes the given skinned mesh from computing bones velocities.
  140298. * 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.
  140299. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  140300. */
  140301. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  140302. /**
  140303. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  140304. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  140305. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  140306. */
  140307. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  140308. /**
  140309. * Disposes the post process.
  140310. * @param camera The camera to dispose the post process on.
  140311. */
  140312. dispose(camera?: Camera): void;
  140313. }
  140314. }
  140315. declare module BABYLON {
  140316. /** @hidden */
  140317. export var refractionPixelShader: {
  140318. name: string;
  140319. shader: string;
  140320. };
  140321. }
  140322. declare module BABYLON {
  140323. /**
  140324. * Post process which applies a refractin texture
  140325. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  140326. */
  140327. export class RefractionPostProcess extends PostProcess {
  140328. /** the base color of the refraction (used to taint the rendering) */
  140329. color: Color3;
  140330. /** simulated refraction depth */
  140331. depth: number;
  140332. /** the coefficient of the base color (0 to remove base color tainting) */
  140333. colorLevel: number;
  140334. private _refTexture;
  140335. private _ownRefractionTexture;
  140336. /**
  140337. * Gets or sets the refraction texture
  140338. * Please note that you are responsible for disposing the texture if you set it manually
  140339. */
  140340. get refractionTexture(): Texture;
  140341. set refractionTexture(value: Texture);
  140342. /**
  140343. * Initializes the RefractionPostProcess
  140344. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  140345. * @param name The name of the effect.
  140346. * @param refractionTextureUrl Url of the refraction texture to use
  140347. * @param color the base color of the refraction (used to taint the rendering)
  140348. * @param depth simulated refraction depth
  140349. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  140350. * @param camera The camera to apply the render pass to.
  140351. * @param options The required width/height ratio to downsize to before computing the render pass.
  140352. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  140353. * @param engine The engine which the post process will be applied. (default: current engine)
  140354. * @param reusable If the post process can be reused on the same frame. (default: false)
  140355. */
  140356. constructor(name: string, refractionTextureUrl: string,
  140357. /** the base color of the refraction (used to taint the rendering) */
  140358. color: Color3,
  140359. /** simulated refraction depth */
  140360. depth: number,
  140361. /** the coefficient of the base color (0 to remove base color tainting) */
  140362. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  140363. /**
  140364. * Disposes of the post process
  140365. * @param camera Camera to dispose post process on
  140366. */
  140367. dispose(camera: Camera): void;
  140368. }
  140369. }
  140370. declare module BABYLON {
  140371. /** @hidden */
  140372. export var sharpenPixelShader: {
  140373. name: string;
  140374. shader: string;
  140375. };
  140376. }
  140377. declare module BABYLON {
  140378. /**
  140379. * The SharpenPostProcess applies a sharpen kernel to every pixel
  140380. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  140381. */
  140382. export class SharpenPostProcess extends PostProcess {
  140383. /**
  140384. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  140385. */
  140386. colorAmount: number;
  140387. /**
  140388. * How much sharpness should be applied (default: 0.3)
  140389. */
  140390. edgeAmount: number;
  140391. /**
  140392. * Creates a new instance ConvolutionPostProcess
  140393. * @param name The name of the effect.
  140394. * @param options The required width/height ratio to downsize to before computing the render pass.
  140395. * @param camera The camera to apply the render pass to.
  140396. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  140397. * @param engine The engine which the post process will be applied. (default: current engine)
  140398. * @param reusable If the post process can be reused on the same frame. (default: false)
  140399. * @param textureType Type of textures used when performing the post process. (default: 0)
  140400. * @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)
  140401. */
  140402. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  140403. }
  140404. }
  140405. declare module BABYLON {
  140406. /**
  140407. * PostProcessRenderPipeline
  140408. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  140409. */
  140410. export class PostProcessRenderPipeline {
  140411. private engine;
  140412. private _renderEffects;
  140413. private _renderEffectsForIsolatedPass;
  140414. /**
  140415. * List of inspectable custom properties (used by the Inspector)
  140416. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  140417. */
  140418. inspectableCustomProperties: IInspectable[];
  140419. /**
  140420. * @hidden
  140421. */
  140422. protected _cameras: Camera[];
  140423. /** @hidden */
  140424. _name: string;
  140425. /**
  140426. * Gets pipeline name
  140427. */
  140428. get name(): string;
  140429. /** Gets the list of attached cameras */
  140430. get cameras(): Camera[];
  140431. /**
  140432. * Initializes a PostProcessRenderPipeline
  140433. * @param engine engine to add the pipeline to
  140434. * @param name name of the pipeline
  140435. */
  140436. constructor(engine: Engine, name: string);
  140437. /**
  140438. * Gets the class name
  140439. * @returns "PostProcessRenderPipeline"
  140440. */
  140441. getClassName(): string;
  140442. /**
  140443. * If all the render effects in the pipeline are supported
  140444. */
  140445. get isSupported(): boolean;
  140446. /**
  140447. * Adds an effect to the pipeline
  140448. * @param renderEffect the effect to add
  140449. */
  140450. addEffect(renderEffect: PostProcessRenderEffect): void;
  140451. /** @hidden */
  140452. _rebuild(): void;
  140453. /** @hidden */
  140454. _enableEffect(renderEffectName: string, cameras: Camera): void;
  140455. /** @hidden */
  140456. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  140457. /** @hidden */
  140458. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  140459. /** @hidden */
  140460. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  140461. /** @hidden */
  140462. _attachCameras(cameras: Camera, unique: boolean): void;
  140463. /** @hidden */
  140464. _attachCameras(cameras: Camera[], unique: boolean): void;
  140465. /** @hidden */
  140466. _detachCameras(cameras: Camera): void;
  140467. /** @hidden */
  140468. _detachCameras(cameras: Nullable<Camera[]>): void;
  140469. /** @hidden */
  140470. _update(): void;
  140471. /** @hidden */
  140472. _reset(): void;
  140473. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  140474. /**
  140475. * Disposes of the pipeline
  140476. */
  140477. dispose(): void;
  140478. }
  140479. }
  140480. declare module BABYLON {
  140481. /**
  140482. * PostProcessRenderPipelineManager class
  140483. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  140484. */
  140485. export class PostProcessRenderPipelineManager {
  140486. private _renderPipelines;
  140487. /**
  140488. * Initializes a PostProcessRenderPipelineManager
  140489. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  140490. */
  140491. constructor();
  140492. /**
  140493. * Gets the list of supported render pipelines
  140494. */
  140495. get supportedPipelines(): PostProcessRenderPipeline[];
  140496. /**
  140497. * Adds a pipeline to the manager
  140498. * @param renderPipeline The pipeline to add
  140499. */
  140500. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  140501. /**
  140502. * Attaches a camera to the pipeline
  140503. * @param renderPipelineName The name of the pipeline to attach to
  140504. * @param cameras the camera to attach
  140505. * @param unique if the camera can be attached multiple times to the pipeline
  140506. */
  140507. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  140508. /**
  140509. * Detaches a camera from the pipeline
  140510. * @param renderPipelineName The name of the pipeline to detach from
  140511. * @param cameras the camera to detach
  140512. */
  140513. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  140514. /**
  140515. * Enables an effect by name on a pipeline
  140516. * @param renderPipelineName the name of the pipeline to enable the effect in
  140517. * @param renderEffectName the name of the effect to enable
  140518. * @param cameras the cameras that the effect should be enabled on
  140519. */
  140520. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  140521. /**
  140522. * Disables an effect by name on a pipeline
  140523. * @param renderPipelineName the name of the pipeline to disable the effect in
  140524. * @param renderEffectName the name of the effect to disable
  140525. * @param cameras the cameras that the effect should be disabled on
  140526. */
  140527. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  140528. /**
  140529. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  140530. */
  140531. update(): void;
  140532. /** @hidden */
  140533. _rebuild(): void;
  140534. /**
  140535. * Disposes of the manager and pipelines
  140536. */
  140537. dispose(): void;
  140538. }
  140539. }
  140540. declare module BABYLON {
  140541. interface Scene {
  140542. /** @hidden (Backing field) */
  140543. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  140544. /**
  140545. * Gets the postprocess render pipeline manager
  140546. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  140547. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  140548. */
  140549. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  140550. }
  140551. /**
  140552. * Defines the Render Pipeline scene component responsible to rendering pipelines
  140553. */
  140554. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  140555. /**
  140556. * The component name helpfull to identify the component in the list of scene components.
  140557. */
  140558. readonly name: string;
  140559. /**
  140560. * The scene the component belongs to.
  140561. */
  140562. scene: Scene;
  140563. /**
  140564. * Creates a new instance of the component for the given scene
  140565. * @param scene Defines the scene to register the component in
  140566. */
  140567. constructor(scene: Scene);
  140568. /**
  140569. * Registers the component in a given scene
  140570. */
  140571. register(): void;
  140572. /**
  140573. * Rebuilds the elements related to this component in case of
  140574. * context lost for instance.
  140575. */
  140576. rebuild(): void;
  140577. /**
  140578. * Disposes the component and the associated ressources
  140579. */
  140580. dispose(): void;
  140581. private _gatherRenderTargets;
  140582. }
  140583. }
  140584. declare module BABYLON {
  140585. /**
  140586. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  140587. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  140588. */
  140589. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  140590. private _scene;
  140591. private _camerasToBeAttached;
  140592. /**
  140593. * ID of the sharpen post process,
  140594. */
  140595. private readonly SharpenPostProcessId;
  140596. /**
  140597. * @ignore
  140598. * ID of the image processing post process;
  140599. */
  140600. readonly ImageProcessingPostProcessId: string;
  140601. /**
  140602. * @ignore
  140603. * ID of the Fast Approximate Anti-Aliasing post process;
  140604. */
  140605. readonly FxaaPostProcessId: string;
  140606. /**
  140607. * ID of the chromatic aberration post process,
  140608. */
  140609. private readonly ChromaticAberrationPostProcessId;
  140610. /**
  140611. * ID of the grain post process
  140612. */
  140613. private readonly GrainPostProcessId;
  140614. /**
  140615. * Sharpen post process which will apply a sharpen convolution to enhance edges
  140616. */
  140617. sharpen: SharpenPostProcess;
  140618. private _sharpenEffect;
  140619. private bloom;
  140620. /**
  140621. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  140622. */
  140623. depthOfField: DepthOfFieldEffect;
  140624. /**
  140625. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  140626. */
  140627. fxaa: FxaaPostProcess;
  140628. /**
  140629. * Image post processing pass used to perform operations such as tone mapping or color grading.
  140630. */
  140631. imageProcessing: ImageProcessingPostProcess;
  140632. /**
  140633. * Chromatic aberration post process which will shift rgb colors in the image
  140634. */
  140635. chromaticAberration: ChromaticAberrationPostProcess;
  140636. private _chromaticAberrationEffect;
  140637. /**
  140638. * Grain post process which add noise to the image
  140639. */
  140640. grain: GrainPostProcess;
  140641. private _grainEffect;
  140642. /**
  140643. * Glow post process which adds a glow to emissive areas of the image
  140644. */
  140645. private _glowLayer;
  140646. /**
  140647. * Animations which can be used to tweak settings over a period of time
  140648. */
  140649. animations: Animation[];
  140650. private _imageProcessingConfigurationObserver;
  140651. private _sharpenEnabled;
  140652. private _bloomEnabled;
  140653. private _depthOfFieldEnabled;
  140654. private _depthOfFieldBlurLevel;
  140655. private _fxaaEnabled;
  140656. private _imageProcessingEnabled;
  140657. private _defaultPipelineTextureType;
  140658. private _bloomScale;
  140659. private _chromaticAberrationEnabled;
  140660. private _grainEnabled;
  140661. private _buildAllowed;
  140662. /**
  140663. * Gets active scene
  140664. */
  140665. get scene(): Scene;
  140666. /**
  140667. * Enable or disable the sharpen process from the pipeline
  140668. */
  140669. set sharpenEnabled(enabled: boolean);
  140670. get sharpenEnabled(): boolean;
  140671. private _resizeObserver;
  140672. private _hardwareScaleLevel;
  140673. private _bloomKernel;
  140674. /**
  140675. * Specifies the size of the bloom blur kernel, relative to the final output size
  140676. */
  140677. get bloomKernel(): number;
  140678. set bloomKernel(value: number);
  140679. /**
  140680. * Specifies the weight of the bloom in the final rendering
  140681. */
  140682. private _bloomWeight;
  140683. /**
  140684. * Specifies the luma threshold for the area that will be blurred by the bloom
  140685. */
  140686. private _bloomThreshold;
  140687. private _hdr;
  140688. /**
  140689. * The strength of the bloom.
  140690. */
  140691. set bloomWeight(value: number);
  140692. get bloomWeight(): number;
  140693. /**
  140694. * The strength of the bloom.
  140695. */
  140696. set bloomThreshold(value: number);
  140697. get bloomThreshold(): number;
  140698. /**
  140699. * The scale of the bloom, lower value will provide better performance.
  140700. */
  140701. set bloomScale(value: number);
  140702. get bloomScale(): number;
  140703. /**
  140704. * Enable or disable the bloom from the pipeline
  140705. */
  140706. set bloomEnabled(enabled: boolean);
  140707. get bloomEnabled(): boolean;
  140708. private _rebuildBloom;
  140709. /**
  140710. * If the depth of field is enabled.
  140711. */
  140712. get depthOfFieldEnabled(): boolean;
  140713. set depthOfFieldEnabled(enabled: boolean);
  140714. /**
  140715. * Blur level of the depth of field effect. (Higher blur will effect performance)
  140716. */
  140717. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  140718. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  140719. /**
  140720. * If the anti aliasing is enabled.
  140721. */
  140722. set fxaaEnabled(enabled: boolean);
  140723. get fxaaEnabled(): boolean;
  140724. private _samples;
  140725. /**
  140726. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  140727. */
  140728. set samples(sampleCount: number);
  140729. get samples(): number;
  140730. /**
  140731. * If image processing is enabled.
  140732. */
  140733. set imageProcessingEnabled(enabled: boolean);
  140734. get imageProcessingEnabled(): boolean;
  140735. /**
  140736. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  140737. */
  140738. set glowLayerEnabled(enabled: boolean);
  140739. get glowLayerEnabled(): boolean;
  140740. /**
  140741. * Gets the glow layer (or null if not defined)
  140742. */
  140743. get glowLayer(): Nullable<GlowLayer>;
  140744. /**
  140745. * Enable or disable the chromaticAberration process from the pipeline
  140746. */
  140747. set chromaticAberrationEnabled(enabled: boolean);
  140748. get chromaticAberrationEnabled(): boolean;
  140749. /**
  140750. * Enable or disable the grain process from the pipeline
  140751. */
  140752. set grainEnabled(enabled: boolean);
  140753. get grainEnabled(): boolean;
  140754. /**
  140755. * @constructor
  140756. * @param name - The rendering pipeline name (default: "")
  140757. * @param hdr - If high dynamic range textures should be used (default: true)
  140758. * @param scene - The scene linked to this pipeline (default: the last created scene)
  140759. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  140760. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  140761. */
  140762. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  140763. /**
  140764. * Get the class name
  140765. * @returns "DefaultRenderingPipeline"
  140766. */
  140767. getClassName(): string;
  140768. /**
  140769. * Force the compilation of the entire pipeline.
  140770. */
  140771. prepare(): void;
  140772. private _hasCleared;
  140773. private _prevPostProcess;
  140774. private _prevPrevPostProcess;
  140775. private _setAutoClearAndTextureSharing;
  140776. private _depthOfFieldSceneObserver;
  140777. private _buildPipeline;
  140778. private _disposePostProcesses;
  140779. /**
  140780. * Adds a camera to the pipeline
  140781. * @param camera the camera to be added
  140782. */
  140783. addCamera(camera: Camera): void;
  140784. /**
  140785. * Removes a camera from the pipeline
  140786. * @param camera the camera to remove
  140787. */
  140788. removeCamera(camera: Camera): void;
  140789. /**
  140790. * Dispose of the pipeline and stop all post processes
  140791. */
  140792. dispose(): void;
  140793. /**
  140794. * Serialize the rendering pipeline (Used when exporting)
  140795. * @returns the serialized object
  140796. */
  140797. serialize(): any;
  140798. /**
  140799. * Parse the serialized pipeline
  140800. * @param source Source pipeline.
  140801. * @param scene The scene to load the pipeline to.
  140802. * @param rootUrl The URL of the serialized pipeline.
  140803. * @returns An instantiated pipeline from the serialized object.
  140804. */
  140805. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  140806. }
  140807. }
  140808. declare module BABYLON {
  140809. /** @hidden */
  140810. export var lensHighlightsPixelShader: {
  140811. name: string;
  140812. shader: string;
  140813. };
  140814. }
  140815. declare module BABYLON {
  140816. /** @hidden */
  140817. export var depthOfFieldPixelShader: {
  140818. name: string;
  140819. shader: string;
  140820. };
  140821. }
  140822. declare module BABYLON {
  140823. /**
  140824. * BABYLON.JS Chromatic Aberration GLSL Shader
  140825. * Author: Olivier Guyot
  140826. * Separates very slightly R, G and B colors on the edges of the screen
  140827. * Inspired by Francois Tarlier & Martins Upitis
  140828. */
  140829. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  140830. /**
  140831. * @ignore
  140832. * The chromatic aberration PostProcess id in the pipeline
  140833. */
  140834. LensChromaticAberrationEffect: string;
  140835. /**
  140836. * @ignore
  140837. * The highlights enhancing PostProcess id in the pipeline
  140838. */
  140839. HighlightsEnhancingEffect: string;
  140840. /**
  140841. * @ignore
  140842. * The depth-of-field PostProcess id in the pipeline
  140843. */
  140844. LensDepthOfFieldEffect: string;
  140845. private _scene;
  140846. private _depthTexture;
  140847. private _grainTexture;
  140848. private _chromaticAberrationPostProcess;
  140849. private _highlightsPostProcess;
  140850. private _depthOfFieldPostProcess;
  140851. private _edgeBlur;
  140852. private _grainAmount;
  140853. private _chromaticAberration;
  140854. private _distortion;
  140855. private _highlightsGain;
  140856. private _highlightsThreshold;
  140857. private _dofDistance;
  140858. private _dofAperture;
  140859. private _dofDarken;
  140860. private _dofPentagon;
  140861. private _blurNoise;
  140862. /**
  140863. * @constructor
  140864. *
  140865. * Effect parameters are as follow:
  140866. * {
  140867. * chromatic_aberration: number; // from 0 to x (1 for realism)
  140868. * edge_blur: number; // from 0 to x (1 for realism)
  140869. * distortion: number; // from 0 to x (1 for realism)
  140870. * grain_amount: number; // from 0 to 1
  140871. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  140872. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  140873. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  140874. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  140875. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  140876. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  140877. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  140878. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  140879. * }
  140880. * Note: if an effect parameter is unset, effect is disabled
  140881. *
  140882. * @param name The rendering pipeline name
  140883. * @param parameters - An object containing all parameters (see above)
  140884. * @param scene The scene linked to this pipeline
  140885. * @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)
  140886. * @param cameras The array of cameras that the rendering pipeline will be attached to
  140887. */
  140888. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  140889. /**
  140890. * Get the class name
  140891. * @returns "LensRenderingPipeline"
  140892. */
  140893. getClassName(): string;
  140894. /**
  140895. * Gets associated scene
  140896. */
  140897. get scene(): Scene;
  140898. /**
  140899. * Gets or sets the edge blur
  140900. */
  140901. get edgeBlur(): number;
  140902. set edgeBlur(value: number);
  140903. /**
  140904. * Gets or sets the grain amount
  140905. */
  140906. get grainAmount(): number;
  140907. set grainAmount(value: number);
  140908. /**
  140909. * Gets or sets the chromatic aberration amount
  140910. */
  140911. get chromaticAberration(): number;
  140912. set chromaticAberration(value: number);
  140913. /**
  140914. * Gets or sets the depth of field aperture
  140915. */
  140916. get dofAperture(): number;
  140917. set dofAperture(value: number);
  140918. /**
  140919. * Gets or sets the edge distortion
  140920. */
  140921. get edgeDistortion(): number;
  140922. set edgeDistortion(value: number);
  140923. /**
  140924. * Gets or sets the depth of field distortion
  140925. */
  140926. get dofDistortion(): number;
  140927. set dofDistortion(value: number);
  140928. /**
  140929. * Gets or sets the darken out of focus amount
  140930. */
  140931. get darkenOutOfFocus(): number;
  140932. set darkenOutOfFocus(value: number);
  140933. /**
  140934. * Gets or sets a boolean indicating if blur noise is enabled
  140935. */
  140936. get blurNoise(): boolean;
  140937. set blurNoise(value: boolean);
  140938. /**
  140939. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  140940. */
  140941. get pentagonBokeh(): boolean;
  140942. set pentagonBokeh(value: boolean);
  140943. /**
  140944. * Gets or sets the highlight grain amount
  140945. */
  140946. get highlightsGain(): number;
  140947. set highlightsGain(value: number);
  140948. /**
  140949. * Gets or sets the highlight threshold
  140950. */
  140951. get highlightsThreshold(): number;
  140952. set highlightsThreshold(value: number);
  140953. /**
  140954. * Sets the amount of blur at the edges
  140955. * @param amount blur amount
  140956. */
  140957. setEdgeBlur(amount: number): void;
  140958. /**
  140959. * Sets edge blur to 0
  140960. */
  140961. disableEdgeBlur(): void;
  140962. /**
  140963. * Sets the amout of grain
  140964. * @param amount Amount of grain
  140965. */
  140966. setGrainAmount(amount: number): void;
  140967. /**
  140968. * Set grain amount to 0
  140969. */
  140970. disableGrain(): void;
  140971. /**
  140972. * Sets the chromatic aberration amount
  140973. * @param amount amount of chromatic aberration
  140974. */
  140975. setChromaticAberration(amount: number): void;
  140976. /**
  140977. * Sets chromatic aberration amount to 0
  140978. */
  140979. disableChromaticAberration(): void;
  140980. /**
  140981. * Sets the EdgeDistortion amount
  140982. * @param amount amount of EdgeDistortion
  140983. */
  140984. setEdgeDistortion(amount: number): void;
  140985. /**
  140986. * Sets edge distortion to 0
  140987. */
  140988. disableEdgeDistortion(): void;
  140989. /**
  140990. * Sets the FocusDistance amount
  140991. * @param amount amount of FocusDistance
  140992. */
  140993. setFocusDistance(amount: number): void;
  140994. /**
  140995. * Disables depth of field
  140996. */
  140997. disableDepthOfField(): void;
  140998. /**
  140999. * Sets the Aperture amount
  141000. * @param amount amount of Aperture
  141001. */
  141002. setAperture(amount: number): void;
  141003. /**
  141004. * Sets the DarkenOutOfFocus amount
  141005. * @param amount amount of DarkenOutOfFocus
  141006. */
  141007. setDarkenOutOfFocus(amount: number): void;
  141008. private _pentagonBokehIsEnabled;
  141009. /**
  141010. * Creates a pentagon bokeh effect
  141011. */
  141012. enablePentagonBokeh(): void;
  141013. /**
  141014. * Disables the pentagon bokeh effect
  141015. */
  141016. disablePentagonBokeh(): void;
  141017. /**
  141018. * Enables noise blur
  141019. */
  141020. enableNoiseBlur(): void;
  141021. /**
  141022. * Disables noise blur
  141023. */
  141024. disableNoiseBlur(): void;
  141025. /**
  141026. * Sets the HighlightsGain amount
  141027. * @param amount amount of HighlightsGain
  141028. */
  141029. setHighlightsGain(amount: number): void;
  141030. /**
  141031. * Sets the HighlightsThreshold amount
  141032. * @param amount amount of HighlightsThreshold
  141033. */
  141034. setHighlightsThreshold(amount: number): void;
  141035. /**
  141036. * Disables highlights
  141037. */
  141038. disableHighlights(): void;
  141039. /**
  141040. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  141041. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  141042. */
  141043. dispose(disableDepthRender?: boolean): void;
  141044. private _createChromaticAberrationPostProcess;
  141045. private _createHighlightsPostProcess;
  141046. private _createDepthOfFieldPostProcess;
  141047. private _createGrainTexture;
  141048. }
  141049. }
  141050. declare module BABYLON {
  141051. /** @hidden */
  141052. export var ssao2PixelShader: {
  141053. name: string;
  141054. shader: string;
  141055. };
  141056. }
  141057. declare module BABYLON {
  141058. /** @hidden */
  141059. export var ssaoCombinePixelShader: {
  141060. name: string;
  141061. shader: string;
  141062. };
  141063. }
  141064. declare module BABYLON {
  141065. /**
  141066. * Render pipeline to produce ssao effect
  141067. */
  141068. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  141069. /**
  141070. * @ignore
  141071. * The PassPostProcess id in the pipeline that contains the original scene color
  141072. */
  141073. SSAOOriginalSceneColorEffect: string;
  141074. /**
  141075. * @ignore
  141076. * The SSAO PostProcess id in the pipeline
  141077. */
  141078. SSAORenderEffect: string;
  141079. /**
  141080. * @ignore
  141081. * The horizontal blur PostProcess id in the pipeline
  141082. */
  141083. SSAOBlurHRenderEffect: string;
  141084. /**
  141085. * @ignore
  141086. * The vertical blur PostProcess id in the pipeline
  141087. */
  141088. SSAOBlurVRenderEffect: string;
  141089. /**
  141090. * @ignore
  141091. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  141092. */
  141093. SSAOCombineRenderEffect: string;
  141094. /**
  141095. * The output strength of the SSAO post-process. Default value is 1.0.
  141096. */
  141097. totalStrength: number;
  141098. /**
  141099. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  141100. */
  141101. maxZ: number;
  141102. /**
  141103. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  141104. */
  141105. minZAspect: number;
  141106. private _samples;
  141107. /**
  141108. * Number of samples used for the SSAO calculations. Default value is 8
  141109. */
  141110. set samples(n: number);
  141111. get samples(): number;
  141112. private _textureSamples;
  141113. /**
  141114. * Number of samples to use for antialiasing
  141115. */
  141116. set textureSamples(n: number);
  141117. get textureSamples(): number;
  141118. /**
  141119. * Ratio object used for SSAO ratio and blur ratio
  141120. */
  141121. private _ratio;
  141122. /**
  141123. * Dynamically generated sphere sampler.
  141124. */
  141125. private _sampleSphere;
  141126. /**
  141127. * Blur filter offsets
  141128. */
  141129. private _samplerOffsets;
  141130. private _expensiveBlur;
  141131. /**
  141132. * If bilateral blur should be used
  141133. */
  141134. set expensiveBlur(b: boolean);
  141135. get expensiveBlur(): boolean;
  141136. /**
  141137. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  141138. */
  141139. radius: number;
  141140. /**
  141141. * The base color of the SSAO post-process
  141142. * The final result is "base + ssao" between [0, 1]
  141143. */
  141144. base: number;
  141145. /**
  141146. * Support test.
  141147. */
  141148. static get IsSupported(): boolean;
  141149. private _scene;
  141150. private _depthTexture;
  141151. private _normalTexture;
  141152. private _randomTexture;
  141153. private _originalColorPostProcess;
  141154. private _ssaoPostProcess;
  141155. private _blurHPostProcess;
  141156. private _blurVPostProcess;
  141157. private _ssaoCombinePostProcess;
  141158. /**
  141159. * Gets active scene
  141160. */
  141161. get scene(): Scene;
  141162. /**
  141163. * @constructor
  141164. * @param name The rendering pipeline name
  141165. * @param scene The scene linked to this pipeline
  141166. * @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 }
  141167. * @param cameras The array of cameras that the rendering pipeline will be attached to
  141168. */
  141169. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  141170. /**
  141171. * Get the class name
  141172. * @returns "SSAO2RenderingPipeline"
  141173. */
  141174. getClassName(): string;
  141175. /**
  141176. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  141177. */
  141178. dispose(disableGeometryBufferRenderer?: boolean): void;
  141179. private _createBlurPostProcess;
  141180. /** @hidden */
  141181. _rebuild(): void;
  141182. private _bits;
  141183. private _radicalInverse_VdC;
  141184. private _hammersley;
  141185. private _hemisphereSample_uniform;
  141186. private _generateHemisphere;
  141187. private _createSSAOPostProcess;
  141188. private _createSSAOCombinePostProcess;
  141189. private _createRandomTexture;
  141190. /**
  141191. * Serialize the rendering pipeline (Used when exporting)
  141192. * @returns the serialized object
  141193. */
  141194. serialize(): any;
  141195. /**
  141196. * Parse the serialized pipeline
  141197. * @param source Source pipeline.
  141198. * @param scene The scene to load the pipeline to.
  141199. * @param rootUrl The URL of the serialized pipeline.
  141200. * @returns An instantiated pipeline from the serialized object.
  141201. */
  141202. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  141203. }
  141204. }
  141205. declare module BABYLON {
  141206. /** @hidden */
  141207. export var ssaoPixelShader: {
  141208. name: string;
  141209. shader: string;
  141210. };
  141211. }
  141212. declare module BABYLON {
  141213. /**
  141214. * Render pipeline to produce ssao effect
  141215. */
  141216. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  141217. /**
  141218. * @ignore
  141219. * The PassPostProcess id in the pipeline that contains the original scene color
  141220. */
  141221. SSAOOriginalSceneColorEffect: string;
  141222. /**
  141223. * @ignore
  141224. * The SSAO PostProcess id in the pipeline
  141225. */
  141226. SSAORenderEffect: string;
  141227. /**
  141228. * @ignore
  141229. * The horizontal blur PostProcess id in the pipeline
  141230. */
  141231. SSAOBlurHRenderEffect: string;
  141232. /**
  141233. * @ignore
  141234. * The vertical blur PostProcess id in the pipeline
  141235. */
  141236. SSAOBlurVRenderEffect: string;
  141237. /**
  141238. * @ignore
  141239. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  141240. */
  141241. SSAOCombineRenderEffect: string;
  141242. /**
  141243. * The output strength of the SSAO post-process. Default value is 1.0.
  141244. */
  141245. totalStrength: number;
  141246. /**
  141247. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  141248. */
  141249. radius: number;
  141250. /**
  141251. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  141252. * Must not be equal to fallOff and superior to fallOff.
  141253. * Default value is 0.0075
  141254. */
  141255. area: number;
  141256. /**
  141257. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  141258. * Must not be equal to area and inferior to area.
  141259. * Default value is 0.000001
  141260. */
  141261. fallOff: number;
  141262. /**
  141263. * The base color of the SSAO post-process
  141264. * The final result is "base + ssao" between [0, 1]
  141265. */
  141266. base: number;
  141267. private _scene;
  141268. private _depthTexture;
  141269. private _randomTexture;
  141270. private _originalColorPostProcess;
  141271. private _ssaoPostProcess;
  141272. private _blurHPostProcess;
  141273. private _blurVPostProcess;
  141274. private _ssaoCombinePostProcess;
  141275. private _firstUpdate;
  141276. /**
  141277. * Gets active scene
  141278. */
  141279. get scene(): Scene;
  141280. /**
  141281. * @constructor
  141282. * @param name - The rendering pipeline name
  141283. * @param scene - The scene linked to this pipeline
  141284. * @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 }
  141285. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  141286. */
  141287. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  141288. /**
  141289. * Get the class name
  141290. * @returns "SSAORenderingPipeline"
  141291. */
  141292. getClassName(): string;
  141293. /**
  141294. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  141295. */
  141296. dispose(disableDepthRender?: boolean): void;
  141297. private _createBlurPostProcess;
  141298. /** @hidden */
  141299. _rebuild(): void;
  141300. private _createSSAOPostProcess;
  141301. private _createSSAOCombinePostProcess;
  141302. private _createRandomTexture;
  141303. }
  141304. }
  141305. declare module BABYLON {
  141306. /** @hidden */
  141307. export var screenSpaceReflectionPixelShader: {
  141308. name: string;
  141309. shader: string;
  141310. };
  141311. }
  141312. declare module BABYLON {
  141313. /**
  141314. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  141315. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  141316. */
  141317. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  141318. /**
  141319. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  141320. */
  141321. threshold: number;
  141322. /**
  141323. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  141324. */
  141325. strength: number;
  141326. /**
  141327. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  141328. */
  141329. reflectionSpecularFalloffExponent: number;
  141330. /**
  141331. * Gets or sets the step size used to iterate until the effect finds the color of the reflection's pixel. Typically in interval [0.1, 1.0]
  141332. */
  141333. step: number;
  141334. /**
  141335. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  141336. */
  141337. roughnessFactor: number;
  141338. private _geometryBufferRenderer;
  141339. private _enableSmoothReflections;
  141340. private _reflectionSamples;
  141341. private _smoothSteps;
  141342. /**
  141343. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  141344. * @param name The name of the effect.
  141345. * @param scene The scene containing the objects to calculate reflections.
  141346. * @param options The required width/height ratio to downsize to before computing the render pass.
  141347. * @param camera The camera to apply the render pass to.
  141348. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  141349. * @param engine The engine which the post process will be applied. (default: current engine)
  141350. * @param reusable If the post process can be reused on the same frame. (default: false)
  141351. * @param textureType Type of textures used when performing the post process. (default: 0)
  141352. * @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)
  141353. */
  141354. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  141355. /**
  141356. * Gets wether or not smoothing reflections is enabled.
  141357. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  141358. */
  141359. get enableSmoothReflections(): boolean;
  141360. /**
  141361. * Sets wether or not smoothing reflections is enabled.
  141362. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  141363. */
  141364. set enableSmoothReflections(enabled: boolean);
  141365. /**
  141366. * Gets the number of samples taken while computing reflections. More samples count is high,
  141367. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  141368. */
  141369. get reflectionSamples(): number;
  141370. /**
  141371. * Sets the number of samples taken while computing reflections. More samples count is high,
  141372. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  141373. */
  141374. set reflectionSamples(samples: number);
  141375. /**
  141376. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  141377. * more the post-process will require GPU power and can generate a drop in FPS.
  141378. * Default value (5.0) work pretty well in all cases but can be adjusted.
  141379. */
  141380. get smoothSteps(): number;
  141381. set smoothSteps(steps: number);
  141382. private _updateEffectDefines;
  141383. }
  141384. }
  141385. declare module BABYLON {
  141386. /** @hidden */
  141387. export var standardPixelShader: {
  141388. name: string;
  141389. shader: string;
  141390. };
  141391. }
  141392. declare module BABYLON {
  141393. /**
  141394. * Standard rendering pipeline
  141395. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  141396. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  141397. */
  141398. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  141399. /**
  141400. * Public members
  141401. */
  141402. /**
  141403. * Post-process which contains the original scene color before the pipeline applies all the effects
  141404. */
  141405. originalPostProcess: Nullable<PostProcess>;
  141406. /**
  141407. * Post-process used to down scale an image x4
  141408. */
  141409. downSampleX4PostProcess: Nullable<PostProcess>;
  141410. /**
  141411. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  141412. */
  141413. brightPassPostProcess: Nullable<PostProcess>;
  141414. /**
  141415. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  141416. */
  141417. blurHPostProcesses: PostProcess[];
  141418. /**
  141419. * Post-process array storing all the vertical blur post-processes used by the pipeline
  141420. */
  141421. blurVPostProcesses: PostProcess[];
  141422. /**
  141423. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  141424. */
  141425. textureAdderPostProcess: Nullable<PostProcess>;
  141426. /**
  141427. * Post-process used to create volumetric lighting effect
  141428. */
  141429. volumetricLightPostProcess: Nullable<PostProcess>;
  141430. /**
  141431. * Post-process used to smooth the previous volumetric light post-process on the X axis
  141432. */
  141433. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  141434. /**
  141435. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  141436. */
  141437. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  141438. /**
  141439. * Post-process used to merge the volumetric light effect and the real scene color
  141440. */
  141441. volumetricLightMergePostProces: Nullable<PostProcess>;
  141442. /**
  141443. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  141444. */
  141445. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  141446. /**
  141447. * Base post-process used to calculate the average luminance of the final image for HDR
  141448. */
  141449. luminancePostProcess: Nullable<PostProcess>;
  141450. /**
  141451. * Post-processes used to create down sample post-processes in order to get
  141452. * the average luminance of the final image for HDR
  141453. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  141454. */
  141455. luminanceDownSamplePostProcesses: PostProcess[];
  141456. /**
  141457. * Post-process used to create a HDR effect (light adaptation)
  141458. */
  141459. hdrPostProcess: Nullable<PostProcess>;
  141460. /**
  141461. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  141462. */
  141463. textureAdderFinalPostProcess: Nullable<PostProcess>;
  141464. /**
  141465. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  141466. */
  141467. lensFlareFinalPostProcess: Nullable<PostProcess>;
  141468. /**
  141469. * Post-process used to merge the final HDR post-process and the real scene color
  141470. */
  141471. hdrFinalPostProcess: Nullable<PostProcess>;
  141472. /**
  141473. * Post-process used to create a lens flare effect
  141474. */
  141475. lensFlarePostProcess: Nullable<PostProcess>;
  141476. /**
  141477. * Post-process that merges the result of the lens flare post-process and the real scene color
  141478. */
  141479. lensFlareComposePostProcess: Nullable<PostProcess>;
  141480. /**
  141481. * Post-process used to create a motion blur effect
  141482. */
  141483. motionBlurPostProcess: Nullable<PostProcess>;
  141484. /**
  141485. * Post-process used to create a depth of field effect
  141486. */
  141487. depthOfFieldPostProcess: Nullable<PostProcess>;
  141488. /**
  141489. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  141490. */
  141491. fxaaPostProcess: Nullable<FxaaPostProcess>;
  141492. /**
  141493. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  141494. */
  141495. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  141496. /**
  141497. * Represents the brightness threshold in order to configure the illuminated surfaces
  141498. */
  141499. brightThreshold: number;
  141500. /**
  141501. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  141502. */
  141503. blurWidth: number;
  141504. /**
  141505. * Sets if the blur for highlighted surfaces must be only horizontal
  141506. */
  141507. horizontalBlur: boolean;
  141508. /**
  141509. * Gets the overall exposure used by the pipeline
  141510. */
  141511. get exposure(): number;
  141512. /**
  141513. * Sets the overall exposure used by the pipeline
  141514. */
  141515. set exposure(value: number);
  141516. /**
  141517. * Texture used typically to simulate "dirty" on camera lens
  141518. */
  141519. lensTexture: Nullable<Texture>;
  141520. /**
  141521. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  141522. */
  141523. volumetricLightCoefficient: number;
  141524. /**
  141525. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  141526. */
  141527. volumetricLightPower: number;
  141528. /**
  141529. * Used the set the blur intensity to smooth the volumetric lights
  141530. */
  141531. volumetricLightBlurScale: number;
  141532. /**
  141533. * Light (spot or directional) used to generate the volumetric lights rays
  141534. * The source light must have a shadow generate so the pipeline can get its
  141535. * depth map
  141536. */
  141537. sourceLight: Nullable<SpotLight | DirectionalLight>;
  141538. /**
  141539. * For eye adaptation, represents the minimum luminance the eye can see
  141540. */
  141541. hdrMinimumLuminance: number;
  141542. /**
  141543. * For eye adaptation, represents the decrease luminance speed
  141544. */
  141545. hdrDecreaseRate: number;
  141546. /**
  141547. * For eye adaptation, represents the increase luminance speed
  141548. */
  141549. hdrIncreaseRate: number;
  141550. /**
  141551. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  141552. */
  141553. get hdrAutoExposure(): boolean;
  141554. /**
  141555. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  141556. */
  141557. set hdrAutoExposure(value: boolean);
  141558. /**
  141559. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  141560. */
  141561. lensColorTexture: Nullable<Texture>;
  141562. /**
  141563. * The overall strengh for the lens flare effect
  141564. */
  141565. lensFlareStrength: number;
  141566. /**
  141567. * Dispersion coefficient for lens flare ghosts
  141568. */
  141569. lensFlareGhostDispersal: number;
  141570. /**
  141571. * Main lens flare halo width
  141572. */
  141573. lensFlareHaloWidth: number;
  141574. /**
  141575. * Based on the lens distortion effect, defines how much the lens flare result
  141576. * is distorted
  141577. */
  141578. lensFlareDistortionStrength: number;
  141579. /**
  141580. * Configures the blur intensity used for for lens flare (halo)
  141581. */
  141582. lensFlareBlurWidth: number;
  141583. /**
  141584. * Lens star texture must be used to simulate rays on the flares and is available
  141585. * in the documentation
  141586. */
  141587. lensStarTexture: Nullable<Texture>;
  141588. /**
  141589. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  141590. * flare effect by taking account of the dirt texture
  141591. */
  141592. lensFlareDirtTexture: Nullable<Texture>;
  141593. /**
  141594. * Represents the focal length for the depth of field effect
  141595. */
  141596. depthOfFieldDistance: number;
  141597. /**
  141598. * Represents the blur intensity for the blurred part of the depth of field effect
  141599. */
  141600. depthOfFieldBlurWidth: number;
  141601. /**
  141602. * Gets how much the image is blurred by the movement while using the motion blur post-process
  141603. */
  141604. get motionStrength(): number;
  141605. /**
  141606. * Sets how much the image is blurred by the movement while using the motion blur post-process
  141607. */
  141608. set motionStrength(strength: number);
  141609. /**
  141610. * Gets wether or not the motion blur post-process is object based or screen based.
  141611. */
  141612. get objectBasedMotionBlur(): boolean;
  141613. /**
  141614. * Sets wether or not the motion blur post-process should be object based or screen based
  141615. */
  141616. set objectBasedMotionBlur(value: boolean);
  141617. /**
  141618. * List of animations for the pipeline (IAnimatable implementation)
  141619. */
  141620. animations: Animation[];
  141621. /**
  141622. * Private members
  141623. */
  141624. private _scene;
  141625. private _currentDepthOfFieldSource;
  141626. private _basePostProcess;
  141627. private _fixedExposure;
  141628. private _currentExposure;
  141629. private _hdrAutoExposure;
  141630. private _hdrCurrentLuminance;
  141631. private _motionStrength;
  141632. private _isObjectBasedMotionBlur;
  141633. private _floatTextureType;
  141634. private _camerasToBeAttached;
  141635. private _ratio;
  141636. private _bloomEnabled;
  141637. private _depthOfFieldEnabled;
  141638. private _vlsEnabled;
  141639. private _lensFlareEnabled;
  141640. private _hdrEnabled;
  141641. private _motionBlurEnabled;
  141642. private _fxaaEnabled;
  141643. private _screenSpaceReflectionsEnabled;
  141644. private _motionBlurSamples;
  141645. private _volumetricLightStepsCount;
  141646. private _samples;
  141647. /**
  141648. * @ignore
  141649. * Specifies if the bloom pipeline is enabled
  141650. */
  141651. get BloomEnabled(): boolean;
  141652. set BloomEnabled(enabled: boolean);
  141653. /**
  141654. * @ignore
  141655. * Specifies if the depth of field pipeline is enabed
  141656. */
  141657. get DepthOfFieldEnabled(): boolean;
  141658. set DepthOfFieldEnabled(enabled: boolean);
  141659. /**
  141660. * @ignore
  141661. * Specifies if the lens flare pipeline is enabed
  141662. */
  141663. get LensFlareEnabled(): boolean;
  141664. set LensFlareEnabled(enabled: boolean);
  141665. /**
  141666. * @ignore
  141667. * Specifies if the HDR pipeline is enabled
  141668. */
  141669. get HDREnabled(): boolean;
  141670. set HDREnabled(enabled: boolean);
  141671. /**
  141672. * @ignore
  141673. * Specifies if the volumetric lights scattering effect is enabled
  141674. */
  141675. get VLSEnabled(): boolean;
  141676. set VLSEnabled(enabled: boolean);
  141677. /**
  141678. * @ignore
  141679. * Specifies if the motion blur effect is enabled
  141680. */
  141681. get MotionBlurEnabled(): boolean;
  141682. set MotionBlurEnabled(enabled: boolean);
  141683. /**
  141684. * Specifies if anti-aliasing is enabled
  141685. */
  141686. get fxaaEnabled(): boolean;
  141687. set fxaaEnabled(enabled: boolean);
  141688. /**
  141689. * Specifies if screen space reflections are enabled.
  141690. */
  141691. get screenSpaceReflectionsEnabled(): boolean;
  141692. set screenSpaceReflectionsEnabled(enabled: boolean);
  141693. /**
  141694. * Specifies the number of steps used to calculate the volumetric lights
  141695. * Typically in interval [50, 200]
  141696. */
  141697. get volumetricLightStepsCount(): number;
  141698. set volumetricLightStepsCount(count: number);
  141699. /**
  141700. * Specifies the number of samples used for the motion blur effect
  141701. * Typically in interval [16, 64]
  141702. */
  141703. get motionBlurSamples(): number;
  141704. set motionBlurSamples(samples: number);
  141705. /**
  141706. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  141707. */
  141708. get samples(): number;
  141709. set samples(sampleCount: number);
  141710. /**
  141711. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  141712. * @constructor
  141713. * @param name The rendering pipeline name
  141714. * @param scene The scene linked to this pipeline
  141715. * @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)
  141716. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  141717. * @param cameras The array of cameras that the rendering pipeline will be attached to
  141718. */
  141719. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  141720. private _buildPipeline;
  141721. private _createDownSampleX4PostProcess;
  141722. private _createBrightPassPostProcess;
  141723. private _createBlurPostProcesses;
  141724. private _createTextureAdderPostProcess;
  141725. private _createVolumetricLightPostProcess;
  141726. private _createLuminancePostProcesses;
  141727. private _createHdrPostProcess;
  141728. private _createLensFlarePostProcess;
  141729. private _createDepthOfFieldPostProcess;
  141730. private _createMotionBlurPostProcess;
  141731. private _getDepthTexture;
  141732. private _disposePostProcesses;
  141733. /**
  141734. * Dispose of the pipeline and stop all post processes
  141735. */
  141736. dispose(): void;
  141737. /**
  141738. * Serialize the rendering pipeline (Used when exporting)
  141739. * @returns the serialized object
  141740. */
  141741. serialize(): any;
  141742. /**
  141743. * Parse the serialized pipeline
  141744. * @param source Source pipeline.
  141745. * @param scene The scene to load the pipeline to.
  141746. * @param rootUrl The URL of the serialized pipeline.
  141747. * @returns An instantiated pipeline from the serialized object.
  141748. */
  141749. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  141750. /**
  141751. * Luminance steps
  141752. */
  141753. static LuminanceSteps: number;
  141754. }
  141755. }
  141756. declare module BABYLON {
  141757. /** @hidden */
  141758. export var stereoscopicInterlacePixelShader: {
  141759. name: string;
  141760. shader: string;
  141761. };
  141762. }
  141763. declare module BABYLON {
  141764. /**
  141765. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  141766. */
  141767. export class StereoscopicInterlacePostProcessI extends PostProcess {
  141768. private _stepSize;
  141769. private _passedProcess;
  141770. /**
  141771. * Initializes a StereoscopicInterlacePostProcessI
  141772. * @param name The name of the effect.
  141773. * @param rigCameras The rig cameras to be appled to the post process
  141774. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  141775. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  141776. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  141777. * @param engine The engine which the post process will be applied. (default: current engine)
  141778. * @param reusable If the post process can be reused on the same frame. (default: false)
  141779. */
  141780. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  141781. }
  141782. /**
  141783. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  141784. */
  141785. export class StereoscopicInterlacePostProcess extends PostProcess {
  141786. private _stepSize;
  141787. private _passedProcess;
  141788. /**
  141789. * Initializes a StereoscopicInterlacePostProcess
  141790. * @param name The name of the effect.
  141791. * @param rigCameras The rig cameras to be appled to the post process
  141792. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  141793. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  141794. * @param engine The engine which the post process will be applied. (default: current engine)
  141795. * @param reusable If the post process can be reused on the same frame. (default: false)
  141796. */
  141797. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  141798. }
  141799. }
  141800. declare module BABYLON {
  141801. /** @hidden */
  141802. export var tonemapPixelShader: {
  141803. name: string;
  141804. shader: string;
  141805. };
  141806. }
  141807. declare module BABYLON {
  141808. /** Defines operator used for tonemapping */
  141809. export enum TonemappingOperator {
  141810. /** Hable */
  141811. Hable = 0,
  141812. /** Reinhard */
  141813. Reinhard = 1,
  141814. /** HejiDawson */
  141815. HejiDawson = 2,
  141816. /** Photographic */
  141817. Photographic = 3
  141818. }
  141819. /**
  141820. * Defines a post process to apply tone mapping
  141821. */
  141822. export class TonemapPostProcess extends PostProcess {
  141823. private _operator;
  141824. /** Defines the required exposure adjustement */
  141825. exposureAdjustment: number;
  141826. /**
  141827. * Creates a new TonemapPostProcess
  141828. * @param name defines the name of the postprocess
  141829. * @param _operator defines the operator to use
  141830. * @param exposureAdjustment defines the required exposure adjustement
  141831. * @param camera defines the camera to use (can be null)
  141832. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  141833. * @param engine defines the hosting engine (can be ignore if camera is set)
  141834. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  141835. */
  141836. constructor(name: string, _operator: TonemappingOperator,
  141837. /** Defines the required exposure adjustement */
  141838. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  141839. }
  141840. }
  141841. declare module BABYLON {
  141842. /** @hidden */
  141843. export var volumetricLightScatteringPixelShader: {
  141844. name: string;
  141845. shader: string;
  141846. };
  141847. }
  141848. declare module BABYLON {
  141849. /** @hidden */
  141850. export var volumetricLightScatteringPassVertexShader: {
  141851. name: string;
  141852. shader: string;
  141853. };
  141854. }
  141855. declare module BABYLON {
  141856. /** @hidden */
  141857. export var volumetricLightScatteringPassPixelShader: {
  141858. name: string;
  141859. shader: string;
  141860. };
  141861. }
  141862. declare module BABYLON {
  141863. /**
  141864. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  141865. */
  141866. export class VolumetricLightScatteringPostProcess extends PostProcess {
  141867. private _volumetricLightScatteringPass;
  141868. private _volumetricLightScatteringRTT;
  141869. private _viewPort;
  141870. private _screenCoordinates;
  141871. private _cachedDefines;
  141872. /**
  141873. * If not undefined, the mesh position is computed from the attached node position
  141874. */
  141875. attachedNode: {
  141876. position: Vector3;
  141877. };
  141878. /**
  141879. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  141880. */
  141881. customMeshPosition: Vector3;
  141882. /**
  141883. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  141884. */
  141885. useCustomMeshPosition: boolean;
  141886. /**
  141887. * If the post-process should inverse the light scattering direction
  141888. */
  141889. invert: boolean;
  141890. /**
  141891. * The internal mesh used by the post-process
  141892. */
  141893. mesh: Mesh;
  141894. /**
  141895. * @hidden
  141896. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  141897. */
  141898. get useDiffuseColor(): boolean;
  141899. set useDiffuseColor(useDiffuseColor: boolean);
  141900. /**
  141901. * Array containing the excluded meshes not rendered in the internal pass
  141902. */
  141903. excludedMeshes: AbstractMesh[];
  141904. /**
  141905. * Controls the overall intensity of the post-process
  141906. */
  141907. exposure: number;
  141908. /**
  141909. * Dissipates each sample's contribution in range [0, 1]
  141910. */
  141911. decay: number;
  141912. /**
  141913. * Controls the overall intensity of each sample
  141914. */
  141915. weight: number;
  141916. /**
  141917. * Controls the density of each sample
  141918. */
  141919. density: number;
  141920. /**
  141921. * @constructor
  141922. * @param name The post-process name
  141923. * @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)
  141924. * @param camera The camera that the post-process will be attached to
  141925. * @param mesh The mesh used to create the light scattering
  141926. * @param samples The post-process quality, default 100
  141927. * @param samplingModeThe post-process filtering mode
  141928. * @param engine The babylon engine
  141929. * @param reusable If the post-process is reusable
  141930. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  141931. */
  141932. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  141933. /**
  141934. * Returns the string "VolumetricLightScatteringPostProcess"
  141935. * @returns "VolumetricLightScatteringPostProcess"
  141936. */
  141937. getClassName(): string;
  141938. private _isReady;
  141939. /**
  141940. * Sets the new light position for light scattering effect
  141941. * @param position The new custom light position
  141942. */
  141943. setCustomMeshPosition(position: Vector3): void;
  141944. /**
  141945. * Returns the light position for light scattering effect
  141946. * @return Vector3 The custom light position
  141947. */
  141948. getCustomMeshPosition(): Vector3;
  141949. /**
  141950. * Disposes the internal assets and detaches the post-process from the camera
  141951. */
  141952. dispose(camera: Camera): void;
  141953. /**
  141954. * Returns the render target texture used by the post-process
  141955. * @return the render target texture used by the post-process
  141956. */
  141957. getPass(): RenderTargetTexture;
  141958. private _meshExcluded;
  141959. private _createPass;
  141960. private _updateMeshScreenCoordinates;
  141961. /**
  141962. * Creates a default mesh for the Volumeric Light Scattering post-process
  141963. * @param name The mesh name
  141964. * @param scene The scene where to create the mesh
  141965. * @return the default mesh
  141966. */
  141967. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  141968. }
  141969. }
  141970. declare module BABYLON {
  141971. interface Scene {
  141972. /** @hidden (Backing field) */
  141973. _boundingBoxRenderer: BoundingBoxRenderer;
  141974. /** @hidden (Backing field) */
  141975. _forceShowBoundingBoxes: boolean;
  141976. /**
  141977. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  141978. */
  141979. forceShowBoundingBoxes: boolean;
  141980. /**
  141981. * Gets the bounding box renderer associated with the scene
  141982. * @returns a BoundingBoxRenderer
  141983. */
  141984. getBoundingBoxRenderer(): BoundingBoxRenderer;
  141985. }
  141986. interface AbstractMesh {
  141987. /** @hidden (Backing field) */
  141988. _showBoundingBox: boolean;
  141989. /**
  141990. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  141991. */
  141992. showBoundingBox: boolean;
  141993. }
  141994. /**
  141995. * Component responsible of rendering the bounding box of the meshes in a scene.
  141996. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  141997. */
  141998. export class BoundingBoxRenderer implements ISceneComponent {
  141999. /**
  142000. * The component name helpfull to identify the component in the list of scene components.
  142001. */
  142002. readonly name: string;
  142003. /**
  142004. * The scene the component belongs to.
  142005. */
  142006. scene: Scene;
  142007. /**
  142008. * Color of the bounding box lines placed in front of an object
  142009. */
  142010. frontColor: Color3;
  142011. /**
  142012. * Color of the bounding box lines placed behind an object
  142013. */
  142014. backColor: Color3;
  142015. /**
  142016. * Defines if the renderer should show the back lines or not
  142017. */
  142018. showBackLines: boolean;
  142019. /**
  142020. * @hidden
  142021. */
  142022. renderList: SmartArray<BoundingBox>;
  142023. private _colorShader;
  142024. private _vertexBuffers;
  142025. private _indexBuffer;
  142026. private _fillIndexBuffer;
  142027. private _fillIndexData;
  142028. /**
  142029. * Instantiates a new bounding box renderer in a scene.
  142030. * @param scene the scene the renderer renders in
  142031. */
  142032. constructor(scene: Scene);
  142033. /**
  142034. * Registers the component in a given scene
  142035. */
  142036. register(): void;
  142037. private _evaluateSubMesh;
  142038. private _activeMesh;
  142039. private _prepareRessources;
  142040. private _createIndexBuffer;
  142041. /**
  142042. * Rebuilds the elements related to this component in case of
  142043. * context lost for instance.
  142044. */
  142045. rebuild(): void;
  142046. /**
  142047. * @hidden
  142048. */
  142049. reset(): void;
  142050. /**
  142051. * Render the bounding boxes of a specific rendering group
  142052. * @param renderingGroupId defines the rendering group to render
  142053. */
  142054. render(renderingGroupId: number): void;
  142055. /**
  142056. * In case of occlusion queries, we can render the occlusion bounding box through this method
  142057. * @param mesh Define the mesh to render the occlusion bounding box for
  142058. */
  142059. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  142060. /**
  142061. * Dispose and release the resources attached to this renderer.
  142062. */
  142063. dispose(): void;
  142064. }
  142065. }
  142066. declare module BABYLON {
  142067. interface Scene {
  142068. /** @hidden (Backing field) */
  142069. _depthRenderer: {
  142070. [id: string]: DepthRenderer;
  142071. };
  142072. /**
  142073. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  142074. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  142075. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  142076. * @returns the created depth renderer
  142077. */
  142078. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  142079. /**
  142080. * Disables a depth renderer for a given camera
  142081. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  142082. */
  142083. disableDepthRenderer(camera?: Nullable<Camera>): void;
  142084. }
  142085. /**
  142086. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  142087. * in several rendering techniques.
  142088. */
  142089. export class DepthRendererSceneComponent implements ISceneComponent {
  142090. /**
  142091. * The component name helpfull to identify the component in the list of scene components.
  142092. */
  142093. readonly name: string;
  142094. /**
  142095. * The scene the component belongs to.
  142096. */
  142097. scene: Scene;
  142098. /**
  142099. * Creates a new instance of the component for the given scene
  142100. * @param scene Defines the scene to register the component in
  142101. */
  142102. constructor(scene: Scene);
  142103. /**
  142104. * Registers the component in a given scene
  142105. */
  142106. register(): void;
  142107. /**
  142108. * Rebuilds the elements related to this component in case of
  142109. * context lost for instance.
  142110. */
  142111. rebuild(): void;
  142112. /**
  142113. * Disposes the component and the associated ressources
  142114. */
  142115. dispose(): void;
  142116. private _gatherRenderTargets;
  142117. private _gatherActiveCameraRenderTargets;
  142118. }
  142119. }
  142120. declare module BABYLON {
  142121. /** @hidden */
  142122. export var outlinePixelShader: {
  142123. name: string;
  142124. shader: string;
  142125. };
  142126. }
  142127. declare module BABYLON {
  142128. /** @hidden */
  142129. export var outlineVertexShader: {
  142130. name: string;
  142131. shader: string;
  142132. };
  142133. }
  142134. declare module BABYLON {
  142135. interface Scene {
  142136. /** @hidden */
  142137. _outlineRenderer: OutlineRenderer;
  142138. /**
  142139. * Gets the outline renderer associated with the scene
  142140. * @returns a OutlineRenderer
  142141. */
  142142. getOutlineRenderer(): OutlineRenderer;
  142143. }
  142144. interface AbstractMesh {
  142145. /** @hidden (Backing field) */
  142146. _renderOutline: boolean;
  142147. /**
  142148. * Gets or sets a boolean indicating if the outline must be rendered as well
  142149. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  142150. */
  142151. renderOutline: boolean;
  142152. /** @hidden (Backing field) */
  142153. _renderOverlay: boolean;
  142154. /**
  142155. * Gets or sets a boolean indicating if the overlay must be rendered as well
  142156. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  142157. */
  142158. renderOverlay: boolean;
  142159. }
  142160. /**
  142161. * This class is responsible to draw bothe outline/overlay of meshes.
  142162. * It should not be used directly but through the available method on mesh.
  142163. */
  142164. export class OutlineRenderer implements ISceneComponent {
  142165. /**
  142166. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  142167. */
  142168. private static _StencilReference;
  142169. /**
  142170. * The name of the component. Each component must have a unique name.
  142171. */
  142172. name: string;
  142173. /**
  142174. * The scene the component belongs to.
  142175. */
  142176. scene: Scene;
  142177. /**
  142178. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  142179. */
  142180. zOffset: number;
  142181. private _engine;
  142182. private _effect;
  142183. private _cachedDefines;
  142184. private _savedDepthWrite;
  142185. /**
  142186. * Instantiates a new outline renderer. (There could be only one per scene).
  142187. * @param scene Defines the scene it belongs to
  142188. */
  142189. constructor(scene: Scene);
  142190. /**
  142191. * Register the component to one instance of a scene.
  142192. */
  142193. register(): void;
  142194. /**
  142195. * Rebuilds the elements related to this component in case of
  142196. * context lost for instance.
  142197. */
  142198. rebuild(): void;
  142199. /**
  142200. * Disposes the component and the associated ressources.
  142201. */
  142202. dispose(): void;
  142203. /**
  142204. * Renders the outline in the canvas.
  142205. * @param subMesh Defines the sumesh to render
  142206. * @param batch Defines the batch of meshes in case of instances
  142207. * @param useOverlay Defines if the rendering is for the overlay or the outline
  142208. */
  142209. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  142210. /**
  142211. * Returns whether or not the outline renderer is ready for a given submesh.
  142212. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  142213. * @param subMesh Defines the submesh to check readyness for
  142214. * @param useInstances Defines wheter wee are trying to render instances or not
  142215. * @returns true if ready otherwise false
  142216. */
  142217. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  142218. private _beforeRenderingMesh;
  142219. private _afterRenderingMesh;
  142220. }
  142221. }
  142222. declare module BABYLON {
  142223. /**
  142224. * Defines the basic options interface of a Sprite Frame Source Size.
  142225. */
  142226. export interface ISpriteJSONSpriteSourceSize {
  142227. /**
  142228. * number of the original width of the Frame
  142229. */
  142230. w: number;
  142231. /**
  142232. * number of the original height of the Frame
  142233. */
  142234. h: number;
  142235. }
  142236. /**
  142237. * Defines the basic options interface of a Sprite Frame Data.
  142238. */
  142239. export interface ISpriteJSONSpriteFrameData {
  142240. /**
  142241. * number of the x offset of the Frame
  142242. */
  142243. x: number;
  142244. /**
  142245. * number of the y offset of the Frame
  142246. */
  142247. y: number;
  142248. /**
  142249. * number of the width of the Frame
  142250. */
  142251. w: number;
  142252. /**
  142253. * number of the height of the Frame
  142254. */
  142255. h: number;
  142256. }
  142257. /**
  142258. * Defines the basic options interface of a JSON Sprite.
  142259. */
  142260. export interface ISpriteJSONSprite {
  142261. /**
  142262. * string name of the Frame
  142263. */
  142264. filename: string;
  142265. /**
  142266. * ISpriteJSONSpriteFrame basic object of the frame data
  142267. */
  142268. frame: ISpriteJSONSpriteFrameData;
  142269. /**
  142270. * boolean to flag is the frame was rotated.
  142271. */
  142272. rotated: boolean;
  142273. /**
  142274. * boolean to flag is the frame was trimmed.
  142275. */
  142276. trimmed: boolean;
  142277. /**
  142278. * ISpriteJSONSpriteFrame basic object of the source data
  142279. */
  142280. spriteSourceSize: ISpriteJSONSpriteFrameData;
  142281. /**
  142282. * ISpriteJSONSpriteFrame basic object of the source data
  142283. */
  142284. sourceSize: ISpriteJSONSpriteSourceSize;
  142285. }
  142286. /**
  142287. * Defines the basic options interface of a JSON atlas.
  142288. */
  142289. export interface ISpriteJSONAtlas {
  142290. /**
  142291. * Array of objects that contain the frame data.
  142292. */
  142293. frames: Array<ISpriteJSONSprite>;
  142294. /**
  142295. * object basic object containing the sprite meta data.
  142296. */
  142297. meta?: object;
  142298. }
  142299. }
  142300. declare module BABYLON {
  142301. /** @hidden */
  142302. export var spriteMapPixelShader: {
  142303. name: string;
  142304. shader: string;
  142305. };
  142306. }
  142307. declare module BABYLON {
  142308. /** @hidden */
  142309. export var spriteMapVertexShader: {
  142310. name: string;
  142311. shader: string;
  142312. };
  142313. }
  142314. declare module BABYLON {
  142315. /**
  142316. * Defines the basic options interface of a SpriteMap
  142317. */
  142318. export interface ISpriteMapOptions {
  142319. /**
  142320. * Vector2 of the number of cells in the grid.
  142321. */
  142322. stageSize?: Vector2;
  142323. /**
  142324. * Vector2 of the size of the output plane in World Units.
  142325. */
  142326. outputSize?: Vector2;
  142327. /**
  142328. * Vector3 of the position of the output plane in World Units.
  142329. */
  142330. outputPosition?: Vector3;
  142331. /**
  142332. * Vector3 of the rotation of the output plane.
  142333. */
  142334. outputRotation?: Vector3;
  142335. /**
  142336. * number of layers that the system will reserve in resources.
  142337. */
  142338. layerCount?: number;
  142339. /**
  142340. * number of max animation frames a single cell will reserve in resources.
  142341. */
  142342. maxAnimationFrames?: number;
  142343. /**
  142344. * number cell index of the base tile when the system compiles.
  142345. */
  142346. baseTile?: number;
  142347. /**
  142348. * boolean flip the sprite after its been repositioned by the framing data.
  142349. */
  142350. flipU?: boolean;
  142351. /**
  142352. * Vector3 scalar of the global RGB values of the SpriteMap.
  142353. */
  142354. colorMultiply?: Vector3;
  142355. }
  142356. /**
  142357. * Defines the IDisposable interface in order to be cleanable from resources.
  142358. */
  142359. export interface ISpriteMap extends IDisposable {
  142360. /**
  142361. * String name of the SpriteMap.
  142362. */
  142363. name: string;
  142364. /**
  142365. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  142366. */
  142367. atlasJSON: ISpriteJSONAtlas;
  142368. /**
  142369. * Texture of the SpriteMap.
  142370. */
  142371. spriteSheet: Texture;
  142372. /**
  142373. * The parameters to initialize the SpriteMap with.
  142374. */
  142375. options: ISpriteMapOptions;
  142376. }
  142377. /**
  142378. * Class used to manage a grid restricted sprite deployment on an Output plane.
  142379. */
  142380. export class SpriteMap implements ISpriteMap {
  142381. /** The Name of the spriteMap */
  142382. name: string;
  142383. /** The JSON file with the frame and meta data */
  142384. atlasJSON: ISpriteJSONAtlas;
  142385. /** The systems Sprite Sheet Texture */
  142386. spriteSheet: Texture;
  142387. /** Arguments passed with the Constructor */
  142388. options: ISpriteMapOptions;
  142389. /** Public Sprite Storage array, parsed from atlasJSON */
  142390. sprites: Array<ISpriteJSONSprite>;
  142391. /** Returns the Number of Sprites in the System */
  142392. get spriteCount(): number;
  142393. /** Returns the Position of Output Plane*/
  142394. get position(): Vector3;
  142395. /** Returns the Position of Output Plane*/
  142396. set position(v: Vector3);
  142397. /** Returns the Rotation of Output Plane*/
  142398. get rotation(): Vector3;
  142399. /** Returns the Rotation of Output Plane*/
  142400. set rotation(v: Vector3);
  142401. /** Sets the AnimationMap*/
  142402. get animationMap(): RawTexture;
  142403. /** Sets the AnimationMap*/
  142404. set animationMap(v: RawTexture);
  142405. /** Scene that the SpriteMap was created in */
  142406. private _scene;
  142407. /** Texture Buffer of Float32 that holds tile frame data*/
  142408. private _frameMap;
  142409. /** Texture Buffers of Float32 that holds tileMap data*/
  142410. private _tileMaps;
  142411. /** Texture Buffer of Float32 that holds Animation Data*/
  142412. private _animationMap;
  142413. /** Custom ShaderMaterial Central to the System*/
  142414. private _material;
  142415. /** Custom ShaderMaterial Central to the System*/
  142416. private _output;
  142417. /** Systems Time Ticker*/
  142418. private _time;
  142419. /**
  142420. * Creates a new SpriteMap
  142421. * @param name defines the SpriteMaps Name
  142422. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  142423. * @param spriteSheet is the Texture that the Sprites are on.
  142424. * @param options a basic deployment configuration
  142425. * @param scene The Scene that the map is deployed on
  142426. */
  142427. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  142428. /**
  142429. * Returns tileID location
  142430. * @returns Vector2 the cell position ID
  142431. */
  142432. getTileID(): Vector2;
  142433. /**
  142434. * Gets the UV location of the mouse over the SpriteMap.
  142435. * @returns Vector2 the UV position of the mouse interaction
  142436. */
  142437. getMousePosition(): Vector2;
  142438. /**
  142439. * Creates the "frame" texture Buffer
  142440. * -------------------------------------
  142441. * Structure of frames
  142442. * "filename": "Falling-Water-2.png",
  142443. * "frame": {"x":69,"y":103,"w":24,"h":32},
  142444. * "rotated": true,
  142445. * "trimmed": true,
  142446. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  142447. * "sourceSize": {"w":32,"h":32}
  142448. * @returns RawTexture of the frameMap
  142449. */
  142450. private _createFrameBuffer;
  142451. /**
  142452. * Creates the tileMap texture Buffer
  142453. * @param buffer normally and array of numbers, or a false to generate from scratch
  142454. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  142455. * @returns RawTexture of the tileMap
  142456. */
  142457. private _createTileBuffer;
  142458. /**
  142459. * Modifies the data of the tileMaps
  142460. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  142461. * @param pos is the iVector2 Coordinates of the Tile
  142462. * @param tile The SpriteIndex of the new Tile
  142463. */
  142464. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  142465. /**
  142466. * Creates the animationMap texture Buffer
  142467. * @param buffer normally and array of numbers, or a false to generate from scratch
  142468. * @returns RawTexture of the animationMap
  142469. */
  142470. private _createTileAnimationBuffer;
  142471. /**
  142472. * Modifies the data of the animationMap
  142473. * @param cellID is the Index of the Sprite
  142474. * @param _frame is the target Animation frame
  142475. * @param toCell is the Target Index of the next frame of the animation
  142476. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  142477. * @param speed is a global scalar of the time variable on the map.
  142478. */
  142479. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  142480. /**
  142481. * Exports the .tilemaps file
  142482. */
  142483. saveTileMaps(): void;
  142484. /**
  142485. * Imports the .tilemaps file
  142486. * @param url of the .tilemaps file
  142487. */
  142488. loadTileMaps(url: string): void;
  142489. /**
  142490. * Release associated resources
  142491. */
  142492. dispose(): void;
  142493. }
  142494. }
  142495. declare module BABYLON {
  142496. /**
  142497. * Class used to manage multiple sprites of different sizes on the same spritesheet
  142498. * @see http://doc.babylonjs.com/babylon101/sprites
  142499. */
  142500. export class SpritePackedManager extends SpriteManager {
  142501. /** defines the packed manager's name */
  142502. name: string;
  142503. /**
  142504. * Creates a new sprite manager from a packed sprite sheet
  142505. * @param name defines the manager's name
  142506. * @param imgUrl defines the sprite sheet url
  142507. * @param capacity defines the maximum allowed number of sprites
  142508. * @param scene defines the hosting scene
  142509. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  142510. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  142511. * @param samplingMode defines the smapling mode to use with spritesheet
  142512. * @param fromPacked set to true; do not alter
  142513. */
  142514. constructor(
  142515. /** defines the packed manager's name */
  142516. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  142517. }
  142518. }
  142519. declare module BABYLON {
  142520. /**
  142521. * Defines the list of states available for a task inside a AssetsManager
  142522. */
  142523. export enum AssetTaskState {
  142524. /**
  142525. * Initialization
  142526. */
  142527. INIT = 0,
  142528. /**
  142529. * Running
  142530. */
  142531. RUNNING = 1,
  142532. /**
  142533. * Done
  142534. */
  142535. DONE = 2,
  142536. /**
  142537. * Error
  142538. */
  142539. ERROR = 3
  142540. }
  142541. /**
  142542. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  142543. */
  142544. export abstract class AbstractAssetTask {
  142545. /**
  142546. * Task name
  142547. */ name: string;
  142548. /**
  142549. * Callback called when the task is successful
  142550. */
  142551. onSuccess: (task: any) => void;
  142552. /**
  142553. * Callback called when the task is not successful
  142554. */
  142555. onError: (task: any, message?: string, exception?: any) => void;
  142556. /**
  142557. * Creates a new AssetsManager
  142558. * @param name defines the name of the task
  142559. */
  142560. constructor(
  142561. /**
  142562. * Task name
  142563. */ name: string);
  142564. private _isCompleted;
  142565. private _taskState;
  142566. private _errorObject;
  142567. /**
  142568. * Get if the task is completed
  142569. */
  142570. get isCompleted(): boolean;
  142571. /**
  142572. * Gets the current state of the task
  142573. */
  142574. get taskState(): AssetTaskState;
  142575. /**
  142576. * Gets the current error object (if task is in error)
  142577. */
  142578. get errorObject(): {
  142579. message?: string;
  142580. exception?: any;
  142581. };
  142582. /**
  142583. * Internal only
  142584. * @hidden
  142585. */
  142586. _setErrorObject(message?: string, exception?: any): void;
  142587. /**
  142588. * Execute the current task
  142589. * @param scene defines the scene where you want your assets to be loaded
  142590. * @param onSuccess is a callback called when the task is successfully executed
  142591. * @param onError is a callback called if an error occurs
  142592. */
  142593. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142594. /**
  142595. * Execute the current task
  142596. * @param scene defines the scene where you want your assets to be loaded
  142597. * @param onSuccess is a callback called when the task is successfully executed
  142598. * @param onError is a callback called if an error occurs
  142599. */
  142600. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142601. /**
  142602. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  142603. * This can be used with failed tasks that have the reason for failure fixed.
  142604. */
  142605. reset(): void;
  142606. private onErrorCallback;
  142607. private onDoneCallback;
  142608. }
  142609. /**
  142610. * Define the interface used by progress events raised during assets loading
  142611. */
  142612. export interface IAssetsProgressEvent {
  142613. /**
  142614. * Defines the number of remaining tasks to process
  142615. */
  142616. remainingCount: number;
  142617. /**
  142618. * Defines the total number of tasks
  142619. */
  142620. totalCount: number;
  142621. /**
  142622. * Defines the task that was just processed
  142623. */
  142624. task: AbstractAssetTask;
  142625. }
  142626. /**
  142627. * Class used to share progress information about assets loading
  142628. */
  142629. export class AssetsProgressEvent implements IAssetsProgressEvent {
  142630. /**
  142631. * Defines the number of remaining tasks to process
  142632. */
  142633. remainingCount: number;
  142634. /**
  142635. * Defines the total number of tasks
  142636. */
  142637. totalCount: number;
  142638. /**
  142639. * Defines the task that was just processed
  142640. */
  142641. task: AbstractAssetTask;
  142642. /**
  142643. * Creates a AssetsProgressEvent
  142644. * @param remainingCount defines the number of remaining tasks to process
  142645. * @param totalCount defines the total number of tasks
  142646. * @param task defines the task that was just processed
  142647. */
  142648. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  142649. }
  142650. /**
  142651. * Define a task used by AssetsManager to load meshes
  142652. */
  142653. export class MeshAssetTask extends AbstractAssetTask {
  142654. /**
  142655. * Defines the name of the task
  142656. */
  142657. name: string;
  142658. /**
  142659. * Defines the list of mesh's names you want to load
  142660. */
  142661. meshesNames: any;
  142662. /**
  142663. * Defines the root url to use as a base to load your meshes and associated resources
  142664. */
  142665. rootUrl: string;
  142666. /**
  142667. * Defines the filename of the scene to load from
  142668. */
  142669. sceneFilename: string;
  142670. /**
  142671. * Gets the list of loaded meshes
  142672. */
  142673. loadedMeshes: Array<AbstractMesh>;
  142674. /**
  142675. * Gets the list of loaded particle systems
  142676. */
  142677. loadedParticleSystems: Array<IParticleSystem>;
  142678. /**
  142679. * Gets the list of loaded skeletons
  142680. */
  142681. loadedSkeletons: Array<Skeleton>;
  142682. /**
  142683. * Gets the list of loaded animation groups
  142684. */
  142685. loadedAnimationGroups: Array<AnimationGroup>;
  142686. /**
  142687. * Callback called when the task is successful
  142688. */
  142689. onSuccess: (task: MeshAssetTask) => void;
  142690. /**
  142691. * Callback called when the task is successful
  142692. */
  142693. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  142694. /**
  142695. * Creates a new MeshAssetTask
  142696. * @param name defines the name of the task
  142697. * @param meshesNames defines the list of mesh's names you want to load
  142698. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  142699. * @param sceneFilename defines the filename of the scene to load from
  142700. */
  142701. constructor(
  142702. /**
  142703. * Defines the name of the task
  142704. */
  142705. name: string,
  142706. /**
  142707. * Defines the list of mesh's names you want to load
  142708. */
  142709. meshesNames: any,
  142710. /**
  142711. * Defines the root url to use as a base to load your meshes and associated resources
  142712. */
  142713. rootUrl: string,
  142714. /**
  142715. * Defines the filename of the scene to load from
  142716. */
  142717. sceneFilename: string);
  142718. /**
  142719. * Execute the current task
  142720. * @param scene defines the scene where you want your assets to be loaded
  142721. * @param onSuccess is a callback called when the task is successfully executed
  142722. * @param onError is a callback called if an error occurs
  142723. */
  142724. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142725. }
  142726. /**
  142727. * Define a task used by AssetsManager to load text content
  142728. */
  142729. export class TextFileAssetTask extends AbstractAssetTask {
  142730. /**
  142731. * Defines the name of the task
  142732. */
  142733. name: string;
  142734. /**
  142735. * Defines the location of the file to load
  142736. */
  142737. url: string;
  142738. /**
  142739. * Gets the loaded text string
  142740. */
  142741. text: string;
  142742. /**
  142743. * Callback called when the task is successful
  142744. */
  142745. onSuccess: (task: TextFileAssetTask) => void;
  142746. /**
  142747. * Callback called when the task is successful
  142748. */
  142749. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  142750. /**
  142751. * Creates a new TextFileAssetTask object
  142752. * @param name defines the name of the task
  142753. * @param url defines the location of the file to load
  142754. */
  142755. constructor(
  142756. /**
  142757. * Defines the name of the task
  142758. */
  142759. name: string,
  142760. /**
  142761. * Defines the location of the file to load
  142762. */
  142763. url: string);
  142764. /**
  142765. * Execute the current task
  142766. * @param scene defines the scene where you want your assets to be loaded
  142767. * @param onSuccess is a callback called when the task is successfully executed
  142768. * @param onError is a callback called if an error occurs
  142769. */
  142770. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142771. }
  142772. /**
  142773. * Define a task used by AssetsManager to load binary data
  142774. */
  142775. export class BinaryFileAssetTask extends AbstractAssetTask {
  142776. /**
  142777. * Defines the name of the task
  142778. */
  142779. name: string;
  142780. /**
  142781. * Defines the location of the file to load
  142782. */
  142783. url: string;
  142784. /**
  142785. * Gets the lodaded data (as an array buffer)
  142786. */
  142787. data: ArrayBuffer;
  142788. /**
  142789. * Callback called when the task is successful
  142790. */
  142791. onSuccess: (task: BinaryFileAssetTask) => void;
  142792. /**
  142793. * Callback called when the task is successful
  142794. */
  142795. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  142796. /**
  142797. * Creates a new BinaryFileAssetTask object
  142798. * @param name defines the name of the new task
  142799. * @param url defines the location of the file to load
  142800. */
  142801. constructor(
  142802. /**
  142803. * Defines the name of the task
  142804. */
  142805. name: string,
  142806. /**
  142807. * Defines the location of the file to load
  142808. */
  142809. url: string);
  142810. /**
  142811. * Execute the current task
  142812. * @param scene defines the scene where you want your assets to be loaded
  142813. * @param onSuccess is a callback called when the task is successfully executed
  142814. * @param onError is a callback called if an error occurs
  142815. */
  142816. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142817. }
  142818. /**
  142819. * Define a task used by AssetsManager to load images
  142820. */
  142821. export class ImageAssetTask extends AbstractAssetTask {
  142822. /**
  142823. * Defines the name of the task
  142824. */
  142825. name: string;
  142826. /**
  142827. * Defines the location of the image to load
  142828. */
  142829. url: string;
  142830. /**
  142831. * Gets the loaded images
  142832. */
  142833. image: HTMLImageElement;
  142834. /**
  142835. * Callback called when the task is successful
  142836. */
  142837. onSuccess: (task: ImageAssetTask) => void;
  142838. /**
  142839. * Callback called when the task is successful
  142840. */
  142841. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  142842. /**
  142843. * Creates a new ImageAssetTask
  142844. * @param name defines the name of the task
  142845. * @param url defines the location of the image to load
  142846. */
  142847. constructor(
  142848. /**
  142849. * Defines the name of the task
  142850. */
  142851. name: string,
  142852. /**
  142853. * Defines the location of the image to load
  142854. */
  142855. url: string);
  142856. /**
  142857. * Execute the current task
  142858. * @param scene defines the scene where you want your assets to be loaded
  142859. * @param onSuccess is a callback called when the task is successfully executed
  142860. * @param onError is a callback called if an error occurs
  142861. */
  142862. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142863. }
  142864. /**
  142865. * Defines the interface used by texture loading tasks
  142866. */
  142867. export interface ITextureAssetTask<TEX extends BaseTexture> {
  142868. /**
  142869. * Gets the loaded texture
  142870. */
  142871. texture: TEX;
  142872. }
  142873. /**
  142874. * Define a task used by AssetsManager to load 2D textures
  142875. */
  142876. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  142877. /**
  142878. * Defines the name of the task
  142879. */
  142880. name: string;
  142881. /**
  142882. * Defines the location of the file to load
  142883. */
  142884. url: string;
  142885. /**
  142886. * Defines if mipmap should not be generated (default is false)
  142887. */
  142888. noMipmap?: boolean | undefined;
  142889. /**
  142890. * Defines if texture must be inverted on Y axis (default is true)
  142891. */
  142892. invertY: boolean;
  142893. /**
  142894. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  142895. */
  142896. samplingMode: number;
  142897. /**
  142898. * Gets the loaded texture
  142899. */
  142900. texture: Texture;
  142901. /**
  142902. * Callback called when the task is successful
  142903. */
  142904. onSuccess: (task: TextureAssetTask) => void;
  142905. /**
  142906. * Callback called when the task is successful
  142907. */
  142908. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  142909. /**
  142910. * Creates a new TextureAssetTask object
  142911. * @param name defines the name of the task
  142912. * @param url defines the location of the file to load
  142913. * @param noMipmap defines if mipmap should not be generated (default is false)
  142914. * @param invertY defines if texture must be inverted on Y axis (default is true)
  142915. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  142916. */
  142917. constructor(
  142918. /**
  142919. * Defines the name of the task
  142920. */
  142921. name: string,
  142922. /**
  142923. * Defines the location of the file to load
  142924. */
  142925. url: string,
  142926. /**
  142927. * Defines if mipmap should not be generated (default is false)
  142928. */
  142929. noMipmap?: boolean | undefined,
  142930. /**
  142931. * Defines if texture must be inverted on Y axis (default is true)
  142932. */
  142933. invertY?: boolean,
  142934. /**
  142935. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  142936. */
  142937. samplingMode?: number);
  142938. /**
  142939. * Execute the current task
  142940. * @param scene defines the scene where you want your assets to be loaded
  142941. * @param onSuccess is a callback called when the task is successfully executed
  142942. * @param onError is a callback called if an error occurs
  142943. */
  142944. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142945. }
  142946. /**
  142947. * Define a task used by AssetsManager to load cube textures
  142948. */
  142949. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  142950. /**
  142951. * Defines the name of the task
  142952. */
  142953. name: string;
  142954. /**
  142955. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  142956. */
  142957. url: string;
  142958. /**
  142959. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  142960. */
  142961. extensions?: string[] | undefined;
  142962. /**
  142963. * Defines if mipmaps should not be generated (default is false)
  142964. */
  142965. noMipmap?: boolean | undefined;
  142966. /**
  142967. * Defines the explicit list of files (undefined by default)
  142968. */
  142969. files?: string[] | undefined;
  142970. /**
  142971. * Gets the loaded texture
  142972. */
  142973. texture: CubeTexture;
  142974. /**
  142975. * Callback called when the task is successful
  142976. */
  142977. onSuccess: (task: CubeTextureAssetTask) => void;
  142978. /**
  142979. * Callback called when the task is successful
  142980. */
  142981. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  142982. /**
  142983. * Creates a new CubeTextureAssetTask
  142984. * @param name defines the name of the task
  142985. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  142986. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  142987. * @param noMipmap defines if mipmaps should not be generated (default is false)
  142988. * @param files defines the explicit list of files (undefined by default)
  142989. */
  142990. constructor(
  142991. /**
  142992. * Defines the name of the task
  142993. */
  142994. name: string,
  142995. /**
  142996. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  142997. */
  142998. url: string,
  142999. /**
  143000. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  143001. */
  143002. extensions?: string[] | undefined,
  143003. /**
  143004. * Defines if mipmaps should not be generated (default is false)
  143005. */
  143006. noMipmap?: boolean | undefined,
  143007. /**
  143008. * Defines the explicit list of files (undefined by default)
  143009. */
  143010. files?: string[] | undefined);
  143011. /**
  143012. * Execute the current task
  143013. * @param scene defines the scene where you want your assets to be loaded
  143014. * @param onSuccess is a callback called when the task is successfully executed
  143015. * @param onError is a callback called if an error occurs
  143016. */
  143017. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  143018. }
  143019. /**
  143020. * Define a task used by AssetsManager to load HDR cube textures
  143021. */
  143022. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  143023. /**
  143024. * Defines the name of the task
  143025. */
  143026. name: string;
  143027. /**
  143028. * Defines the location of the file to load
  143029. */
  143030. url: string;
  143031. /**
  143032. * Defines the desired size (the more it increases the longer the generation will be)
  143033. */
  143034. size: number;
  143035. /**
  143036. * Defines if mipmaps should not be generated (default is false)
  143037. */
  143038. noMipmap: boolean;
  143039. /**
  143040. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  143041. */
  143042. generateHarmonics: boolean;
  143043. /**
  143044. * 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)
  143045. */
  143046. gammaSpace: boolean;
  143047. /**
  143048. * Internal Use Only
  143049. */
  143050. reserved: boolean;
  143051. /**
  143052. * Gets the loaded texture
  143053. */
  143054. texture: HDRCubeTexture;
  143055. /**
  143056. * Callback called when the task is successful
  143057. */
  143058. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  143059. /**
  143060. * Callback called when the task is successful
  143061. */
  143062. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  143063. /**
  143064. * Creates a new HDRCubeTextureAssetTask object
  143065. * @param name defines the name of the task
  143066. * @param url defines the location of the file to load
  143067. * @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.
  143068. * @param noMipmap defines if mipmaps should not be generated (default is false)
  143069. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  143070. * @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)
  143071. * @param reserved Internal use only
  143072. */
  143073. constructor(
  143074. /**
  143075. * Defines the name of the task
  143076. */
  143077. name: string,
  143078. /**
  143079. * Defines the location of the file to load
  143080. */
  143081. url: string,
  143082. /**
  143083. * Defines the desired size (the more it increases the longer the generation will be)
  143084. */
  143085. size: number,
  143086. /**
  143087. * Defines if mipmaps should not be generated (default is false)
  143088. */
  143089. noMipmap?: boolean,
  143090. /**
  143091. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  143092. */
  143093. generateHarmonics?: boolean,
  143094. /**
  143095. * 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)
  143096. */
  143097. gammaSpace?: boolean,
  143098. /**
  143099. * Internal Use Only
  143100. */
  143101. reserved?: boolean);
  143102. /**
  143103. * Execute the current task
  143104. * @param scene defines the scene where you want your assets to be loaded
  143105. * @param onSuccess is a callback called when the task is successfully executed
  143106. * @param onError is a callback called if an error occurs
  143107. */
  143108. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  143109. }
  143110. /**
  143111. * Define a task used by AssetsManager to load Equirectangular cube textures
  143112. */
  143113. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  143114. /**
  143115. * Defines the name of the task
  143116. */
  143117. name: string;
  143118. /**
  143119. * Defines the location of the file to load
  143120. */
  143121. url: string;
  143122. /**
  143123. * Defines the desired size (the more it increases the longer the generation will be)
  143124. */
  143125. size: number;
  143126. /**
  143127. * Defines if mipmaps should not be generated (default is false)
  143128. */
  143129. noMipmap: boolean;
  143130. /**
  143131. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  143132. * but the standard material would require them in Gamma space) (default is true)
  143133. */
  143134. gammaSpace: boolean;
  143135. /**
  143136. * Gets the loaded texture
  143137. */
  143138. texture: EquiRectangularCubeTexture;
  143139. /**
  143140. * Callback called when the task is successful
  143141. */
  143142. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  143143. /**
  143144. * Callback called when the task is successful
  143145. */
  143146. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  143147. /**
  143148. * Creates a new EquiRectangularCubeTextureAssetTask object
  143149. * @param name defines the name of the task
  143150. * @param url defines the location of the file to load
  143151. * @param size defines the desired size (the more it increases the longer the generation will be)
  143152. * If the size is omitted this implies you are using a preprocessed cubemap.
  143153. * @param noMipmap defines if mipmaps should not be generated (default is false)
  143154. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  143155. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  143156. * (default is true)
  143157. */
  143158. constructor(
  143159. /**
  143160. * Defines the name of the task
  143161. */
  143162. name: string,
  143163. /**
  143164. * Defines the location of the file to load
  143165. */
  143166. url: string,
  143167. /**
  143168. * Defines the desired size (the more it increases the longer the generation will be)
  143169. */
  143170. size: number,
  143171. /**
  143172. * Defines if mipmaps should not be generated (default is false)
  143173. */
  143174. noMipmap?: boolean,
  143175. /**
  143176. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  143177. * but the standard material would require them in Gamma space) (default is true)
  143178. */
  143179. gammaSpace?: boolean);
  143180. /**
  143181. * Execute the current task
  143182. * @param scene defines the scene where you want your assets to be loaded
  143183. * @param onSuccess is a callback called when the task is successfully executed
  143184. * @param onError is a callback called if an error occurs
  143185. */
  143186. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  143187. }
  143188. /**
  143189. * This class can be used to easily import assets into a scene
  143190. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  143191. */
  143192. export class AssetsManager {
  143193. private _scene;
  143194. private _isLoading;
  143195. protected _tasks: AbstractAssetTask[];
  143196. protected _waitingTasksCount: number;
  143197. protected _totalTasksCount: number;
  143198. /**
  143199. * Callback called when all tasks are processed
  143200. */
  143201. onFinish: (tasks: AbstractAssetTask[]) => void;
  143202. /**
  143203. * Callback called when a task is successful
  143204. */
  143205. onTaskSuccess: (task: AbstractAssetTask) => void;
  143206. /**
  143207. * Callback called when a task had an error
  143208. */
  143209. onTaskError: (task: AbstractAssetTask) => void;
  143210. /**
  143211. * Callback called when a task is done (whatever the result is)
  143212. */
  143213. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  143214. /**
  143215. * Observable called when all tasks are processed
  143216. */
  143217. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  143218. /**
  143219. * Observable called when a task had an error
  143220. */
  143221. onTaskErrorObservable: Observable<AbstractAssetTask>;
  143222. /**
  143223. * Observable called when all tasks were executed
  143224. */
  143225. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  143226. /**
  143227. * Observable called when a task is done (whatever the result is)
  143228. */
  143229. onProgressObservable: Observable<IAssetsProgressEvent>;
  143230. /**
  143231. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  143232. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  143233. */
  143234. useDefaultLoadingScreen: boolean;
  143235. /**
  143236. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  143237. * when all assets have been downloaded.
  143238. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  143239. */
  143240. autoHideLoadingUI: boolean;
  143241. /**
  143242. * Creates a new AssetsManager
  143243. * @param scene defines the scene to work on
  143244. */
  143245. constructor(scene: Scene);
  143246. /**
  143247. * Add a MeshAssetTask to the list of active tasks
  143248. * @param taskName defines the name of the new task
  143249. * @param meshesNames defines the name of meshes to load
  143250. * @param rootUrl defines the root url to use to locate files
  143251. * @param sceneFilename defines the filename of the scene file
  143252. * @returns a new MeshAssetTask object
  143253. */
  143254. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  143255. /**
  143256. * Add a TextFileAssetTask to the list of active tasks
  143257. * @param taskName defines the name of the new task
  143258. * @param url defines the url of the file to load
  143259. * @returns a new TextFileAssetTask object
  143260. */
  143261. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  143262. /**
  143263. * Add a BinaryFileAssetTask to the list of active tasks
  143264. * @param taskName defines the name of the new task
  143265. * @param url defines the url of the file to load
  143266. * @returns a new BinaryFileAssetTask object
  143267. */
  143268. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  143269. /**
  143270. * Add a ImageAssetTask to the list of active tasks
  143271. * @param taskName defines the name of the new task
  143272. * @param url defines the url of the file to load
  143273. * @returns a new ImageAssetTask object
  143274. */
  143275. addImageTask(taskName: string, url: string): ImageAssetTask;
  143276. /**
  143277. * Add a TextureAssetTask to the list of active tasks
  143278. * @param taskName defines the name of the new task
  143279. * @param url defines the url of the file to load
  143280. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  143281. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  143282. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  143283. * @returns a new TextureAssetTask object
  143284. */
  143285. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  143286. /**
  143287. * Add a CubeTextureAssetTask to the list of active tasks
  143288. * @param taskName defines the name of the new task
  143289. * @param url defines the url of the file to load
  143290. * @param extensions defines the extension to use to load the cube map (can be null)
  143291. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  143292. * @param files defines the list of files to load (can be null)
  143293. * @returns a new CubeTextureAssetTask object
  143294. */
  143295. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  143296. /**
  143297. *
  143298. * Add a HDRCubeTextureAssetTask to the list of active tasks
  143299. * @param taskName defines the name of the new task
  143300. * @param url defines the url of the file to load
  143301. * @param size defines the size you want for the cubemap (can be null)
  143302. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  143303. * @param generateHarmonics defines if you want to automatically generate (true by default)
  143304. * @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)
  143305. * @param reserved Internal use only
  143306. * @returns a new HDRCubeTextureAssetTask object
  143307. */
  143308. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  143309. /**
  143310. *
  143311. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  143312. * @param taskName defines the name of the new task
  143313. * @param url defines the url of the file to load
  143314. * @param size defines the size you want for the cubemap (can be null)
  143315. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  143316. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  143317. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  143318. * @returns a new EquiRectangularCubeTextureAssetTask object
  143319. */
  143320. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  143321. /**
  143322. * Remove a task from the assets manager.
  143323. * @param task the task to remove
  143324. */
  143325. removeTask(task: AbstractAssetTask): void;
  143326. private _decreaseWaitingTasksCount;
  143327. private _runTask;
  143328. /**
  143329. * Reset the AssetsManager and remove all tasks
  143330. * @return the current instance of the AssetsManager
  143331. */
  143332. reset(): AssetsManager;
  143333. /**
  143334. * Start the loading process
  143335. * @return the current instance of the AssetsManager
  143336. */
  143337. load(): AssetsManager;
  143338. /**
  143339. * Start the loading process as an async operation
  143340. * @return a promise returning the list of failed tasks
  143341. */
  143342. loadAsync(): Promise<void>;
  143343. }
  143344. }
  143345. declare module BABYLON {
  143346. /**
  143347. * Wrapper class for promise with external resolve and reject.
  143348. */
  143349. export class Deferred<T> {
  143350. /**
  143351. * The promise associated with this deferred object.
  143352. */
  143353. readonly promise: Promise<T>;
  143354. private _resolve;
  143355. private _reject;
  143356. /**
  143357. * The resolve method of the promise associated with this deferred object.
  143358. */
  143359. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  143360. /**
  143361. * The reject method of the promise associated with this deferred object.
  143362. */
  143363. get reject(): (reason?: any) => void;
  143364. /**
  143365. * Constructor for this deferred object.
  143366. */
  143367. constructor();
  143368. }
  143369. }
  143370. declare module BABYLON {
  143371. /**
  143372. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  143373. */
  143374. export class MeshExploder {
  143375. private _centerMesh;
  143376. private _meshes;
  143377. private _meshesOrigins;
  143378. private _toCenterVectors;
  143379. private _scaledDirection;
  143380. private _newPosition;
  143381. private _centerPosition;
  143382. /**
  143383. * Explodes meshes from a center mesh.
  143384. * @param meshes The meshes to explode.
  143385. * @param centerMesh The mesh to be center of explosion.
  143386. */
  143387. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  143388. private _setCenterMesh;
  143389. /**
  143390. * Get class name
  143391. * @returns "MeshExploder"
  143392. */
  143393. getClassName(): string;
  143394. /**
  143395. * "Exploded meshes"
  143396. * @returns Array of meshes with the centerMesh at index 0.
  143397. */
  143398. getMeshes(): Array<Mesh>;
  143399. /**
  143400. * Explodes meshes giving a specific direction
  143401. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  143402. */
  143403. explode(direction?: number): void;
  143404. }
  143405. }
  143406. declare module BABYLON {
  143407. /**
  143408. * Class used to help managing file picking and drag'n'drop
  143409. */
  143410. export class FilesInput {
  143411. /**
  143412. * List of files ready to be loaded
  143413. */
  143414. static get FilesToLoad(): {
  143415. [key: string]: File;
  143416. };
  143417. /**
  143418. * Callback called when a file is processed
  143419. */
  143420. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  143421. private _engine;
  143422. private _currentScene;
  143423. private _sceneLoadedCallback;
  143424. private _progressCallback;
  143425. private _additionalRenderLoopLogicCallback;
  143426. private _textureLoadingCallback;
  143427. private _startingProcessingFilesCallback;
  143428. private _onReloadCallback;
  143429. private _errorCallback;
  143430. private _elementToMonitor;
  143431. private _sceneFileToLoad;
  143432. private _filesToLoad;
  143433. /**
  143434. * Creates a new FilesInput
  143435. * @param engine defines the rendering engine
  143436. * @param scene defines the hosting scene
  143437. * @param sceneLoadedCallback callback called when scene is loaded
  143438. * @param progressCallback callback called to track progress
  143439. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  143440. * @param textureLoadingCallback callback called when a texture is loading
  143441. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  143442. * @param onReloadCallback callback called when a reload is requested
  143443. * @param errorCallback callback call if an error occurs
  143444. */
  143445. 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);
  143446. private _dragEnterHandler;
  143447. private _dragOverHandler;
  143448. private _dropHandler;
  143449. /**
  143450. * Calls this function to listen to drag'n'drop events on a specific DOM element
  143451. * @param elementToMonitor defines the DOM element to track
  143452. */
  143453. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  143454. /**
  143455. * Release all associated resources
  143456. */
  143457. dispose(): void;
  143458. private renderFunction;
  143459. private drag;
  143460. private drop;
  143461. private _traverseFolder;
  143462. private _processFiles;
  143463. /**
  143464. * Load files from a drop event
  143465. * @param event defines the drop event to use as source
  143466. */
  143467. loadFiles(event: any): void;
  143468. private _processReload;
  143469. /**
  143470. * Reload the current scene from the loaded files
  143471. */
  143472. reload(): void;
  143473. }
  143474. }
  143475. declare module BABYLON {
  143476. /**
  143477. * Defines the root class used to create scene optimization to use with SceneOptimizer
  143478. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143479. */
  143480. export class SceneOptimization {
  143481. /**
  143482. * Defines the priority of this optimization (0 by default which means first in the list)
  143483. */
  143484. priority: number;
  143485. /**
  143486. * Gets a string describing the action executed by the current optimization
  143487. * @returns description string
  143488. */
  143489. getDescription(): string;
  143490. /**
  143491. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143492. * @param scene defines the current scene where to apply this optimization
  143493. * @param optimizer defines the current optimizer
  143494. * @returns true if everything that can be done was applied
  143495. */
  143496. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143497. /**
  143498. * Creates the SceneOptimization object
  143499. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  143500. * @param desc defines the description associated with the optimization
  143501. */
  143502. constructor(
  143503. /**
  143504. * Defines the priority of this optimization (0 by default which means first in the list)
  143505. */
  143506. priority?: number);
  143507. }
  143508. /**
  143509. * Defines an optimization used to reduce the size of render target textures
  143510. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143511. */
  143512. export class TextureOptimization extends SceneOptimization {
  143513. /**
  143514. * Defines the priority of this optimization (0 by default which means first in the list)
  143515. */
  143516. priority: number;
  143517. /**
  143518. * 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
  143519. */
  143520. maximumSize: number;
  143521. /**
  143522. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  143523. */
  143524. step: number;
  143525. /**
  143526. * Gets a string describing the action executed by the current optimization
  143527. * @returns description string
  143528. */
  143529. getDescription(): string;
  143530. /**
  143531. * Creates the TextureOptimization object
  143532. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  143533. * @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
  143534. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  143535. */
  143536. constructor(
  143537. /**
  143538. * Defines the priority of this optimization (0 by default which means first in the list)
  143539. */
  143540. priority?: number,
  143541. /**
  143542. * 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
  143543. */
  143544. maximumSize?: number,
  143545. /**
  143546. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  143547. */
  143548. step?: number);
  143549. /**
  143550. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143551. * @param scene defines the current scene where to apply this optimization
  143552. * @param optimizer defines the current optimizer
  143553. * @returns true if everything that can be done was applied
  143554. */
  143555. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143556. }
  143557. /**
  143558. * Defines an optimization used to increase or decrease the rendering resolution
  143559. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143560. */
  143561. export class HardwareScalingOptimization extends SceneOptimization {
  143562. /**
  143563. * Defines the priority of this optimization (0 by default which means first in the list)
  143564. */
  143565. priority: number;
  143566. /**
  143567. * Defines the maximum scale to use (2 by default)
  143568. */
  143569. maximumScale: number;
  143570. /**
  143571. * Defines the step to use between two passes (0.5 by default)
  143572. */
  143573. step: number;
  143574. private _currentScale;
  143575. private _directionOffset;
  143576. /**
  143577. * Gets a string describing the action executed by the current optimization
  143578. * @return description string
  143579. */
  143580. getDescription(): string;
  143581. /**
  143582. * Creates the HardwareScalingOptimization object
  143583. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  143584. * @param maximumScale defines the maximum scale to use (2 by default)
  143585. * @param step defines the step to use between two passes (0.5 by default)
  143586. */
  143587. constructor(
  143588. /**
  143589. * Defines the priority of this optimization (0 by default which means first in the list)
  143590. */
  143591. priority?: number,
  143592. /**
  143593. * Defines the maximum scale to use (2 by default)
  143594. */
  143595. maximumScale?: number,
  143596. /**
  143597. * Defines the step to use between two passes (0.5 by default)
  143598. */
  143599. step?: number);
  143600. /**
  143601. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143602. * @param scene defines the current scene where to apply this optimization
  143603. * @param optimizer defines the current optimizer
  143604. * @returns true if everything that can be done was applied
  143605. */
  143606. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143607. }
  143608. /**
  143609. * Defines an optimization used to remove shadows
  143610. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143611. */
  143612. export class ShadowsOptimization extends SceneOptimization {
  143613. /**
  143614. * Gets a string describing the action executed by the current optimization
  143615. * @return description string
  143616. */
  143617. getDescription(): string;
  143618. /**
  143619. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143620. * @param scene defines the current scene where to apply this optimization
  143621. * @param optimizer defines the current optimizer
  143622. * @returns true if everything that can be done was applied
  143623. */
  143624. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143625. }
  143626. /**
  143627. * Defines an optimization used to turn post-processes off
  143628. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143629. */
  143630. export class PostProcessesOptimization extends SceneOptimization {
  143631. /**
  143632. * Gets a string describing the action executed by the current optimization
  143633. * @return description string
  143634. */
  143635. getDescription(): string;
  143636. /**
  143637. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143638. * @param scene defines the current scene where to apply this optimization
  143639. * @param optimizer defines the current optimizer
  143640. * @returns true if everything that can be done was applied
  143641. */
  143642. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143643. }
  143644. /**
  143645. * Defines an optimization used to turn lens flares off
  143646. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143647. */
  143648. export class LensFlaresOptimization extends SceneOptimization {
  143649. /**
  143650. * Gets a string describing the action executed by the current optimization
  143651. * @return description string
  143652. */
  143653. getDescription(): string;
  143654. /**
  143655. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143656. * @param scene defines the current scene where to apply this optimization
  143657. * @param optimizer defines the current optimizer
  143658. * @returns true if everything that can be done was applied
  143659. */
  143660. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143661. }
  143662. /**
  143663. * Defines an optimization based on user defined callback.
  143664. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143665. */
  143666. export class CustomOptimization extends SceneOptimization {
  143667. /**
  143668. * Callback called to apply the custom optimization.
  143669. */
  143670. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  143671. /**
  143672. * Callback called to get custom description
  143673. */
  143674. onGetDescription: () => string;
  143675. /**
  143676. * Gets a string describing the action executed by the current optimization
  143677. * @returns description string
  143678. */
  143679. getDescription(): string;
  143680. /**
  143681. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143682. * @param scene defines the current scene where to apply this optimization
  143683. * @param optimizer defines the current optimizer
  143684. * @returns true if everything that can be done was applied
  143685. */
  143686. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143687. }
  143688. /**
  143689. * Defines an optimization used to turn particles off
  143690. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143691. */
  143692. export class ParticlesOptimization extends SceneOptimization {
  143693. /**
  143694. * Gets a string describing the action executed by the current optimization
  143695. * @return description string
  143696. */
  143697. getDescription(): string;
  143698. /**
  143699. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143700. * @param scene defines the current scene where to apply this optimization
  143701. * @param optimizer defines the current optimizer
  143702. * @returns true if everything that can be done was applied
  143703. */
  143704. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143705. }
  143706. /**
  143707. * Defines an optimization used to turn render targets off
  143708. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143709. */
  143710. export class RenderTargetsOptimization extends SceneOptimization {
  143711. /**
  143712. * Gets a string describing the action executed by the current optimization
  143713. * @return description string
  143714. */
  143715. getDescription(): string;
  143716. /**
  143717. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143718. * @param scene defines the current scene where to apply this optimization
  143719. * @param optimizer defines the current optimizer
  143720. * @returns true if everything that can be done was applied
  143721. */
  143722. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143723. }
  143724. /**
  143725. * Defines an optimization used to merge meshes with compatible materials
  143726. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143727. */
  143728. export class MergeMeshesOptimization extends SceneOptimization {
  143729. private static _UpdateSelectionTree;
  143730. /**
  143731. * Gets or sets a boolean which defines if optimization octree has to be updated
  143732. */
  143733. static get UpdateSelectionTree(): boolean;
  143734. /**
  143735. * Gets or sets a boolean which defines if optimization octree has to be updated
  143736. */
  143737. static set UpdateSelectionTree(value: boolean);
  143738. /**
  143739. * Gets a string describing the action executed by the current optimization
  143740. * @return description string
  143741. */
  143742. getDescription(): string;
  143743. private _canBeMerged;
  143744. /**
  143745. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143746. * @param scene defines the current scene where to apply this optimization
  143747. * @param optimizer defines the current optimizer
  143748. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  143749. * @returns true if everything that can be done was applied
  143750. */
  143751. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  143752. }
  143753. /**
  143754. * Defines a list of options used by SceneOptimizer
  143755. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143756. */
  143757. export class SceneOptimizerOptions {
  143758. /**
  143759. * Defines the target frame rate to reach (60 by default)
  143760. */
  143761. targetFrameRate: number;
  143762. /**
  143763. * Defines the interval between two checkes (2000ms by default)
  143764. */
  143765. trackerDuration: number;
  143766. /**
  143767. * Gets the list of optimizations to apply
  143768. */
  143769. optimizations: SceneOptimization[];
  143770. /**
  143771. * Creates a new list of options used by SceneOptimizer
  143772. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  143773. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  143774. */
  143775. constructor(
  143776. /**
  143777. * Defines the target frame rate to reach (60 by default)
  143778. */
  143779. targetFrameRate?: number,
  143780. /**
  143781. * Defines the interval between two checkes (2000ms by default)
  143782. */
  143783. trackerDuration?: number);
  143784. /**
  143785. * Add a new optimization
  143786. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  143787. * @returns the current SceneOptimizerOptions
  143788. */
  143789. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  143790. /**
  143791. * Add a new custom optimization
  143792. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  143793. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  143794. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  143795. * @returns the current SceneOptimizerOptions
  143796. */
  143797. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  143798. /**
  143799. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  143800. * @param targetFrameRate defines the target frame rate (60 by default)
  143801. * @returns a SceneOptimizerOptions object
  143802. */
  143803. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  143804. /**
  143805. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  143806. * @param targetFrameRate defines the target frame rate (60 by default)
  143807. * @returns a SceneOptimizerOptions object
  143808. */
  143809. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  143810. /**
  143811. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  143812. * @param targetFrameRate defines the target frame rate (60 by default)
  143813. * @returns a SceneOptimizerOptions object
  143814. */
  143815. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  143816. }
  143817. /**
  143818. * Class used to run optimizations in order to reach a target frame rate
  143819. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143820. */
  143821. export class SceneOptimizer implements IDisposable {
  143822. private _isRunning;
  143823. private _options;
  143824. private _scene;
  143825. private _currentPriorityLevel;
  143826. private _targetFrameRate;
  143827. private _trackerDuration;
  143828. private _currentFrameRate;
  143829. private _sceneDisposeObserver;
  143830. private _improvementMode;
  143831. /**
  143832. * Defines an observable called when the optimizer reaches the target frame rate
  143833. */
  143834. onSuccessObservable: Observable<SceneOptimizer>;
  143835. /**
  143836. * Defines an observable called when the optimizer enables an optimization
  143837. */
  143838. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  143839. /**
  143840. * Defines an observable called when the optimizer is not able to reach the target frame rate
  143841. */
  143842. onFailureObservable: Observable<SceneOptimizer>;
  143843. /**
  143844. * Gets a boolean indicating if the optimizer is in improvement mode
  143845. */
  143846. get isInImprovementMode(): boolean;
  143847. /**
  143848. * Gets the current priority level (0 at start)
  143849. */
  143850. get currentPriorityLevel(): number;
  143851. /**
  143852. * Gets the current frame rate checked by the SceneOptimizer
  143853. */
  143854. get currentFrameRate(): number;
  143855. /**
  143856. * Gets or sets the current target frame rate (60 by default)
  143857. */
  143858. get targetFrameRate(): number;
  143859. /**
  143860. * Gets or sets the current target frame rate (60 by default)
  143861. */
  143862. set targetFrameRate(value: number);
  143863. /**
  143864. * Gets or sets the current interval between two checks (every 2000ms by default)
  143865. */
  143866. get trackerDuration(): number;
  143867. /**
  143868. * Gets or sets the current interval between two checks (every 2000ms by default)
  143869. */
  143870. set trackerDuration(value: number);
  143871. /**
  143872. * Gets the list of active optimizations
  143873. */
  143874. get optimizations(): SceneOptimization[];
  143875. /**
  143876. * Creates a new SceneOptimizer
  143877. * @param scene defines the scene to work on
  143878. * @param options defines the options to use with the SceneOptimizer
  143879. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  143880. * @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)
  143881. */
  143882. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  143883. /**
  143884. * Stops the current optimizer
  143885. */
  143886. stop(): void;
  143887. /**
  143888. * Reset the optimizer to initial step (current priority level = 0)
  143889. */
  143890. reset(): void;
  143891. /**
  143892. * Start the optimizer. By default it will try to reach a specific framerate
  143893. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  143894. */
  143895. start(): void;
  143896. private _checkCurrentState;
  143897. /**
  143898. * Release all resources
  143899. */
  143900. dispose(): void;
  143901. /**
  143902. * Helper function to create a SceneOptimizer with one single line of code
  143903. * @param scene defines the scene to work on
  143904. * @param options defines the options to use with the SceneOptimizer
  143905. * @param onSuccess defines a callback to call on success
  143906. * @param onFailure defines a callback to call on failure
  143907. * @returns the new SceneOptimizer object
  143908. */
  143909. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  143910. }
  143911. }
  143912. declare module BABYLON {
  143913. /**
  143914. * Class used to serialize a scene into a string
  143915. */
  143916. export class SceneSerializer {
  143917. /**
  143918. * Clear cache used by a previous serialization
  143919. */
  143920. static ClearCache(): void;
  143921. /**
  143922. * Serialize a scene into a JSON compatible object
  143923. * @param scene defines the scene to serialize
  143924. * @returns a JSON compatible object
  143925. */
  143926. static Serialize(scene: Scene): any;
  143927. /**
  143928. * Serialize a mesh into a JSON compatible object
  143929. * @param toSerialize defines the mesh to serialize
  143930. * @param withParents defines if parents must be serialized as well
  143931. * @param withChildren defines if children must be serialized as well
  143932. * @returns a JSON compatible object
  143933. */
  143934. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  143935. }
  143936. }
  143937. declare module BABYLON {
  143938. /**
  143939. * Class used to host texture specific utilities
  143940. */
  143941. export class TextureTools {
  143942. /**
  143943. * Uses the GPU to create a copy texture rescaled at a given size
  143944. * @param texture Texture to copy from
  143945. * @param width defines the desired width
  143946. * @param height defines the desired height
  143947. * @param useBilinearMode defines if bilinear mode has to be used
  143948. * @return the generated texture
  143949. */
  143950. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  143951. }
  143952. }
  143953. declare module BABYLON {
  143954. /**
  143955. * This represents the different options available for the video capture.
  143956. */
  143957. export interface VideoRecorderOptions {
  143958. /** Defines the mime type of the video. */
  143959. mimeType: string;
  143960. /** Defines the FPS the video should be recorded at. */
  143961. fps: number;
  143962. /** Defines the chunk size for the recording data. */
  143963. recordChunckSize: number;
  143964. /** The audio tracks to attach to the recording. */
  143965. audioTracks?: MediaStreamTrack[];
  143966. }
  143967. /**
  143968. * This can help with recording videos from BabylonJS.
  143969. * This is based on the available WebRTC functionalities of the browser.
  143970. *
  143971. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  143972. */
  143973. export class VideoRecorder {
  143974. private static readonly _defaultOptions;
  143975. /**
  143976. * Returns whether or not the VideoRecorder is available in your browser.
  143977. * @param engine Defines the Babylon Engine.
  143978. * @returns true if supported otherwise false.
  143979. */
  143980. static IsSupported(engine: Engine): boolean;
  143981. private readonly _options;
  143982. private _canvas;
  143983. private _mediaRecorder;
  143984. private _recordedChunks;
  143985. private _fileName;
  143986. private _resolve;
  143987. private _reject;
  143988. /**
  143989. * True when a recording is already in progress.
  143990. */
  143991. get isRecording(): boolean;
  143992. /**
  143993. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  143994. * @param engine Defines the BabylonJS Engine you wish to record.
  143995. * @param options Defines options that can be used to customize the capture.
  143996. */
  143997. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  143998. /**
  143999. * Stops the current recording before the default capture timeout passed in the startRecording function.
  144000. */
  144001. stopRecording(): void;
  144002. /**
  144003. * Starts recording the canvas for a max duration specified in parameters.
  144004. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  144005. * If null no automatic download will start and you can rely on the promise to get the data back.
  144006. * @param maxDuration Defines the maximum recording time in seconds.
  144007. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  144008. * @return A promise callback at the end of the recording with the video data in Blob.
  144009. */
  144010. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  144011. /**
  144012. * Releases internal resources used during the recording.
  144013. */
  144014. dispose(): void;
  144015. private _handleDataAvailable;
  144016. private _handleError;
  144017. private _handleStop;
  144018. }
  144019. }
  144020. declare module BABYLON {
  144021. /**
  144022. * Class containing a set of static utilities functions for screenshots
  144023. */
  144024. export class ScreenshotTools {
  144025. /**
  144026. * Captures a screenshot of the current rendering
  144027. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  144028. * @param engine defines the rendering engine
  144029. * @param camera defines the source camera
  144030. * @param size This parameter can be set to a single number or to an object with the
  144031. * following (optional) properties: precision, width, height. If a single number is passed,
  144032. * it will be used for both width and height. If an object is passed, the screenshot size
  144033. * will be derived from the parameters. The precision property is a multiplier allowing
  144034. * rendering at a higher or lower resolution
  144035. * @param successCallback defines the callback receives a single parameter which contains the
  144036. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  144037. * src parameter of an <img> to display it
  144038. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  144039. * Check your browser for supported MIME types
  144040. */
  144041. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  144042. /**
  144043. * Captures a screenshot of the current rendering
  144044. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  144045. * @param engine defines the rendering engine
  144046. * @param camera defines the source camera
  144047. * @param size This parameter can be set to a single number or to an object with the
  144048. * following (optional) properties: precision, width, height. If a single number is passed,
  144049. * it will be used for both width and height. If an object is passed, the screenshot size
  144050. * will be derived from the parameters. The precision property is a multiplier allowing
  144051. * rendering at a higher or lower resolution
  144052. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  144053. * Check your browser for supported MIME types
  144054. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  144055. * to the src parameter of an <img> to display it
  144056. */
  144057. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  144058. /**
  144059. * Generates an image screenshot from the specified camera.
  144060. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  144061. * @param engine The engine to use for rendering
  144062. * @param camera The camera to use for rendering
  144063. * @param size This parameter can be set to a single number or to an object with the
  144064. * following (optional) properties: precision, width, height. If a single number is passed,
  144065. * it will be used for both width and height. If an object is passed, the screenshot size
  144066. * will be derived from the parameters. The precision property is a multiplier allowing
  144067. * rendering at a higher or lower resolution
  144068. * @param successCallback The callback receives a single parameter which contains the
  144069. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  144070. * src parameter of an <img> to display it
  144071. * @param mimeType The MIME type of the screenshot image (default: image/png).
  144072. * Check your browser for supported MIME types
  144073. * @param samples Texture samples (default: 1)
  144074. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  144075. * @param fileName A name for for the downloaded file.
  144076. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  144077. */
  144078. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  144079. /**
  144080. * Generates an image screenshot from the specified camera.
  144081. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  144082. * @param engine The engine to use for rendering
  144083. * @param camera The camera to use for rendering
  144084. * @param size This parameter can be set to a single number or to an object with the
  144085. * following (optional) properties: precision, width, height. If a single number is passed,
  144086. * it will be used for both width and height. If an object is passed, the screenshot size
  144087. * will be derived from the parameters. The precision property is a multiplier allowing
  144088. * rendering at a higher or lower resolution
  144089. * @param mimeType The MIME type of the screenshot image (default: image/png).
  144090. * Check your browser for supported MIME types
  144091. * @param samples Texture samples (default: 1)
  144092. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  144093. * @param fileName A name for for the downloaded file.
  144094. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  144095. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  144096. * to the src parameter of an <img> to display it
  144097. */
  144098. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  144099. /**
  144100. * Gets height and width for screenshot size
  144101. * @private
  144102. */
  144103. private static _getScreenshotSize;
  144104. }
  144105. }
  144106. declare module BABYLON {
  144107. /**
  144108. * Interface for a data buffer
  144109. */
  144110. export interface IDataBuffer {
  144111. /**
  144112. * Reads bytes from the data buffer.
  144113. * @param byteOffset The byte offset to read
  144114. * @param byteLength The byte length to read
  144115. * @returns A promise that resolves when the bytes are read
  144116. */
  144117. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  144118. /**
  144119. * The byte length of the buffer.
  144120. */
  144121. readonly byteLength: number;
  144122. }
  144123. /**
  144124. * Utility class for reading from a data buffer
  144125. */
  144126. export class DataReader {
  144127. /**
  144128. * The data buffer associated with this data reader.
  144129. */
  144130. readonly buffer: IDataBuffer;
  144131. /**
  144132. * The current byte offset from the beginning of the data buffer.
  144133. */
  144134. byteOffset: number;
  144135. private _dataView;
  144136. private _dataByteOffset;
  144137. /**
  144138. * Constructor
  144139. * @param buffer The buffer to read
  144140. */
  144141. constructor(buffer: IDataBuffer);
  144142. /**
  144143. * Loads the given byte length.
  144144. * @param byteLength The byte length to load
  144145. * @returns A promise that resolves when the load is complete
  144146. */
  144147. loadAsync(byteLength: number): Promise<void>;
  144148. /**
  144149. * Read a unsigned 32-bit integer from the currently loaded data range.
  144150. * @returns The 32-bit integer read
  144151. */
  144152. readUint32(): number;
  144153. /**
  144154. * Read a byte array from the currently loaded data range.
  144155. * @param byteLength The byte length to read
  144156. * @returns The byte array read
  144157. */
  144158. readUint8Array(byteLength: number): Uint8Array;
  144159. /**
  144160. * Read a string from the currently loaded data range.
  144161. * @param byteLength The byte length to read
  144162. * @returns The string read
  144163. */
  144164. readString(byteLength: number): string;
  144165. /**
  144166. * Skips the given byte length the currently loaded data range.
  144167. * @param byteLength The byte length to skip
  144168. */
  144169. skipBytes(byteLength: number): void;
  144170. }
  144171. }
  144172. declare module BABYLON {
  144173. /**
  144174. * Class for storing data to local storage if available or in-memory storage otherwise
  144175. */
  144176. export class DataStorage {
  144177. private static _Storage;
  144178. private static _GetStorage;
  144179. /**
  144180. * Reads a string from the data storage
  144181. * @param key The key to read
  144182. * @param defaultValue The value if the key doesn't exist
  144183. * @returns The string value
  144184. */
  144185. static ReadString(key: string, defaultValue: string): string;
  144186. /**
  144187. * Writes a string to the data storage
  144188. * @param key The key to write
  144189. * @param value The value to write
  144190. */
  144191. static WriteString(key: string, value: string): void;
  144192. /**
  144193. * Reads a boolean from the data storage
  144194. * @param key The key to read
  144195. * @param defaultValue The value if the key doesn't exist
  144196. * @returns The boolean value
  144197. */
  144198. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  144199. /**
  144200. * Writes a boolean to the data storage
  144201. * @param key The key to write
  144202. * @param value The value to write
  144203. */
  144204. static WriteBoolean(key: string, value: boolean): void;
  144205. /**
  144206. * Reads a number from the data storage
  144207. * @param key The key to read
  144208. * @param defaultValue The value if the key doesn't exist
  144209. * @returns The number value
  144210. */
  144211. static ReadNumber(key: string, defaultValue: number): number;
  144212. /**
  144213. * Writes a number to the data storage
  144214. * @param key The key to write
  144215. * @param value The value to write
  144216. */
  144217. static WriteNumber(key: string, value: number): void;
  144218. }
  144219. }
  144220. declare module BABYLON {
  144221. /**
  144222. * Options used for hit testing
  144223. */
  144224. export interface IWebXRLegacyHitTestOptions {
  144225. /**
  144226. * Only test when user interacted with the scene. Default - hit test every frame
  144227. */
  144228. testOnPointerDownOnly?: boolean;
  144229. /**
  144230. * The node to use to transform the local results to world coordinates
  144231. */
  144232. worldParentNode?: TransformNode;
  144233. }
  144234. /**
  144235. * Interface defining the babylon result of raycasting/hit-test
  144236. */
  144237. export interface IWebXRLegacyHitResult {
  144238. /**
  144239. * Transformation matrix that can be applied to a node that will put it in the hit point location
  144240. */
  144241. transformationMatrix: Matrix;
  144242. /**
  144243. * The native hit test result
  144244. */
  144245. xrHitResult: XRHitResult | XRHitTestResult;
  144246. }
  144247. /**
  144248. * The currently-working hit-test module.
  144249. * Hit test (or Ray-casting) is used to interact with the real world.
  144250. * For further information read here - https://github.com/immersive-web/hit-test
  144251. */
  144252. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  144253. /**
  144254. * options to use when constructing this feature
  144255. */
  144256. readonly options: IWebXRLegacyHitTestOptions;
  144257. private _direction;
  144258. private _mat;
  144259. private _onSelectEnabled;
  144260. private _origin;
  144261. /**
  144262. * The module's name
  144263. */
  144264. static readonly Name: string;
  144265. /**
  144266. * The (Babylon) version of this module.
  144267. * This is an integer representing the implementation version.
  144268. * This number does not correspond to the WebXR specs version
  144269. */
  144270. static readonly Version: number;
  144271. /**
  144272. * Populated with the last native XR Hit Results
  144273. */
  144274. lastNativeXRHitResults: XRHitResult[];
  144275. /**
  144276. * Triggered when new babylon (transformed) hit test results are available
  144277. */
  144278. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  144279. /**
  144280. * Creates a new instance of the (legacy version) hit test feature
  144281. * @param _xrSessionManager an instance of WebXRSessionManager
  144282. * @param options options to use when constructing this feature
  144283. */
  144284. constructor(_xrSessionManager: WebXRSessionManager,
  144285. /**
  144286. * options to use when constructing this feature
  144287. */
  144288. options?: IWebXRLegacyHitTestOptions);
  144289. /**
  144290. * execute a hit test with an XR Ray
  144291. *
  144292. * @param xrSession a native xrSession that will execute this hit test
  144293. * @param xrRay the ray (position and direction) to use for ray-casting
  144294. * @param referenceSpace native XR reference space to use for the hit-test
  144295. * @param filter filter function that will filter the results
  144296. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  144297. */
  144298. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  144299. /**
  144300. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  144301. * @param event the (select) event to use to select with
  144302. * @param referenceSpace the reference space to use for this hit test
  144303. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  144304. */
  144305. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  144306. /**
  144307. * attach this feature
  144308. * Will usually be called by the features manager
  144309. *
  144310. * @returns true if successful.
  144311. */
  144312. attach(): boolean;
  144313. /**
  144314. * detach this feature.
  144315. * Will usually be called by the features manager
  144316. *
  144317. * @returns true if successful.
  144318. */
  144319. detach(): boolean;
  144320. /**
  144321. * Dispose this feature and all of the resources attached
  144322. */
  144323. dispose(): void;
  144324. protected _onXRFrame(frame: XRFrame): void;
  144325. private _onHitTestResults;
  144326. private _onSelect;
  144327. }
  144328. }
  144329. declare module BABYLON {
  144330. /**
  144331. * Options used in the plane detector module
  144332. */
  144333. export interface IWebXRPlaneDetectorOptions {
  144334. /**
  144335. * The node to use to transform the local results to world coordinates
  144336. */
  144337. worldParentNode?: TransformNode;
  144338. }
  144339. /**
  144340. * A babylon interface for a WebXR plane.
  144341. * A Plane is actually a polygon, built from N points in space
  144342. *
  144343. * Supported in chrome 79, not supported in canary 81 ATM
  144344. */
  144345. export interface IWebXRPlane {
  144346. /**
  144347. * a babylon-assigned ID for this polygon
  144348. */
  144349. id: number;
  144350. /**
  144351. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  144352. */
  144353. polygonDefinition: Array<Vector3>;
  144354. /**
  144355. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  144356. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  144357. */
  144358. transformationMatrix: Matrix;
  144359. /**
  144360. * the native xr-plane object
  144361. */
  144362. xrPlane: XRPlane;
  144363. }
  144364. /**
  144365. * The plane detector is used to detect planes in the real world when in AR
  144366. * For more information see https://github.com/immersive-web/real-world-geometry/
  144367. */
  144368. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  144369. private _options;
  144370. private _detectedPlanes;
  144371. private _enabled;
  144372. private _lastFrameDetected;
  144373. /**
  144374. * The module's name
  144375. */
  144376. static readonly Name: string;
  144377. /**
  144378. * The (Babylon) version of this module.
  144379. * This is an integer representing the implementation version.
  144380. * This number does not correspond to the WebXR specs version
  144381. */
  144382. static readonly Version: number;
  144383. /**
  144384. * Observers registered here will be executed when a new plane was added to the session
  144385. */
  144386. onPlaneAddedObservable: Observable<IWebXRPlane>;
  144387. /**
  144388. * Observers registered here will be executed when a plane is no longer detected in the session
  144389. */
  144390. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  144391. /**
  144392. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  144393. * This can execute N times every frame
  144394. */
  144395. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  144396. /**
  144397. * construct a new Plane Detector
  144398. * @param _xrSessionManager an instance of xr Session manager
  144399. * @param _options configuration to use when constructing this feature
  144400. */
  144401. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  144402. /**
  144403. * Dispose this feature and all of the resources attached
  144404. */
  144405. dispose(): void;
  144406. protected _onXRFrame(frame: XRFrame): void;
  144407. private _init;
  144408. private _updatePlaneWithXRPlane;
  144409. /**
  144410. * avoiding using Array.find for global support.
  144411. * @param xrPlane the plane to find in the array
  144412. */
  144413. private findIndexInPlaneArray;
  144414. }
  144415. }
  144416. declare module BABYLON {
  144417. /**
  144418. * Configuration options of the anchor system
  144419. */
  144420. export interface IWebXRAnchorSystemOptions {
  144421. /**
  144422. * Should a new anchor be added every time a select event is triggered
  144423. */
  144424. addAnchorOnSelect?: boolean;
  144425. /**
  144426. * should the anchor system use plane detection.
  144427. * If set to true, the plane-detection feature should be set using setPlaneDetector
  144428. */
  144429. usePlaneDetection?: boolean;
  144430. /**
  144431. * a node that will be used to convert local to world coordinates
  144432. */
  144433. worldParentNode?: TransformNode;
  144434. }
  144435. /**
  144436. * A babylon container for an XR Anchor
  144437. */
  144438. export interface IWebXRAnchor {
  144439. /**
  144440. * A babylon-assigned ID for this anchor
  144441. */
  144442. id: number;
  144443. /**
  144444. * Transformation matrix to apply to an object attached to this anchor
  144445. */
  144446. transformationMatrix: Matrix;
  144447. /**
  144448. * The native anchor object
  144449. */
  144450. xrAnchor: XRAnchor;
  144451. }
  144452. /**
  144453. * An implementation of the anchor system of WebXR.
  144454. * Note that the current documented implementation is not available in any browser. Future implementations
  144455. * will use the frame to create an anchor and not the session or a detected plane
  144456. * For further information see https://github.com/immersive-web/anchors/
  144457. */
  144458. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  144459. private _options;
  144460. private _enabled;
  144461. private _hitTestModule;
  144462. private _lastFrameDetected;
  144463. private _onSelect;
  144464. private _planeDetector;
  144465. private _trackedAnchors;
  144466. /**
  144467. * The module's name
  144468. */
  144469. static readonly Name: string;
  144470. /**
  144471. * The (Babylon) version of this module.
  144472. * This is an integer representing the implementation version.
  144473. * This number does not correspond to the WebXR specs version
  144474. */
  144475. static readonly Version: number;
  144476. /**
  144477. * Observers registered here will be executed when a new anchor was added to the session
  144478. */
  144479. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  144480. /**
  144481. * Observers registered here will be executed when an anchor was removed from the session
  144482. */
  144483. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  144484. /**
  144485. * Observers registered here will be executed when an existing anchor updates
  144486. * This can execute N times every frame
  144487. */
  144488. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  144489. /**
  144490. * constructs a new anchor system
  144491. * @param _xrSessionManager an instance of WebXRSessionManager
  144492. * @param _options configuration object for this feature
  144493. */
  144494. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  144495. /**
  144496. * Add anchor at a specific XR point.
  144497. *
  144498. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  144499. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  144500. * @returns a promise the fulfills when the anchor was created
  144501. */
  144502. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  144503. /**
  144504. * attach this feature
  144505. * Will usually be called by the features manager
  144506. *
  144507. * @returns true if successful.
  144508. */
  144509. attach(): boolean;
  144510. /**
  144511. * detach this feature.
  144512. * Will usually be called by the features manager
  144513. *
  144514. * @returns true if successful.
  144515. */
  144516. detach(): boolean;
  144517. /**
  144518. * Dispose this feature and all of the resources attached
  144519. */
  144520. dispose(): void;
  144521. /**
  144522. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  144523. * @param hitTestModule the hit-test module to use.
  144524. */
  144525. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  144526. /**
  144527. * set the plane detector to use in order to create anchors from frames
  144528. * @param planeDetector the plane-detector module to use
  144529. * @param enable enable plane-anchors. default is true
  144530. */
  144531. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  144532. protected _onXRFrame(frame: XRFrame): void;
  144533. /**
  144534. * avoiding using Array.find for global support.
  144535. * @param xrAnchor the plane to find in the array
  144536. */
  144537. private _findIndexInAnchorArray;
  144538. private _updateAnchorWithXRFrame;
  144539. }
  144540. }
  144541. declare module BABYLON {
  144542. /**
  144543. * Options interface for the background remover plugin
  144544. */
  144545. export interface IWebXRBackgroundRemoverOptions {
  144546. /**
  144547. * Further background meshes to disable when entering AR
  144548. */
  144549. backgroundMeshes?: AbstractMesh[];
  144550. /**
  144551. * flags to configure the removal of the environment helper.
  144552. * If not set, the entire background will be removed. If set, flags should be set as well.
  144553. */
  144554. environmentHelperRemovalFlags?: {
  144555. /**
  144556. * Should the skybox be removed (default false)
  144557. */
  144558. skyBox?: boolean;
  144559. /**
  144560. * Should the ground be removed (default false)
  144561. */
  144562. ground?: boolean;
  144563. };
  144564. /**
  144565. * don't disable the environment helper
  144566. */
  144567. ignoreEnvironmentHelper?: boolean;
  144568. }
  144569. /**
  144570. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  144571. */
  144572. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  144573. /**
  144574. * read-only options to be used in this module
  144575. */
  144576. readonly options: IWebXRBackgroundRemoverOptions;
  144577. /**
  144578. * The module's name
  144579. */
  144580. static readonly Name: string;
  144581. /**
  144582. * The (Babylon) version of this module.
  144583. * This is an integer representing the implementation version.
  144584. * This number does not correspond to the WebXR specs version
  144585. */
  144586. static readonly Version: number;
  144587. /**
  144588. * registered observers will be triggered when the background state changes
  144589. */
  144590. onBackgroundStateChangedObservable: Observable<boolean>;
  144591. /**
  144592. * constructs a new background remover module
  144593. * @param _xrSessionManager the session manager for this module
  144594. * @param options read-only options to be used in this module
  144595. */
  144596. constructor(_xrSessionManager: WebXRSessionManager,
  144597. /**
  144598. * read-only options to be used in this module
  144599. */
  144600. options?: IWebXRBackgroundRemoverOptions);
  144601. /**
  144602. * attach this feature
  144603. * Will usually be called by the features manager
  144604. *
  144605. * @returns true if successful.
  144606. */
  144607. attach(): boolean;
  144608. /**
  144609. * detach this feature.
  144610. * Will usually be called by the features manager
  144611. *
  144612. * @returns true if successful.
  144613. */
  144614. detach(): boolean;
  144615. /**
  144616. * Dispose this feature and all of the resources attached
  144617. */
  144618. dispose(): void;
  144619. protected _onXRFrame(_xrFrame: XRFrame): void;
  144620. private _setBackgroundState;
  144621. }
  144622. }
  144623. declare module BABYLON {
  144624. /**
  144625. * Options for the controller physics feature
  144626. */
  144627. export class IWebXRControllerPhysicsOptions {
  144628. /**
  144629. * Should the headset get its own impostor
  144630. */
  144631. enableHeadsetImpostor?: boolean;
  144632. /**
  144633. * Optional parameters for the headset impostor
  144634. */
  144635. headsetImpostorParams?: {
  144636. /**
  144637. * The type of impostor to create. Default is sphere
  144638. */
  144639. impostorType: number;
  144640. /**
  144641. * the size of the impostor. Defaults to 10cm
  144642. */
  144643. impostorSize?: number | {
  144644. width: number;
  144645. height: number;
  144646. depth: number;
  144647. };
  144648. /**
  144649. * Friction definitions
  144650. */
  144651. friction?: number;
  144652. /**
  144653. * Restitution
  144654. */
  144655. restitution?: number;
  144656. };
  144657. /**
  144658. * The physics properties of the future impostors
  144659. */
  144660. physicsProperties?: {
  144661. /**
  144662. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  144663. * Note that this requires a physics engine that supports mesh impostors!
  144664. */
  144665. useControllerMesh?: boolean;
  144666. /**
  144667. * The type of impostor to create. Default is sphere
  144668. */
  144669. impostorType?: number;
  144670. /**
  144671. * the size of the impostor. Defaults to 10cm
  144672. */
  144673. impostorSize?: number | {
  144674. width: number;
  144675. height: number;
  144676. depth: number;
  144677. };
  144678. /**
  144679. * Friction definitions
  144680. */
  144681. friction?: number;
  144682. /**
  144683. * Restitution
  144684. */
  144685. restitution?: number;
  144686. };
  144687. /**
  144688. * the xr input to use with this pointer selection
  144689. */
  144690. xrInput: WebXRInput;
  144691. }
  144692. /**
  144693. * Add physics impostor to your webxr controllers,
  144694. * including naive calculation of their linear and angular velocity
  144695. */
  144696. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  144697. private readonly _options;
  144698. private _attachController;
  144699. private _controllers;
  144700. private _debugMode;
  144701. private _delta;
  144702. private _headsetImpostor?;
  144703. private _headsetMesh?;
  144704. private _lastTimestamp;
  144705. private _tmpQuaternion;
  144706. private _tmpVector;
  144707. /**
  144708. * The module's name
  144709. */
  144710. static readonly Name: string;
  144711. /**
  144712. * The (Babylon) version of this module.
  144713. * This is an integer representing the implementation version.
  144714. * This number does not correspond to the webxr specs version
  144715. */
  144716. static readonly Version: number;
  144717. /**
  144718. * Construct a new Controller Physics Feature
  144719. * @param _xrSessionManager the corresponding xr session manager
  144720. * @param _options options to create this feature with
  144721. */
  144722. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  144723. /**
  144724. * @hidden
  144725. * enable debugging - will show console outputs and the impostor mesh
  144726. */
  144727. _enablePhysicsDebug(): void;
  144728. /**
  144729. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  144730. * @param xrController the controller to add
  144731. */
  144732. addController(xrController: WebXRInputSource): void;
  144733. /**
  144734. * attach this feature
  144735. * Will usually be called by the features manager
  144736. *
  144737. * @returns true if successful.
  144738. */
  144739. attach(): boolean;
  144740. /**
  144741. * detach this feature.
  144742. * Will usually be called by the features manager
  144743. *
  144744. * @returns true if successful.
  144745. */
  144746. detach(): boolean;
  144747. /**
  144748. * Get the headset impostor, if enabled
  144749. * @returns the impostor
  144750. */
  144751. getHeadsetImpostor(): PhysicsImpostor | undefined;
  144752. /**
  144753. * Get the physics impostor of a specific controller.
  144754. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  144755. * @param controller the controller or the controller id of which to get the impostor
  144756. * @returns the impostor or null
  144757. */
  144758. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  144759. /**
  144760. * Update the physics properties provided in the constructor
  144761. * @param newProperties the new properties object
  144762. */
  144763. setPhysicsProperties(newProperties: {
  144764. impostorType?: number;
  144765. impostorSize?: number | {
  144766. width: number;
  144767. height: number;
  144768. depth: number;
  144769. };
  144770. friction?: number;
  144771. restitution?: number;
  144772. }): void;
  144773. protected _onXRFrame(_xrFrame: any): void;
  144774. private _detachController;
  144775. }
  144776. }
  144777. declare module BABYLON {
  144778. /**
  144779. * Options used for hit testing (version 2)
  144780. */
  144781. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  144782. /**
  144783. * Do not create a permanent hit test. Will usually be used when only
  144784. * transient inputs are needed.
  144785. */
  144786. disablePermanentHitTest?: boolean;
  144787. /**
  144788. * Enable transient (for example touch-based) hit test inspections
  144789. */
  144790. enableTransientHitTest?: boolean;
  144791. /**
  144792. * Offset ray for the permanent hit test
  144793. */
  144794. offsetRay?: Vector3;
  144795. /**
  144796. * Offset ray for the transient hit test
  144797. */
  144798. transientOffsetRay?: Vector3;
  144799. /**
  144800. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  144801. */
  144802. useReferenceSpace?: boolean;
  144803. }
  144804. /**
  144805. * Interface defining the babylon result of hit-test
  144806. */
  144807. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  144808. /**
  144809. * The input source that generated this hit test (if transient)
  144810. */
  144811. inputSource?: XRInputSource;
  144812. /**
  144813. * Is this a transient hit test
  144814. */
  144815. isTransient?: boolean;
  144816. /**
  144817. * Position of the hit test result
  144818. */
  144819. position: Vector3;
  144820. /**
  144821. * Rotation of the hit test result
  144822. */
  144823. rotationQuaternion: Quaternion;
  144824. }
  144825. /**
  144826. * The currently-working hit-test module.
  144827. * Hit test (or Ray-casting) is used to interact with the real world.
  144828. * For further information read here - https://github.com/immersive-web/hit-test
  144829. *
  144830. * Tested on chrome (mobile) 80.
  144831. */
  144832. export class WebXRHitTest extends WebXRAbstractFeature {
  144833. /**
  144834. * options to use when constructing this feature
  144835. */
  144836. readonly options: IWebXRHitTestOptions;
  144837. private _tmpMat;
  144838. private _tmpPos;
  144839. private _tmpQuat;
  144840. private _transientXrHitTestSource;
  144841. private _xrHitTestSource;
  144842. private initHitTestSource;
  144843. /**
  144844. * The module's name
  144845. */
  144846. static readonly Name: string;
  144847. /**
  144848. * The (Babylon) version of this module.
  144849. * This is an integer representing the implementation version.
  144850. * This number does not correspond to the WebXR specs version
  144851. */
  144852. static readonly Version: number;
  144853. /**
  144854. * When set to true, each hit test will have its own position/rotation objects
  144855. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  144856. * the developers will clone them or copy them as they see fit.
  144857. */
  144858. autoCloneTransformation: boolean;
  144859. /**
  144860. * Populated with the last native XR Hit Results
  144861. */
  144862. lastNativeXRHitResults: XRHitResult[];
  144863. /**
  144864. * Triggered when new babylon (transformed) hit test results are available
  144865. */
  144866. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  144867. /**
  144868. * Use this to temporarily pause hit test checks.
  144869. */
  144870. paused: boolean;
  144871. /**
  144872. * Creates a new instance of the hit test feature
  144873. * @param _xrSessionManager an instance of WebXRSessionManager
  144874. * @param options options to use when constructing this feature
  144875. */
  144876. constructor(_xrSessionManager: WebXRSessionManager,
  144877. /**
  144878. * options to use when constructing this feature
  144879. */
  144880. options?: IWebXRHitTestOptions);
  144881. /**
  144882. * attach this feature
  144883. * Will usually be called by the features manager
  144884. *
  144885. * @returns true if successful.
  144886. */
  144887. attach(): boolean;
  144888. /**
  144889. * detach this feature.
  144890. * Will usually be called by the features manager
  144891. *
  144892. * @returns true if successful.
  144893. */
  144894. detach(): boolean;
  144895. /**
  144896. * Dispose this feature and all of the resources attached
  144897. */
  144898. dispose(): void;
  144899. protected _onXRFrame(frame: XRFrame): void;
  144900. private _processWebXRHitTestResult;
  144901. }
  144902. }
  144903. declare module BABYLON {
  144904. /**
  144905. * The motion controller class for all microsoft mixed reality controllers
  144906. */
  144907. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  144908. protected readonly _mapping: {
  144909. defaultButton: {
  144910. valueNodeName: string;
  144911. unpressedNodeName: string;
  144912. pressedNodeName: string;
  144913. };
  144914. defaultAxis: {
  144915. valueNodeName: string;
  144916. minNodeName: string;
  144917. maxNodeName: string;
  144918. };
  144919. buttons: {
  144920. "xr-standard-trigger": {
  144921. rootNodeName: string;
  144922. componentProperty: string;
  144923. states: string[];
  144924. };
  144925. "xr-standard-squeeze": {
  144926. rootNodeName: string;
  144927. componentProperty: string;
  144928. states: string[];
  144929. };
  144930. "xr-standard-touchpad": {
  144931. rootNodeName: string;
  144932. labelAnchorNodeName: string;
  144933. touchPointNodeName: string;
  144934. };
  144935. "xr-standard-thumbstick": {
  144936. rootNodeName: string;
  144937. componentProperty: string;
  144938. states: string[];
  144939. };
  144940. };
  144941. axes: {
  144942. "xr-standard-touchpad": {
  144943. "x-axis": {
  144944. rootNodeName: string;
  144945. };
  144946. "y-axis": {
  144947. rootNodeName: string;
  144948. };
  144949. };
  144950. "xr-standard-thumbstick": {
  144951. "x-axis": {
  144952. rootNodeName: string;
  144953. };
  144954. "y-axis": {
  144955. rootNodeName: string;
  144956. };
  144957. };
  144958. };
  144959. };
  144960. /**
  144961. * The base url used to load the left and right controller models
  144962. */
  144963. static MODEL_BASE_URL: string;
  144964. /**
  144965. * The name of the left controller model file
  144966. */
  144967. static MODEL_LEFT_FILENAME: string;
  144968. /**
  144969. * The name of the right controller model file
  144970. */
  144971. static MODEL_RIGHT_FILENAME: string;
  144972. profileId: string;
  144973. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  144974. protected _getFilenameAndPath(): {
  144975. filename: string;
  144976. path: string;
  144977. };
  144978. protected _getModelLoadingConstraints(): boolean;
  144979. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  144980. protected _setRootMesh(meshes: AbstractMesh[]): void;
  144981. protected _updateModel(): void;
  144982. }
  144983. }
  144984. declare module BABYLON {
  144985. /**
  144986. * The motion controller class for oculus touch (quest, rift).
  144987. * This class supports legacy mapping as well the standard xr mapping
  144988. */
  144989. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  144990. private _forceLegacyControllers;
  144991. private _modelRootNode;
  144992. /**
  144993. * The base url used to load the left and right controller models
  144994. */
  144995. static MODEL_BASE_URL: string;
  144996. /**
  144997. * The name of the left controller model file
  144998. */
  144999. static MODEL_LEFT_FILENAME: string;
  145000. /**
  145001. * The name of the right controller model file
  145002. */
  145003. static MODEL_RIGHT_FILENAME: string;
  145004. /**
  145005. * Base Url for the Quest controller model.
  145006. */
  145007. static QUEST_MODEL_BASE_URL: string;
  145008. profileId: string;
  145009. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  145010. protected _getFilenameAndPath(): {
  145011. filename: string;
  145012. path: string;
  145013. };
  145014. protected _getModelLoadingConstraints(): boolean;
  145015. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  145016. protected _setRootMesh(meshes: AbstractMesh[]): void;
  145017. protected _updateModel(): void;
  145018. /**
  145019. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  145020. * between the touch and touch 2.
  145021. */
  145022. private _isQuest;
  145023. }
  145024. }
  145025. declare module BABYLON {
  145026. /**
  145027. * The motion controller class for the standard HTC-Vive controllers
  145028. */
  145029. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  145030. private _modelRootNode;
  145031. /**
  145032. * The base url used to load the left and right controller models
  145033. */
  145034. static MODEL_BASE_URL: string;
  145035. /**
  145036. * File name for the controller model.
  145037. */
  145038. static MODEL_FILENAME: string;
  145039. profileId: string;
  145040. /**
  145041. * Create a new Vive motion controller object
  145042. * @param scene the scene to use to create this controller
  145043. * @param gamepadObject the corresponding gamepad object
  145044. * @param handness the handness of the controller
  145045. */
  145046. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  145047. protected _getFilenameAndPath(): {
  145048. filename: string;
  145049. path: string;
  145050. };
  145051. protected _getModelLoadingConstraints(): boolean;
  145052. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  145053. protected _setRootMesh(meshes: AbstractMesh[]): void;
  145054. protected _updateModel(): void;
  145055. }
  145056. }
  145057. declare module BABYLON {
  145058. /**
  145059. * A cursor which tracks a point on a path
  145060. */
  145061. export class PathCursor {
  145062. private path;
  145063. /**
  145064. * Stores path cursor callbacks for when an onchange event is triggered
  145065. */
  145066. private _onchange;
  145067. /**
  145068. * The value of the path cursor
  145069. */
  145070. value: number;
  145071. /**
  145072. * The animation array of the path cursor
  145073. */
  145074. animations: Animation[];
  145075. /**
  145076. * Initializes the path cursor
  145077. * @param path The path to track
  145078. */
  145079. constructor(path: Path2);
  145080. /**
  145081. * Gets the cursor point on the path
  145082. * @returns A point on the path cursor at the cursor location
  145083. */
  145084. getPoint(): Vector3;
  145085. /**
  145086. * Moves the cursor ahead by the step amount
  145087. * @param step The amount to move the cursor forward
  145088. * @returns This path cursor
  145089. */
  145090. moveAhead(step?: number): PathCursor;
  145091. /**
  145092. * Moves the cursor behind by the step amount
  145093. * @param step The amount to move the cursor back
  145094. * @returns This path cursor
  145095. */
  145096. moveBack(step?: number): PathCursor;
  145097. /**
  145098. * Moves the cursor by the step amount
  145099. * If the step amount is greater than one, an exception is thrown
  145100. * @param step The amount to move the cursor
  145101. * @returns This path cursor
  145102. */
  145103. move(step: number): PathCursor;
  145104. /**
  145105. * Ensures that the value is limited between zero and one
  145106. * @returns This path cursor
  145107. */
  145108. private ensureLimits;
  145109. /**
  145110. * Runs onchange callbacks on change (used by the animation engine)
  145111. * @returns This path cursor
  145112. */
  145113. private raiseOnChange;
  145114. /**
  145115. * Executes a function on change
  145116. * @param f A path cursor onchange callback
  145117. * @returns This path cursor
  145118. */
  145119. onchange(f: (cursor: PathCursor) => void): PathCursor;
  145120. }
  145121. }
  145122. declare module BABYLON {
  145123. /** @hidden */
  145124. export var blurPixelShader: {
  145125. name: string;
  145126. shader: string;
  145127. };
  145128. }
  145129. declare module BABYLON {
  145130. /** @hidden */
  145131. export var pointCloudVertexDeclaration: {
  145132. name: string;
  145133. shader: string;
  145134. };
  145135. }
  145136. // Mixins
  145137. interface Window {
  145138. mozIndexedDB: IDBFactory;
  145139. webkitIndexedDB: IDBFactory;
  145140. msIndexedDB: IDBFactory;
  145141. webkitURL: typeof URL;
  145142. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  145143. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  145144. WebGLRenderingContext: WebGLRenderingContext;
  145145. MSGesture: MSGesture;
  145146. CANNON: any;
  145147. AudioContext: AudioContext;
  145148. webkitAudioContext: AudioContext;
  145149. PointerEvent: any;
  145150. Math: Math;
  145151. Uint8Array: Uint8ArrayConstructor;
  145152. Float32Array: Float32ArrayConstructor;
  145153. mozURL: typeof URL;
  145154. msURL: typeof URL;
  145155. VRFrameData: any; // WebVR, from specs 1.1
  145156. DracoDecoderModule: any;
  145157. setImmediate(handler: (...args: any[]) => void): number;
  145158. }
  145159. interface HTMLCanvasElement {
  145160. requestPointerLock(): void;
  145161. msRequestPointerLock?(): void;
  145162. mozRequestPointerLock?(): void;
  145163. webkitRequestPointerLock?(): void;
  145164. /** Track wether a record is in progress */
  145165. isRecording: boolean;
  145166. /** Capture Stream method defined by some browsers */
  145167. captureStream(fps?: number): MediaStream;
  145168. }
  145169. interface CanvasRenderingContext2D {
  145170. msImageSmoothingEnabled: boolean;
  145171. }
  145172. interface MouseEvent {
  145173. mozMovementX: number;
  145174. mozMovementY: number;
  145175. webkitMovementX: number;
  145176. webkitMovementY: number;
  145177. msMovementX: number;
  145178. msMovementY: number;
  145179. }
  145180. interface Navigator {
  145181. mozGetVRDevices: (any: any) => any;
  145182. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  145183. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  145184. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  145185. webkitGetGamepads(): Gamepad[];
  145186. msGetGamepads(): Gamepad[];
  145187. webkitGamepads(): Gamepad[];
  145188. }
  145189. interface HTMLVideoElement {
  145190. mozSrcObject: any;
  145191. }
  145192. interface Math {
  145193. fround(x: number): number;
  145194. imul(a: number, b: number): number;
  145195. }
  145196. interface WebGLRenderingContext {
  145197. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  145198. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  145199. vertexAttribDivisor(index: number, divisor: number): void;
  145200. createVertexArray(): any;
  145201. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  145202. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  145203. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  145204. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  145205. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  145206. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  145207. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  145208. // Queries
  145209. createQuery(): WebGLQuery;
  145210. deleteQuery(query: WebGLQuery): void;
  145211. beginQuery(target: number, query: WebGLQuery): void;
  145212. endQuery(target: number): void;
  145213. getQueryParameter(query: WebGLQuery, pname: number): any;
  145214. getQuery(target: number, pname: number): any;
  145215. MAX_SAMPLES: number;
  145216. RGBA8: number;
  145217. READ_FRAMEBUFFER: number;
  145218. DRAW_FRAMEBUFFER: number;
  145219. UNIFORM_BUFFER: number;
  145220. HALF_FLOAT_OES: number;
  145221. RGBA16F: number;
  145222. RGBA32F: number;
  145223. R32F: number;
  145224. RG32F: number;
  145225. RGB32F: number;
  145226. R16F: number;
  145227. RG16F: number;
  145228. RGB16F: number;
  145229. RED: number;
  145230. RG: number;
  145231. R8: number;
  145232. RG8: number;
  145233. UNSIGNED_INT_24_8: number;
  145234. DEPTH24_STENCIL8: number;
  145235. MIN: number;
  145236. MAX: number;
  145237. /* Multiple Render Targets */
  145238. drawBuffers(buffers: number[]): void;
  145239. readBuffer(src: number): void;
  145240. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  145241. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  145242. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  145243. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  145244. // Occlusion Query
  145245. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  145246. ANY_SAMPLES_PASSED: number;
  145247. QUERY_RESULT_AVAILABLE: number;
  145248. QUERY_RESULT: number;
  145249. }
  145250. interface WebGLProgram {
  145251. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  145252. }
  145253. interface EXT_disjoint_timer_query {
  145254. QUERY_COUNTER_BITS_EXT: number;
  145255. TIME_ELAPSED_EXT: number;
  145256. TIMESTAMP_EXT: number;
  145257. GPU_DISJOINT_EXT: number;
  145258. QUERY_RESULT_EXT: number;
  145259. QUERY_RESULT_AVAILABLE_EXT: number;
  145260. queryCounterEXT(query: WebGLQuery, target: number): void;
  145261. createQueryEXT(): WebGLQuery;
  145262. beginQueryEXT(target: number, query: WebGLQuery): void;
  145263. endQueryEXT(target: number): void;
  145264. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  145265. deleteQueryEXT(query: WebGLQuery): void;
  145266. }
  145267. interface WebGLUniformLocation {
  145268. _currentState: any;
  145269. }
  145270. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  145271. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  145272. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  145273. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  145274. interface WebGLRenderingContext {
  145275. readonly RASTERIZER_DISCARD: number;
  145276. readonly DEPTH_COMPONENT24: number;
  145277. readonly TEXTURE_3D: number;
  145278. readonly TEXTURE_2D_ARRAY: number;
  145279. readonly TEXTURE_COMPARE_FUNC: number;
  145280. readonly TEXTURE_COMPARE_MODE: number;
  145281. readonly COMPARE_REF_TO_TEXTURE: number;
  145282. readonly TEXTURE_WRAP_R: number;
  145283. readonly HALF_FLOAT: number;
  145284. readonly RGB8: number;
  145285. readonly RED_INTEGER: number;
  145286. readonly RG_INTEGER: number;
  145287. readonly RGB_INTEGER: number;
  145288. readonly RGBA_INTEGER: number;
  145289. readonly R8_SNORM: number;
  145290. readonly RG8_SNORM: number;
  145291. readonly RGB8_SNORM: number;
  145292. readonly RGBA8_SNORM: number;
  145293. readonly R8I: number;
  145294. readonly RG8I: number;
  145295. readonly RGB8I: number;
  145296. readonly RGBA8I: number;
  145297. readonly R8UI: number;
  145298. readonly RG8UI: number;
  145299. readonly RGB8UI: number;
  145300. readonly RGBA8UI: number;
  145301. readonly R16I: number;
  145302. readonly RG16I: number;
  145303. readonly RGB16I: number;
  145304. readonly RGBA16I: number;
  145305. readonly R16UI: number;
  145306. readonly RG16UI: number;
  145307. readonly RGB16UI: number;
  145308. readonly RGBA16UI: number;
  145309. readonly R32I: number;
  145310. readonly RG32I: number;
  145311. readonly RGB32I: number;
  145312. readonly RGBA32I: number;
  145313. readonly R32UI: number;
  145314. readonly RG32UI: number;
  145315. readonly RGB32UI: number;
  145316. readonly RGBA32UI: number;
  145317. readonly RGB10_A2UI: number;
  145318. readonly R11F_G11F_B10F: number;
  145319. readonly RGB9_E5: number;
  145320. readonly RGB10_A2: number;
  145321. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  145322. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  145323. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  145324. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  145325. readonly DEPTH_COMPONENT32F: number;
  145326. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  145327. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  145328. 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;
  145329. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  145330. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  145331. readonly TRANSFORM_FEEDBACK: number;
  145332. readonly INTERLEAVED_ATTRIBS: number;
  145333. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  145334. createTransformFeedback(): WebGLTransformFeedback;
  145335. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  145336. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  145337. beginTransformFeedback(primitiveMode: number): void;
  145338. endTransformFeedback(): void;
  145339. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  145340. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  145341. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  145342. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  145343. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  145344. }
  145345. interface ImageBitmap {
  145346. readonly width: number;
  145347. readonly height: number;
  145348. close(): void;
  145349. }
  145350. interface WebGLQuery extends WebGLObject {
  145351. }
  145352. declare var WebGLQuery: {
  145353. prototype: WebGLQuery;
  145354. new(): WebGLQuery;
  145355. };
  145356. interface WebGLSampler extends WebGLObject {
  145357. }
  145358. declare var WebGLSampler: {
  145359. prototype: WebGLSampler;
  145360. new(): WebGLSampler;
  145361. };
  145362. interface WebGLSync extends WebGLObject {
  145363. }
  145364. declare var WebGLSync: {
  145365. prototype: WebGLSync;
  145366. new(): WebGLSync;
  145367. };
  145368. interface WebGLTransformFeedback extends WebGLObject {
  145369. }
  145370. declare var WebGLTransformFeedback: {
  145371. prototype: WebGLTransformFeedback;
  145372. new(): WebGLTransformFeedback;
  145373. };
  145374. interface WebGLVertexArrayObject extends WebGLObject {
  145375. }
  145376. declare var WebGLVertexArrayObject: {
  145377. prototype: WebGLVertexArrayObject;
  145378. new(): WebGLVertexArrayObject;
  145379. };
  145380. // Type definitions for WebVR API
  145381. // Project: https://w3c.github.io/webvr/
  145382. // Definitions by: six a <https://github.com/lostfictions>
  145383. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  145384. interface VRDisplay extends EventTarget {
  145385. /**
  145386. * Dictionary of capabilities describing the VRDisplay.
  145387. */
  145388. readonly capabilities: VRDisplayCapabilities;
  145389. /**
  145390. * z-depth defining the far plane of the eye view frustum
  145391. * enables mapping of values in the render target depth
  145392. * attachment to scene coordinates. Initially set to 10000.0.
  145393. */
  145394. depthFar: number;
  145395. /**
  145396. * z-depth defining the near plane of the eye view frustum
  145397. * enables mapping of values in the render target depth
  145398. * attachment to scene coordinates. Initially set to 0.01.
  145399. */
  145400. depthNear: number;
  145401. /**
  145402. * An identifier for this distinct VRDisplay. Used as an
  145403. * association point in the Gamepad API.
  145404. */
  145405. readonly displayId: number;
  145406. /**
  145407. * A display name, a user-readable name identifying it.
  145408. */
  145409. readonly displayName: string;
  145410. readonly isConnected: boolean;
  145411. readonly isPresenting: boolean;
  145412. /**
  145413. * If this VRDisplay supports room-scale experiences, the optional
  145414. * stage attribute contains details on the room-scale parameters.
  145415. */
  145416. readonly stageParameters: VRStageParameters | null;
  145417. /**
  145418. * Passing the value returned by `requestAnimationFrame` to
  145419. * `cancelAnimationFrame` will unregister the callback.
  145420. * @param handle Define the hanle of the request to cancel
  145421. */
  145422. cancelAnimationFrame(handle: number): void;
  145423. /**
  145424. * Stops presenting to the VRDisplay.
  145425. * @returns a promise to know when it stopped
  145426. */
  145427. exitPresent(): Promise<void>;
  145428. /**
  145429. * Return the current VREyeParameters for the given eye.
  145430. * @param whichEye Define the eye we want the parameter for
  145431. * @returns the eye parameters
  145432. */
  145433. getEyeParameters(whichEye: string): VREyeParameters;
  145434. /**
  145435. * Populates the passed VRFrameData with the information required to render
  145436. * the current frame.
  145437. * @param frameData Define the data structure to populate
  145438. * @returns true if ok otherwise false
  145439. */
  145440. getFrameData(frameData: VRFrameData): boolean;
  145441. /**
  145442. * Get the layers currently being presented.
  145443. * @returns the list of VR layers
  145444. */
  145445. getLayers(): VRLayer[];
  145446. /**
  145447. * Return a VRPose containing the future predicted pose of the VRDisplay
  145448. * when the current frame will be presented. The value returned will not
  145449. * change until JavaScript has returned control to the browser.
  145450. *
  145451. * The VRPose will contain the position, orientation, velocity,
  145452. * and acceleration of each of these properties.
  145453. * @returns the pose object
  145454. */
  145455. getPose(): VRPose;
  145456. /**
  145457. * Return the current instantaneous pose of the VRDisplay, with no
  145458. * prediction applied.
  145459. * @returns the current instantaneous pose
  145460. */
  145461. getImmediatePose(): VRPose;
  145462. /**
  145463. * The callback passed to `requestAnimationFrame` will be called
  145464. * any time a new frame should be rendered. When the VRDisplay is
  145465. * presenting the callback will be called at the native refresh
  145466. * rate of the HMD. When not presenting this function acts
  145467. * identically to how window.requestAnimationFrame acts. Content should
  145468. * make no assumptions of frame rate or vsync behavior as the HMD runs
  145469. * asynchronously from other displays and at differing refresh rates.
  145470. * @param callback Define the eaction to run next frame
  145471. * @returns the request handle it
  145472. */
  145473. requestAnimationFrame(callback: FrameRequestCallback): number;
  145474. /**
  145475. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  145476. * Repeat calls while already presenting will update the VRLayers being displayed.
  145477. * @param layers Define the list of layer to present
  145478. * @returns a promise to know when the request has been fulfilled
  145479. */
  145480. requestPresent(layers: VRLayer[]): Promise<void>;
  145481. /**
  145482. * Reset the pose for this display, treating its current position and
  145483. * orientation as the "origin/zero" values. VRPose.position,
  145484. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  145485. * updated when calling resetPose(). This should be called in only
  145486. * sitting-space experiences.
  145487. */
  145488. resetPose(): void;
  145489. /**
  145490. * The VRLayer provided to the VRDisplay will be captured and presented
  145491. * in the HMD. Calling this function has the same effect on the source
  145492. * canvas as any other operation that uses its source image, and canvases
  145493. * created without preserveDrawingBuffer set to true will be cleared.
  145494. * @param pose Define the pose to submit
  145495. */
  145496. submitFrame(pose?: VRPose): void;
  145497. }
  145498. declare var VRDisplay: {
  145499. prototype: VRDisplay;
  145500. new(): VRDisplay;
  145501. };
  145502. interface VRLayer {
  145503. leftBounds?: number[] | Float32Array | null;
  145504. rightBounds?: number[] | Float32Array | null;
  145505. source?: HTMLCanvasElement | null;
  145506. }
  145507. interface VRDisplayCapabilities {
  145508. readonly canPresent: boolean;
  145509. readonly hasExternalDisplay: boolean;
  145510. readonly hasOrientation: boolean;
  145511. readonly hasPosition: boolean;
  145512. readonly maxLayers: number;
  145513. }
  145514. interface VREyeParameters {
  145515. /** @deprecated */
  145516. readonly fieldOfView: VRFieldOfView;
  145517. readonly offset: Float32Array;
  145518. readonly renderHeight: number;
  145519. readonly renderWidth: number;
  145520. }
  145521. interface VRFieldOfView {
  145522. readonly downDegrees: number;
  145523. readonly leftDegrees: number;
  145524. readonly rightDegrees: number;
  145525. readonly upDegrees: number;
  145526. }
  145527. interface VRFrameData {
  145528. readonly leftProjectionMatrix: Float32Array;
  145529. readonly leftViewMatrix: Float32Array;
  145530. readonly pose: VRPose;
  145531. readonly rightProjectionMatrix: Float32Array;
  145532. readonly rightViewMatrix: Float32Array;
  145533. readonly timestamp: number;
  145534. }
  145535. interface VRPose {
  145536. readonly angularAcceleration: Float32Array | null;
  145537. readonly angularVelocity: Float32Array | null;
  145538. readonly linearAcceleration: Float32Array | null;
  145539. readonly linearVelocity: Float32Array | null;
  145540. readonly orientation: Float32Array | null;
  145541. readonly position: Float32Array | null;
  145542. readonly timestamp: number;
  145543. }
  145544. interface VRStageParameters {
  145545. sittingToStandingTransform?: Float32Array;
  145546. sizeX?: number;
  145547. sizeY?: number;
  145548. }
  145549. interface Navigator {
  145550. getVRDisplays(): Promise<VRDisplay[]>;
  145551. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  145552. }
  145553. interface Window {
  145554. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  145555. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  145556. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  145557. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  145558. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  145559. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  145560. }
  145561. interface Gamepad {
  145562. readonly displayId: number;
  145563. }
  145564. type XRSessionMode =
  145565. | "inline"
  145566. | "immersive-vr"
  145567. | "immersive-ar";
  145568. type XRReferenceSpaceType =
  145569. | "viewer"
  145570. | "local"
  145571. | "local-floor"
  145572. | "bounded-floor"
  145573. | "unbounded";
  145574. type XREnvironmentBlendMode =
  145575. | "opaque"
  145576. | "additive"
  145577. | "alpha-blend";
  145578. type XRVisibilityState =
  145579. | "visible"
  145580. | "visible-blurred"
  145581. | "hidden";
  145582. type XRHandedness =
  145583. | "none"
  145584. | "left"
  145585. | "right";
  145586. type XRTargetRayMode =
  145587. | "gaze"
  145588. | "tracked-pointer"
  145589. | "screen";
  145590. type XREye =
  145591. | "none"
  145592. | "left"
  145593. | "right";
  145594. type XREventType =
  145595. | "devicechange"
  145596. | "visibilitychange"
  145597. | "end"
  145598. | "inputsourceschange"
  145599. | "select"
  145600. | "selectstart"
  145601. | "selectend"
  145602. | "squeeze"
  145603. | "squeezestart"
  145604. | "squeezeend"
  145605. | "reset";
  145606. interface XRSpace extends EventTarget {
  145607. }
  145608. interface XRRenderState {
  145609. depthNear?: number;
  145610. depthFar?: number;
  145611. inlineVerticalFieldOfView?: number;
  145612. baseLayer?: XRWebGLLayer;
  145613. }
  145614. interface XRInputSource {
  145615. handedness: XRHandedness;
  145616. targetRayMode: XRTargetRayMode;
  145617. targetRaySpace: XRSpace;
  145618. gripSpace: XRSpace | undefined;
  145619. gamepad: Gamepad | undefined;
  145620. profiles: Array<string>;
  145621. }
  145622. interface XRSessionInit {
  145623. optionalFeatures?: XRReferenceSpaceType[];
  145624. requiredFeatures?: XRReferenceSpaceType[];
  145625. }
  145626. interface XRSession extends XRAnchorCreator {
  145627. addEventListener: Function;
  145628. removeEventListener: Function;
  145629. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  145630. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  145631. requestAnimationFrame: Function;
  145632. end(): Promise<void>;
  145633. renderState: XRRenderState;
  145634. inputSources: Array<XRInputSource>;
  145635. // hit test
  145636. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  145637. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  145638. // legacy AR hit test
  145639. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  145640. // legacy plane detection
  145641. updateWorldTrackingState(options: {
  145642. planeDetectionState?: { enabled: boolean; }
  145643. }): void;
  145644. }
  145645. interface XRReferenceSpace extends XRSpace {
  145646. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  145647. onreset: any;
  145648. }
  145649. type XRPlaneSet = Set<XRPlane>;
  145650. type XRAnchorSet = Set<XRAnchor>;
  145651. interface XRFrame {
  145652. session: XRSession;
  145653. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  145654. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  145655. // AR
  145656. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  145657. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  145658. // Anchors
  145659. trackedAnchors?: XRAnchorSet;
  145660. // Planes
  145661. worldInformation: {
  145662. detectedPlanes?: XRPlaneSet;
  145663. };
  145664. }
  145665. interface XRViewerPose extends XRPose {
  145666. views: Array<XRView>;
  145667. }
  145668. interface XRPose {
  145669. transform: XRRigidTransform;
  145670. emulatedPosition: boolean;
  145671. }
  145672. interface XRWebGLLayerOptions {
  145673. antialias?: boolean;
  145674. depth?: boolean;
  145675. stencil?: boolean;
  145676. alpha?: boolean;
  145677. multiview?: boolean;
  145678. framebufferScaleFactor?: number;
  145679. }
  145680. declare var XRWebGLLayer: {
  145681. prototype: XRWebGLLayer;
  145682. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  145683. };
  145684. interface XRWebGLLayer {
  145685. framebuffer: WebGLFramebuffer;
  145686. framebufferWidth: number;
  145687. framebufferHeight: number;
  145688. getViewport: Function;
  145689. }
  145690. declare class XRRigidTransform {
  145691. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  145692. position: DOMPointReadOnly;
  145693. orientation: DOMPointReadOnly;
  145694. matrix: Float32Array;
  145695. inverse: XRRigidTransform;
  145696. }
  145697. interface XRView {
  145698. eye: XREye;
  145699. projectionMatrix: Float32Array;
  145700. transform: XRRigidTransform;
  145701. }
  145702. interface XRInputSourceChangeEvent {
  145703. session: XRSession;
  145704. removed: Array<XRInputSource>;
  145705. added: Array<XRInputSource>;
  145706. }
  145707. interface XRInputSourceEvent extends Event {
  145708. readonly frame: XRFrame;
  145709. readonly inputSource: XRInputSource;
  145710. }
  145711. // Experimental(er) features
  145712. declare class XRRay {
  145713. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  145714. origin: DOMPointReadOnly;
  145715. direction: DOMPointReadOnly;
  145716. matrix: Float32Array;
  145717. }
  145718. declare enum XRHitTestTrackableType {
  145719. "point",
  145720. "plane"
  145721. }
  145722. interface XRHitResult {
  145723. hitMatrix: Float32Array;
  145724. }
  145725. interface XRTransientInputHitTestResult {
  145726. readonly inputSource: XRInputSource;
  145727. readonly results: Array<XRHitTestResult>;
  145728. }
  145729. interface XRHitTestResult {
  145730. getPose(baseSpace: XRSpace): XRPose | undefined;
  145731. }
  145732. interface XRHitTestSource {
  145733. cancel(): void;
  145734. }
  145735. interface XRTransientInputHitTestSource {
  145736. cancel(): void;
  145737. }
  145738. interface XRHitTestOptionsInit {
  145739. space: XRSpace;
  145740. entityTypes?: Array<XRHitTestTrackableType>;
  145741. offsetRay?: XRRay;
  145742. }
  145743. interface XRTransientInputHitTestOptionsInit {
  145744. profile: string;
  145745. entityTypes?: Array<XRHitTestTrackableType>;
  145746. offsetRay?: XRRay;
  145747. }
  145748. interface XRAnchor {
  145749. // remove?
  145750. id?: string;
  145751. anchorSpace: XRSpace;
  145752. lastChangedTime: number;
  145753. detach(): void;
  145754. }
  145755. interface XRPlane extends XRAnchorCreator {
  145756. orientation: "Horizontal" | "Vertical";
  145757. planeSpace: XRSpace;
  145758. polygon: Array<DOMPointReadOnly>;
  145759. lastChangedTime: number;
  145760. }
  145761. interface XRAnchorCreator {
  145762. // AR Anchors
  145763. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  145764. }